Reduce code duplication.
[gnulib.git] / lib / fcntl.in.h
1 /* Like <fcntl.h>, but with non-working flags defined to 0.
2
3    Copyright (C) 2006-2008 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 @PRAGMA_SYSTEM_HEADER@
21
22 #if defined __need_system_fcntl_h
23 /* Special invocation convention.  */
24
25 #include <sys/types.h>
26 #include <sys/stat.h>
27 #include <unistd.h>
28 #@INCLUDE_NEXT@ @NEXT_FCNTL_H@
29
30 #else
31 /* Normal invocation convention.  */
32
33 #ifndef _GL_FCNTL_H
34
35 #include <sys/types.h>
36 #include <sys/stat.h>
37 #include <unistd.h>
38 /* The include_next requires a split double-inclusion guard.  */
39 #@INCLUDE_NEXT@ @NEXT_FCNTL_H@
40
41 #ifndef _GL_FCNTL_H
42 #define _GL_FCNTL_H
43
44
45 /* Declare overridden functions.  */
46
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50
51 #if (@GNULIB_OPEN@ && @REPLACE_OPEN@) || defined FCHDIR_REPLACEMENT
52 # undef open
53 # define open rpl_open
54 extern int open (const char *filename, int flags, ...);
55 #endif
56
57 #ifdef __cplusplus
58 }
59 #endif
60
61
62 /* Fix up the O_* macros.  */
63
64 #if !defined O_DIRECT && defined O_DIRECTIO
65 /* Tru64 spells it `O_DIRECTIO'.  */
66 # define O_DIRECT O_DIRECTIO
67 #endif
68
69 #ifndef O_DIRECT
70 # define O_DIRECT 0
71 #endif
72
73 #ifndef O_DIRECTORY
74 # define O_DIRECTORY 0
75 #endif
76
77 #ifndef O_DSYNC
78 # define O_DSYNC 0
79 #endif
80
81 #ifndef O_NDELAY
82 # define O_NDELAY 0
83 #endif
84
85 #ifndef O_NOATIME
86 # define O_NOATIME 0
87 #endif
88
89 #ifndef O_NONBLOCK
90 # define O_NONBLOCK O_NDELAY
91 #endif
92
93 #ifndef O_NOCTTY
94 # define O_NOCTTY 0
95 #endif
96
97 #ifndef O_NOFOLLOW
98 # define O_NOFOLLOW 0
99 #endif
100
101 #ifndef O_NOLINKS
102 # define O_NOLINKS 0
103 #endif
104
105 #ifndef O_RSYNC
106 # define O_RSYNC 0
107 #endif
108
109 #ifndef O_SYNC
110 # define O_SYNC 0
111 #endif
112
113 /* For systems that distinguish between text and binary I/O.
114    O_BINARY is usually declared in fcntl.h  */
115 #if !defined O_BINARY && defined _O_BINARY
116   /* For MSC-compatible compilers.  */
117 # define O_BINARY _O_BINARY
118 # define O_TEXT _O_TEXT
119 #endif
120
121 #ifdef __BEOS__
122   /* BeOS 5 has O_BINARY and O_TEXT, but they have no effect.  */
123 # undef O_BINARY
124 # undef O_TEXT
125 #endif
126
127 #ifndef O_BINARY
128 # define O_BINARY 0
129 # define O_TEXT 0
130 #endif
131
132
133 #endif /* _GL_FCNTL_H */
134 #endif /* _GL_FCNTL_H */
135 #endif