1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ 2 /* A GNU-like <signal.h>. 3 4 Copyright (C) 2006-2021 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 OS/2 kLIBC 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__ || defined __KLIBC__) \ 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-2021 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_MDA (func, rettype, parameters); 220 is to be used when func is a Microsoft deprecated alias, on native Windows. 221 It declares a C++ alias called GNULIB_NAMESPACE::func 222 that redirects to _func, if GNULIB_NAMESPACE is defined. 223 Example: 224 _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...)); 225 */ 226 #define _GL_CXXALIAS_MDA(func,rettype,parameters) \ 227 _GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters) 228 229 /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); 230 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); 231 except that the C function rpl_func may have a slightly different 232 declaration. A cast is used to silence the "invalid conversion" error 233 that would otherwise occur. */ 234 #if defined __cplusplus && defined GNULIB_NAMESPACE 235 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 236 namespace GNULIB_NAMESPACE \ 237 { \ 238 static const struct _gl_ ## func ## _wrapper \ 239 { \ 240 typedef rettype (*type) parameters; \ 241 \ 242 inline operator type () const \ 243 { \ 244 return reinterpret_cast<type>(::rpl_func); \ 245 } \ 246 } func = {}; \ 247 } \ 248 _GL_EXTERN_C int _gl_cxxalias_dummy 249 #else 250 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 251 _GL_EXTERN_C int _gl_cxxalias_dummy 252 #endif 253 254 /* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters); 255 is like _GL_CXXALIAS_MDA (func, rettype, parameters); 256 except that the C function func may have a slightly different declaration. 257 A cast is used to silence the "invalid conversion" error that would 258 otherwise occur. */ 259 #define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \ 260 _GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters) 261 262 /* _GL_CXXALIAS_SYS (func, rettype, parameters); 263 declares a C++ alias called GNULIB_NAMESPACE::func 264 that redirects to the system provided function func, if GNULIB_NAMESPACE 265 is defined. 266 Example: 267 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); 268 269 Wrapping func in an object with an inline conversion operator 270 avoids a reference to func unless GNULIB_NAMESPACE::func is 271 actually used in the program. */ 272 #if defined __cplusplus && defined GNULIB_NAMESPACE 273 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 274 namespace GNULIB_NAMESPACE \ 275 { \ 276 static const struct _gl_ ## func ## _wrapper \ 277 { \ 278 typedef rettype (*type) parameters; \ 279 \ 280 inline operator type () const \ 281 { \ 282 return ::func; \ 283 } \ 284 } func = {}; \ 285 } \ 286 _GL_EXTERN_C int _gl_cxxalias_dummy 287 #else 288 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 289 _GL_EXTERN_C int _gl_cxxalias_dummy 290 #endif 291 292 /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); 293 is like _GL_CXXALIAS_SYS (func, rettype, parameters); 294 except that the C function func may have a slightly different declaration. 295 A cast is used to silence the "invalid conversion" error that would 296 otherwise occur. */ 297 #if defined __cplusplus && defined GNULIB_NAMESPACE 298 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 299 namespace GNULIB_NAMESPACE \ 300 { \ 301 static const struct _gl_ ## func ## _wrapper \ 302 { \ 303 typedef rettype (*type) parameters; \ 304 \ 305 inline operator type () const \ 306 { \ 307 return reinterpret_cast<type>(::func); \ 308 } \ 309 } func = {}; \ 310 } \ 311 _GL_EXTERN_C int _gl_cxxalias_dummy 312 #else 313 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 314 _GL_EXTERN_C int _gl_cxxalias_dummy 315 #endif 316 317 /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); 318 is like _GL_CXXALIAS_SYS (func, rettype, parameters); 319 except that the C function is picked among a set of overloaded functions, 320 namely the one with rettype2 and parameters2. Two consecutive casts 321 are used to silence the "cannot find a match" and "invalid conversion" 322 errors that would otherwise occur. */ 323 #if defined __cplusplus && defined GNULIB_NAMESPACE 324 /* The outer cast must be a reinterpret_cast. 325 The inner cast: When the function is defined as a set of overloaded 326 functions, it works as a static_cast<>, choosing the designated variant. 327 When the function is defined as a single variant, it works as a 328 reinterpret_cast<>. The parenthesized cast syntax works both ways. */ 329 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 330 namespace GNULIB_NAMESPACE \ 331 { \ 332 static const struct _gl_ ## func ## _wrapper \ 333 { \ 334 typedef rettype (*type) parameters; \ 335 \ 336 inline operator type () const \ 337 { \ 338 return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \ 339 } \ 340 } func = {}; \ 341 } \ 342 _GL_EXTERN_C int _gl_cxxalias_dummy 343 #else 344 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 345 _GL_EXTERN_C int _gl_cxxalias_dummy 346 #endif 347 348 /* _GL_CXXALIASWARN (func); 349 causes a warning to be emitted when ::func is used but not when 350 GNULIB_NAMESPACE::func is used. func must be defined without overloaded 351 variants. */ 352 #if defined __cplusplus && defined GNULIB_NAMESPACE 353 # define _GL_CXXALIASWARN(func) \ 354 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) 355 # define _GL_CXXALIASWARN_1(func,namespace) \ 356 _GL_CXXALIASWARN_2 (func, namespace) 357 /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 358 we enable the warning only when not optimizing. */ 359 # if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__) 360 # define _GL_CXXALIASWARN_2(func,namespace) \ 361 _GL_WARN_ON_USE (func, \ 362 "The symbol ::" #func " refers to the system function. " \ 363 "Use " #namespace "::" #func " instead.") 364 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 365 # define _GL_CXXALIASWARN_2(func,namespace) \ 366 extern __typeof__ (func) func 367 # else 368 # define _GL_CXXALIASWARN_2(func,namespace) \ 369 _GL_EXTERN_C int _gl_cxxalias_dummy 370 # endif 371 #else 372 # define _GL_CXXALIASWARN(func) \ 373 _GL_EXTERN_C int _gl_cxxalias_dummy 374 #endif 375 376 /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); 377 causes a warning to be emitted when the given overloaded variant of ::func 378 is used but not when GNULIB_NAMESPACE::func is used. */ 379 #if defined __cplusplus && defined GNULIB_NAMESPACE 380 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 381 _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ 382 GNULIB_NAMESPACE) 383 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ 384 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) 385 /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 386 we enable the warning only when not optimizing. */ 387 # if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__) 388 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 389 _GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \ 390 "The symbol ::" #func " refers to the system function. " \ 391 "Use " #namespace "::" #func " instead.") 392 # else 393 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 394 _GL_EXTERN_C int _gl_cxxalias_dummy 395 # endif 396 #else 397 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 398 _GL_EXTERN_C int _gl_cxxalias_dummy 399 #endif 400 401 #endif /* _GL_CXXDEFS_H */ 402 403 /* The definition of _GL_ARG_NONNULL is copied here. */ 404 /* A C macro for declaring that specific arguments must not be NULL. 405 Copyright (C) 2009-2021 Free Software Foundation, Inc. 406 407 This program is free software: you can redistribute it and/or modify it 408 under the terms of the GNU General Public License as published 409 by the Free Software Foundation; either version 3 of the License, or 410 (at your option) any later version. 411 412 This program is distributed in the hope that it will be useful, 413 but WITHOUT ANY WARRANTY; without even the implied warranty of 414 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 415 General Public License for more details. 416 417 You should have received a copy of the GNU General Public License 418 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 419 420 /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools 421 that the values passed as arguments n, ..., m must be non-NULL pointers. 422 n = 1 stands for the first argument, n = 2 for the second argument etc. */ 423 #ifndef _GL_ARG_NONNULL 424 # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__ 425 # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) 426 # else 427 # define _GL_ARG_NONNULL(params) 428 # endif 429 #endif 430 431 /* The definition of _GL_WARN_ON_USE is copied here. */ 432 /* A C macro for emitting warnings if a function is used. 433 Copyright (C) 2010-2021 Free Software Foundation, Inc. 434 435 This program is free software: you can redistribute it and/or modify it 436 under the terms of the GNU General Public License as published 437 by the Free Software Foundation; either version 3 of the License, or 438 (at your option) any later version. 439 440 This program is distributed in the hope that it will be useful, 441 but WITHOUT ANY WARRANTY; without even the implied warranty of 442 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 443 General Public License for more details. 444 445 You should have received a copy of the GNU General Public License 446 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 447 448 /* _GL_WARN_ON_USE (function, "literal string") issues a declaration 449 for FUNCTION which will then trigger a compiler warning containing 450 the text of "literal string" anywhere that function is called, if 451 supported by the compiler. If the compiler does not support this 452 feature, the macro expands to an unused extern declaration. 453 454 _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the 455 attribute used in _GL_WARN_ON_USE. If the compiler does not support 456 this feature, it expands to empty. 457 458 These macros are useful for marking a function as a potential 459 portability trap, with the intent that "literal string" include 460 instructions on the replacement function that should be used 461 instead. 462 _GL_WARN_ON_USE is for functions with 'extern' linkage. 463 _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline' 464 linkage. 465 466 However, one of the reasons that a function is a portability trap is 467 if it has the wrong signature. Declaring FUNCTION with a different 468 signature in C is a compilation error, so this macro must use the 469 same type as any existing declaration so that programs that avoid 470 the problematic FUNCTION do not fail to compile merely because they 471 included a header that poisoned the function. But this implies that 472 _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already 473 have a declaration. Use of this macro implies that there must not 474 be any other macro hiding the declaration of FUNCTION; but 475 undefining FUNCTION first is part of the poisoning process anyway 476 (although for symbols that are provided only via a macro, the result 477 is a compilation error rather than a warning containing 478 "literal string"). Also note that in C++, it is only safe to use if 479 FUNCTION has no overloads. 480 481 For an example, it is possible to poison 'getline' by: 482 - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]], 483 [getline]) in configure.ac, which potentially defines 484 HAVE_RAW_DECL_GETLINE 485 - adding this code to a header that wraps the system <stdio.h>: 486 #undef getline 487 #if HAVE_RAW_DECL_GETLINE 488 _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but" 489 "not universally present; use the gnulib module getline"); 490 #endif 491 492 It is not possible to directly poison global variables. But it is 493 possible to write a wrapper accessor function, and poison that 494 (less common usage, like &environ, will cause a compilation error 495 rather than issue the nice warning, but the end result of informing 496 the developer about their portability problem is still achieved): 497 #if HAVE_RAW_DECL_ENVIRON 498 static char *** 499 rpl_environ (void) { return &environ; } 500 _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); 501 # undef environ 502 # define environ (*rpl_environ ()) 503 #endif 504 or better (avoiding contradictory use of 'static' and 'extern'): 505 #if HAVE_RAW_DECL_ENVIRON 506 static char *** 507 _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared") 508 rpl_environ (void) { return &environ; } 509 # undef environ 510 # define environ (*rpl_environ ()) 511 #endif 512 */ 513 #ifndef _GL_WARN_ON_USE 514 515 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 516 /* A compiler attribute is available in gcc versions 4.3.0 and later. */ 517 # define _GL_WARN_ON_USE(function, message) \ 518 extern __typeof__ (function) function __attribute__ ((__warning__ (message))) 519 # define _GL_WARN_ON_USE_ATTRIBUTE(message) \ 520 __attribute__ ((__warning__ (message))) 521 # elif __clang_major__ >= 4 522 /* Another compiler attribute is available in clang. */ 523 # define _GL_WARN_ON_USE(function, message) \ 524 extern __typeof__ (function) function \ 525 __attribute__ ((__diagnose_if__ (1, message, "warning"))) 526 # define _GL_WARN_ON_USE_ATTRIBUTE(message) \ 527 __attribute__ ((__diagnose_if__ (1, message, "warning"))) 528 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 529 /* Verify the existence of the function. */ 530 # define _GL_WARN_ON_USE(function, message) \ 531 extern __typeof__ (function) function 532 # define _GL_WARN_ON_USE_ATTRIBUTE(message) 533 # else /* Unsupported. */ 534 # define _GL_WARN_ON_USE(function, message) \ 535 _GL_WARN_EXTERN_C int _gl_warn_on_use 536 # define _GL_WARN_ON_USE_ATTRIBUTE(message) 537 # endif 538 #endif 539 540 /* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message") 541 is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the 542 function is declared with the given prototype, consisting of return type, 543 parameters, and attributes. 544 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does 545 not work in this case. */ 546 #ifndef _GL_WARN_ON_USE_CXX 547 # if !defined __cplusplus 548 # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 549 _GL_WARN_ON_USE (function, msg) 550 # else 551 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 552 /* A compiler attribute is available in gcc versions 4.3.0 and later. */ 553 # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 554 extern rettype_gcc function parameters_and_attributes \ 555 __attribute__ ((__warning__ (msg))) 556 # elif __clang_major__ >= 4 557 /* Another compiler attribute is available in clang. */ 558 # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 559 extern rettype_clang function parameters_and_attributes \ 560 __attribute__ ((__diagnose_if__ (1, msg, "warning"))) 561 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 562 /* Verify the existence of the function. */ 563 # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 564 extern rettype_gcc function parameters_and_attributes 565 # else /* Unsupported. */ 566 # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 567 _GL_WARN_EXTERN_C int _gl_warn_on_use 568 # endif 569 # endif 570 #endif 571 572 /* _GL_WARN_EXTERN_C declaration; 573 performs the declaration with C linkage. */ 574 #ifndef _GL_WARN_EXTERN_C 575 # if defined __cplusplus 576 # define _GL_WARN_EXTERN_C extern "C" 577 # else 578 # define _GL_WARN_EXTERN_C extern 579 # endif 580 #endif 581 582 /* On AIX, sig_atomic_t already includes volatile. C99 requires that 583 'volatile sig_atomic_t' ignore the extra modifier, but C89 did not. 584 Hence, redefine this to a non-volatile type as needed. */ 585 #if ! 1 586 # if !GNULIB_defined_sig_atomic_t 587 typedef int rpl_sig_atomic_t; 588 # undef sig_atomic_t 589 # define sig_atomic_t rpl_sig_atomic_t 590 # define GNULIB_defined_sig_atomic_t 1 591 # endif 592 #endif 593 594 /* A set or mask of signals. */ 595 #if !1 596 # if !GNULIB_defined_sigset_t 597 typedef unsigned int sigset_t; 598 # define GNULIB_defined_sigset_t 1 599 # endif 600 #endif 601 602 /* Define sighandler_t, the type of signal handlers. A GNU extension. */ 603 #if !0 604 # ifdef __cplusplus 605 extern "C" { 606 # endif 607 # if !GNULIB_defined_sighandler_t 608 typedef void (*sighandler_t) (int); 609 # define GNULIB_defined_sighandler_t 1 610 # endif 611 # ifdef __cplusplus 612 } 613 # endif 614 #endif 615 616 617 #if 0 618 # ifndef SIGPIPE 619 /* Define SIGPIPE to a value that does not overlap with other signals. */ 620 # define SIGPIPE 13 621 # define GNULIB_defined_SIGPIPE 1 622 /* To actually use SIGPIPE, you also need the gnulib modules 'sigprocmask', 623 'write', 'stdio'. */ 624 # endif 625 #endif 626 627 628 /* Maximum signal number + 1. */ 629 #ifndef NSIG 630 # if defined __TANDEM 631 # define NSIG 32 632 # endif 633 #endif 634 635 636 #if 0 637 # if 0 638 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 639 # undef pthread_sigmask 640 # define pthread_sigmask rpl_pthread_sigmask 641 # endif 642 _GL_FUNCDECL_RPL (pthread_sigmask, int, 643 (int how, 644 const sigset_t *restrict new_mask, 645 sigset_t *restrict old_mask)); 646 _GL_CXXALIAS_RPL (pthread_sigmask, int, 647 (int how, 648 const sigset_t *restrict new_mask, 649 sigset_t *restrict old_mask)); 650 # else 651 # if !(1 || defined pthread_sigmask) 652 _GL_FUNCDECL_SYS (pthread_sigmask, int, 653 (int how, 654 const sigset_t *restrict new_mask, 655 sigset_t *restrict old_mask)); 656 # endif 657 _GL_CXXALIAS_SYS (pthread_sigmask, int, 658 (int how, 659 const sigset_t *restrict new_mask, 660 sigset_t *restrict old_mask)); 661 # endif 662 # if __GLIBC__ >= 2 663 _GL_CXXALIASWARN (pthread_sigmask); 664 # endif 665 #elif defined GNULIB_POSIXCHECK 666 # undef pthread_sigmask 667 # if HAVE_RAW_DECL_PTHREAD_SIGMASK 668 _GL_WARN_ON_USE (pthread_sigmask, "pthread_sigmask is not portable - " 669 "use gnulib module pthread_sigmask for portability"); 670 # endif 671 #endif 672 673 674 #if 1 675 # if 0 676 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 677 # undef raise 678 # define raise rpl_raise 679 # endif 680 _GL_FUNCDECL_RPL (raise, int, (int sig)); 681 _GL_CXXALIAS_RPL (raise, int, (int sig)); 682 # else 683 # if !1 684 _GL_FUNCDECL_SYS (raise, int, (int sig)); 685 # endif 686 _GL_CXXALIAS_SYS (raise, int, (int sig)); 687 # endif 688 # if __GLIBC__ >= 2 689 _GL_CXXALIASWARN (raise); 690 # endif 691 #elif defined GNULIB_POSIXCHECK 692 # undef raise 693 /* Assume raise is always declared. */ 694 _GL_WARN_ON_USE (raise, "raise can crash on native Windows - " 695 "use gnulib module raise for portability"); 696 #endif 697 698 699 #if 0 700 # if !1 701 702 # ifndef GNULIB_defined_signal_blocking 703 # define GNULIB_defined_signal_blocking 1 704 # endif 705 706 /* Maximum signal number + 1. */ 707 # ifndef NSIG 708 # define NSIG 32 709 # endif 710 711 /* This code supports only 32 signals. */ 712 # if !GNULIB_defined_verify_NSIG_constraint 713 typedef int verify_NSIG_constraint[NSIG <= 32 ? 1 : -1]; 714 # define GNULIB_defined_verify_NSIG_constraint 1 715 # endif 716 717 # endif 718 719 /* When also using extern inline, suppress the use of static inline in 720 standard headers of problematic Apple configurations, as Libc at 721 least through Libc-825.26 (2013-04-09) mishandles it; see, e.g., 722 <https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html>. 723 Perhaps Apple will fix this some day. */ 724 #if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \ 725 && (defined __i386__ || defined __x86_64__)) 726 # undef sigaddset 727 # undef sigdelset 728 # undef sigemptyset 729 # undef sigfillset 730 # undef sigismember 731 #endif 732 733 /* Test whether a given signal is contained in a signal set. */ 734 # if 1 735 /* This function is defined as a macro on Mac OS X. */ 736 # if defined __cplusplus && defined GNULIB_NAMESPACE 737 # undef sigismember 738 # endif 739 # else 740 _GL_FUNCDECL_SYS (sigismember, int, (const sigset_t *set, int sig) 741 _GL_ARG_NONNULL ((1))); 742 # endif 743 _GL_CXXALIAS_SYS (sigismember, int, (const sigset_t *set, int sig)); 744 _GL_CXXALIASWARN (sigismember); 745 746 /* Initialize a signal set to the empty set. */ 747 # if 1 748 /* This function is defined as a macro on Mac OS X. */ 749 # if defined __cplusplus && defined GNULIB_NAMESPACE 750 # undef sigemptyset 751 # endif 752 # else 753 _GL_FUNCDECL_SYS (sigemptyset, int, (sigset_t *set) _GL_ARG_NONNULL ((1))); 754 # endif 755 _GL_CXXALIAS_SYS (sigemptyset, int, (sigset_t *set)); 756 _GL_CXXALIASWARN (sigemptyset); 757 758 /* Add a signal to a signal set. */ 759 # if 1 760 /* This function is defined as a macro on Mac OS X. */ 761 # if defined __cplusplus && defined GNULIB_NAMESPACE 762 # undef sigaddset 763 # endif 764 # else 765 _GL_FUNCDECL_SYS (sigaddset, int, (sigset_t *set, int sig) 766 _GL_ARG_NONNULL ((1))); 767 # endif 768 _GL_CXXALIAS_SYS (sigaddset, int, (sigset_t *set, int sig)); 769 _GL_CXXALIASWARN (sigaddset); 770 771 /* Remove a signal from a signal set. */ 772 # if 1 773 /* This function is defined as a macro on Mac OS X. */ 774 # if defined __cplusplus && defined GNULIB_NAMESPACE 775 # undef sigdelset 776 # endif 777 # else 778 _GL_FUNCDECL_SYS (sigdelset, int, (sigset_t *set, int sig) 779 _GL_ARG_NONNULL ((1))); 780 # endif 781 _GL_CXXALIAS_SYS (sigdelset, int, (sigset_t *set, int sig)); 782 _GL_CXXALIASWARN (sigdelset); 783 784 /* Fill a signal set with all possible signals. */ 785 # if 1 786 /* This function is defined as a macro on Mac OS X. */ 787 # if defined __cplusplus && defined GNULIB_NAMESPACE 788 # undef sigfillset 789 # endif 790 # else 791 _GL_FUNCDECL_SYS (sigfillset, int, (sigset_t *set) _GL_ARG_NONNULL ((1))); 792 # endif 793 _GL_CXXALIAS_SYS (sigfillset, int, (sigset_t *set)); 794 _GL_CXXALIASWARN (sigfillset); 795 796 /* Return the set of those blocked signals that are pending. */ 797 # if !1 798 _GL_FUNCDECL_SYS (sigpending, int, (sigset_t *set) _GL_ARG_NONNULL ((1))); 799 # endif 800 _GL_CXXALIAS_SYS (sigpending, int, (sigset_t *set)); 801 _GL_CXXALIASWARN (sigpending); 802 803 /* If OLD_SET is not NULL, put the current set of blocked signals in *OLD_SET. 804 Then, if SET is not NULL, affect the current set of blocked signals by 805 combining it with *SET as indicated in OPERATION. 806 In this implementation, you are not allowed to change a signal handler 807 while the signal is blocked. */ 808 # if !1 809 # define SIG_BLOCK 0 /* blocked_set = blocked_set | *set; */ 810 # define SIG_SETMASK 1 /* blocked_set = *set; */ 811 # define SIG_UNBLOCK 2 /* blocked_set = blocked_set & ~*set; */ 812 _GL_FUNCDECL_SYS (sigprocmask, int, 813 (int operation, 814 const sigset_t *restrict set, 815 sigset_t *restrict old_set)); 816 # endif 817 _GL_CXXALIAS_SYS (sigprocmask, int, 818 (int operation, 819 const sigset_t *restrict set, 820 sigset_t *restrict old_set)); 821 _GL_CXXALIASWARN (sigprocmask); 822 823 /* Install the handler FUNC for signal SIG, and return the previous 824 handler. */ 825 # ifdef __cplusplus 826 extern "C" { 827 # endif 828 # if !GNULIB_defined_function_taking_int_returning_void_t 829 typedef void (*_gl_function_taking_int_returning_void_t) (int); 830 # define GNULIB_defined_function_taking_int_returning_void_t 1 831 # endif 832 # ifdef __cplusplus 833 } 834 # endif 835 # if !1 836 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 837 # define signal rpl_signal 838 # endif 839 _GL_FUNCDECL_RPL (signal, _gl_function_taking_int_returning_void_t, 840 (int sig, _gl_function_taking_int_returning_void_t func)); 841 _GL_CXXALIAS_RPL (signal, _gl_function_taking_int_returning_void_t, 842 (int sig, _gl_function_taking_int_returning_void_t func)); 843 # else 844 /* On OpenBSD, the declaration of 'signal' may not be present at this point, 845 because it occurs in <sys/signal.h>, not <signal.h> directly. */ 846 # if defined __OpenBSD__ 847 _GL_FUNCDECL_SYS (signal, _gl_function_taking_int_returning_void_t, 848 (int sig, _gl_function_taking_int_returning_void_t func)); 849 # endif 850 _GL_CXXALIAS_SYS (signal, _gl_function_taking_int_returning_void_t, 851 (int sig, _gl_function_taking_int_returning_void_t func)); 852 # endif 853 # if __GLIBC__ >= 2 854 _GL_CXXALIASWARN (signal); 855 # endif 856 857 # if !1 && GNULIB_defined_SIGPIPE 858 /* Raise signal SIGPIPE. */ 859 _GL_EXTERN_C int _gl_raise_SIGPIPE (void); 860 # endif 861 862 #elif defined GNULIB_POSIXCHECK 863 # undef sigaddset 864 # if HAVE_RAW_DECL_SIGADDSET 865 _GL_WARN_ON_USE (sigaddset, "sigaddset is unportable - " 866 "use the gnulib module sigprocmask for portability"); 867 # endif 868 # undef sigdelset 869 # if HAVE_RAW_DECL_SIGDELSET 870 _GL_WARN_ON_USE (sigdelset, "sigdelset is unportable - " 871 "use the gnulib module sigprocmask for portability"); 872 # endif 873 # undef sigemptyset 874 # if HAVE_RAW_DECL_SIGEMPTYSET 875 _GL_WARN_ON_USE (sigemptyset, "sigemptyset is unportable - " 876 "use the gnulib module sigprocmask for portability"); 877 # endif 878 # undef sigfillset 879 # if HAVE_RAW_DECL_SIGFILLSET 880 _GL_WARN_ON_USE (sigfillset, "sigfillset is unportable - " 881 "use the gnulib module sigprocmask for portability"); 882 # endif 883 # undef sigismember 884 # if HAVE_RAW_DECL_SIGISMEMBER 885 _GL_WARN_ON_USE (sigismember, "sigismember is unportable - " 886 "use the gnulib module sigprocmask for portability"); 887 # endif 888 # undef sigpending 889 # if HAVE_RAW_DECL_SIGPENDING 890 _GL_WARN_ON_USE (sigpending, "sigpending is unportable - " 891 "use the gnulib module sigprocmask for portability"); 892 # endif 893 # undef sigprocmask 894 # if HAVE_RAW_DECL_SIGPROCMASK 895 _GL_WARN_ON_USE (sigprocmask, "sigprocmask is unportable - " 896 "use the gnulib module sigprocmask for portability"); 897 # endif 898 #endif /* 0 */ 899 900 901 #if 0 902 # if !1 903 904 # if !1 905 906 # if !GNULIB_defined_siginfo_types 907 908 /* Present to allow compilation, but unsupported by gnulib. */ 909 union sigval 910 { 911 int sival_int; 912 void *sival_ptr; 913 }; 914 915 /* Present to allow compilation, but unsupported by gnulib. */ 916 struct siginfo_t 917 { 918 int si_signo; 919 int si_code; 920 int si_errno; 921 pid_t si_pid; 922 uid_t si_uid; 923 void *si_addr; 924 int si_status; 925 long si_band; 926 union sigval si_value; 927 }; 928 typedef struct siginfo_t siginfo_t; 929 930 # define GNULIB_defined_siginfo_types 1 931 # endif 932 933 # endif /* !1 */ 934 935 /* We assume that platforms which lack the sigaction() function also lack 936 the 'struct sigaction' type, and vice versa. */ 937 938 # if !GNULIB_defined_struct_sigaction 939 940 struct sigaction 941 { 942 union 943 { 944 void (*_sa_handler) (int); 945 /* Present to allow compilation, but unsupported by gnulib. POSIX 946 says that implementations may, but not must, make sa_sigaction 947 overlap with sa_handler, but we know of no implementation where 948 they do not overlap. */ 949 void (*_sa_sigaction) (int, siginfo_t *, void *); 950 } _sa_func; 951 sigset_t sa_mask; 952 /* Not all POSIX flags are supported. */ 953 int sa_flags; 954 }; 955 # define sa_handler _sa_func._sa_handler 956 # define sa_sigaction _sa_func._sa_sigaction 957 /* Unsupported flags are not present. */ 958 # define SA_RESETHAND 1 959 # define SA_NODEFER 2 960 # define SA_RESTART 4 961 962 # define GNULIB_defined_struct_sigaction 1 963 # endif 964 965 _GL_FUNCDECL_SYS (sigaction, int, (int, const struct sigaction *restrict, 966 struct sigaction *restrict)); 967 968 # elif !1 969 970 # define sa_sigaction sa_handler 971 972 # endif /* !1, !1 */ 973 974 _GL_CXXALIAS_SYS (sigaction, int, (int, const struct sigaction *restrict, 975 struct sigaction *restrict)); 976 _GL_CXXALIASWARN (sigaction); 977 978 #elif defined GNULIB_POSIXCHECK 979 # undef sigaction 980 # if HAVE_RAW_DECL_SIGACTION 981 _GL_WARN_ON_USE (sigaction, "sigaction is unportable - " 982 "use the gnulib module sigaction for portability"); 983 # endif 984 #endif 985 986 /* Some systems don't have SA_NODEFER. */ 987 #ifndef SA_NODEFER 988 # define SA_NODEFER 0 989 #endif 990 991 992 #endif /* _GL_SIGNAL_H */ 993 #endif /* _GL_SIGNAL_H */ 994 #endif 995