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.h41
1 files changed, 28 insertions, 13 deletions
diff --git a/gl/fcntl.in.h b/gl/fcntl.in.h
index eea3b954..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-2024 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,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__
@@ -140,14 +149,14 @@ _GL_CXXALIASWARN (creat);
140# undef fcntl 149# undef fcntl
141# define fcntl rpl_fcntl 150# define fcntl rpl_fcntl
142# endif 151# endif
143_GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...)); 152_GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...), );
144_GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...)); 153_GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...));
145# if !GNULIB_defined_rpl_fcntl 154# if !GNULIB_defined_rpl_fcntl
146# define GNULIB_defined_rpl_fcntl 1 155# define GNULIB_defined_rpl_fcntl 1
147# endif 156# endif
148# else 157# else
149# if !@HAVE_FCNTL@ 158# if !@HAVE_FCNTL@
150_GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...)); 159_GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...), );
151# if !GNULIB_defined_fcntl 160# if !GNULIB_defined_fcntl
152# define GNULIB_defined_fcntl 1 161# define GNULIB_defined_fcntl 1
153# endif 162# endif
@@ -169,7 +178,7 @@ _GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - "
169# undef open 178# undef open
170# define open rpl_open 179# define open rpl_open
171# endif 180# endif
172_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) 181_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...),
173 _GL_ARG_NONNULL ((1))); 182 _GL_ARG_NONNULL ((1)));
174_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); 183_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
175# elif defined _WIN32 && !defined __CYGWIN__ 184# elif defined _WIN32 && !defined __CYGWIN__
@@ -200,7 +209,9 @@ _GL_WARN_ON_USE (open, "open is not always POSIX compliant - "
200# undef open 209# undef open
201# define open _open 210# define open _open
202# endif 211# endif
203_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, ...));
204# else 215# else
205_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); 216_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
206# endif 217# endif
@@ -216,14 +227,14 @@ _GL_CXXALIASWARN (open);
216# define openat rpl_openat 227# define openat rpl_openat
217# endif 228# endif
218_GL_FUNCDECL_RPL (openat, int, 229_GL_FUNCDECL_RPL (openat, int,
219 (int fd, char const *file, int flags, /* mode_t mode */ ...) 230 (int fd, char const *file, int flags, /* mode_t mode */ ...),
220 _GL_ARG_NONNULL ((2))); 231 _GL_ARG_NONNULL ((2)));
221_GL_CXXALIAS_RPL (openat, int, 232_GL_CXXALIAS_RPL (openat, int,
222 (int fd, char const *file, int flags, /* mode_t mode */ ...)); 233 (int fd, char const *file, int flags, /* mode_t mode */ ...));
223# else 234# else
224# if !@HAVE_OPENAT@ 235# if !@HAVE_OPENAT@
225_GL_FUNCDECL_SYS (openat, int, 236_GL_FUNCDECL_SYS (openat, int,
226 (int fd, char const *file, int flags, /* mode_t mode */ ...) 237 (int fd, char const *file, int flags, /* mode_t mode */ ...),
227 _GL_ARG_NONNULL ((2))); 238 _GL_ARG_NONNULL ((2)));
228# endif 239# endif
229_GL_CXXALIAS_SYS (openat, int, 240_GL_CXXALIAS_SYS (openat, int,
@@ -304,7 +315,7 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
304#endif 315#endif
305 316
306#ifndef O_DIRECTORY 317#ifndef O_DIRECTORY
307# define O_DIRECTORY 0 318# define O_DIRECTORY 0x20000000 /* Try to not collide with system O_* flags. */
308#endif 319#endif
309 320
310#ifndef O_DSYNC 321#ifndef O_DSYNC
@@ -368,8 +379,12 @@ _GL_WARN_ON_USE (openat, "openat is not portable - "
368# define O_RSYNC 0 379# define O_RSYNC 0
369#endif 380#endif
370 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
371#ifndef O_SEARCH 386#ifndef O_SEARCH
372# 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. */
373#endif 388#endif
374 389
375#ifndef O_SYNC 390#ifndef O_SYNC