b0a90fc74678bac5acac8113670b61cac700e732
[debian/gzip] / lib / fcntl.in.h
1 /* Like <fcntl.h>, but with non-working flags defined to 0.
2
3    Copyright (C) 2006-2010 Free Software Foundation, Inc.
4
5    This program is free software: you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 3 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17
18 /* written by Paul Eggert */
19
20 #if __GNUC__ >= 3
21 @PRAGMA_SYSTEM_HEADER@
22 #endif
23
24 #if defined __need_system_fcntl_h
25 /* Special invocation convention.  */
26
27 #include <sys/types.h>
28 #ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems.  */
29 # include <sys/stat.h>
30 #endif
31 #@INCLUDE_NEXT@ @NEXT_FCNTL_H@
32
33 #else
34 /* Normal invocation convention.  */
35
36 #ifndef _GL_FCNTL_H
37
38 #include <sys/types.h>
39 #ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems.  */
40 # include <sys/stat.h>
41 #endif
42 /* The include_next requires a split double-inclusion guard.  */
43 #@INCLUDE_NEXT@ @NEXT_FCNTL_H@
44
45 #ifndef _GL_FCNTL_H
46 #define _GL_FCNTL_H
47
48 #ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems.  */
49 # include <unistd.h>
50 #endif
51
52
53 /* The definition of GL_LINK_WARNING is copied here.  */
54
55 /* The definition of _GL_ARG_NONNULL is copied here.  */
56
57
58 /* Declare overridden functions.  */
59
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63
64 #if @GNULIB_FCNTL@
65 # if @REPLACE_FCNTL@
66 #  undef fcntl
67 #  define fcntl rpl_fcntl
68 # endif
69 # if !@HAVE_FCNTL@ || @REPLACE_FCNTL@
70 extern int fcntl (int fd, int action, ...);
71 # endif
72 #elif defined GNULIB_POSIXCHECK
73 # undef fcntl
74 # define fcntl \
75     (GL_LINK_WARNING ("fcntl is not always POSIX compliant - " \
76                       "use gnulib module fcntl for portability"), \
77      fcntl)
78 #endif
79
80 #if @GNULIB_OPEN@
81 # if @REPLACE_OPEN@
82 #  undef open
83 #  define open rpl_open
84 extern int open (const char *filename, int flags, ...) _GL_ARG_NONNULL ((1));
85 # endif
86 #elif defined GNULIB_POSIXCHECK
87 # undef open
88 # define open \
89     (GL_LINK_WARNING ("open is not always POSIX compliant - " \
90                       "use gnulib module open for portability"), \
91      open)
92 #endif
93
94 #if @GNULIB_OPENAT@
95 # if @REPLACE_OPENAT@
96 #  undef openat
97 #  define openat rpl_openat
98 # endif
99 # if !@HAVE_OPENAT@ || @REPLACE_OPENAT@
100 extern int openat (int fd, char const *file, int flags, /* mode_t mode */ ...)
101      _GL_ARG_NONNULL ((2));
102 # endif
103 #elif defined GNULIB_POSIXCHECK
104 # undef openat
105 # define openat \
106     (GL_LINK_WARNING ("openat is not portable - " \
107                       "use gnulib module openat for portability"), \
108      openat)
109 #endif
110
111 #ifdef __cplusplus
112 }
113 #endif
114
115 /* Fix up the FD_* macros, only known to be missing on mingw.  */
116
117 #ifndef FD_CLOEXEC
118 # define FD_CLOEXEC 1
119 #endif
120
121 /* Fix up the supported F_* macros.  Intentionally leave other F_*
122    macros undefined.  Only known to be missing on mingw.  */
123
124 #ifndef F_DUPFD_CLOEXEC
125 # define F_DUPFD_CLOEXEC 0x40000000
126 /* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise.  */
127 # define GNULIB_defined_F_DUPFD_CLOEXEC 1
128 #else
129 # define GNULIB_defined_F_DUPFD_CLOEXEC 0
130 #endif
131
132 #ifndef F_DUPFD
133 # define F_DUPFD 1
134 #endif
135
136 #ifndef F_GETFD
137 # define F_GETFD 2
138 #endif
139
140 /* Fix up the O_* macros.  */
141
142 #if !defined O_DIRECT && defined O_DIRECTIO
143 /* Tru64 spells it `O_DIRECTIO'.  */
144 # define O_DIRECT O_DIRECTIO
145 #endif
146
147 #if !defined O_CLOEXEC && defined O_NOINHERIT
148 /* Mingw spells it `O_NOINHERIT'.  Intentionally leave it
149    undefined if not available.  */
150 # define O_CLOEXEC O_NOINHERIT
151 #endif
152
153 #ifndef O_DIRECT
154 # define O_DIRECT 0
155 #endif
156
157 #ifndef O_DIRECTORY
158 # define O_DIRECTORY 0
159 #endif
160
161 #ifndef O_DSYNC
162 # define O_DSYNC 0
163 #endif
164
165 #ifndef O_NDELAY
166 # define O_NDELAY 0
167 #endif
168
169 #ifndef O_NOATIME
170 # define O_NOATIME 0
171 #endif
172
173 #ifndef O_NONBLOCK
174 # define O_NONBLOCK O_NDELAY
175 #endif
176
177 #ifndef O_NOCTTY
178 # define O_NOCTTY 0
179 #endif
180
181 #ifndef O_NOFOLLOW
182 # define O_NOFOLLOW 0
183 #endif
184
185 #ifndef O_NOLINKS
186 # define O_NOLINKS 0
187 #endif
188
189 #ifndef O_RSYNC
190 # define O_RSYNC 0
191 #endif
192
193 #ifndef O_SYNC
194 # define O_SYNC 0
195 #endif
196
197 #ifndef O_TTY_INIT
198 # define O_TTY_INIT 0
199 #endif
200
201 /* For systems that distinguish between text and binary I/O.
202    O_BINARY is usually declared in fcntl.h  */
203 #if !defined O_BINARY && defined _O_BINARY
204   /* For MSC-compatible compilers.  */
205 # define O_BINARY _O_BINARY
206 # define O_TEXT _O_TEXT
207 #endif
208
209 #if defined __BEOS__ || defined __HAIKU__
210   /* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect.  */
211 # undef O_BINARY
212 # undef O_TEXT
213 #endif
214
215 #ifndef O_BINARY
216 # define O_BINARY 0
217 # define O_TEXT 0
218 #endif
219
220 /* Fix up the AT_* macros.  */
221
222 /* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive.  Its
223    value exceeds INT_MAX, so its use as an int doesn't conform to the
224    C standard, and GCC and Sun C complain in some cases.  If the bug
225    is present, undef AT_FDCWD here, so it can be redefined below.  */
226 #if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553
227 # undef AT_FDCWD
228 #endif
229
230 /* Use the same bit pattern as Solaris 9, but with the proper
231    signedness.  The bit pattern is important, in case this actually is
232    Solaris with the above workaround.  */
233 #ifndef AT_FDCWD
234 # define AT_FDCWD (-3041965)
235 #endif
236
237 /* Use the same values as Solaris 9.  This shouldn't matter, but
238    there's no real reason to differ.  */
239 #ifndef AT_SYMLINK_NOFOLLOW
240 # define AT_SYMLINK_NOFOLLOW 4096
241 #endif
242
243 #ifndef AT_REMOVEDIR
244 # define AT_REMOVEDIR 1
245 #endif
246
247 /* Solaris 9 lacks these two, so just pick unique values.  */
248 #ifndef AT_SYMLINK_FOLLOW
249 # define AT_SYMLINK_FOLLOW 2
250 #endif
251
252 #ifndef AT_EACCESS
253 # define AT_EACCESS 4
254 #endif
255
256
257 #endif /* _GL_FCNTL_H */
258 #endif /* _GL_FCNTL_H */
259 #endif