diff options
Diffstat (limited to 'gl/fcntl.in.h')
| -rw-r--r-- | gl/fcntl.in.h | 98 |
1 files changed, 76 insertions, 22 deletions
diff --git a/gl/fcntl.in.h b/gl/fcntl.in.h index eea3b954..52727074 100644 --- a/gl/fcntl.in.h +++ b/gl/fcntl.in.h | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* Like <fcntl.h>, but with non-working flags defined to 0. | 1 | /* Like <fcntl.h>, but with non-working flags defined to 0. |
| 2 | 2 | ||
| 3 | Copyright (C) 2006-2024 Free Software Foundation, Inc. | 3 | Copyright (C) 2006-2026 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | This file is free software: you can redistribute it and/or modify | 5 | This file is free software: you can redistribute it and/or modify |
| 6 | it under the terms of the GNU Lesser General Public License as | 6 | it under the terms of the GNU Lesser General Public License as |
| @@ -22,8 +22,12 @@ | |||
| 22 | #endif | 22 | #endif |
| 23 | @PRAGMA_COLUMNS@ | 23 | @PRAGMA_COLUMNS@ |
| 24 | 24 | ||
| 25 | #if defined __need_system_fcntl_h | 25 | #if defined __need_system_fcntl_h || defined _@GUARD_PREFIX@_ALREADY_INCLUDING_FCNTL_H |
| 26 | /* Special invocation convention. */ | 26 | /* Special invocation convention: |
| 27 | - On Haiku we have a sequence of nested includes | ||
| 28 | <fcntl.h> -> <unistd.h> -> <fcntl.h> | ||
| 29 | In this situation, GNULIB_defined_O_NONBLOCK gets defined before the | ||
| 30 | system's definition of O_NONBLOCK is processed. */ | ||
| 27 | 31 | ||
| 28 | /* Needed before <sys/stat.h>. | 32 | /* Needed before <sys/stat.h>. |
| 29 | May also define off_t to a 64-bit type on native Windows. */ | 33 | May also define off_t to a 64-bit type on native Windows. */ |
| @@ -50,8 +54,11 @@ | |||
| 50 | 54 | ||
| 51 | #ifndef _@GUARD_PREFIX@_FCNTL_H | 55 | #ifndef _@GUARD_PREFIX@_FCNTL_H |
| 52 | 56 | ||
| 57 | #define _@GUARD_PREFIX@_ALREADY_INCLUDING_FCNTL_H | ||
| 58 | |||
| 53 | /* Needed before <sys/stat.h>. | 59 | /* Needed before <sys/stat.h>. |
| 54 | May also define off_t to a 64-bit type on native Windows. */ | 60 | May also define off_t to a 64-bit type on native Windows. |
| 61 | Also defines off64_t on macOS, NetBSD, OpenBSD, MSVC, Cygwin, Haiku. */ | ||
| 55 | #include <sys/types.h> | 62 | #include <sys/types.h> |
| 56 | /* On some systems other than glibc, <sys/stat.h> is a prerequisite of | 63 | /* On some systems other than glibc, <sys/stat.h> is a prerequisite of |
| 57 | <fcntl.h>. On glibc systems, we would like to avoid namespace pollution. | 64 | <fcntl.h>. On glibc systems, we would like to avoid namespace pollution. |
| @@ -71,6 +78,8 @@ | |||
| 71 | # include <io.h> | 78 | # include <io.h> |
| 72 | #endif | 79 | #endif |
| 73 | 80 | ||
| 81 | #undef _@GUARD_PREFIX@_ALREADY_INCLUDING_FCNTL_H | ||
| 82 | |||
| 74 | #ifndef _@GUARD_PREFIX@_FCNTL_H | 83 | #ifndef _@GUARD_PREFIX@_FCNTL_H |
| 75 | #define _@GUARD_PREFIX@_FCNTL_H | 84 | #define _@GUARD_PREFIX@_FCNTL_H |
| 76 | 85 | ||
| @@ -99,7 +108,7 @@ | |||
| 99 | # undef creat | 108 | # undef creat |
| 100 | # define creat rpl_creat | 109 | # define creat rpl_creat |
| 101 | # endif | 110 | # endif |
| 102 | _GL_FUNCDECL_RPL (creat, int, (const char *filename, mode_t mode) | 111 | _GL_FUNCDECL_RPL (creat, int, (const char *filename, mode_t mode), |
| 103 | _GL_ARG_NONNULL ((1))); | 112 | _GL_ARG_NONNULL ((1))); |
| 104 | _GL_CXXALIAS_RPL (creat, int, (const char *filename, mode_t mode)); | 113 | _GL_CXXALIAS_RPL (creat, int, (const char *filename, mode_t mode)); |
| 105 | # elif defined _WIN32 && !defined __CYGWIN__ | 114 | # elif defined _WIN32 && !defined __CYGWIN__ |
| @@ -113,7 +122,6 @@ _GL_CXXALIAS_SYS (creat, int, (const char *filename, mode_t mode)); | |||
| 113 | # endif | 122 | # endif |
| 114 | _GL_CXXALIASWARN (creat); | 123 | _GL_CXXALIASWARN (creat); |
| 115 | #elif defined GNULIB_POSIXCHECK | 124 | #elif defined GNULIB_POSIXCHECK |
| 116 | # undef creat | ||
| 117 | /* Assume creat is always declared. */ | 125 | /* Assume creat is always declared. */ |
| 118 | _GL_WARN_ON_USE (creat, "creat is not always POSIX compliant - " | 126 | _GL_WARN_ON_USE (creat, "creat is not always POSIX compliant - " |
| 119 | "use gnulib module creat for portability"); | 127 | "use gnulib module creat for portability"); |
| @@ -140,14 +148,14 @@ _GL_CXXALIASWARN (creat); | |||
| 140 | # undef fcntl | 148 | # undef fcntl |
| 141 | # define fcntl rpl_fcntl | 149 | # define fcntl rpl_fcntl |
| 142 | # endif | 150 | # endif |
| 143 | _GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...)); | 151 | _GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...), ); |
| 144 | _GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...)); | 152 | _GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...)); |
| 145 | # if !GNULIB_defined_rpl_fcntl | 153 | # if !GNULIB_defined_rpl_fcntl |
| 146 | # define GNULIB_defined_rpl_fcntl 1 | 154 | # define GNULIB_defined_rpl_fcntl 1 |
| 147 | # endif | 155 | # endif |
| 148 | # else | 156 | # else |
| 149 | # if !@HAVE_FCNTL@ | 157 | # if !@HAVE_FCNTL@ |
| 150 | _GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...)); | 158 | _GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...), ); |
| 151 | # if !GNULIB_defined_fcntl | 159 | # if !GNULIB_defined_fcntl |
| 152 | # define GNULIB_defined_fcntl 1 | 160 | # define GNULIB_defined_fcntl 1 |
| 153 | # endif | 161 | # endif |
| @@ -156,7 +164,6 @@ _GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...)); | |||
| 156 | # endif | 164 | # endif |
| 157 | _GL_CXXALIASWARN (fcntl); | 165 | _GL_CXXALIASWARN (fcntl); |
| 158 | #elif defined GNULIB_POSIXCHECK | 166 | #elif defined GNULIB_POSIXCHECK |
| 159 | # undef fcntl | ||
| 160 | # if HAVE_RAW_DECL_FCNTL | 167 | # if HAVE_RAW_DECL_FCNTL |
| 161 | _GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - " | 168 | _GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - " |
| 162 | "use gnulib module fcntl for portability"); | 169 | "use gnulib module fcntl for portability"); |
| @@ -169,7 +176,7 @@ _GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - " | |||
| 169 | # undef open | 176 | # undef open |
| 170 | # define open rpl_open | 177 | # define open rpl_open |
| 171 | # endif | 178 | # endif |
| 172 | _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) | 179 | _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...), |
| 173 | _GL_ARG_NONNULL ((1))); | 180 | _GL_ARG_NONNULL ((1))); |
| 174 | _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); | 181 | _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); |
| 175 | # elif defined _WIN32 && !defined __CYGWIN__ | 182 | # elif defined _WIN32 && !defined __CYGWIN__ |
| @@ -187,7 +194,6 @@ _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); | |||
| 187 | _GL_CXXALIASWARN (open); | 194 | _GL_CXXALIASWARN (open); |
| 188 | # endif | 195 | # endif |
| 189 | #elif defined GNULIB_POSIXCHECK | 196 | #elif defined GNULIB_POSIXCHECK |
| 190 | # undef open | ||
| 191 | /* Assume open is always declared. */ | 197 | /* Assume open is always declared. */ |
| 192 | _GL_WARN_ON_USE (open, "open is not always POSIX compliant - " | 198 | _GL_WARN_ON_USE (open, "open is not always POSIX compliant - " |
| 193 | "use gnulib module open for portability"); | 199 | "use gnulib module open for portability"); |
| @@ -200,7 +206,9 @@ _GL_WARN_ON_USE (open, "open is not always POSIX compliant - " | |||
| 200 | # undef open | 206 | # undef open |
| 201 | # define open _open | 207 | # define open _open |
| 202 | # endif | 208 | # endif |
| 203 | _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...)); | 209 | /* Need to cast, because in MSVC the parameter list of _open as a C++ function |
| 210 | is (const char *, int, int = 0). */ | ||
| 211 | _GL_CXXALIAS_MDA_CAST (open, int, (const char *filename, int flags, ...)); | ||
| 204 | # else | 212 | # else |
| 205 | _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); | 213 | _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); |
| 206 | # endif | 214 | # endif |
| @@ -216,14 +224,14 @@ _GL_CXXALIASWARN (open); | |||
| 216 | # define openat rpl_openat | 224 | # define openat rpl_openat |
| 217 | # endif | 225 | # endif |
| 218 | _GL_FUNCDECL_RPL (openat, int, | 226 | _GL_FUNCDECL_RPL (openat, int, |
| 219 | (int fd, char const *file, int flags, /* mode_t mode */ ...) | 227 | (int fd, char const *file, int flags, /* mode_t mode */ ...), |
| 220 | _GL_ARG_NONNULL ((2))); | 228 | _GL_ARG_NONNULL ((2))); |
| 221 | _GL_CXXALIAS_RPL (openat, int, | 229 | _GL_CXXALIAS_RPL (openat, int, |
| 222 | (int fd, char const *file, int flags, /* mode_t mode */ ...)); | 230 | (int fd, char const *file, int flags, /* mode_t mode */ ...)); |
| 223 | # else | 231 | # else |
| 224 | # if !@HAVE_OPENAT@ | 232 | # if !@HAVE_OPENAT@ |
| 225 | _GL_FUNCDECL_SYS (openat, int, | 233 | _GL_FUNCDECL_SYS (openat, int, |
| 226 | (int fd, char const *file, int flags, /* mode_t mode */ ...) | 234 | (int fd, char const *file, int flags, /* mode_t mode */ ...), |
| 227 | _GL_ARG_NONNULL ((2))); | 235 | _GL_ARG_NONNULL ((2))); |
| 228 | # endif | 236 | # endif |
| 229 | _GL_CXXALIAS_SYS (openat, int, | 237 | _GL_CXXALIAS_SYS (openat, int, |
| @@ -231,13 +239,51 @@ _GL_CXXALIAS_SYS (openat, int, | |||
| 231 | # endif | 239 | # endif |
| 232 | _GL_CXXALIASWARN (openat); | 240 | _GL_CXXALIASWARN (openat); |
| 233 | #elif defined GNULIB_POSIXCHECK | 241 | #elif defined GNULIB_POSIXCHECK |
| 234 | # undef openat | ||
| 235 | # if HAVE_RAW_DECL_OPENAT | 242 | # if HAVE_RAW_DECL_OPENAT |
| 236 | _GL_WARN_ON_USE (openat, "openat is not portable - " | 243 | _GL_WARN_ON_USE (openat, "openat is not portable - " |
| 237 | "use gnulib module openat for portability"); | 244 | "use gnulib module openat for portability"); |
| 238 | # endif | 245 | # endif |
| 239 | #endif | 246 | #endif |
| 240 | 247 | ||
| 248 | #if @GNULIB_OPENAT2@ | ||
| 249 | # if !defined RESOLVE_NO_XDEV && defined __has_include | ||
| 250 | # if __has_include (<linux/openat2.h>) | ||
| 251 | # include <linux/openat2.h> | ||
| 252 | # endif | ||
| 253 | # endif | ||
| 254 | # ifndef RESOLVE_NO_XDEV | ||
| 255 | struct open_how | ||
| 256 | { | ||
| 257 | # ifdef __UINT64_TYPE__ | ||
| 258 | __UINT64_TYPE__ flags, mode, resolve; | ||
| 259 | # else | ||
| 260 | unsigned long long int flags, mode, resolve; | ||
| 261 | # endif | ||
| 262 | }; | ||
| 263 | # define RESOLVE_NO_XDEV 0x01 | ||
| 264 | # define RESOLVE_NO_MAGICLINKS 0x02 | ||
| 265 | # define RESOLVE_NO_SYMLINKS 0x04 | ||
| 266 | # define RESOLVE_BENEATH 0x08 | ||
| 267 | # define RESOLVE_IN_ROOT 0x10 | ||
| 268 | # define RESOLVE_CACHED 0x20 | ||
| 269 | # endif | ||
| 270 | |||
| 271 | # if !@HAVE_OPENAT2@ | ||
| 272 | _GL_FUNCDECL_SYS (openat2, int, | ||
| 273 | (int fd, char const *file, struct open_how const *how, | ||
| 274 | size_t size), | ||
| 275 | _GL_ARG_NONNULL ((2, 3))); | ||
| 276 | # endif | ||
| 277 | _GL_CXXALIAS_SYS (openat2, int, | ||
| 278 | (int fd, char const *file, struct open_how const *how, | ||
| 279 | size_t size)); | ||
| 280 | _GL_CXXALIASWARN (openat2); | ||
| 281 | #elif defined GNULIB_POSIXCHECK | ||
| 282 | # if HAVE_RAW_DECL_OPENAT2 | ||
| 283 | _GL_WARN_ON_USE (openat2, "openat2 is not portable - " | ||
| 284 | "use gnulib module openat2 for portability"); | ||
| 285 | # endif | ||
| 286 | #endif | ||
| 241 | 287 | ||
| 242 | /* Fix up the FD_* macros, only known to be missing on mingw. */ | 288 | /* Fix up the FD_* macros, only known to be missing on mingw. */ |
| 243 | 289 | ||
| @@ -282,11 +328,6 @@ _GL_WARN_ON_USE (openat, "openat is not portable - " | |||
| 282 | # endif | 328 | # endif |
| 283 | #endif | 329 | #endif |
| 284 | 330 | ||
| 285 | #if !defined O_DIRECT && defined O_DIRECTIO | ||
| 286 | /* Tru64 spells it 'O_DIRECTIO'. */ | ||
| 287 | # define O_DIRECT O_DIRECTIO | ||
| 288 | #endif | ||
| 289 | |||
| 290 | #if !defined O_CLOEXEC && defined O_NOINHERIT | 331 | #if !defined O_CLOEXEC && defined O_NOINHERIT |
| 291 | /* Mingw spells it 'O_NOINHERIT'. */ | 332 | /* Mingw spells it 'O_NOINHERIT'. */ |
| 292 | # define O_CLOEXEC O_NOINHERIT | 333 | # define O_CLOEXEC O_NOINHERIT |
| @@ -304,7 +345,7 @@ _GL_WARN_ON_USE (openat, "openat is not portable - " | |||
| 304 | #endif | 345 | #endif |
| 305 | 346 | ||
| 306 | #ifndef O_DIRECTORY | 347 | #ifndef O_DIRECTORY |
| 307 | # define O_DIRECTORY 0 | 348 | # define O_DIRECTORY 0x20000000 /* Try to not collide with system O_* flags. */ |
| 308 | #endif | 349 | #endif |
| 309 | 350 | ||
| 310 | #ifndef O_DSYNC | 351 | #ifndef O_DSYNC |
| @@ -368,8 +409,12 @@ _GL_WARN_ON_USE (openat, "openat is not portable - " | |||
| 368 | # define O_RSYNC 0 | 409 | # define O_RSYNC 0 |
| 369 | #endif | 410 | #endif |
| 370 | 411 | ||
| 412 | #if defined O_SEARCH && defined O_PATH && O_SEARCH == O_PATH | ||
| 413 | # undef O_SEARCH /* musl mistakenly #defines O_SEARCH to O_PATH. */ | ||
| 414 | #endif | ||
| 415 | |||
| 371 | #ifndef O_SEARCH | 416 | #ifndef O_SEARCH |
| 372 | # define O_SEARCH O_RDONLY /* This is often close enough in older systems. */ | 417 | # define O_SEARCH O_RDONLY /* Often close enough in non-POSIX systems. */ |
| 373 | #endif | 418 | #endif |
| 374 | 419 | ||
| 375 | #ifndef O_SYNC | 420 | #ifndef O_SYNC |
| @@ -445,6 +490,15 @@ _GL_WARN_ON_USE (openat, "openat is not portable - " | |||
| 445 | # define AT_NO_AUTOMOUNT 0 | 490 | # define AT_NO_AUTOMOUNT 0 |
| 446 | #endif | 491 | #endif |
| 447 | 492 | ||
| 493 | /* errno when openat+O_NOFOLLOW fails because the file is a symlink. */ | ||
| 494 | #if defined __FreeBSD__ || defined __FreeBSD_kernel__ || defined __DragonFly__ | ||
| 495 | # define _GL_OPENAT_ESYMLINK EMLINK | ||
| 496 | #elif defined __NetBSD__ | ||
| 497 | # define _GL_OPENAT_ESYMLINK EFTYPE | ||
| 498 | #else | ||
| 499 | # define _GL_OPENAT_ESYMLINK ELOOP | ||
| 500 | #endif | ||
| 501 | |||
| 448 | #endif /* _@GUARD_PREFIX@_FCNTL_H */ | 502 | #endif /* _@GUARD_PREFIX@_FCNTL_H */ |
| 449 | #endif /* _@GUARD_PREFIX@_FCNTL_H */ | 503 | #endif /* _@GUARD_PREFIX@_FCNTL_H */ |
| 450 | #endif | 504 | #endif |
