* build-aux/bootstrap (slurp): Remove obsolescent gettext.m4 patch.
[gnulib.git] / tests / test-fcntl-h.c
1 /* Test of <fcntl.h> substitute.
2    Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
3
4    This program is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 3 of the License, or
7    (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
16
17 /* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
18
19 #include <config.h>
20
21 #include <fcntl.h>
22
23 /* Check that the various O_* macros are defined.  */
24 int o = O_DIRECT | O_DIRECTORY | O_DSYNC | O_NDELAY | O_NOATIME | O_NONBLOCK
25         | O_NOCTTY | O_NOFOLLOW | O_NOLINKS | O_RSYNC | O_SYNC | O_TTY_INIT
26         | O_BINARY | O_TEXT;
27
28 /* Check that the various SEEK_* macros are defined.  */
29 int sk[] = { SEEK_CUR, SEEK_END, SEEK_SET };
30
31 /* Check that the FD_* macros are defined.  */
32 int i = FD_CLOEXEC;
33
34 int
35 main (void)
36 {
37   /* Ensure no overlap in SEEK_*. */
38   switch (0)
39     {
40     case SEEK_CUR:
41     case SEEK_END:
42     case SEEK_SET:
43       ;
44     }
45
46   /* Ensure no dangerous overlap in non-zero gnulib-defined replacements.  */
47   switch (O_RDONLY)
48     {
49       /* Access modes */
50     case O_RDONLY:
51     case O_WRONLY:
52     case O_RDWR:
53 #if O_EXEC && O_EXEC != O_RDONLY
54     case O_EXEC:
55 #endif
56 #if O_SEARCH && O_EXEC != O_SEARCH && O_SEARCH != O_RDONLY
57     case O_SEARCH:
58 #endif
59       i = O_ACCMODE == (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH);
60       break;
61
62       /* Everyone should have these */
63     case O_CREAT:
64     case O_EXCL:
65     case O_TRUNC:
66     case O_APPEND:
67       break;
68
69       /* These might be 0 or O_RDONLY, only test non-zero versions.  */
70 #if O_CLOEXEC
71     case O_CLOEXEC:
72 #endif
73 #if O_DIRECT
74     case O_DIRECT:
75 #endif
76 #if O_DIRECTORY
77     case O_DIRECTORY:
78 #endif
79 #if O_DSYNC
80     case O_DSYNC:
81 #endif
82 #if O_NOATIME
83     case O_NOATIME:
84 #endif
85 #if O_NONBLOCK
86     case O_NONBLOCK:
87 #endif
88 #if O_NOCTTY
89     case O_NOCTTY:
90 #endif
91 #if O_NOFOLLOW
92     case O_NOFOLLOW:
93 #endif
94 #if O_NOLINKS
95     case O_NOLINKS:
96 #endif
97 #if O_RSYNC && O_RSYNC != O_DSYNC
98     case O_RSYNC:
99 #endif
100 #if O_SYNC && O_SYNC != O_RSYNC
101     case O_SYNC:
102 #endif
103 #if O_TTY_INIT
104     case O_TTY_INIT:
105 #endif
106 #if O_BINARY
107     case O_BINARY:
108 #endif
109 #if O_TEXT
110     case O_TEXT:
111 #endif
112       ;
113     }
114
115   return !i;
116 }