e83ab1a11eb7f398d35e14ec61968810e1ebfdda
[debian/gzip] / lib / sys_stat.in.h
1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* Provide a more complete sys/stat header file.
4    Copyright (C) 2005-2010 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, or (at your option)
9    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, write to the Free Software Foundation,
18    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
19
20 /* Written by Eric Blake, Paul Eggert, and Jim Meyering.  */
21
22 /* This file is supposed to be used on platforms where <sys/stat.h> is
23    incomplete.  It is intended to provide definitions and prototypes
24    needed by an application.  Start with what the system provides.  */
25
26 #if __GNUC__ >= 3
27 @PRAGMA_SYSTEM_HEADER@
28 #endif
29
30 #if defined __need_system_sys_stat_h
31 /* Special invocation convention.  */
32
33 #@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
34
35 #else
36 /* Normal invocation convention.  */
37
38 #ifndef _GL_SYS_STAT_H
39
40 /* Get nlink_t.  */
41 #include <sys/types.h>
42
43 /* Get struct timespec.  */
44 #include <time.h>
45
46 /* The include_next requires a split double-inclusion guard.  */
47 #@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
48
49 #ifndef _GL_SYS_STAT_H
50 #define _GL_SYS_STAT_H
51
52 /* The definition of GL_LINK_WARNING is copied here.  */
53
54 /* The definition of _GL_ARG_NONNULL is copied here.  */
55
56 /* Before doing "#define mkdir rpl_mkdir" below, we need to include all
57    headers that may declare mkdir().  */
58 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
59 # include <io.h>
60 #endif
61
62 #ifndef S_IFMT
63 # define S_IFMT 0170000
64 #endif
65
66 #if STAT_MACROS_BROKEN
67 # undef S_ISBLK
68 # undef S_ISCHR
69 # undef S_ISDIR
70 # undef S_ISFIFO
71 # undef S_ISLNK
72 # undef S_ISNAM
73 # undef S_ISMPB
74 # undef S_ISMPC
75 # undef S_ISNWK
76 # undef S_ISREG
77 # undef S_ISSOCK
78 #endif
79
80 #ifndef S_ISBLK
81 # ifdef S_IFBLK
82 #  define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
83 # else
84 #  define S_ISBLK(m) 0
85 # endif
86 #endif
87
88 #ifndef S_ISCHR
89 # ifdef S_IFCHR
90 #  define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
91 # else
92 #  define S_ISCHR(m) 0
93 # endif
94 #endif
95
96 #ifndef S_ISDIR
97 # ifdef S_IFDIR
98 #  define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
99 # else
100 #  define S_ISDIR(m) 0
101 # endif
102 #endif
103
104 #ifndef S_ISDOOR /* Solaris 2.5 and up */
105 # define S_ISDOOR(m) 0
106 #endif
107
108 #ifndef S_ISFIFO
109 # ifdef S_IFIFO
110 #  define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
111 # else
112 #  define S_ISFIFO(m) 0
113 # endif
114 #endif
115
116 #ifndef S_ISLNK
117 # ifdef S_IFLNK
118 #  define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
119 # else
120 #  define S_ISLNK(m) 0
121 # endif
122 #endif
123
124 #ifndef S_ISMPB /* V7 */
125 # ifdef S_IFMPB
126 #  define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
127 #  define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
128 # else
129 #  define S_ISMPB(m) 0
130 #  define S_ISMPC(m) 0
131 # endif
132 #endif
133
134 #ifndef S_ISNAM /* Xenix */
135 # ifdef S_IFNAM
136 #  define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
137 # else
138 #  define S_ISNAM(m) 0
139 # endif
140 #endif
141
142 #ifndef S_ISNWK /* HP/UX */
143 # ifdef S_IFNWK
144 #  define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
145 # else
146 #  define S_ISNWK(m) 0
147 # endif
148 #endif
149
150 #ifndef S_ISPORT /* Solaris 10 and up */
151 # define S_ISPORT(m) 0
152 #endif
153
154 #ifndef S_ISREG
155 # ifdef S_IFREG
156 #  define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
157 # else
158 #  define S_ISREG(m) 0
159 # endif
160 #endif
161
162 #ifndef S_ISSOCK
163 # ifdef S_IFSOCK
164 #  define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
165 # else
166 #  define S_ISSOCK(m) 0
167 # endif
168 #endif
169
170
171 #ifndef S_TYPEISMQ
172 # define S_TYPEISMQ(p) 0
173 #endif
174
175 #ifndef S_TYPEISTMO
176 # define S_TYPEISTMO(p) 0
177 #endif
178
179
180 #ifndef S_TYPEISSEM
181 # ifdef S_INSEM
182 #  define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
183 # else
184 #  define S_TYPEISSEM(p) 0
185 # endif
186 #endif
187
188 #ifndef S_TYPEISSHM
189 # ifdef S_INSHD
190 #  define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
191 # else
192 #  define S_TYPEISSHM(p) 0
193 # endif
194 #endif
195
196 /* high performance ("contiguous data") */
197 #ifndef S_ISCTG
198 # define S_ISCTG(p) 0
199 #endif
200
201 /* Cray DMF (data migration facility): off line, with data  */
202 #ifndef S_ISOFD
203 # define S_ISOFD(p) 0
204 #endif
205
206 /* Cray DMF (data migration facility): off line, with no data  */
207 #ifndef S_ISOFL
208 # define S_ISOFL(p) 0
209 #endif
210
211 /* 4.4BSD whiteout */
212 #ifndef S_ISWHT
213 # define S_ISWHT(m) 0
214 #endif
215
216 /* If any of the following are undefined,
217    define them to their de facto standard values.  */
218 #if !S_ISUID
219 # define S_ISUID 04000
220 #endif
221 #if !S_ISGID
222 # define S_ISGID 02000
223 #endif
224
225 /* S_ISVTX is a common extension to POSIX.  */
226 #ifndef S_ISVTX
227 # define S_ISVTX 01000
228 #endif
229
230 #if !S_IRUSR && S_IREAD
231 # define S_IRUSR S_IREAD
232 #endif
233 #if !S_IRUSR
234 # define S_IRUSR 00400
235 #endif
236 #if !S_IRGRP
237 # define S_IRGRP (S_IRUSR >> 3)
238 #endif
239 #if !S_IROTH
240 # define S_IROTH (S_IRUSR >> 6)
241 #endif
242
243 #if !S_IWUSR && S_IWRITE
244 # define S_IWUSR S_IWRITE
245 #endif
246 #if !S_IWUSR
247 # define S_IWUSR 00200
248 #endif
249 #if !S_IWGRP
250 # define S_IWGRP (S_IWUSR >> 3)
251 #endif
252 #if !S_IWOTH
253 # define S_IWOTH (S_IWUSR >> 6)
254 #endif
255
256 #if !S_IXUSR && S_IEXEC
257 # define S_IXUSR S_IEXEC
258 #endif
259 #if !S_IXUSR
260 # define S_IXUSR 00100
261 #endif
262 #if !S_IXGRP
263 # define S_IXGRP (S_IXUSR >> 3)
264 #endif
265 #if !S_IXOTH
266 # define S_IXOTH (S_IXUSR >> 6)
267 #endif
268
269 #if !S_IRWXU
270 # define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
271 #endif
272 #if !S_IRWXG
273 # define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
274 #endif
275 #if !S_IRWXO
276 # define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
277 #endif
278
279 /* S_IXUGO is a common extension to POSIX.  */
280 #if !S_IXUGO
281 # define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
282 #endif
283
284 #ifndef S_IRWXUGO
285 # define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
286 #endif
287
288 /* Macros for futimens and utimensat.  */
289 #ifndef UTIME_NOW
290 # define UTIME_NOW (-1)
291 # define UTIME_OMIT (-2)
292 #endif
293
294
295 #ifdef __cplusplus
296 extern "C" {
297 #endif
298
299
300 #if @GNULIB_FCHMODAT@
301 # if !@HAVE_FCHMODAT@
302 extern int fchmodat (int fd, char const *file, mode_t mode, int flag)
303      _GL_ARG_NONNULL ((2));
304 # endif
305 #elif defined GNULIB_POSIXCHECK
306 # undef fchmodat
307 # define fchmodat(d,n,m,f)                         \
308     (GL_LINK_WARNING ("fchmodat is not portable - " \
309                       "use gnulib module openat for portability"), \
310      fchmodat (d, n, m, f))
311 #endif
312
313
314 #if @REPLACE_FSTAT@
315 # define fstat rpl_fstat
316 extern int fstat (int fd, struct stat *buf) _GL_ARG_NONNULL ((2));
317 #endif
318
319
320 #if @GNULIB_FSTATAT@
321 # if @REPLACE_FSTATAT@
322 #  undef fstatat
323 #  define fstatat rpl_fstatat
324 # endif
325 # if !@HAVE_FSTATAT@ || @REPLACE_FSTATAT@
326 extern int fstatat (int fd, char const *name, struct stat *st, int flags)
327      _GL_ARG_NONNULL ((2, 3));
328 # endif
329 #elif defined GNULIB_POSIXCHECK
330 # undef fstatat
331 # define fstatat(d,n,s,f)                         \
332     (GL_LINK_WARNING ("fstatat is not portable - " \
333                       "use gnulib module openat for portability"), \
334      fstatat (d, n, s, f))
335 #endif
336
337
338 #if @GNULIB_FUTIMENS@
339 # if @REPLACE_FUTIMENS@
340 #  undef futimens
341 #  define futimens rpl_futimens
342 # endif
343 # if !@HAVE_FUTIMENS@ || @REPLACE_FUTIMENS@
344 extern int futimens (int fd, struct timespec const times[2]);
345 # endif
346 #elif defined GNULIB_POSIXCHECK
347 # undef futimens
348 # define futimens(f,t)                         \
349     (GL_LINK_WARNING ("futimens is not portable - " \
350                       "use gnulib module futimens for portability"), \
351      futimens (f, t))
352 #endif
353
354
355 #if @GNULIB_LCHMOD@
356 /* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
357    denotes a symbolic link.  */
358 # if !@HAVE_LCHMOD@
359 /* The lchmod replacement follows symbolic links.  Callers should take
360    this into account; lchmod should be applied only to arguments that
361    are known to not be symbolic links.  On hosts that lack lchmod,
362    this can lead to race conditions between the check and the
363    invocation of lchmod, but we know of no workarounds that are
364    reliable in general.  You might try requesting support for lchmod
365    from your operating system supplier.  */
366 #  define lchmod chmod
367 # endif
368 # if 0 /* assume already declared */
369 extern int lchmod (const char *filename, mode_t mode) _GL_ARG_NONNULL ((1));
370 # endif
371 #elif defined GNULIB_POSIXCHECK
372 # undef lchmod
373 # define lchmod(f,m) \
374     (GL_LINK_WARNING ("lchmod is unportable - " \
375                       "use gnulib module lchmod for portability"), \
376      lchmod (f, m))
377 #endif
378
379
380 #if @GNULIB_LSTAT@
381 # if ! @HAVE_LSTAT@
382 /* mingw does not support symlinks, therefore it does not have lstat.  But
383    without links, stat does just fine.  */
384 #  define lstat stat
385 # elif @REPLACE_LSTAT@
386 #  undef lstat
387 #  define lstat rpl_lstat
388 extern int rpl_lstat (const char *name, struct stat *buf)
389      _GL_ARG_NONNULL ((1, 2));
390 # endif
391 #elif defined GNULIB_POSIXCHECK
392 # undef lstat
393 # define lstat(p,b)                                                     \
394   (GL_LINK_WARNING ("lstat is unportable - "                            \
395                     "use gnulib module lstat for portability"),         \
396    lstat (p, b))
397 #endif
398
399
400 #if @REPLACE_MKDIR@
401 # undef mkdir
402 # define mkdir rpl_mkdir
403 extern int mkdir (char const *name, mode_t mode) _GL_ARG_NONNULL ((1));
404 #else
405 /* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
406    Additionally, it declares _mkdir (and depending on compile flags, an
407    alias mkdir), only in the nonstandard <io.h>, which is included above.  */
408 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
409
410 static inline int
411 rpl_mkdir (char const *name, mode_t mode)
412 {
413   return _mkdir (name);
414 }
415
416 #  define mkdir rpl_mkdir
417 # endif
418 #endif
419
420
421 #if @GNULIB_MKDIRAT@
422 # if !@HAVE_MKDIRAT@
423 extern int mkdirat (int fd, char const *file, mode_t mode)
424      _GL_ARG_NONNULL ((2));
425 # endif
426 #elif defined GNULIB_POSIXCHECK
427 # undef mkdirat
428 # define mkdirat(d,n,m)                         \
429     (GL_LINK_WARNING ("mkdirat is not portable - " \
430                       "use gnulib module openat for portability"), \
431      mkdirat (d, n, m))
432 #endif
433
434
435 #if @GNULIB_MKFIFO@
436 # if @REPLACE_MKFIFO@
437 #  undef mkfifo
438 #  define mkfifo rpl_mkfifo
439 # endif
440 # if !@HAVE_MKFIFO@ || @REPLACE_MKFIFO@
441 extern int mkfifo (char const *file, mode_t mode) _GL_ARG_NONNULL ((1));
442 # endif
443 #elif defined GNULIB_POSIXCHECK
444 # undef mkfifo
445 # define mkfifo(n,m)                                                    \
446     (GL_LINK_WARNING ("mkfifo is not portable - "                       \
447                       "use gnulib module mkfifo for portability"),      \
448      mkfifo (n, m))
449 #endif
450
451
452 #if @GNULIB_MKFIFOAT@
453 # if !@HAVE_MKFIFOAT@
454 extern int mkfifoat (int fd, char const *file, mode_t mode)
455      _GL_ARG_NONNULL ((2));
456 # endif
457 #elif defined GNULIB_POSIXCHECK
458 # undef mkfifoat
459 # define mkfifoat(d,n,m)                                     \
460     (GL_LINK_WARNING ("mkfifoat is not portable - " \
461                       "use gnulib module mkfifoat for portability"), \
462      mkfifoat (d, n, m))
463 #endif
464
465
466 #if @GNULIB_MKNOD@
467 # if @REPLACE_MKNOD@
468 #  undef mknod
469 #  define mknod rpl_mknod
470 # endif
471 # if !@HAVE_MKNOD@ || @REPLACE_MKNOD@
472 extern int mknod (char const *file, mode_t mode, dev_t dev)
473      _GL_ARG_NONNULL ((1));
474 # endif
475 #elif defined GNULIB_POSIXCHECK
476 # undef mknod
477 # define mknod(n,m,d)                                                   \
478     (GL_LINK_WARNING ("mknod is not portable - "                        \
479                       "use gnulib module mknod for portability"),       \
480      mknod (n, m, d))
481 #endif
482
483
484 #if @GNULIB_MKNODAT@
485 # if !@HAVE_MKNODAT@
486 extern int mknodat (int fd, char const *file, mode_t mode, dev_t dev)
487      _GL_ARG_NONNULL ((2));
488 # endif
489 #elif defined GNULIB_POSIXCHECK
490 # undef mknodat
491 # define mknodat(f,n,m,d)                            \
492     (GL_LINK_WARNING ("mknodat is not portable - " \
493                       "use gnulib module mkfifoat for portability"), \
494      mknodat (f, n, m, d))
495 #endif
496
497
498 #if @GNULIB_STAT@
499 # if @REPLACE_STAT@
500 /* We can't use the object-like #define stat rpl_stat, because of
501    struct stat.  This means that rpl_stat will not be used if the user
502    does (stat)(a,b).  Oh well.  */
503 #  undef stat
504 #  ifdef _LARGE_FILES
505     /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
506        so we have to replace stat64() instead of stat(). */
507 #   define stat stat64
508 #   undef stat64
509 #   define stat64(name, st) rpl_stat (name, st)
510 #  else /* !_LARGE_FILES */
511 #   define stat(name, st) rpl_stat (name, st)
512 #  endif /* !_LARGE_FILES */
513 extern int stat (const char *name, struct stat *buf) _GL_ARG_NONNULL ((1, 2));
514 # endif
515 #elif defined GNULIB_POSIXCHECK
516 # undef stat
517 # define stat(p,b)                                                      \
518   (GL_LINK_WARNING ("stat is unportable - "                             \
519                     "use gnulib module stat for portability"),          \
520    stat (p, b))
521 #endif
522
523
524 #if @GNULIB_UTIMENSAT@
525 # if @REPLACE_UTIMENSAT@
526 #  undef utimensat
527 #  define utimensat rpl_utimensat
528 # endif
529 # if !@HAVE_UTIMENSAT@ || @REPLACE_UTIMENSAT@
530    extern int utimensat (int fd, char const *name,
531                          struct timespec const times[2], int flag)
532         _GL_ARG_NONNULL ((2));
533 # endif
534 #elif defined GNULIB_POSIXCHECK
535 # undef utimensat
536 # define utimensat(d,n,t,f)                          \
537     (GL_LINK_WARNING ("utimensat is not portable - " \
538                       "use gnulib module utimensat for portability"), \
539      utimensat (d, n, t, f))
540 #endif
541
542
543 #ifdef __cplusplus
544 }
545 #endif
546
547
548 #endif /* _GL_SYS_STAT_H */
549 #endif /* _GL_SYS_STAT_H */
550 #endif