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