1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ 2 /* Like <fcntl.h>, but with non-working flags defined to 0. 3 4 Copyright (C) 2006-2010 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 <http://www.gnu.org/licenses/>. */ 18 19 /* written by Paul Eggert */ 20 21 #if __GNUC__ >= 3 22 #pragma GCC system_header 23 #endif 24 25 #if defined __need_system_fcntl_h 26 /* Special invocation convention. */ 27 28 #include <sys/types.h> 29 #ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */ 30 # include <sys/stat.h> 31 #endif 32 #include_next <fcntl.h> 33 34 #else 35 /* Normal invocation convention. */ 36 37 #ifndef _GL_FCNTL_H 38 39 #include <sys/types.h> 40 #ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */ 41 # include <sys/stat.h> 42 #endif 43 /* The include_next requires a split double-inclusion guard. */ 44 #include_next <fcntl.h> 45 46 #ifndef _GL_FCNTL_H 47 #define _GL_FCNTL_H 48 49 #ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */ 50 # include <unistd.h> 51 #endif 52 53 54 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 55 #ifndef _GL_CXXDEFS_H 56 #define _GL_CXXDEFS_H 57 58 /* The three most frequent use cases of these macros are: 59 60 * For providing a substitute for a function that is missing on some 61 platforms, but is declared and works fine on the platforms on which 62 it exists: 63 64 #if @GNULIB_FOO@ 65 # if !@HAVE_FOO@ 66 _GL_FUNCDECL_SYS (foo, ...); 67 # endif 68 _GL_CXXALIAS_SYS (foo, ...); 69 _GL_CXXALIASWARN (foo); 70 #elif defined GNULIB_POSIXCHECK 71 ... 72 #endif 73 74 * For providing a replacement for a function that exists on all platforms, 75 but is broken/insufficient and needs to be replaced on some platforms: 76 77 #if @GNULIB_FOO@ 78 # if @REPLACE_FOO@ 79 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 80 # undef foo 81 # define foo rpl_foo 82 # endif 83 _GL_FUNCDECL_RPL (foo, ...); 84 _GL_CXXALIAS_RPL (foo, ...); 85 # else 86 _GL_CXXALIAS_SYS (foo, ...); 87 # endif 88 _GL_CXXALIASWARN (foo); 89 #elif defined GNULIB_POSIXCHECK 90 ... 91 #endif 92 93 * For providing a replacement for a function that exists on some platforms 94 but is broken/insufficient and needs to be replaced on some of them and 95 is additionally either missing or undeclared on some other platforms: 96 97 #if @GNULIB_FOO@ 98 # if @REPLACE_FOO@ 99 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 100 # undef foo 101 # define foo rpl_foo 102 # endif 103 _GL_FUNCDECL_RPL (foo, ...); 104 _GL_CXXALIAS_RPL (foo, ...); 105 # else 106 # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ 107 _GL_FUNCDECL_SYS (foo, ...); 108 # endif 109 _GL_CXXALIAS_SYS (foo, ...); 110 # endif 111 _GL_CXXALIASWARN (foo); 112 #elif defined GNULIB_POSIXCHECK 113 ... 114 #endif 115 */ 116 117 /* _GL_EXTERN_C declaration; 118 performs the declaration with C linkage. */ 119 #if defined __cplusplus 120 # define _GL_EXTERN_C extern "C" 121 #else 122 # define _GL_EXTERN_C extern 123 #endif 124 125 /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); 126 declares a replacement function, named rpl_func, with the given prototype, 127 consisting of return type, parameters, and attributes. 128 Example: 129 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) 130 _GL_ARG_NONNULL ((1))); 131 */ 132 #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ 133 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) 134 #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ 135 _GL_EXTERN_C rettype rpl_func parameters_and_attributes 136 137 /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); 138 declares the system function, named func, with the given prototype, 139 consisting of return type, parameters, and attributes. 140 Example: 141 _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) 142 _GL_ARG_NONNULL ((1))); 143 */ 144 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ 145 _GL_EXTERN_C rettype func parameters_and_attributes 146 147 /* _GL_CXXALIAS_RPL (func, rettype, parameters); 148 declares a C++ alias called GNULIB_NAMESPACE::func 149 that redirects to rpl_func, if GNULIB_NAMESPACE is defined. 150 Example: 151 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); 152 */ 153 #define _GL_CXXALIAS_RPL(func,rettype,parameters) \ 154 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) 155 #if defined __cplusplus && defined GNULIB_NAMESPACE 156 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 157 namespace GNULIB_NAMESPACE \ 158 { \ 159 rettype (*const func) parameters = ::rpl_func; \ 160 } \ 161 _GL_EXTERN_C int _gl_cxxalias_dummy 162 #else 163 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 164 _GL_EXTERN_C int _gl_cxxalias_dummy 165 #endif 166 167 /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); 168 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); 169 except that the C function rpl_func may have a slightly different 170 declaration. A cast is used to silence the "invalid conversion" error 171 that would otherwise occur. */ 172 #if defined __cplusplus && defined GNULIB_NAMESPACE 173 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 174 namespace GNULIB_NAMESPACE \ 175 { \ 176 rettype (*const func) parameters = \ 177 reinterpret_cast<rettype(*)parameters>(::rpl_func); \ 178 } \ 179 _GL_EXTERN_C int _gl_cxxalias_dummy 180 #else 181 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 182 _GL_EXTERN_C int _gl_cxxalias_dummy 183 #endif 184 185 /* _GL_CXXALIAS_SYS (func, rettype, parameters); 186 declares a C++ alias called GNULIB_NAMESPACE::func 187 that redirects to the system provided function func, if GNULIB_NAMESPACE 188 is defined. 189 Example: 190 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); 191 */ 192 #if defined __cplusplus && defined GNULIB_NAMESPACE 193 /* If we were to write 194 rettype (*const func) parameters = ::func; 195 like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls 196 better (remove an indirection through a 'static' pointer variable), 197 but then the _GL_CXXALIASWARN macro below would cause a warning not only 198 for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */ 199 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 200 namespace GNULIB_NAMESPACE \ 201 { \ 202 static rettype (*func) parameters = ::func; \ 203 } \ 204 _GL_EXTERN_C int _gl_cxxalias_dummy 205 #else 206 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 207 _GL_EXTERN_C int _gl_cxxalias_dummy 208 #endif 209 210 /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); 211 is like _GL_CXXALIAS_SYS (func, rettype, parameters); 212 except that the C function func may have a slightly different declaration. 213 A cast is used to silence the "invalid conversion" error that would 214 otherwise occur. */ 215 #if defined __cplusplus && defined GNULIB_NAMESPACE 216 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 217 namespace GNULIB_NAMESPACE \ 218 { \ 219 static rettype (*func) parameters = \ 220 reinterpret_cast<rettype(*)parameters>(::func); \ 221 } \ 222 _GL_EXTERN_C int _gl_cxxalias_dummy 223 #else 224 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 225 _GL_EXTERN_C int _gl_cxxalias_dummy 226 #endif 227 228 /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); 229 is like _GL_CXXALIAS_SYS (func, rettype, parameters); 230 except that the C function is picked among a set of overloaded functions, 231 namely the one with rettype2 and parameters2. Two consecutive casts 232 are used to silence the "cannot find a match" and "invalid conversion" 233 errors that would otherwise occur. */ 234 #if defined __cplusplus && defined GNULIB_NAMESPACE 235 /* The outer cast must be a reinterpret_cast. 236 The inner cast: When the function is defined as a set of overloaded 237 functions, it works as a static_cast<>, choosing the designated variant. 238 When the function is defined as a single variant, it works as a 239 reinterpret_cast<>. The parenthesized cast syntax works both ways. */ 240 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 241 namespace GNULIB_NAMESPACE \ 242 { \ 243 static rettype (*func) parameters = \ 244 reinterpret_cast<rettype(*)parameters>( \ 245 (rettype2(*)parameters2)(::func)); \ 246 } \ 247 _GL_EXTERN_C int _gl_cxxalias_dummy 248 #else 249 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 250 _GL_EXTERN_C int _gl_cxxalias_dummy 251 #endif 252 253 /* _GL_CXXALIASWARN (func); 254 causes a warning to be emitted when ::func is used but not when 255 GNULIB_NAMESPACE::func is used. func must be defined without overloaded 256 variants. */ 257 #if defined __cplusplus && defined GNULIB_NAMESPACE 258 # define _GL_CXXALIASWARN(func) \ 259 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) 260 # define _GL_CXXALIASWARN_1(func,namespace) \ 261 _GL_CXXALIASWARN_2 (func, namespace) 262 # define _GL_CXXALIASWARN_2(func,namespace) \ 263 _GL_WARN_ON_USE (func, \ 264 "The symbol ::" #func " refers to the system function. " \ 265 "Use " #namespace "::" #func " instead.") 266 #else 267 # define _GL_CXXALIASWARN(func) \ 268 _GL_EXTERN_C int _gl_cxxalias_dummy 269 #endif 270 271 /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); 272 causes a warning to be emitted when the given overloaded variant of ::func 273 is used but not when GNULIB_NAMESPACE::func is used. */ 274 #if defined __cplusplus && defined GNULIB_NAMESPACE 275 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 276 _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ 277 GNULIB_NAMESPACE) 278 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ 279 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) 280 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 281 _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ 282 "The symbol ::" #func " refers to the system function. " \ 283 "Use " #namespace "::" #func " instead.") 284 #else 285 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 286 _GL_EXTERN_C int _gl_cxxalias_dummy 287 #endif 288 289 #endif /* _GL_CXXDEFS_H */ 290 291 /* The definition of _GL_ARG_NONNULL is copied here. */ 292 /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools 293 that the values passed as arguments n, ..., m must be non-NULL pointers. 294 n = 1 stands for the first argument, n = 2 for the second argument etc. */ 295 #ifndef _GL_ARG_NONNULL 296 # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 297 # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) 298 # else 299 # define _GL_ARG_NONNULL(params) 300 # endif 301 #endif 302 303 /* The definition of _GL_WARN_ON_USE is copied here. */ 304 #ifndef _GL_WARN_ON_USE 305 306 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 307 /* A compiler attribute is available in gcc versions 4.3.0 and later. */ 308 # define _GL_WARN_ON_USE(function, message) \ 309 extern __typeof__ (function) function __attribute__ ((__warning__ (message))) 310 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 311 /* Verify the existence of the function. */ 312 # define _GL_WARN_ON_USE(function, message) \ 313 extern __typeof__ (function) function 314 # else /* Unsupported. */ 315 # define _GL_WARN_ON_USE(function, message) \ 316 _GL_WARN_EXTERN_C int _gl_warn_on_use 317 # endif 318 #endif 319 320 /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string") 321 is like _GL_WARN_ON_USE (function, "string"), except that the function is 322 declared with the given prototype, consisting of return type, parameters, 323 and attributes. 324 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does 325 not work in this case. */ 326 #ifndef _GL_WARN_ON_USE_CXX 327 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 328 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 329 extern rettype function parameters_and_attributes \ 330 __attribute__ ((__warning__ (msg))) 331 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 332 /* Verify the existence of the function. */ 333 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 334 extern rettype function parameters_and_attributes 335 # else /* Unsupported. */ 336 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 337 _GL_WARN_EXTERN_C int _gl_warn_on_use 338 # endif 339 #endif 340 341 /* _GL_WARN_EXTERN_C declaration; 342 performs the declaration with C linkage. */ 343 #ifndef _GL_WARN_EXTERN_C 344 # if defined __cplusplus 345 # define _GL_WARN_EXTERN_C extern "C" 346 # else 347 # define _GL_WARN_EXTERN_C extern 348 # endif 349 #endif 350 351 352 /* Declare overridden functions. */ 353 354 #if 1 355 # if 1 356 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 357 # undef fcntl 358 # define fcntl rpl_fcntl 359 # endif 360 _GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...)); 361 _GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...)); 362 # else 363 # if !1 364 _GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...)); 365 # endif 366 _GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...)); 367 # endif 368 _GL_CXXALIASWARN (fcntl); 369 #elif defined GNULIB_POSIXCHECK 370 # undef fcntl 371 # if HAVE_RAW_DECL_FCNTL 372 _GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - " 373 "use gnulib module fcntl for portability"); 374 # endif 375 #endif 376 377 #if 1 378 # if 0 379 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 380 # undef open 381 # define open rpl_open 382 # endif 383 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) 384 _GL_ARG_NONNULL ((1))); 385 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); 386 # else 387 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); 388 # endif 389 _GL_CXXALIASWARN (open); 390 #elif defined GNULIB_POSIXCHECK 391 # undef open 392 /* Assume open is always declared. */ 393 _GL_WARN_ON_USE (open, "open is not always POSIX compliant - " 394 "use gnulib module open for portability"); 395 #endif 396 397 #if 0 398 # if 0 399 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 400 # undef openat 401 # define openat rpl_openat 402 # endif 403 _GL_FUNCDECL_RPL (openat, int, 404 (int fd, char const *file, int flags, /* mode_t mode */ ...) 405 _GL_ARG_NONNULL ((2))); 406 _GL_CXXALIAS_RPL (openat, int, 407 (int fd, char const *file, int flags, /* mode_t mode */ ...)); 408 # else 409 # if !1 410 _GL_FUNCDECL_SYS (openat, int, 411 (int fd, char const *file, int flags, /* mode_t mode */ ...) 412 _GL_ARG_NONNULL ((2))); 413 # endif 414 _GL_CXXALIAS_SYS (openat, int, 415 (int fd, char const *file, int flags, /* mode_t mode */ ...)); 416 # endif 417 _GL_CXXALIASWARN (openat); 418 #elif defined GNULIB_POSIXCHECK 419 # undef openat 420 # if HAVE_RAW_DECL_OPENAT 421 _GL_WARN_ON_USE (openat, "openat is not portable - " 422 "use gnulib module openat for portability"); 423 # endif 424 #endif 425 426 427 /* Fix up the FD_* macros, only known to be missing on mingw. */ 428 429 #ifndef FD_CLOEXEC 430 # define FD_CLOEXEC 1 431 #endif 432 433 /* Fix up the supported F_* macros. Intentionally leave other F_* 434 macros undefined. Only known to be missing on mingw. */ 435 436 #ifndef F_DUPFD_CLOEXEC 437 # define F_DUPFD_CLOEXEC 0x40000000 438 /* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise. */ 439 # define GNULIB_defined_F_DUPFD_CLOEXEC 1 440 #else 441 # define GNULIB_defined_F_DUPFD_CLOEXEC 0 442 #endif 443 444 #ifndef F_DUPFD 445 # define F_DUPFD 1 446 #endif 447 448 #ifndef F_GETFD 449 # define F_GETFD 2 450 #endif 451 452 /* Fix up the O_* macros. */ 453 454 #if !defined O_DIRECT && defined O_DIRECTIO 455 /* Tru64 spells it `O_DIRECTIO'. */ 456 # define O_DIRECT O_DIRECTIO 457 #endif 458 459 #if !defined O_CLOEXEC && defined O_NOINHERIT 460 /* Mingw spells it `O_NOINHERIT'. Intentionally leave it 461 undefined if not available. */ 462 # define O_CLOEXEC O_NOINHERIT 463 #endif 464 465 #ifndef O_DIRECT 466 # define O_DIRECT 0 467 #endif 468 469 #ifndef O_DIRECTORY 470 # define O_DIRECTORY 0 471 #endif 472 473 #ifndef O_DSYNC 474 # define O_DSYNC 0 475 #endif 476 477 #ifndef O_NDELAY 478 # define O_NDELAY 0 479 #endif 480 481 #ifndef O_NOATIME 482 # define O_NOATIME 0 483 #endif 484 485 #ifndef O_NONBLOCK 486 # define O_NONBLOCK O_NDELAY 487 #endif 488 489 #ifndef O_NOCTTY 490 # define O_NOCTTY 0 491 #endif 492 493 #ifndef O_NOFOLLOW 494 # define O_NOFOLLOW 0 495 #endif 496 497 #ifndef O_NOLINKS 498 # define O_NOLINKS 0 499 #endif 500 501 #ifndef O_RSYNC 502 # define O_RSYNC 0 503 #endif 504 505 #ifndef O_SYNC 506 # define O_SYNC 0 507 #endif 508 509 #ifndef O_TTY_INIT 510 # define O_TTY_INIT 0 511 #endif 512 513 /* For systems that distinguish between text and binary I/O. 514 O_BINARY is usually declared in fcntl.h */ 515 #if !defined O_BINARY && defined _O_BINARY 516 /* For MSC-compatible compilers. */ 517 # define O_BINARY _O_BINARY 518 # define O_TEXT _O_TEXT 519 #endif 520 521 #if defined __BEOS__ || defined __HAIKU__ 522 /* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect. */ 523 # undef O_BINARY 524 # undef O_TEXT 525 #endif 526 527 #ifndef O_BINARY 528 # define O_BINARY 0 529 # define O_TEXT 0 530 #endif 531 532 /* Fix up the AT_* macros. */ 533 534 /* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its 535 value exceeds INT_MAX, so its use as an int doesn't conform to the 536 C standard, and GCC and Sun C complain in some cases. If the bug 537 is present, undef AT_FDCWD here, so it can be redefined below. */ 538 #if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553 539 # undef AT_FDCWD 540 #endif 541 542 /* Use the same bit pattern as Solaris 9, but with the proper 543 signedness. The bit pattern is important, in case this actually is 544 Solaris with the above workaround. */ 545 #ifndef AT_FDCWD 546 # define AT_FDCWD (-3041965) 547 #endif 548 549 /* Use the same values as Solaris 9. This shouldn't matter, but 550 there's no real reason to differ. */ 551 #ifndef AT_SYMLINK_NOFOLLOW 552 # define AT_SYMLINK_NOFOLLOW 4096 553 #endif 554 555 #ifndef AT_REMOVEDIR 556 # define AT_REMOVEDIR 1 557 #endif 558 559 /* Solaris 9 lacks these two, so just pick unique values. */ 560 #ifndef AT_SYMLINK_FOLLOW 561 # define AT_SYMLINK_FOLLOW 2 562 #endif 563 564 #ifndef AT_EACCESS 565 # define AT_EACCESS 4 566 #endif 567 568 569 #endif /* _GL_FCNTL_H */ 570 #endif /* _GL_FCNTL_H */ 571 #endif 572