summaryrefslogtreecommitdiffstats
path: root/gl/fcntl.in.h
diff options
context:
space:
mode:
Diffstat (limited to 'gl/fcntl.in.h')
-rw-r--r--gl/fcntl.in.h46
1 files changed, 33 insertions, 13 deletions
diff --git a/gl/fcntl.in.h b/gl/fcntl.in.h
index e034eaf9..c5068ed4 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-2023 Free Software Foundation, Inc. 3 Copyright (C) 2006-2025 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,9 +78,16 @@
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
86/* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
87#if !_GL_CONFIG_H_INCLUDED
88 #error "Please include config.h first."
89#endif
90
77#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */ 91#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */
78# include <unistd.h> 92# include <unistd.h>
79#endif 93#endif
@@ -94,7 +108,7 @@
94# undef creat 108# undef creat
95# define creat rpl_creat 109# define creat rpl_creat
96# endif 110# endif
97_GL_FUNCDECL_RPL (creat, int, (const char *filename, mode_t mode) 111_GL_FUNCDECL_RPL (creat, int, (const char *filename, mode_t mode),
98 _GL_ARG_NONNULL ((1))); 112 _GL_ARG_NONNULL ((1)));
99_GL_CXXALIAS_RPL (creat, int, (const char *filename, mode_t mode)); 113_GL_CXXALIAS_RPL (creat, int, (const char *filename, mode_t mode));
100# elif defined _WIN32 && !defined __CYGWIN__ 114# elif defined _WIN32 && !defined __CYGWIN__
@@ -135,14 +149,14 @@ _GL_CXXALIASWARN (creat);
135# undef fcntl 149# undef fcntl
136# define fcntl rpl_fcntl 150# define fcntl rpl_fcntl
137# endif 151# endif
138_GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...)); 152_GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...), );
139_GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...)); 153_GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...));
140# if !GNULIB_defined_rpl_fcntl 154# if !GNULIB_defined_rpl_fcntl
141# define GNULIB_defined_rpl_fcntl 1 155# define GNULIB_defined_rpl_fcntl 1
142# endif 156# endif
143# else 157# else
144# if !@HAVE_FCNTL@ 158# if !@HAVE_FCNTL@
145_GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...)); 159_GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...), );
146# if !GNULIB_defined_fcntl 160# if !GNULIB_defined_fcntl
147# define GNULIB_defined_fcntl 1 161# define GNULIB_defined_fcntl 1
148# endif 162# endif
@@ -164,7 +178,7 @@ _GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - "
164# undef open 178# undef open
165# define open rpl_open 179# define open rpl_open
166# endif 180# endif
167_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) 181_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...),
168 _GL_ARG_NONNULL ((1))); 182 _GL_ARG_NONNULL ((1)));
169_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); 183_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
170# elif defined _WIN32 && !defined __CYGWIN__ 184# elif defined _WIN32 && !defined __CYGWIN__
@@ -195,7 +209,9 @@ _GL_WARN_ON_USE (open, "open is not always POSIX compliant - "
195# undef open 209# undef open
196# define open _open 210# define open _open
197# endif 211# endif
198_GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...)); 212/* Need to cast, because in MSVC the parameter list of _open as a C++ function
213 is (const char *, int, int = 0). */
214_GL_CXXALIAS_MDA_CAST (open, int, (const char *filename, int flags, ...));
199# else 215# else
200_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); 216_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
201# endif 217# endif
@@ -211,14 +227,14 @@ _GL_CXXALIASWARN (open);
211# define openat rpl_openat 227# define openat rpl_openat
212# endif 228# endif
213_GL_FUNCDECL_RPL (openat, int, 229_GL_FUNCDECL_RPL (openat, int,
214 (int fd, char const *file, int flags, /* mode_t mode */ ...) 230 (int fd, char const *file, int flags, /* mode_t mode */ ...),
215 _GL_ARG_NONNULL ((2))); 231 _GL_ARG_NONNULL ((2)));
216_GL_CXXALIAS_RPL (openat, int, 232_GL_CXXALIAS_RPL (openat, int,
217 (int fd, char const *file, int flags, /* mode_t mode */ ...)); 233 (int fd, char const *file, int flags, /* mode_t mode */ ...));
218# else 234# else
219# if !@HAVE_OPENAT@ 235# if !@HAVE_OPENAT@
220_GL_FUNCDECL_SYS (openat, int, 236_GL_FUNCDECL_SYS (openat, int,
221 (int fd, char const *file, int flags, /* mode_t mode */ ...) 237 (int fd, char const *file, int flags, /* mode_t mode */ ...),
222 _GL_ARG_NONNULL ((2))); 238 _GL_ARG_NONNULL ((2)));
223# endif 239# endif
224_GL_CXXALIAS_SYS (openat, int, 240_GL_CXXALIAS_SYS (openat, int,
@@ -299,7 +315,7 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
299#endif 315#endif
300 316
301#ifndef O_DIRECTORY 317#ifndef O_DIRECTORY
302# define O_DIRECTORY 0 318# define O_DIRECTORY 0x20000000 /* Try to not collide with system O_* flags. */
303#endif 319#endif
304 320
305#ifndef O_DSYNC 321#ifndef O_DSYNC
@@ -363,8 +379,12 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
363# define O_RSYNC 0 379# define O_RSYNC 0
364#endif 380#endif
365 381
382#if defined O_SEARCH && defined O_PATH && O_SEARCH == O_PATH
383# undef O_SEARCH /* musl mistakenly #defines O_SEARCH to O_PATH. */
384#endif
385
366#ifndef O_SEARCH 386#ifndef O_SEARCH
367# define O_SEARCH O_RDONLY /* This is often close enough in older systems. */ 387# define O_SEARCH O_RDONLY /* Often close enough in non-POSIX systems. */
368#endif 388#endif
369 389
370#ifndef O_SYNC 390#ifndef O_SYNC