1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ 2 /* Like <fcntl.h>, but with non-working flags defined to 0. 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 /* written by Paul Eggert */ 20 21 #if __GNUC__ >= 3 22 #pragma GCC system_header 23 #endif 24 25 26 #if defined __need_system_fcntl_h 27 /* Special invocation convention. */ 28 29 /* Needed before <sys/stat.h>. 30 May also define off_t to a 64-bit type on native Windows. */ 31 #include <sys/types.h> 32 /* On some systems other than glibc, <sys/stat.h> is a prerequisite of 33 <fcntl.h>. On glibc systems, we would like to avoid namespace pollution. 34 But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an 35 extern "C" { ... } block, which leads to errors in C++ mode with the 36 overridden <sys/stat.h> from gnulib. These errors are known to be gone 37 with g++ version >= 4.3. */ 38 #if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))) 39 # include <sys/stat.h> 40 #endif 41 #include_next <fcntl.h> 42 43 /* Native Windows platforms declare open(), creat() in <io.h>. */ 44 #if (0 || 1 || defined GNULIB_POSIXCHECK) \ 45 && (defined _WIN32 && ! defined __CYGWIN__) 46 # include <io.h> 47 #endif 48 49 #else 50 /* Normal invocation convention. */ 51 52 #ifndef _GL_FCNTL_H 53 54 /* Needed before <sys/stat.h>. 55 May also define off_t to a 64-bit type on native Windows. */ 56 #include <sys/types.h> 57 /* On some systems other than glibc, <sys/stat.h> is a prerequisite of 58 <fcntl.h>. On glibc systems, we would like to avoid namespace pollution. 59 But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an 60 extern "C" { ... } block, which leads to errors in C++ mode with the 61 overridden <sys/stat.h> from gnulib. These errors are known to be gone 62 with g++ version >= 4.3. */ 63 #if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && (defined __ICC || !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))) 64 # include <sys/stat.h> 65 #endif 66 /* The include_next requires a split double-inclusion guard. */ 67 #include_next <fcntl.h> 68 69 /* Native Windows platforms declare open(), creat() in <io.h>. */ 70 #if (0 || 1 || defined GNULIB_POSIXCHECK) \ 71 && (defined _WIN32 && ! defined __CYGWIN__) 72 # include <io.h> 73 #endif 74 75 #ifndef _GL_FCNTL_H 76 #define _GL_FCNTL_H 77 78 #ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */ 79 # include <unistd.h> 80 #endif 81 82 83 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 84 /* C++ compatible function declaration macros. 85 Copyright (C) 2010-2021 Free Software Foundation, Inc. 86 87 This program is free software: you can redistribute it and/or modify it 88 under the terms of the GNU General Public License as published 89 by the Free Software Foundation; either version 3 of the License, or 90 (at your option) any later version. 91 92 This program is distributed in the hope that it will be useful, 93 but WITHOUT ANY WARRANTY; without even the implied warranty of 94 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 95 General Public License for more details. 96 97 You should have received a copy of the GNU General Public License 98 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 99 100 #ifndef _GL_CXXDEFS_H 101 #define _GL_CXXDEFS_H 102 103 /* Begin/end the GNULIB_NAMESPACE namespace. */ 104 #if defined __cplusplus && defined GNULIB_NAMESPACE 105 # define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE { 106 # define _GL_END_NAMESPACE } 107 #else 108 # define _GL_BEGIN_NAMESPACE 109 # define _GL_END_NAMESPACE 110 #endif 111 112 /* The three most frequent use cases of these macros are: 113 114 * For providing a substitute for a function that is missing on some 115 platforms, but is declared and works fine on the platforms on which 116 it exists: 117 118 #if @GNULIB_FOO@ 119 # if !@HAVE_FOO@ 120 _GL_FUNCDECL_SYS (foo, ...); 121 # endif 122 _GL_CXXALIAS_SYS (foo, ...); 123 _GL_CXXALIASWARN (foo); 124 #elif defined GNULIB_POSIXCHECK 125 ... 126 #endif 127 128 * For providing a replacement for a function that exists on all platforms, 129 but is broken/insufficient and needs to be replaced on some platforms: 130 131 #if @GNULIB_FOO@ 132 # if @REPLACE_FOO@ 133 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 134 # undef foo 135 # define foo rpl_foo 136 # endif 137 _GL_FUNCDECL_RPL (foo, ...); 138 _GL_CXXALIAS_RPL (foo, ...); 139 # else 140 _GL_CXXALIAS_SYS (foo, ...); 141 # endif 142 _GL_CXXALIASWARN (foo); 143 #elif defined GNULIB_POSIXCHECK 144 ... 145 #endif 146 147 * For providing a replacement for a function that exists on some platforms 148 but is broken/insufficient and needs to be replaced on some of them and 149 is additionally either missing or undeclared on some other platforms: 150 151 #if @GNULIB_FOO@ 152 # if @REPLACE_FOO@ 153 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 154 # undef foo 155 # define foo rpl_foo 156 # endif 157 _GL_FUNCDECL_RPL (foo, ...); 158 _GL_CXXALIAS_RPL (foo, ...); 159 # else 160 # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ 161 _GL_FUNCDECL_SYS (foo, ...); 162 # endif 163 _GL_CXXALIAS_SYS (foo, ...); 164 # endif 165 _GL_CXXALIASWARN (foo); 166 #elif defined GNULIB_POSIXCHECK 167 ... 168 #endif 169 */ 170 171 /* _GL_EXTERN_C declaration; 172 performs the declaration with C linkage. */ 173 #if defined __cplusplus 174 # define _GL_EXTERN_C extern "C" 175 #else 176 # define _GL_EXTERN_C extern 177 #endif 178 179 /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); 180 declares a replacement function, named rpl_func, with the given prototype, 181 consisting of return type, parameters, and attributes. 182 Example: 183 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) 184 _GL_ARG_NONNULL ((1))); 185 */ 186 #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ 187 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) 188 #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ 189 _GL_EXTERN_C rettype rpl_func parameters_and_attributes 190 191 /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); 192 declares the system function, named func, with the given prototype, 193 consisting of return type, parameters, and attributes. 194 Example: 195 _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) 196 _GL_ARG_NONNULL ((1))); 197 */ 198 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ 199 _GL_EXTERN_C rettype func parameters_and_attributes 200 201 /* _GL_CXXALIAS_RPL (func, rettype, parameters); 202 declares a C++ alias called GNULIB_NAMESPACE::func 203 that redirects to rpl_func, if GNULIB_NAMESPACE is defined. 204 Example: 205 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); 206 207 Wrapping rpl_func in an object with an inline conversion operator 208 avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is 209 actually used in the program. */ 210 #define _GL_CXXALIAS_RPL(func,rettype,parameters) \ 211 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) 212 #if defined __cplusplus && defined GNULIB_NAMESPACE 213 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 214 namespace GNULIB_NAMESPACE \ 215 { \ 216 static const struct _gl_ ## func ## _wrapper \ 217 { \ 218 typedef rettype (*type) parameters; \ 219 \ 220 inline operator type () const \ 221 { \ 222 return ::rpl_func; \ 223 } \ 224 } func = {}; \ 225 } \ 226 _GL_EXTERN_C int _gl_cxxalias_dummy 227 #else 228 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 229 _GL_EXTERN_C int _gl_cxxalias_dummy 230 #endif 231 232 /* _GL_CXXALIAS_MDA (func, rettype, parameters); 233 is to be used when func is a Microsoft deprecated alias, on native Windows. 234 It declares a C++ alias called GNULIB_NAMESPACE::func 235 that redirects to _func, if GNULIB_NAMESPACE is defined. 236 Example: 237 _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...)); 238 */ 239 #define _GL_CXXALIAS_MDA(func,rettype,parameters) \ 240 _GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters) 241 242 /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); 243 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); 244 except that the C function rpl_func may have a slightly different 245 declaration. A cast is used to silence the "invalid conversion" error 246 that would otherwise occur. */ 247 #if defined __cplusplus && defined GNULIB_NAMESPACE 248 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 249 namespace GNULIB_NAMESPACE \ 250 { \ 251 static const struct _gl_ ## func ## _wrapper \ 252 { \ 253 typedef rettype (*type) parameters; \ 254 \ 255 inline operator type () const \ 256 { \ 257 return reinterpret_cast<type>(::rpl_func); \ 258 } \ 259 } func = {}; \ 260 } \ 261 _GL_EXTERN_C int _gl_cxxalias_dummy 262 #else 263 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 264 _GL_EXTERN_C int _gl_cxxalias_dummy 265 #endif 266 267 /* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters); 268 is like _GL_CXXALIAS_MDA (func, rettype, parameters); 269 except that the C function func may have a slightly different declaration. 270 A cast is used to silence the "invalid conversion" error that would 271 otherwise occur. */ 272 #define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \ 273 _GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters) 274 275 /* _GL_CXXALIAS_SYS (func, rettype, parameters); 276 declares a C++ alias called GNULIB_NAMESPACE::func 277 that redirects to the system provided function func, if GNULIB_NAMESPACE 278 is defined. 279 Example: 280 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); 281 282 Wrapping func in an object with an inline conversion operator 283 avoids a reference to func unless GNULIB_NAMESPACE::func is 284 actually used in the program. */ 285 #if defined __cplusplus && defined GNULIB_NAMESPACE 286 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 287 namespace GNULIB_NAMESPACE \ 288 { \ 289 static const struct _gl_ ## func ## _wrapper \ 290 { \ 291 typedef rettype (*type) parameters; \ 292 \ 293 inline operator type () const \ 294 { \ 295 return ::func; \ 296 } \ 297 } func = {}; \ 298 } \ 299 _GL_EXTERN_C int _gl_cxxalias_dummy 300 #else 301 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 302 _GL_EXTERN_C int _gl_cxxalias_dummy 303 #endif 304 305 /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); 306 is like _GL_CXXALIAS_SYS (func, rettype, parameters); 307 except that the C function func may have a slightly different declaration. 308 A cast is used to silence the "invalid conversion" error that would 309 otherwise occur. */ 310 #if defined __cplusplus && defined GNULIB_NAMESPACE 311 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 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>(::func); \ 321 } \ 322 } func = {}; \ 323 } \ 324 _GL_EXTERN_C int _gl_cxxalias_dummy 325 #else 326 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 327 _GL_EXTERN_C int _gl_cxxalias_dummy 328 #endif 329 330 /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); 331 is like _GL_CXXALIAS_SYS (func, rettype, parameters); 332 except that the C function is picked among a set of overloaded functions, 333 namely the one with rettype2 and parameters2. Two consecutive casts 334 are used to silence the "cannot find a match" and "invalid conversion" 335 errors that would otherwise occur. */ 336 #if defined __cplusplus && defined GNULIB_NAMESPACE 337 /* The outer cast must be a reinterpret_cast. 338 The inner cast: When the function is defined as a set of overloaded 339 functions, it works as a static_cast<>, choosing the designated variant. 340 When the function is defined as a single variant, it works as a 341 reinterpret_cast<>. The parenthesized cast syntax works both ways. */ 342 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 343 namespace GNULIB_NAMESPACE \ 344 { \ 345 static const struct _gl_ ## func ## _wrapper \ 346 { \ 347 typedef rettype (*type) parameters; \ 348 \ 349 inline operator type () const \ 350 { \ 351 return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \ 352 } \ 353 } func = {}; \ 354 } \ 355 _GL_EXTERN_C int _gl_cxxalias_dummy 356 #else 357 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 358 _GL_EXTERN_C int _gl_cxxalias_dummy 359 #endif 360 361 /* _GL_CXXALIASWARN (func); 362 causes a warning to be emitted when ::func is used but not when 363 GNULIB_NAMESPACE::func is used. func must be defined without overloaded 364 variants. */ 365 #if defined __cplusplus && defined GNULIB_NAMESPACE 366 # define _GL_CXXALIASWARN(func) \ 367 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) 368 # define _GL_CXXALIASWARN_1(func,namespace) \ 369 _GL_CXXALIASWARN_2 (func, namespace) 370 /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 371 we enable the warning only when not optimizing. */ 372 # if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__) 373 # define _GL_CXXALIASWARN_2(func,namespace) \ 374 _GL_WARN_ON_USE (func, \ 375 "The symbol ::" #func " refers to the system function. " \ 376 "Use " #namespace "::" #func " instead.") 377 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 378 # define _GL_CXXALIASWARN_2(func,namespace) \ 379 extern __typeof__ (func) func 380 # else 381 # define _GL_CXXALIASWARN_2(func,namespace) \ 382 _GL_EXTERN_C int _gl_cxxalias_dummy 383 # endif 384 #else 385 # define _GL_CXXALIASWARN(func) \ 386 _GL_EXTERN_C int _gl_cxxalias_dummy 387 #endif 388 389 /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); 390 causes a warning to be emitted when the given overloaded variant of ::func 391 is used but not when GNULIB_NAMESPACE::func is used. */ 392 #if defined __cplusplus && defined GNULIB_NAMESPACE 393 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 394 _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ 395 GNULIB_NAMESPACE) 396 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ 397 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) 398 /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 399 we enable the warning only when not optimizing. */ 400 # if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__) 401 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 402 _GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \ 403 "The symbol ::" #func " refers to the system function. " \ 404 "Use " #namespace "::" #func " instead.") 405 # else 406 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 407 _GL_EXTERN_C int _gl_cxxalias_dummy 408 # endif 409 #else 410 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 411 _GL_EXTERN_C int _gl_cxxalias_dummy 412 #endif 413 414 #endif /* _GL_CXXDEFS_H */ 415 416 /* The definition of _GL_ARG_NONNULL is copied here. */ 417 /* A C macro for declaring that specific arguments must not be NULL. 418 Copyright (C) 2009-2021 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_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools 434 that the values passed as arguments n, ..., m must be non-NULL pointers. 435 n = 1 stands for the first argument, n = 2 for the second argument etc. */ 436 #ifndef _GL_ARG_NONNULL 437 # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__ 438 # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) 439 # else 440 # define _GL_ARG_NONNULL(params) 441 # endif 442 #endif 443 444 /* The definition of _GL_WARN_ON_USE is copied here. */ 445 /* A C macro for emitting warnings if a function is used. 446 Copyright (C) 2010-2021 Free Software Foundation, Inc. 447 448 This program is free software: you can redistribute it and/or modify it 449 under the terms of the GNU General Public License as published 450 by the Free Software Foundation; either version 3 of the License, or 451 (at your option) any later version. 452 453 This program is distributed in the hope that it will be useful, 454 but WITHOUT ANY WARRANTY; without even the implied warranty of 455 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 456 General Public License for more details. 457 458 You should have received a copy of the GNU General Public License 459 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 460 461 /* _GL_WARN_ON_USE (function, "literal string") issues a declaration 462 for FUNCTION which will then trigger a compiler warning containing 463 the text of "literal string" anywhere that function is called, if 464 supported by the compiler. If the compiler does not support this 465 feature, the macro expands to an unused extern declaration. 466 467 _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the 468 attribute used in _GL_WARN_ON_USE. If the compiler does not support 469 this feature, it expands to empty. 470 471 These macros are useful for marking a function as a potential 472 portability trap, with the intent that "literal string" include 473 instructions on the replacement function that should be used 474 instead. 475 _GL_WARN_ON_USE is for functions with 'extern' linkage. 476 _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline' 477 linkage. 478 479 However, one of the reasons that a function is a portability trap is 480 if it has the wrong signature. Declaring FUNCTION with a different 481 signature in C is a compilation error, so this macro must use the 482 same type as any existing declaration so that programs that avoid 483 the problematic FUNCTION do not fail to compile merely because they 484 included a header that poisoned the function. But this implies that 485 _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already 486 have a declaration. Use of this macro implies that there must not 487 be any other macro hiding the declaration of FUNCTION; but 488 undefining FUNCTION first is part of the poisoning process anyway 489 (although for symbols that are provided only via a macro, the result 490 is a compilation error rather than a warning containing 491 "literal string"). Also note that in C++, it is only safe to use if 492 FUNCTION has no overloads. 493 494 For an example, it is possible to poison 'getline' by: 495 - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]], 496 [getline]) in configure.ac, which potentially defines 497 HAVE_RAW_DECL_GETLINE 498 - adding this code to a header that wraps the system <stdio.h>: 499 #undef getline 500 #if HAVE_RAW_DECL_GETLINE 501 _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but" 502 "not universally present; use the gnulib module getline"); 503 #endif 504 505 It is not possible to directly poison global variables. But it is 506 possible to write a wrapper accessor function, and poison that 507 (less common usage, like &environ, will cause a compilation error 508 rather than issue the nice warning, but the end result of informing 509 the developer about their portability problem is still achieved): 510 #if HAVE_RAW_DECL_ENVIRON 511 static char *** 512 rpl_environ (void) { return &environ; } 513 _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); 514 # undef environ 515 # define environ (*rpl_environ ()) 516 #endif 517 or better (avoiding contradictory use of 'static' and 'extern'): 518 #if HAVE_RAW_DECL_ENVIRON 519 static char *** 520 _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared") 521 rpl_environ (void) { return &environ; } 522 # undef environ 523 # define environ (*rpl_environ ()) 524 #endif 525 */ 526 #ifndef _GL_WARN_ON_USE 527 528 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 529 /* A compiler attribute is available in gcc versions 4.3.0 and later. */ 530 # define _GL_WARN_ON_USE(function, message) \ 531 extern __typeof__ (function) function __attribute__ ((__warning__ (message))) 532 # define _GL_WARN_ON_USE_ATTRIBUTE(message) \ 533 __attribute__ ((__warning__ (message))) 534 # elif __clang_major__ >= 4 535 /* Another compiler attribute is available in clang. */ 536 # define _GL_WARN_ON_USE(function, message) \ 537 extern __typeof__ (function) function \ 538 __attribute__ ((__diagnose_if__ (1, message, "warning"))) 539 # define _GL_WARN_ON_USE_ATTRIBUTE(message) \ 540 __attribute__ ((__diagnose_if__ (1, message, "warning"))) 541 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 542 /* Verify the existence of the function. */ 543 # define _GL_WARN_ON_USE(function, message) \ 544 extern __typeof__ (function) function 545 # define _GL_WARN_ON_USE_ATTRIBUTE(message) 546 # else /* Unsupported. */ 547 # define _GL_WARN_ON_USE(function, message) \ 548 _GL_WARN_EXTERN_C int _gl_warn_on_use 549 # define _GL_WARN_ON_USE_ATTRIBUTE(message) 550 # endif 551 #endif 552 553 /* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message") 554 is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the 555 function is declared with the given prototype, consisting of return type, 556 parameters, and attributes. 557 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does 558 not work in this case. */ 559 #ifndef _GL_WARN_ON_USE_CXX 560 # if !defined __cplusplus 561 # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 562 _GL_WARN_ON_USE (function, msg) 563 # else 564 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 565 /* A compiler attribute is available in gcc versions 4.3.0 and later. */ 566 # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 567 extern rettype_gcc function parameters_and_attributes \ 568 __attribute__ ((__warning__ (msg))) 569 # elif __clang_major__ >= 4 570 /* Another compiler attribute is available in clang. */ 571 # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 572 extern rettype_clang function parameters_and_attributes \ 573 __attribute__ ((__diagnose_if__ (1, msg, "warning"))) 574 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 575 /* Verify the existence of the function. */ 576 # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 577 extern rettype_gcc function parameters_and_attributes 578 # else /* Unsupported. */ 579 # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \ 580 _GL_WARN_EXTERN_C int _gl_warn_on_use 581 # endif 582 # endif 583 #endif 584 585 /* _GL_WARN_EXTERN_C declaration; 586 performs the declaration with C linkage. */ 587 #ifndef _GL_WARN_EXTERN_C 588 # if defined __cplusplus 589 # define _GL_WARN_EXTERN_C extern "C" 590 # else 591 # define _GL_WARN_EXTERN_C extern 592 # endif 593 #endif 594 595 596 /* Declare overridden functions. */ 597 598 #if 0 599 # if 0 600 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 601 # undef creat 602 # define creat rpl_creat 603 # endif 604 _GL_FUNCDECL_RPL (creat, int, (const char *filename, mode_t mode) 605 _GL_ARG_NONNULL ((1))); 606 _GL_CXXALIAS_RPL (creat, int, (const char *filename, mode_t mode)); 607 # elif defined _WIN32 && !defined __CYGWIN__ 608 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 609 # undef creat 610 # define creat _creat 611 # endif 612 _GL_CXXALIAS_MDA (creat, int, (const char *filename, mode_t mode)); 613 # else 614 _GL_CXXALIAS_SYS (creat, int, (const char *filename, mode_t mode)); 615 # endif 616 _GL_CXXALIASWARN (creat); 617 #elif defined GNULIB_POSIXCHECK 618 # undef creat 619 /* Assume creat is always declared. */ 620 _GL_WARN_ON_USE (creat, "creat is not always POSIX compliant - " 621 "use gnulib module creat for portability"); 622 #elif 1 623 /* On native Windows, map 'creat' to '_creat', so that -loldnames is not 624 required. In C++ with GNULIB_NAMESPACE, avoid differences between 625 platforms by defining GNULIB_NAMESPACE::creat always. */ 626 # if defined _WIN32 && !defined __CYGWIN__ 627 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 628 # undef creat 629 # define creat _creat 630 # endif 631 /* Need to cast, because in mingw the last argument is 'int mode'. */ 632 _GL_CXXALIAS_MDA_CAST (creat, int, (const char *filename, mode_t mode)); 633 # else 634 _GL_CXXALIAS_SYS (creat, int, (const char *filename, mode_t mode)); 635 # endif 636 _GL_CXXALIASWARN (creat); 637 #endif 638 639 #if 1 640 # if 0 641 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 642 # undef fcntl 643 # define fcntl rpl_fcntl 644 # endif 645 _GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...)); 646 _GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...)); 647 # if !GNULIB_defined_rpl_fcntl 648 # define GNULIB_defined_rpl_fcntl 1 649 # endif 650 # else 651 # if !1 652 _GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...)); 653 # if !GNULIB_defined_fcntl 654 # define GNULIB_defined_fcntl 1 655 # endif 656 # endif 657 _GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...)); 658 # endif 659 _GL_CXXALIASWARN (fcntl); 660 #elif defined GNULIB_POSIXCHECK 661 # undef fcntl 662 # if HAVE_RAW_DECL_FCNTL 663 _GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - " 664 "use gnulib module fcntl for portability"); 665 # endif 666 #endif 667 668 #if 1 669 # if 0 670 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 671 # undef open 672 # define open rpl_open 673 # endif 674 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) 675 _GL_ARG_NONNULL ((1))); 676 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); 677 # elif defined _WIN32 && !defined __CYGWIN__ 678 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 679 # undef open 680 # define open _open 681 # endif 682 _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...)); 683 # else 684 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); 685 # endif 686 /* On HP-UX 11, in C++ mode, open() is defined as an inline function with a 687 default argument. _GL_CXXALIASWARN does not work in this case. */ 688 # if !defined __hpux 689 _GL_CXXALIASWARN (open); 690 # endif 691 #elif defined GNULIB_POSIXCHECK 692 # undef open 693 /* Assume open is always declared. */ 694 _GL_WARN_ON_USE (open, "open is not always POSIX compliant - " 695 "use gnulib module open for portability"); 696 #elif 1 697 /* On native Windows, map 'open' to '_open', so that -loldnames is not 698 required. In C++ with GNULIB_NAMESPACE, avoid differences between 699 platforms by defining GNULIB_NAMESPACE::open always. */ 700 # if defined _WIN32 && !defined __CYGWIN__ 701 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 702 # undef open 703 # define open _open 704 # endif 705 _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...)); 706 # else 707 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); 708 # endif 709 # if !defined __hpux 710 _GL_CXXALIASWARN (open); 711 # endif 712 #endif 713 714 #if 1 715 # if 0 716 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 717 # undef openat 718 # define openat rpl_openat 719 # endif 720 _GL_FUNCDECL_RPL (openat, int, 721 (int fd, char const *file, int flags, /* mode_t mode */ ...) 722 _GL_ARG_NONNULL ((2))); 723 _GL_CXXALIAS_RPL (openat, int, 724 (int fd, char const *file, int flags, /* mode_t mode */ ...)); 725 # else 726 # if !1 727 _GL_FUNCDECL_SYS (openat, int, 728 (int fd, char const *file, int flags, /* mode_t mode */ ...) 729 _GL_ARG_NONNULL ((2))); 730 # endif 731 _GL_CXXALIAS_SYS (openat, int, 732 (int fd, char const *file, int flags, /* mode_t mode */ ...)); 733 # endif 734 _GL_CXXALIASWARN (openat); 735 #elif defined GNULIB_POSIXCHECK 736 # undef openat 737 # if HAVE_RAW_DECL_OPENAT 738 _GL_WARN_ON_USE (openat, "openat is not portable - " 739 "use gnulib module openat for portability"); 740 # endif 741 #endif 742 743 744 /* Fix up the FD_* macros, only known to be missing on mingw. */ 745 746 #ifndef FD_CLOEXEC 747 # define FD_CLOEXEC 1 748 #endif 749 750 /* Fix up the supported F_* macros. Intentionally leave other F_* 751 macros undefined. Only known to be missing on mingw. */ 752 753 #ifndef F_DUPFD_CLOEXEC 754 # define F_DUPFD_CLOEXEC 0x40000000 755 /* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise. */ 756 # define GNULIB_defined_F_DUPFD_CLOEXEC 1 757 #else 758 # define GNULIB_defined_F_DUPFD_CLOEXEC 0 759 #endif 760 761 #ifndef F_DUPFD 762 # define F_DUPFD 1 763 #endif 764 765 #ifndef F_GETFD 766 # define F_GETFD 2 767 #endif 768 769 /* Fix up the O_* macros. */ 770 771 /* AIX 7.1 with XL C 12.1 defines O_CLOEXEC, O_NOFOLLOW, and O_TTY_INIT 772 to values outside 'int' range, so omit these misdefinitions. 773 But avoid namespace pollution on non-AIX systems. */ 774 #ifdef _AIX 775 # include <limits.h> 776 # if defined O_CLOEXEC && ! (INT_MIN <= O_CLOEXEC && O_CLOEXEC <= INT_MAX) 777 # undef O_CLOEXEC 778 # endif 779 # if defined O_NOFOLLOW && ! (INT_MIN <= O_NOFOLLOW && O_NOFOLLOW <= INT_MAX) 780 # undef O_NOFOLLOW 781 # endif 782 # if defined O_TTY_INIT && ! (INT_MIN <= O_TTY_INIT && O_TTY_INIT <= INT_MAX) 783 # undef O_TTY_INIT 784 # endif 785 #endif 786 787 #if !defined O_DIRECT && defined O_DIRECTIO 788 /* Tru64 spells it 'O_DIRECTIO'. */ 789 # define O_DIRECT O_DIRECTIO 790 #endif 791 792 #if !defined O_CLOEXEC && defined O_NOINHERIT 793 /* Mingw spells it 'O_NOINHERIT'. */ 794 # define O_CLOEXEC O_NOINHERIT 795 #endif 796 797 #ifndef O_CLOEXEC 798 # define O_CLOEXEC 0x40000000 /* Try to not collide with system O_* flags. */ 799 # define GNULIB_defined_O_CLOEXEC 1 800 #else 801 # define GNULIB_defined_O_CLOEXEC 0 802 #endif 803 804 #ifndef O_DIRECT 805 # define O_DIRECT 0 806 #endif 807 808 #ifndef O_DIRECTORY 809 # define O_DIRECTORY 0 810 #endif 811 812 #ifndef O_DSYNC 813 # define O_DSYNC 0 814 #endif 815 816 #ifndef O_EXEC 817 # define O_EXEC O_RDONLY /* This is often close enough in older systems. */ 818 #endif 819 820 #ifndef O_IGNORE_CTTY 821 # define O_IGNORE_CTTY 0 822 #endif 823 824 #ifndef O_NDELAY 825 # define O_NDELAY 0 826 #endif 827 828 #ifndef O_NOATIME 829 # define O_NOATIME 0 830 #endif 831 832 #ifndef O_NONBLOCK 833 # define O_NONBLOCK O_NDELAY 834 #endif 835 836 /* If the gnulib module 'nonblocking' is in use, guarantee a working non-zero 837 value of O_NONBLOCK. Otherwise, O_NONBLOCK is defined (above) to O_NDELAY 838 or to 0 as fallback. */ 839 #if 0 840 # if O_NONBLOCK 841 # define GNULIB_defined_O_NONBLOCK 0 842 # else 843 # define GNULIB_defined_O_NONBLOCK 1 844 # undef O_NONBLOCK 845 # define O_NONBLOCK 0x40000000 846 # endif 847 #endif 848 849 #ifndef O_NOCTTY 850 # define O_NOCTTY 0 851 #endif 852 853 #ifndef O_NOFOLLOW 854 # define O_NOFOLLOW 0 855 #endif 856 857 #ifndef O_NOLINK 858 # define O_NOLINK 0 859 #endif 860 861 #ifndef O_NOLINKS 862 # define O_NOLINKS 0 863 #endif 864 865 #ifndef O_NOTRANS 866 # define O_NOTRANS 0 867 #endif 868 869 #ifndef O_RSYNC 870 # define O_RSYNC 0 871 #endif 872 873 #ifndef O_SEARCH 874 # define O_SEARCH O_RDONLY /* This is often close enough in older systems. */ 875 #endif 876 877 #ifndef O_SYNC 878 # define O_SYNC 0 879 #endif 880 881 #ifndef O_TTY_INIT 882 # define O_TTY_INIT 0 883 #endif 884 885 #if ~O_ACCMODE & (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH) 886 # undef O_ACCMODE 887 # define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH) 888 #endif 889 890 /* For systems that distinguish between text and binary I/O. 891 O_BINARY is usually declared in fcntl.h */ 892 #if !defined O_BINARY && defined _O_BINARY 893 /* For MSC-compatible compilers. */ 894 # define O_BINARY _O_BINARY 895 # define O_TEXT _O_TEXT 896 #endif 897 898 #if defined __BEOS__ || defined __HAIKU__ 899 /* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect. */ 900 # undef O_BINARY 901 # undef O_TEXT 902 #endif 903 904 #ifndef O_BINARY 905 # define O_BINARY 0 906 # define O_TEXT 0 907 #endif 908 909 /* Fix up the AT_* macros. */ 910 911 /* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its 912 value exceeds INT_MAX, so its use as an int doesn't conform to the 913 C standard, and GCC and Sun C complain in some cases. If the bug 914 is present, undef AT_FDCWD here, so it can be redefined below. */ 915 #if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553 916 # undef AT_FDCWD 917 #endif 918 919 /* Use the same bit pattern as Solaris 9, but with the proper 920 signedness. The bit pattern is important, in case this actually is 921 Solaris with the above workaround. */ 922 #ifndef AT_FDCWD 923 # define AT_FDCWD (-3041965) 924 #endif 925 926 /* Use the same values as Solaris 9. This shouldn't matter, but 927 there's no real reason to differ. */ 928 #ifndef AT_SYMLINK_NOFOLLOW 929 # define AT_SYMLINK_NOFOLLOW 4096 930 #endif 931 932 #ifndef AT_REMOVEDIR 933 # define AT_REMOVEDIR 1 934 #endif 935 936 /* Solaris 9 lacks these two, so just pick unique values. */ 937 #ifndef AT_SYMLINK_FOLLOW 938 # define AT_SYMLINK_FOLLOW 2 939 #endif 940 941 #ifndef AT_EACCESS 942 # define AT_EACCESS 4 943 #endif 944 945 946 #endif /* _GL_FCNTL_H */ 947 #endif /* _GL_FCNTL_H */ 948 #endif 949