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