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.
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)
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.
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. */
20 /* Written by Eric Blake, Paul Eggert, and Jim Meyering. */
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. */
27 @PRAGMA_SYSTEM_HEADER@
30 #if defined __need_system_sys_stat_h
31 /* Special invocation convention. */
33 #@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
36 /* Normal invocation convention. */
38 #ifndef _GL_SYS_STAT_H
41 #include <sys/types.h>
43 /* Get struct timespec. */
46 /* The include_next requires a split double-inclusion guard. */
47 #@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
49 #ifndef _GL_SYS_STAT_H
50 #define _GL_SYS_STAT_H
52 /* The definition of GL_LINK_WARNING is copied here. */
54 /* The definition of _GL_ARG_NONNULL is copied here. */
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__
63 # define S_IFMT 0170000
66 #if STAT_MACROS_BROKEN
82 # define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
90 # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
98 # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
100 # define S_ISDIR(m) 0
104 #ifndef S_ISDOOR /* Solaris 2.5 and up */
105 # define S_ISDOOR(m) 0
110 # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
112 # define S_ISFIFO(m) 0
118 # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
120 # define S_ISLNK(m) 0
124 #ifndef S_ISMPB /* V7 */
126 # define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
127 # define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
129 # define S_ISMPB(m) 0
130 # define S_ISMPC(m) 0
134 #ifndef S_ISNAM /* Xenix */
136 # define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
138 # define S_ISNAM(m) 0
142 #ifndef S_ISNWK /* HP/UX */
144 # define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
146 # define S_ISNWK(m) 0
150 #ifndef S_ISPORT /* Solaris 10 and up */
151 # define S_ISPORT(m) 0
156 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
158 # define S_ISREG(m) 0
164 # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
166 # define S_ISSOCK(m) 0
172 # define S_TYPEISMQ(p) 0
176 # define S_TYPEISTMO(p) 0
182 # define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
184 # define S_TYPEISSEM(p) 0
190 # define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
192 # define S_TYPEISSHM(p) 0
196 /* high performance ("contiguous data") */
198 # define S_ISCTG(p) 0
201 /* Cray DMF (data migration facility): off line, with data */
203 # define S_ISOFD(p) 0
206 /* Cray DMF (data migration facility): off line, with no data */
208 # define S_ISOFL(p) 0
211 /* 4.4BSD whiteout */
213 # define S_ISWHT(m) 0
216 /* If any of the following are undefined,
217 define them to their de facto standard values. */
219 # define S_ISUID 04000
222 # define S_ISGID 02000
225 /* S_ISVTX is a common extension to POSIX. */
227 # define S_ISVTX 01000
230 #if !S_IRUSR && S_IREAD
231 # define S_IRUSR S_IREAD
234 # define S_IRUSR 00400
237 # define S_IRGRP (S_IRUSR >> 3)
240 # define S_IROTH (S_IRUSR >> 6)
243 #if !S_IWUSR && S_IWRITE
244 # define S_IWUSR S_IWRITE
247 # define S_IWUSR 00200
250 # define S_IWGRP (S_IWUSR >> 3)
253 # define S_IWOTH (S_IWUSR >> 6)
256 #if !S_IXUSR && S_IEXEC
257 # define S_IXUSR S_IEXEC
260 # define S_IXUSR 00100
263 # define S_IXGRP (S_IXUSR >> 3)
266 # define S_IXOTH (S_IXUSR >> 6)
270 # define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
273 # define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
276 # define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
279 /* S_IXUGO is a common extension to POSIX. */
281 # define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
285 # define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
288 /* Macros for futimens and utimensat. */
290 # define UTIME_NOW (-1)
291 # define UTIME_OMIT (-2)
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));
305 #elif defined GNULIB_POSIXCHECK
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))
315 # define fstat rpl_fstat
316 extern int fstat (int fd, struct stat *buf) _GL_ARG_NONNULL ((2));
321 # if @REPLACE_FSTATAT@
323 # define fstatat rpl_fstatat
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));
329 #elif defined GNULIB_POSIXCHECK
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))
338 #if @GNULIB_FUTIMENS@
339 # if @REPLACE_FUTIMENS@
341 # define futimens rpl_futimens
343 # if !@HAVE_FUTIMENS@ || @REPLACE_FUTIMENS@
344 extern int futimens (int fd, struct timespec const times[2]);
346 #elif defined GNULIB_POSIXCHECK
348 # define futimens(f,t) \
349 (GL_LINK_WARNING ("futimens is not portable - " \
350 "use gnulib module futimens for portability"), \
356 /* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
357 denotes a symbolic link. */
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
368 # if 0 /* assume already declared */
369 extern int lchmod (const char *filename, mode_t mode) _GL_ARG_NONNULL ((1));
371 #elif defined GNULIB_POSIXCHECK
373 # define lchmod(f,m) \
374 (GL_LINK_WARNING ("lchmod is unportable - " \
375 "use gnulib module lchmod for portability"), \
382 /* mingw does not support symlinks, therefore it does not have lstat. But
383 without links, stat does just fine. */
385 # elif @REPLACE_LSTAT@
387 # define lstat rpl_lstat
388 extern int rpl_lstat (const char *name, struct stat *buf)
389 _GL_ARG_NONNULL ((1, 2));
391 #elif defined GNULIB_POSIXCHECK
393 # define lstat(p,b) \
394 (GL_LINK_WARNING ("lstat is unportable - " \
395 "use gnulib module lstat for portability"), \
402 # define mkdir rpl_mkdir
403 extern int mkdir (char const *name, mode_t mode) _GL_ARG_NONNULL ((1));
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__
411 rpl_mkdir (char const *name, mode_t mode)
413 return _mkdir (name);
416 # define mkdir rpl_mkdir
423 extern int mkdirat (int fd, char const *file, mode_t mode)
424 _GL_ARG_NONNULL ((2));
426 #elif defined GNULIB_POSIXCHECK
428 # define mkdirat(d,n,m) \
429 (GL_LINK_WARNING ("mkdirat is not portable - " \
430 "use gnulib module openat for portability"), \
436 # if @REPLACE_MKFIFO@
438 # define mkfifo rpl_mkfifo
440 # if !@HAVE_MKFIFO@ || @REPLACE_MKFIFO@
441 extern int mkfifo (char const *file, mode_t mode) _GL_ARG_NONNULL ((1));
443 #elif defined GNULIB_POSIXCHECK
445 # define mkfifo(n,m) \
446 (GL_LINK_WARNING ("mkfifo is not portable - " \
447 "use gnulib module mkfifo for portability"), \
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));
457 #elif defined GNULIB_POSIXCHECK
459 # define mkfifoat(d,n,m) \
460 (GL_LINK_WARNING ("mkfifoat is not portable - " \
461 "use gnulib module mkfifoat for portability"), \
469 # define mknod rpl_mknod
471 # if !@HAVE_MKNOD@ || @REPLACE_MKNOD@
472 extern int mknod (char const *file, mode_t mode, dev_t dev)
473 _GL_ARG_NONNULL ((1));
475 #elif defined GNULIB_POSIXCHECK
477 # define mknod(n,m,d) \
478 (GL_LINK_WARNING ("mknod is not portable - " \
479 "use gnulib module mknod for portability"), \
486 extern int mknodat (int fd, char const *file, mode_t mode, dev_t dev)
487 _GL_ARG_NONNULL ((2));
489 #elif defined GNULIB_POSIXCHECK
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))
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. */
505 /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
506 so we have to replace stat64() instead of stat(). */
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));
515 #elif defined GNULIB_POSIXCHECK
518 (GL_LINK_WARNING ("stat is unportable - " \
519 "use gnulib module stat for portability"), \
524 #if @GNULIB_UTIMENSAT@
525 # if @REPLACE_UTIMENSAT@
527 # define utimensat rpl_utimensat
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));
534 #elif defined GNULIB_POSIXCHECK
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))
548 #endif /* _GL_SYS_STAT_H */
549 #endif /* _GL_SYS_STAT_H */