Enchant: libgnu/sys/file.h Source File

Enchant Generic spell checking library

file.h
1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* Provide a more complete sys/file.h.
3
4 Copyright (C) 2007-2024 Free Software Foundation, Inc.
5
6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
10
11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18
19 /* Written by Richard W.M. Jones. */
20
21 #ifndef _GL_SYS_FILE_H
22
23 #if __GNUC__ >= 3
24 #pragma GCC system_header
25 #endif
26
27
28 /* The include_next requires a split double-inclusion guard. */
29 #if 1
30 # include_next <sys/file.h>
31 #endif
32
33 #ifndef _GL_SYS_FILE_H
34 #define _GL_SYS_FILE_H
35
36 /* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
37 #if !_GL_CONFIG_H_INCLUDED
38 #error "Please include config.h first."
39 #endif
40
41 #ifndef LOCK_SH
42 /* Operations for the 'flock' call (same as Linux kernel constants). */
43 # define LOCK_SH 1 /* Shared lock. */
44 # define LOCK_EX 2 /* Exclusive lock. */
45 # define LOCK_UN 8 /* Unlock. */
46
47 /* Can be OR'd into one of the above. */
48 # define LOCK_NB 4 /* Don't block when locking. */
49 #endif
50
51 /* The definition of _GL_WARN_ON_USE is copied here. */
52 /* A C macro for emitting warnings if a function is used.
53 Copyright (C) 2010-2024 Free Software Foundation, Inc.
54
55 This program is free software: you can redistribute it and/or modify it
56 under the terms of the GNU Lesser General Public License as published
57 by the Free Software Foundation; either version 2 of the License, or
58 (at your option) any later version.
59
60 This program is distributed in the hope that it will be useful,
61 but WITHOUT ANY WARRANTY; without even the implied warranty of
62 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
63 Lesser General Public License for more details.
64
65 You should have received a copy of the GNU Lesser General Public License
66 along with this program. If not, see <https://www.gnu.org/licenses/>. */
67
68 /* _GL_WARN_ON_USE (function, "literal string") issues a declaration
69 for FUNCTION which will then trigger a compiler warning containing
70 the text of "literal string" anywhere that function is called, if
71 supported by the compiler. If the compiler does not support this
72 feature, the macro expands to an unused extern declaration.
73
74 _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
75 attribute used in _GL_WARN_ON_USE. If the compiler does not support
76 this feature, it expands to empty.
77
78 These macros are useful for marking a function as a potential
79 portability trap, with the intent that "literal string" include
80 instructions on the replacement function that should be used
81 instead.
82 _GL_WARN_ON_USE is for functions with 'extern' linkage.
83 _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
84 linkage.
85
86 _GL_WARN_ON_USE should not be used more than once for a given function
87 in a given compilation unit (because this may generate a warning even
88 if the function is never called).
89
90 However, one of the reasons that a function is a portability trap is
91 if it has the wrong signature. Declaring FUNCTION with a different
92 signature in C is a compilation error, so this macro must use the
93 same type as any existing declaration so that programs that avoid
94 the problematic FUNCTION do not fail to compile merely because they
95 included a header that poisoned the function. But this implies that
96 _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
97 have a declaration. Use of this macro implies that there must not
98 be any other macro hiding the declaration of FUNCTION; but
99 undefining FUNCTION first is part of the poisoning process anyway
100 (although for symbols that are provided only via a macro, the result
101 is a compilation error rather than a warning containing
102 "literal string"). Also note that in C++, it is only safe to use if
103 FUNCTION has no overloads.
104
105 For an example, it is possible to poison 'getline' by:
106 - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
107 [getline]) in configure.ac, which potentially defines
108 HAVE_RAW_DECL_GETLINE
109 - adding this code to a header that wraps the system <stdio.h>:
110 #undef getline
111 #if HAVE_RAW_DECL_GETLINE
112 _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
113 "not universally present; use the gnulib module getline");
114 #endif
115
116 It is not possible to directly poison global variables. But it is
117 possible to write a wrapper accessor function, and poison that
118 (less common usage, like &environ, will cause a compilation error
119 rather than issue the nice warning, but the end result of informing
120 the developer about their portability problem is still achieved):
121 #if HAVE_RAW_DECL_ENVIRON
122 static char ***
123 rpl_environ (void) { return &environ; }
124 _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
125 # undef environ
126 # define environ (*rpl_environ ())
127 #endif
128 or better (avoiding contradictory use of 'static' and 'extern'):
129 #if HAVE_RAW_DECL_ENVIRON
130 static char ***
131 _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
132 rpl_environ (void) { return &environ; }
133 # undef environ
134 # define environ (*rpl_environ ())
135 #endif
136 */
137 #ifndef _GL_WARN_ON_USE
138
139 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
140 /* A compiler attribute is available in gcc versions 4.3.0 and later. */
141 # define _GL_WARN_ON_USE(function, message) \
142 _GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message)))
143 # define _GL_WARN_ON_USE_ATTRIBUTE(message) \
144 __attribute__ ((__warning__ (message)))
145 # elif __clang_major__ >= 4
146 /* Another compiler attribute is available in clang. */
147 # define _GL_WARN_ON_USE(function, message) \
148 _GL_WARN_EXTERN_C __typeof__ (function) function \
149 __attribute__ ((__diagnose_if__ (1, message, "warning")))
150 # define _GL_WARN_ON_USE_ATTRIBUTE(message) \
151 __attribute__ ((__diagnose_if__ (1, message, "warning")))
152 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
153 /* Verify the existence of the function. */
154 # define _GL_WARN_ON_USE(function, message) \
155 _GL_WARN_EXTERN_C __typeof__ (function) function
156 # define _GL_WARN_ON_USE_ATTRIBUTE(message)
157 # else /* Unsupported. */
158 # define _GL_WARN_ON_USE(function, message) \
159 _GL_WARN_EXTERN_C int _gl_warn_on_use
160 # define _GL_WARN_ON_USE_ATTRIBUTE(message)
161 # endif
162 #endif
163
164 /* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message")
165 is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the
166 function is declared with the given prototype, consisting of return type,
167 parameters, and attributes.
168 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
169 not work in this case. */
170 #ifndef _GL_WARN_ON_USE_CXX
171 # if !defined __cplusplus
172 # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
173 _GL_WARN_ON_USE (function, msg)
174 # else
175 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
176 /* A compiler attribute is available in gcc versions 4.3.0 and later. */
177 # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
178 extern rettype_gcc function parameters_and_attributes \
179 __attribute__ ((__warning__ (msg)))
180 # elif __clang_major__ >= 4
181 /* Another compiler attribute is available in clang. */
182 # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
183 extern rettype_clang function parameters_and_attributes \
184 __attribute__ ((__diagnose_if__ (1, msg, "warning")))
185 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
186 /* Verify the existence of the function. */
187 # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
188 extern rettype_gcc function parameters_and_attributes
189 # else /* Unsupported. */
190 # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
191 _GL_WARN_EXTERN_C int _gl_warn_on_use
192 # endif
193 # endif
194 #endif
195
196 /* _GL_WARN_EXTERN_C declaration;
197 performs the declaration with C linkage. */
198 #ifndef _GL_WARN_EXTERN_C
199 # if defined __cplusplus
200 # define _GL_WARN_EXTERN_C extern "C"
201 # else
202 # define _GL_WARN_EXTERN_C extern
203 # endif
204 #endif
205
206 #if 1
207 /* Apply or remove advisory locks on an open file.
208 Return 0 if successful, otherwise -1 and errno set. */
209 # if !1
210 extern int flock (int fd, int operation);
211 # endif
212 #elif defined GNULIB_POSIXCHECK
213 # undef flock
214 # if HAVE_RAW_DECL_FLOCK
215 _GL_WARN_ON_USE (flock, "flock is unportable - "
216 "use gnulib module flock for portability");
217 # endif
218 #endif
219
220
221 #endif /* _GL_SYS_FILE_H */
222 #endif /* _GL_SYS_FILE_H */