1 | /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ |
2 | /* A GNU-like <signal.h>. |
3 | |
4 | Copyright (C) 2006-2019 Free Software Foundation, Inc. |
5 | |
6 | This program is free software: you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 3 of the License, or |
9 | (at your option) any later version. |
10 | |
11 | This program 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 General Public License for more details. |
15 | |
16 | You should have received a copy of the GNU General Public License |
17 | along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
18 | |
19 | #if __GNUC__ >= 3 |
20 | #pragma GCC system_header |
21 | #endif |
22 | |
23 | |
24 | #if defined __need_sig_atomic_t || defined __need_sigset_t || defined _GL_ALREADY_INCLUDING_SIGNAL_H || (defined _SIGNAL_H && !defined __SIZEOF_PTHREAD_MUTEX_T) |
25 | /* Special invocation convention: |
26 | - Inside glibc header files. |
27 | - On glibc systems we have a sequence of nested includes |
28 | <signal.h> -> <ucontext.h> -> <signal.h>. |
29 | In this situation, the functions are not yet declared, therefore we cannot |
30 | provide the C++ aliases. |
31 | - On glibc systems with GCC 4.3 we have a sequence of nested includes |
32 | <csignal> -> </usr/include/signal.h> -> <sys/ucontext.h> -> <signal.h>. |
33 | In this situation, some of the functions are not yet declared, therefore |
34 | we cannot provide the C++ aliases. */ |
35 | |
36 | # include_next <signal.h> |
37 | |
38 | #else |
39 | /* Normal invocation convention. */ |
40 | |
41 | #ifndef _GL_SIGNAL_H |
42 | |
43 | #define _GL_ALREADY_INCLUDING_SIGNAL_H |
44 | |
45 | /* Define pid_t, uid_t. |
46 | Also, mingw defines sigset_t not in <signal.h>, but in <sys/types.h>. |
47 | On Solaris 10, <signal.h> includes <sys/types.h>, which eventually includes |
48 | us; so include <sys/types.h> now, before the second inclusion guard. */ |
49 | #include <sys/types.h> |
50 | |
51 | /* The include_next requires a split double-inclusion guard. */ |
52 | #include_next <signal.h> |
53 | |
54 | #undef _GL_ALREADY_INCLUDING_SIGNAL_H |
55 | |
56 | #ifndef _GL_SIGNAL_H |
57 | #define _GL_SIGNAL_H |
58 | |
59 | /* Mac OS X 10.3, FreeBSD 6.4, OpenBSD 3.8, OSF/1 4.0, Solaris 2.6, Android |
60 | declare pthread_sigmask in <pthread.h>, not in <signal.h>. |
61 | But avoid namespace pollution on glibc systems.*/ |
62 | #if (0 || defined GNULIB_POSIXCHECK) \ |
63 | && ((defined __APPLE__ && defined __MACH__) \ |
64 | || defined __FreeBSD__ || defined __OpenBSD__ || defined __osf__ \ |
65 | || defined __sun || defined __ANDROID__) \ |
66 | && ! defined __GLIBC__ |
67 | # include <pthread.h> |
68 | #endif |
69 | |
70 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ |
71 | /* C++ compatible function declaration macros. |
72 | Copyright (C) 2010-2019 Free Software Foundation, Inc. |
73 | |
74 | This program is free software: you can redistribute it and/or modify it |
75 | under the terms of the GNU General Public License as published |
76 | by the Free Software Foundation; either version 3 of the License, or |
77 | (at your option) any later version. |
78 | |
79 | This program is distributed in the hope that it will be useful, |
80 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
81 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
82 | General Public License for more details. |
83 | |
84 | You should have received a copy of the GNU General Public License |
85 | along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
86 | |
87 | #ifndef _GL_CXXDEFS_H |
88 | #define _GL_CXXDEFS_H |
89 | |
90 | /* Begin/end the GNULIB_NAMESPACE namespace. */ |
91 | #if defined __cplusplus && defined GNULIB_NAMESPACE |
92 | # define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE { |
93 | # define _GL_END_NAMESPACE } |
94 | #else |
95 | # define _GL_BEGIN_NAMESPACE |
96 | # define _GL_END_NAMESPACE |
97 | #endif |
98 | |
99 | /* The three most frequent use cases of these macros are: |
100 | |
101 | * For providing a substitute for a function that is missing on some |
102 | platforms, but is declared and works fine on the platforms on which |
103 | it exists: |
104 | |
105 | #if @GNULIB_FOO@ |
106 | # if !@HAVE_FOO@ |
107 | _GL_FUNCDECL_SYS (foo, ...); |
108 | # endif |
109 | _GL_CXXALIAS_SYS (foo, ...); |
110 | _GL_CXXALIASWARN (foo); |
111 | #elif defined GNULIB_POSIXCHECK |
112 | ... |
113 | #endif |
114 | |
115 | * For providing a replacement for a function that exists on all platforms, |
116 | but is broken/insufficient and needs to be replaced on some platforms: |
117 | |
118 | #if @GNULIB_FOO@ |
119 | # if @REPLACE_FOO@ |
120 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
121 | # undef foo |
122 | # define foo rpl_foo |
123 | # endif |
124 | _GL_FUNCDECL_RPL (foo, ...); |
125 | _GL_CXXALIAS_RPL (foo, ...); |
126 | # else |
127 | _GL_CXXALIAS_SYS (foo, ...); |
128 | # endif |
129 | _GL_CXXALIASWARN (foo); |
130 | #elif defined GNULIB_POSIXCHECK |
131 | ... |
132 | #endif |
133 | |
134 | * For providing a replacement for a function that exists on some platforms |
135 | but is broken/insufficient and needs to be replaced on some of them and |
136 | is additionally either missing or undeclared on some other platforms: |
137 | |
138 | #if @GNULIB_FOO@ |
139 | # if @REPLACE_FOO@ |
140 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
141 | # undef foo |
142 | # define foo rpl_foo |
143 | # endif |
144 | _GL_FUNCDECL_RPL (foo, ...); |
145 | _GL_CXXALIAS_RPL (foo, ...); |
146 | # else |
147 | # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ |
148 | _GL_FUNCDECL_SYS (foo, ...); |
149 | # endif |
150 | _GL_CXXALIAS_SYS (foo, ...); |
151 | # endif |
152 | _GL_CXXALIASWARN (foo); |
153 | #elif defined GNULIB_POSIXCHECK |
154 | ... |
155 | #endif |
156 | */ |
157 | |
158 | /* _GL_EXTERN_C declaration; |
159 | performs the declaration with C linkage. */ |
160 | #if defined __cplusplus |
161 | # define _GL_EXTERN_C extern "C" |
162 | #else |
163 | # define _GL_EXTERN_C extern |
164 | #endif |
165 | |
166 | /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); |
167 | declares a replacement function, named rpl_func, with the given prototype, |
168 | consisting of return type, parameters, and attributes. |
169 | Example: |
170 | _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) |
171 | _GL_ARG_NONNULL ((1))); |
172 | */ |
173 | #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ |
174 | _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) |
175 | #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ |
176 | _GL_EXTERN_C rettype rpl_func parameters_and_attributes |
177 | |
178 | /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); |
179 | declares the system function, named func, with the given prototype, |
180 | consisting of return type, parameters, and attributes. |
181 | Example: |
182 | _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) |
183 | _GL_ARG_NONNULL ((1))); |
184 | */ |
185 | #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ |
186 | _GL_EXTERN_C rettype func parameters_and_attributes |
187 | |
188 | /* _GL_CXXALIAS_RPL (func, rettype, parameters); |
189 | declares a C++ alias called GNULIB_NAMESPACE::func |
190 | that redirects to rpl_func, if GNULIB_NAMESPACE is defined. |
191 | Example: |
192 | _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); |
193 | |
194 | Wrapping rpl_func in an object with an inline conversion operator |
195 | avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is |
196 | actually used in the program. */ |
197 | #define _GL_CXXALIAS_RPL(func,rettype,parameters) \ |
198 | _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) |
199 | #if defined __cplusplus && defined GNULIB_NAMESPACE |
200 | # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ |
201 | namespace GNULIB_NAMESPACE \ |
202 | { \ |
203 | static const struct _gl_ ## func ## _wrapper \ |
204 | { \ |
205 | typedef rettype (*type) parameters; \ |
206 | \ |
207 | inline operator type () const \ |
208 | { \ |
209 | return ::rpl_func; \ |
210 | } \ |
211 | } func = {}; \ |
212 | } \ |
213 | _GL_EXTERN_C int _gl_cxxalias_dummy |
214 | #else |
215 | # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ |
216 | _GL_EXTERN_C int _gl_cxxalias_dummy |
217 | #endif |
218 | |
219 | /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); |
220 | is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); |
221 | except that the C function rpl_func may have a slightly different |
222 | declaration. A cast is used to silence the "invalid conversion" error |
223 | that would otherwise occur. */ |
224 | #if defined __cplusplus && defined GNULIB_NAMESPACE |
225 | # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ |
226 | namespace GNULIB_NAMESPACE \ |
227 | { \ |
228 | static const struct _gl_ ## func ## _wrapper \ |
229 | { \ |
230 | typedef rettype (*type) parameters; \ |
231 | \ |
232 | inline operator type () const \ |
233 | { \ |
234 | return reinterpret_cast<type>(::rpl_func); \ |
235 | } \ |
236 | } func = {}; \ |
237 | } \ |
238 | _GL_EXTERN_C int _gl_cxxalias_dummy |
239 | #else |
240 | # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ |
241 | _GL_EXTERN_C int _gl_cxxalias_dummy |
242 | #endif |
243 | |
244 | /* _GL_CXXALIAS_SYS (func, rettype, parameters); |
245 | declares a C++ alias called GNULIB_NAMESPACE::func |
246 | that redirects to the system provided function func, if GNULIB_NAMESPACE |
247 | is defined. |
248 | Example: |
249 | _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); |
250 | |
251 | Wrapping func in an object with an inline conversion operator |
252 | avoids a reference to func unless GNULIB_NAMESPACE::func is |
253 | actually used in the program. */ |
254 | #if defined __cplusplus && defined GNULIB_NAMESPACE |
255 | # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ |
256 | namespace GNULIB_NAMESPACE \ |
257 | { \ |
258 | static const struct _gl_ ## func ## _wrapper \ |
259 | { \ |
260 | typedef rettype (*type) parameters; \ |
261 | \ |
262 | inline operator type () const \ |
263 | { \ |
264 | return ::func; \ |
265 | } \ |
266 | } func = {}; \ |
267 | } \ |
268 | _GL_EXTERN_C int _gl_cxxalias_dummy |
269 | #else |
270 | # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ |
271 | _GL_EXTERN_C int _gl_cxxalias_dummy |
272 | #endif |
273 | |
274 | /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); |
275 | is like _GL_CXXALIAS_SYS (func, rettype, parameters); |
276 | except that the C function func may have a slightly different declaration. |
277 | A cast is used to silence the "invalid conversion" error that would |
278 | otherwise occur. */ |
279 | #if defined __cplusplus && defined GNULIB_NAMESPACE |
280 | # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ |
281 | namespace GNULIB_NAMESPACE \ |
282 | { \ |
283 | static const struct _gl_ ## func ## _wrapper \ |
284 | { \ |
285 | typedef rettype (*type) parameters; \ |
286 | \ |
287 | inline operator type () const \ |
288 | { \ |
289 | return reinterpret_cast<type>(::func); \ |
290 | } \ |
291 | } func = {}; \ |
292 | } \ |
293 | _GL_EXTERN_C int _gl_cxxalias_dummy |
294 | #else |
295 | # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ |
296 | _GL_EXTERN_C int _gl_cxxalias_dummy |
297 | #endif |
298 | |
299 | /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); |
300 | is like _GL_CXXALIAS_SYS (func, rettype, parameters); |
301 | except that the C function is picked among a set of overloaded functions, |
302 | namely the one with rettype2 and parameters2. Two consecutive casts |
303 | are used to silence the "cannot find a match" and "invalid conversion" |
304 | errors that would otherwise occur. */ |
305 | #if defined __cplusplus && defined GNULIB_NAMESPACE |
306 | /* The outer cast must be a reinterpret_cast. |
307 | The inner cast: When the function is defined as a set of overloaded |
308 | functions, it works as a static_cast<>, choosing the designated variant. |
309 | When the function is defined as a single variant, it works as a |
310 | reinterpret_cast<>. The parenthesized cast syntax works both ways. */ |
311 | # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ |
312 | namespace GNULIB_NAMESPACE \ |
313 | { \ |
314 | static const struct _gl_ ## func ## _wrapper \ |
315 | { \ |
316 | typedef rettype (*type) parameters; \ |
317 | \ |
318 | inline operator type () const \ |
319 | { \ |
320 | return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \ |
321 | } \ |
322 | } func = {}; \ |
323 | } \ |
324 | _GL_EXTERN_C int _gl_cxxalias_dummy |
325 | #else |
326 | # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ |
327 | _GL_EXTERN_C int _gl_cxxalias_dummy |
328 | #endif |
329 | |
330 | /* _GL_CXXALIASWARN (func); |
331 | causes a warning to be emitted when ::func is used but not when |
332 | GNULIB_NAMESPACE::func is used. func must be defined without overloaded |
333 | variants. */ |
334 | #if defined __cplusplus && defined GNULIB_NAMESPACE |
335 | # define _GL_CXXALIASWARN(func) \ |
336 | _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) |
337 | # define _GL_CXXALIASWARN_1(func,namespace) \ |
338 | _GL_CXXALIASWARN_2 (func, namespace) |
339 | /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, |
340 | we enable the warning only when not optimizing. */ |
341 | # if !__OPTIMIZE__ |
342 | # define _GL_CXXALIASWARN_2(func,namespace) \ |
343 | _GL_WARN_ON_USE (func, \ |
344 | "The symbol ::" #func " refers to the system function. " \ |
345 | "Use " #namespace "::" #func " instead.") |
346 | # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING |
347 | # define _GL_CXXALIASWARN_2(func,namespace) \ |
348 | extern __typeof__ (func) func |
349 | # else |
350 | # define _GL_CXXALIASWARN_2(func,namespace) \ |
351 | _GL_EXTERN_C int _gl_cxxalias_dummy |
352 | # endif |
353 | #else |
354 | # define _GL_CXXALIASWARN(func) \ |
355 | _GL_EXTERN_C int _gl_cxxalias_dummy |
356 | #endif |
357 | |
358 | /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); |
359 | causes a warning to be emitted when the given overloaded variant of ::func |
360 | is used but not when GNULIB_NAMESPACE::func is used. */ |
361 | #if defined __cplusplus && defined GNULIB_NAMESPACE |
362 | # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ |
363 | _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ |
364 | GNULIB_NAMESPACE) |
365 | # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ |
366 | _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) |
367 | /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, |
368 | we enable the warning only when not optimizing. */ |
369 | # if !__OPTIMIZE__ |
370 | # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ |
371 | _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ |
372 | "The symbol ::" #func " refers to the system function. " \ |
373 | "Use " #namespace "::" #func " instead.") |
374 | # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING |
375 | # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ |
376 | extern __typeof__ (func) func |
377 | # else |
378 | # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ |
379 | _GL_EXTERN_C int _gl_cxxalias_dummy |
380 | # endif |
381 | #else |
382 | # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ |
383 | _GL_EXTERN_C int _gl_cxxalias_dummy |
384 | #endif |
385 | |
386 | #endif /* _GL_CXXDEFS_H */ |
387 | |
388 | /* The definition of _GL_ARG_NONNULL is copied here. */ |
389 | /* A C macro for declaring that specific arguments must not be NULL. |
390 | Copyright (C) 2009-2019 Free Software Foundation, Inc. |
391 | |
392 | This program is free software: you can redistribute it and/or modify it |
393 | under the terms of the GNU General Public License as published |
394 | by the Free Software Foundation; either version 3 of the License, or |
395 | (at your option) any later version. |
396 | |
397 | This program is distributed in the hope that it will be useful, |
398 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
399 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
400 | General Public License for more details. |
401 | |
402 | You should have received a copy of the GNU General Public License |
403 | along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
404 | |
405 | /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools |
406 | that the values passed as arguments n, ..., m must be non-NULL pointers. |
407 | n = 1 stands for the first argument, n = 2 for the second argument etc. */ |
408 | #ifndef _GL_ARG_NONNULL |
409 | # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 |
410 | # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) |
411 | # else |
412 | # define _GL_ARG_NONNULL(params) |
413 | # endif |
414 | #endif |
415 | |
416 | /* The definition of _GL_WARN_ON_USE is copied here. */ |
417 | /* A C macro for emitting warnings if a function is used. |
418 | Copyright (C) 2010-2019 Free Software Foundation, Inc. |
419 | |
420 | This program is free software: you can redistribute it and/or modify it |
421 | under the terms of the GNU General Public License as published |
422 | by the Free Software Foundation; either version 3 of the License, or |
423 | (at your option) any later version. |
424 | |
425 | This program is distributed in the hope that it will be useful, |
426 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
427 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
428 | General Public License for more details. |
429 | |
430 | You should have received a copy of the GNU General Public License |
431 | along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
432 | |
433 | /* _GL_WARN_ON_USE (function, "literal string") issues a declaration |
434 | for FUNCTION which will then trigger a compiler warning containing |
435 | the text of "literal string" anywhere that function is called, if |
436 | supported by the compiler. If the compiler does not support this |
437 | feature, the macro expands to an unused extern declaration. |
438 | |
439 | _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the |
440 | attribute used in _GL_WARN_ON_USE. If the compiler does not support |
441 | this feature, it expands to empty. |
442 | |
443 | These macros are useful for marking a function as a potential |
444 | portability trap, with the intent that "literal string" include |
445 | instructions on the replacement function that should be used |
446 | instead. |
447 | _GL_WARN_ON_USE is for functions with 'extern' linkage. |
448 | _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline' |
449 | linkage. |
450 | |
451 | However, one of the reasons that a function is a portability trap is |
452 | if it has the wrong signature. Declaring FUNCTION with a different |
453 | signature in C is a compilation error, so this macro must use the |
454 | same type as any existing declaration so that programs that avoid |
455 | the problematic FUNCTION do not fail to compile merely because they |
456 | included a header that poisoned the function. But this implies that |
457 | _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already |
458 | have a declaration. Use of this macro implies that there must not |
459 | be any other macro hiding the declaration of FUNCTION; but |
460 | undefining FUNCTION first is part of the poisoning process anyway |
461 | (although for symbols that are provided only via a macro, the result |
462 | is a compilation error rather than a warning containing |
463 | "literal string"). Also note that in C++, it is only safe to use if |
464 | FUNCTION has no overloads. |
465 | |
466 | For an example, it is possible to poison 'getline' by: |
467 | - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]], |
468 | [getline]) in configure.ac, which potentially defines |
469 | HAVE_RAW_DECL_GETLINE |
470 | - adding this code to a header that wraps the system <stdio.h>: |
471 | #undef getline |
472 | #if HAVE_RAW_DECL_GETLINE |
473 | _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but" |
474 | "not universally present; use the gnulib module getline"); |
475 | #endif |
476 | |
477 | It is not possible to directly poison global variables. But it is |
478 | possible to write a wrapper accessor function, and poison that |
479 | (less common usage, like &environ, will cause a compilation error |
480 | rather than issue the nice warning, but the end result of informing |
481 | the developer about their portability problem is still achieved): |
482 | #if HAVE_RAW_DECL_ENVIRON |
483 | static char *** |
484 | rpl_environ (void) { return &environ; } |
485 | _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); |
486 | # undef environ |
487 | # define environ (*rpl_environ ()) |
488 | #endif |
489 | or better (avoiding contradictory use of 'static' and 'extern'): |
490 | #if HAVE_RAW_DECL_ENVIRON |
491 | static char *** |
492 | _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared") |
493 | rpl_environ (void) { return &environ; } |
494 | # undef environ |
495 | # define environ (*rpl_environ ()) |
496 | #endif |
497 | */ |
498 | #ifndef _GL_WARN_ON_USE |
499 | |
500 | # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) |
501 | /* A compiler attribute is available in gcc versions 4.3.0 and later. */ |
502 | # define _GL_WARN_ON_USE(function, message) \ |
503 | extern __typeof__ (function) function __attribute__ ((__warning__ (message))) |
504 | # define _GL_WARN_ON_USE_ATTRIBUTE(message) \ |
505 | __attribute__ ((__warning__ (message))) |
506 | # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING |
507 | /* Verify the existence of the function. */ |
508 | # define _GL_WARN_ON_USE(function, message) \ |
509 | extern __typeof__ (function) function |
510 | # define _GL_WARN_ON_USE_ATTRIBUTE(message) |
511 | # else /* Unsupported. */ |
512 | # define _GL_WARN_ON_USE(function, message) \ |
513 | _GL_WARN_EXTERN_C int _gl_warn_on_use |
514 | # define _GL_WARN_ON_USE_ATTRIBUTE(message) |
515 | # endif |
516 | #endif |
517 | |
518 | /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string") |
519 | is like _GL_WARN_ON_USE (function, "string"), except that the function is |
520 | declared with the given prototype, consisting of return type, parameters, |
521 | and attributes. |
522 | This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does |
523 | not work in this case. */ |
524 | #ifndef _GL_WARN_ON_USE_CXX |
525 | # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) |
526 | # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ |
527 | extern rettype function parameters_and_attributes \ |
528 | __attribute__ ((__warning__ (msg))) |
529 | # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING |
530 | /* Verify the existence of the function. */ |
531 | # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ |
532 | extern rettype function parameters_and_attributes |
533 | # else /* Unsupported. */ |
534 | # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ |
535 | _GL_WARN_EXTERN_C int _gl_warn_on_use |
536 | # endif |
537 | #endif |
538 | |
539 | /* _GL_WARN_EXTERN_C declaration; |
540 | performs the declaration with C linkage. */ |
541 | #ifndef _GL_WARN_EXTERN_C |
542 | # if defined __cplusplus |
543 | # define _GL_WARN_EXTERN_C extern "C" |
544 | # else |
545 | # define _GL_WARN_EXTERN_C extern |
546 | # endif |
547 | #endif |
548 | |
549 | /* On AIX, sig_atomic_t already includes volatile. C99 requires that |
550 | 'volatile sig_atomic_t' ignore the extra modifier, but C89 did not. |
551 | Hence, redefine this to a non-volatile type as needed. */ |
552 | #if ! 1 |
553 | # if !GNULIB_defined_sig_atomic_t |
554 | typedef int rpl_sig_atomic_t; |
555 | # undef sig_atomic_t |
556 | # define sig_atomic_t rpl_sig_atomic_t |
557 | # define GNULIB_defined_sig_atomic_t 1 |
558 | # endif |
559 | #endif |
560 | |
561 | /* A set or mask of signals. */ |
562 | #if !1 |
563 | # if !GNULIB_defined_sigset_t |
564 | typedef unsigned int sigset_t; |
565 | # define GNULIB_defined_sigset_t 1 |
566 | # endif |
567 | #endif |
568 | |
569 | /* Define sighandler_t, the type of signal handlers. A GNU extension. */ |
570 | #if !1 |
571 | # ifdef __cplusplus |
572 | extern "C" { |
573 | # endif |
574 | # if !GNULIB_defined_sighandler_t |
575 | typedef void (*sighandler_t) (int); |
576 | # define GNULIB_defined_sighandler_t 1 |
577 | # endif |
578 | # ifdef __cplusplus |
579 | } |
580 | # endif |
581 | #endif |
582 | |
583 | |
584 | #if 0 |
585 | # ifndef SIGPIPE |
586 | /* Define SIGPIPE to a value that does not overlap with other signals. */ |
587 | # define SIGPIPE 13 |
588 | # define GNULIB_defined_SIGPIPE 1 |
589 | /* To actually use SIGPIPE, you also need the gnulib modules 'sigprocmask', |
590 | 'write', 'stdio'. */ |
591 | # endif |
592 | #endif |
593 | |
594 | |
595 | /* Maximum signal number + 1. */ |
596 | #ifndef NSIG |
597 | # if defined __TANDEM |
598 | # define NSIG 32 |
599 | # endif |
600 | #endif |
601 | |
602 | |
603 | #if 0 |
604 | # if 0 |
605 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
606 | # undef pthread_sigmask |
607 | # define pthread_sigmask rpl_pthread_sigmask |
608 | # endif |
609 | _GL_FUNCDECL_RPL (pthread_sigmask, int, |
610 | (int how, const sigset_t *new_mask, sigset_t *old_mask)); |
611 | _GL_CXXALIAS_RPL (pthread_sigmask, int, |
612 | (int how, const sigset_t *new_mask, sigset_t *old_mask)); |
613 | # else |
614 | # if !(1 || defined pthread_sigmask) |
615 | _GL_FUNCDECL_SYS (pthread_sigmask, int, |
616 | (int how, const sigset_t *new_mask, sigset_t *old_mask)); |
617 | # endif |
618 | _GL_CXXALIAS_SYS (pthread_sigmask, int, |
619 | (int how, const sigset_t *new_mask, sigset_t *old_mask)); |
620 | # endif |
621 | _GL_CXXALIASWARN (pthread_sigmask); |
622 | #elif defined GNULIB_POSIXCHECK |
623 | # undef pthread_sigmask |
624 | # if HAVE_RAW_DECL_PTHREAD_SIGMASK |
625 | _GL_WARN_ON_USE (pthread_sigmask, "pthread_sigmask is not portable - " |
626 | "use gnulib module pthread_sigmask for portability" ); |
627 | # endif |
628 | #endif |
629 | |
630 | |
631 | #if 1 |
632 | # if 0 |
633 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
634 | # undef raise |
635 | # define raise rpl_raise |
636 | # endif |
637 | _GL_FUNCDECL_RPL (raise, int, (int sig)); |
638 | _GL_CXXALIAS_RPL (raise, int, (int sig)); |
639 | # else |
640 | # if !1 |
641 | _GL_FUNCDECL_SYS (raise, int, (int sig)); |
642 | # endif |
643 | _GL_CXXALIAS_SYS (raise, int, (int sig)); |
644 | # endif |
645 | _GL_CXXALIASWARN (raise); |
646 | #elif defined GNULIB_POSIXCHECK |
647 | # undef raise |
648 | /* Assume raise is always declared. */ |
649 | _GL_WARN_ON_USE (raise, "raise can crash on native Windows - " |
650 | "use gnulib module raise for portability" ); |
651 | #endif |
652 | |
653 | |
654 | #if 1 |
655 | # if !1 |
656 | |
657 | # ifndef GNULIB_defined_signal_blocking |
658 | # define GNULIB_defined_signal_blocking 1 |
659 | # endif |
660 | |
661 | /* Maximum signal number + 1. */ |
662 | # ifndef NSIG |
663 | # define NSIG 32 |
664 | # endif |
665 | |
666 | /* This code supports only 32 signals. */ |
667 | # if !GNULIB_defined_verify_NSIG_constraint |
668 | typedef int verify_NSIG_constraint[NSIG <= 32 ? 1 : -1]; |
669 | # define GNULIB_defined_verify_NSIG_constraint 1 |
670 | # endif |
671 | |
672 | # endif |
673 | |
674 | /* When also using extern inline, suppress the use of static inline in |
675 | standard headers of problematic Apple configurations, as Libc at |
676 | least through Libc-825.26 (2013-04-09) mishandles it; see, e.g., |
677 | <https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html>. |
678 | Perhaps Apple will fix this some day. */ |
679 | #if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \ |
680 | && (defined __i386__ || defined __x86_64__)) |
681 | # undef sigaddset |
682 | # undef sigdelset |
683 | # undef sigemptyset |
684 | # undef sigfillset |
685 | # undef sigismember |
686 | #endif |
687 | |
688 | /* Test whether a given signal is contained in a signal set. */ |
689 | # if 1 |
690 | /* This function is defined as a macro on Mac OS X. */ |
691 | # if defined __cplusplus && defined GNULIB_NAMESPACE |
692 | # undef sigismember |
693 | # endif |
694 | # else |
695 | _GL_FUNCDECL_SYS (sigismember, int, (const sigset_t *set, int sig) |
696 | _GL_ARG_NONNULL ((1))); |
697 | # endif |
698 | _GL_CXXALIAS_SYS (sigismember, int, (const sigset_t *set, int sig)); |
699 | _GL_CXXALIASWARN (sigismember); |
700 | |
701 | /* Initialize a signal set to the empty set. */ |
702 | # if 1 |
703 | /* This function is defined as a macro on Mac OS X. */ |
704 | # if defined __cplusplus && defined GNULIB_NAMESPACE |
705 | # undef sigemptyset |
706 | # endif |
707 | # else |
708 | _GL_FUNCDECL_SYS (sigemptyset, int, (sigset_t *set) _GL_ARG_NONNULL ((1))); |
709 | # endif |
710 | _GL_CXXALIAS_SYS (sigemptyset, int, (sigset_t *set)); |
711 | _GL_CXXALIASWARN (sigemptyset); |
712 | |
713 | /* Add a signal to a signal set. */ |
714 | # if 1 |
715 | /* This function is defined as a macro on Mac OS X. */ |
716 | # if defined __cplusplus && defined GNULIB_NAMESPACE |
717 | # undef sigaddset |
718 | # endif |
719 | # else |
720 | _GL_FUNCDECL_SYS (sigaddset, int, (sigset_t *set, int sig) |
721 | _GL_ARG_NONNULL ((1))); |
722 | # endif |
723 | _GL_CXXALIAS_SYS (sigaddset, int, (sigset_t *set, int sig)); |
724 | _GL_CXXALIASWARN (sigaddset); |
725 | |
726 | /* Remove a signal from a signal set. */ |
727 | # if 1 |
728 | /* This function is defined as a macro on Mac OS X. */ |
729 | # if defined __cplusplus && defined GNULIB_NAMESPACE |
730 | # undef sigdelset |
731 | # endif |
732 | # else |
733 | _GL_FUNCDECL_SYS (sigdelset, int, (sigset_t *set, int sig) |
734 | _GL_ARG_NONNULL ((1))); |
735 | # endif |
736 | _GL_CXXALIAS_SYS (sigdelset, int, (sigset_t *set, int sig)); |
737 | _GL_CXXALIASWARN (sigdelset); |
738 | |
739 | /* Fill a signal set with all possible signals. */ |
740 | # if 1 |
741 | /* This function is defined as a macro on Mac OS X. */ |
742 | # if defined __cplusplus && defined GNULIB_NAMESPACE |
743 | # undef sigfillset |
744 | # endif |
745 | # else |
746 | _GL_FUNCDECL_SYS (sigfillset, int, (sigset_t *set) _GL_ARG_NONNULL ((1))); |
747 | # endif |
748 | _GL_CXXALIAS_SYS (sigfillset, int, (sigset_t *set)); |
749 | _GL_CXXALIASWARN (sigfillset); |
750 | |
751 | /* Return the set of those blocked signals that are pending. */ |
752 | # if !1 |
753 | _GL_FUNCDECL_SYS (sigpending, int, (sigset_t *set) _GL_ARG_NONNULL ((1))); |
754 | # endif |
755 | _GL_CXXALIAS_SYS (sigpending, int, (sigset_t *set)); |
756 | _GL_CXXALIASWARN (sigpending); |
757 | |
758 | /* If OLD_SET is not NULL, put the current set of blocked signals in *OLD_SET. |
759 | Then, if SET is not NULL, affect the current set of blocked signals by |
760 | combining it with *SET as indicated in OPERATION. |
761 | In this implementation, you are not allowed to change a signal handler |
762 | while the signal is blocked. */ |
763 | # if !1 |
764 | # define SIG_BLOCK 0 /* blocked_set = blocked_set | *set; */ |
765 | # define SIG_SETMASK 1 /* blocked_set = *set; */ |
766 | # define SIG_UNBLOCK 2 /* blocked_set = blocked_set & ~*set; */ |
767 | _GL_FUNCDECL_SYS (sigprocmask, int, |
768 | (int operation, const sigset_t *set, sigset_t *old_set)); |
769 | # endif |
770 | _GL_CXXALIAS_SYS (sigprocmask, int, |
771 | (int operation, const sigset_t *set, sigset_t *old_set)); |
772 | _GL_CXXALIASWARN (sigprocmask); |
773 | |
774 | /* Install the handler FUNC for signal SIG, and return the previous |
775 | handler. */ |
776 | # ifdef __cplusplus |
777 | extern "C" { |
778 | # endif |
779 | # if !GNULIB_defined_function_taking_int_returning_void_t |
780 | typedef void (*_gl_function_taking_int_returning_void_t) (int); |
781 | # define GNULIB_defined_function_taking_int_returning_void_t 1 |
782 | # endif |
783 | # ifdef __cplusplus |
784 | } |
785 | # endif |
786 | # if !1 |
787 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
788 | # define signal rpl_signal |
789 | # endif |
790 | _GL_FUNCDECL_RPL (signal, _gl_function_taking_int_returning_void_t, |
791 | (int sig, _gl_function_taking_int_returning_void_t func)); |
792 | _GL_CXXALIAS_RPL (signal, _gl_function_taking_int_returning_void_t, |
793 | (int sig, _gl_function_taking_int_returning_void_t func)); |
794 | # else |
795 | _GL_CXXALIAS_SYS (signal, _gl_function_taking_int_returning_void_t, |
796 | (int sig, _gl_function_taking_int_returning_void_t func)); |
797 | # endif |
798 | _GL_CXXALIASWARN (signal); |
799 | |
800 | # if !1 && GNULIB_defined_SIGPIPE |
801 | /* Raise signal SIGPIPE. */ |
802 | _GL_EXTERN_C int _gl_raise_SIGPIPE (void); |
803 | # endif |
804 | |
805 | #elif defined GNULIB_POSIXCHECK |
806 | # undef sigaddset |
807 | # if HAVE_RAW_DECL_SIGADDSET |
808 | _GL_WARN_ON_USE (sigaddset, "sigaddset is unportable - " |
809 | "use the gnulib module sigprocmask for portability" ); |
810 | # endif |
811 | # undef sigdelset |
812 | # if HAVE_RAW_DECL_SIGDELSET |
813 | _GL_WARN_ON_USE (sigdelset, "sigdelset is unportable - " |
814 | "use the gnulib module sigprocmask for portability" ); |
815 | # endif |
816 | # undef sigemptyset |
817 | # if HAVE_RAW_DECL_SIGEMPTYSET |
818 | _GL_WARN_ON_USE (sigemptyset, "sigemptyset is unportable - " |
819 | "use the gnulib module sigprocmask for portability" ); |
820 | # endif |
821 | # undef sigfillset |
822 | # if HAVE_RAW_DECL_SIGFILLSET |
823 | _GL_WARN_ON_USE (sigfillset, "sigfillset is unportable - " |
824 | "use the gnulib module sigprocmask for portability" ); |
825 | # endif |
826 | # undef sigismember |
827 | # if HAVE_RAW_DECL_SIGISMEMBER |
828 | _GL_WARN_ON_USE (sigismember, "sigismember is unportable - " |
829 | "use the gnulib module sigprocmask for portability" ); |
830 | # endif |
831 | # undef sigpending |
832 | # if HAVE_RAW_DECL_SIGPENDING |
833 | _GL_WARN_ON_USE (sigpending, "sigpending is unportable - " |
834 | "use the gnulib module sigprocmask for portability" ); |
835 | # endif |
836 | # undef sigprocmask |
837 | # if HAVE_RAW_DECL_SIGPROCMASK |
838 | _GL_WARN_ON_USE (sigprocmask, "sigprocmask is unportable - " |
839 | "use the gnulib module sigprocmask for portability" ); |
840 | # endif |
841 | #endif /* 1 */ |
842 | |
843 | |
844 | #if 1 |
845 | # if !1 |
846 | |
847 | # if !1 |
848 | |
849 | # if !GNULIB_defined_siginfo_types |
850 | |
851 | /* Present to allow compilation, but unsupported by gnulib. */ |
852 | union sigval |
853 | { |
854 | int sival_int; |
855 | void *sival_ptr; |
856 | }; |
857 | |
858 | /* Present to allow compilation, but unsupported by gnulib. */ |
859 | struct siginfo_t |
860 | { |
861 | int si_signo; |
862 | int si_code; |
863 | int si_errno; |
864 | pid_t si_pid; |
865 | uid_t si_uid; |
866 | void *si_addr; |
867 | int si_status; |
868 | long si_band; |
869 | union sigval si_value; |
870 | }; |
871 | typedef struct siginfo_t siginfo_t; |
872 | |
873 | # define GNULIB_defined_siginfo_types 1 |
874 | # endif |
875 | |
876 | # endif /* !1 */ |
877 | |
878 | /* We assume that platforms which lack the sigaction() function also lack |
879 | the 'struct sigaction' type, and vice versa. */ |
880 | |
881 | # if !GNULIB_defined_struct_sigaction |
882 | |
883 | struct sigaction |
884 | { |
885 | union |
886 | { |
887 | void (*_sa_handler) (int); |
888 | /* Present to allow compilation, but unsupported by gnulib. POSIX |
889 | says that implementations may, but not must, make sa_sigaction |
890 | overlap with sa_handler, but we know of no implementation where |
891 | they do not overlap. */ |
892 | void (*_sa_sigaction) (int, siginfo_t *, void *); |
893 | } _sa_func; |
894 | sigset_t sa_mask; |
895 | /* Not all POSIX flags are supported. */ |
896 | int sa_flags; |
897 | }; |
898 | # define sa_handler _sa_func._sa_handler |
899 | # define sa_sigaction _sa_func._sa_sigaction |
900 | /* Unsupported flags are not present. */ |
901 | # define SA_RESETHAND 1 |
902 | # define SA_NODEFER 2 |
903 | # define SA_RESTART 4 |
904 | |
905 | # define GNULIB_defined_struct_sigaction 1 |
906 | # endif |
907 | |
908 | _GL_FUNCDECL_SYS (sigaction, int, (int, const struct sigaction *restrict, |
909 | struct sigaction *restrict)); |
910 | |
911 | # elif !1 |
912 | |
913 | # define sa_sigaction sa_handler |
914 | |
915 | # endif /* !1, !1 */ |
916 | |
917 | _GL_CXXALIAS_SYS (sigaction, int, (int, const struct sigaction *restrict, |
918 | struct sigaction *restrict)); |
919 | _GL_CXXALIASWARN (sigaction); |
920 | |
921 | #elif defined GNULIB_POSIXCHECK |
922 | # undef sigaction |
923 | # if HAVE_RAW_DECL_SIGACTION |
924 | _GL_WARN_ON_USE (sigaction, "sigaction is unportable - " |
925 | "use the gnulib module sigaction for portability" ); |
926 | # endif |
927 | #endif |
928 | |
929 | /* Some systems don't have SA_NODEFER. */ |
930 | #ifndef SA_NODEFER |
931 | # define SA_NODEFER 0 |
932 | #endif |
933 | |
934 | |
935 | #endif /* _GL_SIGNAL_H */ |
936 | #endif /* _GL_SIGNAL_H */ |
937 | #endif |
938 | |