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