1 /* Test of <sys/stat.h> substitute.
2 Copyright (C) 2007-2024 Free Software Foundation, Inc.
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.
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.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2007. */
23 /* Check the existence of some macros. */
27 #ifdef S_IFBLK /* missing on MSVC */
30 S_IFCHR
, S_IFDIR
, S_IFIFO
, S_IFREG
,
31 #ifdef S_IFLNK /* missing on native Windows and DJGPP */
34 #ifdef S_IFSOCK /* missing on native Windows and DJGPP */
37 S_IRWXU
, S_IRUSR
, S_IWUSR
, S_IXUSR
,
38 S_IRWXG
, S_IRGRP
, S_IWGRP
, S_IXGRP
,
39 S_IRWXO
, S_IROTH
, S_IWOTH
, S_IXOTH
,
40 S_ISUID
, S_ISGID
, S_ISVTX
,
62 static_assert (S_IRWXU
== (S_IRUSR
| S_IWUSR
| S_IXUSR
));
63 static_assert (S_IRWXG
== (S_IRGRP
| S_IWGRP
| S_IXGRP
));
64 static_assert (S_IRWXO
== (S_IROTH
| S_IWOTH
| S_IXOTH
));
67 static_assert (S_ISBLK (S_IFBLK
));
69 static_assert (!S_ISBLK (S_IFCHR
));
70 static_assert (!S_ISBLK (S_IFDIR
));
71 static_assert (!S_ISBLK (S_IFIFO
));
72 static_assert (!S_ISBLK (S_IFREG
));
74 static_assert (!S_ISBLK (S_IFLNK
));
77 static_assert (!S_ISBLK (S_IFSOCK
));
81 static_assert (!S_ISCHR (S_IFBLK
));
83 static_assert (S_ISCHR (S_IFCHR
));
84 static_assert (!S_ISCHR (S_IFDIR
));
85 static_assert (!S_ISCHR (S_IFIFO
));
86 static_assert (!S_ISCHR (S_IFREG
));
88 static_assert (!S_ISCHR (S_IFLNK
));
91 static_assert (!S_ISCHR (S_IFSOCK
));
95 static_assert (!S_ISDIR (S_IFBLK
));
97 static_assert (!S_ISDIR (S_IFCHR
));
98 static_assert (S_ISDIR (S_IFDIR
));
99 static_assert (!S_ISDIR (S_IFIFO
));
100 static_assert (!S_ISDIR (S_IFREG
));
102 static_assert (!S_ISDIR (S_IFLNK
));
105 static_assert (!S_ISDIR (S_IFSOCK
));
109 static_assert (!S_ISFIFO (S_IFBLK
));
111 static_assert (!S_ISFIFO (S_IFCHR
));
112 static_assert (!S_ISFIFO (S_IFDIR
));
113 static_assert (S_ISFIFO (S_IFIFO
));
114 static_assert (!S_ISFIFO (S_IFREG
));
116 static_assert (!S_ISFIFO (S_IFLNK
));
119 static_assert (!S_ISFIFO (S_IFSOCK
));
123 static_assert (!S_ISREG (S_IFBLK
));
125 static_assert (!S_ISREG (S_IFCHR
));
126 static_assert (!S_ISREG (S_IFDIR
));
127 static_assert (!S_ISREG (S_IFIFO
));
128 static_assert (S_ISREG (S_IFREG
));
130 static_assert (!S_ISREG (S_IFLNK
));
133 static_assert (!S_ISREG (S_IFSOCK
));
137 static_assert (!S_ISLNK (S_IFBLK
));
139 static_assert (!S_ISLNK (S_IFCHR
));
140 static_assert (!S_ISLNK (S_IFDIR
));
141 static_assert (!S_ISLNK (S_IFIFO
));
142 static_assert (!S_ISLNK (S_IFREG
));
144 static_assert (S_ISLNK (S_IFLNK
));
147 static_assert (!S_ISLNK (S_IFSOCK
));
151 static_assert (!S_ISSOCK (S_IFBLK
));
153 static_assert (!S_ISSOCK (S_IFCHR
));
154 static_assert (!S_ISSOCK (S_IFDIR
));
155 static_assert (!S_ISSOCK (S_IFIFO
));
156 static_assert (!S_ISSOCK (S_IFREG
));
158 static_assert (!S_ISSOCK (S_IFLNK
));
161 static_assert (S_ISSOCK (S_IFSOCK
));
165 static_assert (!S_ISDOOR (S_IFBLK
));
167 static_assert (!S_ISDOOR (S_IFCHR
));
168 static_assert (!S_ISDOOR (S_IFDIR
));
169 static_assert (!S_ISDOOR (S_IFIFO
));
170 static_assert (!S_ISDOOR (S_IFREG
));
172 static_assert (!S_ISDOOR (S_IFLNK
));
175 static_assert (!S_ISDOOR (S_IFSOCK
));
179 static_assert (!S_ISMPB (S_IFBLK
));
181 static_assert (!S_ISMPB (S_IFCHR
));
182 static_assert (!S_ISMPB (S_IFDIR
));
183 static_assert (!S_ISMPB (S_IFIFO
));
184 static_assert (!S_ISMPB (S_IFREG
));
186 static_assert (!S_ISMPB (S_IFLNK
));
189 static_assert (!S_ISMPB (S_IFSOCK
));
193 static_assert (!S_ISMPX (S_IFBLK
));
195 static_assert (!S_ISMPX (S_IFCHR
));
196 static_assert (!S_ISMPX (S_IFDIR
));
197 static_assert (!S_ISMPX (S_IFIFO
));
198 static_assert (!S_ISMPX (S_IFREG
));
200 static_assert (!S_ISMPX (S_IFLNK
));
203 static_assert (!S_ISMPX (S_IFSOCK
));
207 static_assert (!S_ISNAM (S_IFBLK
));
209 static_assert (!S_ISNAM (S_IFCHR
));
210 static_assert (!S_ISNAM (S_IFDIR
));
211 static_assert (!S_ISNAM (S_IFIFO
));
212 static_assert (!S_ISNAM (S_IFREG
));
214 static_assert (!S_ISNAM (S_IFLNK
));
217 static_assert (!S_ISNAM (S_IFSOCK
));
221 static_assert (!S_ISNWK (S_IFBLK
));
223 static_assert (!S_ISNWK (S_IFCHR
));
224 static_assert (!S_ISNWK (S_IFDIR
));
225 static_assert (!S_ISNWK (S_IFIFO
));
226 static_assert (!S_ISNWK (S_IFREG
));
228 static_assert (!S_ISNWK (S_IFLNK
));
231 static_assert (!S_ISNWK (S_IFSOCK
));
235 static_assert (!S_ISPORT (S_IFBLK
));
237 static_assert (!S_ISPORT (S_IFCHR
));
238 static_assert (!S_ISPORT (S_IFDIR
));
239 static_assert (!S_ISPORT (S_IFIFO
));
240 static_assert (!S_ISPORT (S_IFREG
));
242 static_assert (!S_ISPORT (S_IFLNK
));
245 static_assert (!S_ISPORT (S_IFSOCK
));
249 static_assert (!S_ISCTG (S_IFBLK
));
251 static_assert (!S_ISCTG (S_IFCHR
));
252 static_assert (!S_ISCTG (S_IFDIR
));
253 static_assert (!S_ISCTG (S_IFIFO
));
254 static_assert (!S_ISCTG (S_IFREG
));
256 static_assert (!S_ISCTG (S_IFLNK
));
259 static_assert (!S_ISCTG (S_IFSOCK
));
263 static_assert (!S_ISOFD (S_IFBLK
));
265 static_assert (!S_ISOFD (S_IFCHR
));
266 static_assert (!S_ISOFD (S_IFDIR
));
267 static_assert (!S_ISOFD (S_IFIFO
));
268 static_assert (!S_ISOFD (S_IFREG
));
270 static_assert (!S_ISOFD (S_IFLNK
));
273 static_assert (!S_ISOFD (S_IFSOCK
));
277 static_assert (!S_ISOFL (S_IFBLK
));
279 static_assert (!S_ISOFL (S_IFCHR
));
280 static_assert (!S_ISOFL (S_IFDIR
));
281 static_assert (!S_ISOFL (S_IFIFO
));
282 static_assert (!S_ISOFL (S_IFREG
));
284 static_assert (!S_ISOFL (S_IFLNK
));
287 static_assert (!S_ISOFL (S_IFSOCK
));
291 static_assert (!S_ISWHT (S_IFBLK
));
293 static_assert (!S_ISWHT (S_IFCHR
));
294 static_assert (!S_ISWHT (S_IFDIR
));
295 static_assert (!S_ISWHT (S_IFIFO
));
296 static_assert (!S_ISWHT (S_IFREG
));
298 static_assert (!S_ISWHT (S_IFLNK
));
301 static_assert (!S_ISWHT (S_IFSOCK
));
304 /* POSIX 2008 requires traditional encoding of permission constants. */
305 static_assert (S_IRWXU
== 00700);
306 static_assert (S_IRUSR
== 00400);
307 static_assert (S_IWUSR
== 00200);
308 static_assert (S_IXUSR
== 00100);
309 static_assert (S_IRWXG
== 00070);
310 static_assert (S_IRGRP
== 00040);
311 static_assert (S_IWGRP
== 00020);
312 static_assert (S_IXGRP
== 00010);
313 static_assert (S_IRWXO
== 00007);
314 static_assert (S_IROTH
== 00004);
315 static_assert (S_IWOTH
== 00002);
316 static_assert (S_IXOTH
== 00001);
317 static_assert (S_ISUID
== 04000);
318 static_assert (S_ISGID
== 02000);
319 static_assert (S_ISVTX
== 01000);
321 #if ((0 <= UTIME_NOW && UTIME_NOW < 1000000000) \
322 || (0 <= UTIME_OMIT && UTIME_OMIT < 1000000000) \
323 || UTIME_NOW == UTIME_OMIT)
327 /* Check the existence of some types. */