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-2013 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, see <http://www.gnu.org/licenses/>. */
19 /* Written by Eric Blake, Paul Eggert, and Jim Meyering. */
21 /* This file is supposed to be used on platforms where <sys/stat.h> is
22 incomplete. It is intended to provide definitions and prototypes
23 needed by an application. Start with what the system provides. */
26 @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 _@GUARD_PREFIX@_SYS_STAT_H
41 May also define off_t to a 64-bit type on native Windows. */
42 #include <sys/types.h>
44 /* Get struct timespec. */
47 /* The include_next requires a split double-inclusion guard. */
48 #@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
50 #ifndef _@GUARD_PREFIX@_SYS_STAT_H
51 #define _@GUARD_PREFIX@_SYS_STAT_H
53 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
55 /* The definition of _GL_ARG_NONNULL is copied here. */
57 /* The definition of _GL_WARN_ON_USE is copied here. */
59 /* Before doing "#define mkdir rpl_mkdir" below, we need to include all
60 headers that may declare mkdir(). Native Windows platforms declare mkdir
61 in <io.h> and/or <direct.h>, not in <unistd.h>. */
62 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
63 # include <io.h> /* mingw32, mingw64 */
64 # include <direct.h> /* mingw64, MSVC 9 */
67 /* Native Windows platforms declare umask() in <io.h>. */
68 #if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
72 /* Large File Support on native Windows. */
73 #if @WINDOWS_64_BIT_ST_SIZE@
74 # define stat _stati64
79 # define S_IFIFO _S_IFIFO
84 # define S_IFMT 0170000
87 #if STAT_MACROS_BROKEN
103 # define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
105 # define S_ISBLK(m) 0
111 # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
113 # define S_ISCHR(m) 0
119 # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
121 # define S_ISDIR(m) 0
125 #ifndef S_ISDOOR /* Solaris 2.5 and up */
126 # define S_ISDOOR(m) 0
131 # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
133 # define S_ISFIFO(m) 0
139 # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
141 # define S_ISLNK(m) 0
145 #ifndef S_ISMPB /* V7 */
147 # define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
148 # define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
150 # define S_ISMPB(m) 0
151 # define S_ISMPC(m) 0
155 #ifndef S_ISMPX /* AIX */
156 # define S_ISMPX(m) 0
159 #ifndef S_ISNAM /* Xenix */
161 # define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
163 # define S_ISNAM(m) 0
167 #ifndef S_ISNWK /* HP/UX */
169 # define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
171 # define S_ISNWK(m) 0
175 #ifndef S_ISPORT /* Solaris 10 and up */
176 # define S_ISPORT(m) 0
181 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
183 # define S_ISREG(m) 0
189 # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
191 # define S_ISSOCK(m) 0
197 # define S_TYPEISMQ(p) 0
201 # define S_TYPEISTMO(p) 0
207 # define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
209 # define S_TYPEISSEM(p) 0
215 # define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
217 # define S_TYPEISSHM(p) 0
221 /* high performance ("contiguous data") */
223 # define S_ISCTG(p) 0
226 /* Cray DMF (data migration facility): off line, with data */
228 # define S_ISOFD(p) 0
231 /* Cray DMF (data migration facility): off line, with no data */
233 # define S_ISOFL(p) 0
236 /* 4.4BSD whiteout */
238 # define S_ISWHT(m) 0
241 /* If any of the following are undefined,
242 define them to their de facto standard values. */
244 # define S_ISUID 04000
247 # define S_ISGID 02000
250 /* S_ISVTX is a common extension to POSIX. */
252 # define S_ISVTX 01000
255 #if !S_IRUSR && S_IREAD
256 # define S_IRUSR S_IREAD
259 # define S_IRUSR 00400
262 # define S_IRGRP (S_IRUSR >> 3)
265 # define S_IROTH (S_IRUSR >> 6)
268 #if !S_IWUSR && S_IWRITE
269 # define S_IWUSR S_IWRITE
272 # define S_IWUSR 00200
275 # define S_IWGRP (S_IWUSR >> 3)
278 # define S_IWOTH (S_IWUSR >> 6)
281 #if !S_IXUSR && S_IEXEC
282 # define S_IXUSR S_IEXEC
285 # define S_IXUSR 00100
288 # define S_IXGRP (S_IXUSR >> 3)
291 # define S_IXOTH (S_IXUSR >> 6)
295 # define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
298 # define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
301 # define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
304 /* S_IXUGO is a common extension to POSIX. */
306 # define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
310 # define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
313 /* Macros for futimens and utimensat. */
315 # define UTIME_NOW (-1)
316 # define UTIME_OMIT (-2)
320 #if @GNULIB_FCHMODAT@
321 # if !@HAVE_FCHMODAT@
322 _GL_FUNCDECL_SYS (fchmodat, int,
323 (int fd, char const *file, mode_t mode, int flag)
324 _GL_ARG_NONNULL ((2)));
326 _GL_CXXALIAS_SYS (fchmodat, int,
327 (int fd, char const *file, mode_t mode, int flag));
328 _GL_CXXALIASWARN (fchmodat);
329 #elif defined GNULIB_POSIXCHECK
331 # if HAVE_RAW_DECL_FCHMODAT
332 _GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - "
333 "use gnulib module openat for portability");
340 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
342 # define fstat rpl_fstat
344 _GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2)));
345 _GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
347 _GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
349 _GL_CXXALIASWARN (fstat);
350 #elif @WINDOWS_64_BIT_ST_SIZE@
351 /* Above, we define stat to _stati64. */
352 # define fstat _fstati64
353 #elif defined GNULIB_POSIXCHECK
355 # if HAVE_RAW_DECL_FSTAT
356 _GL_WARN_ON_USE (fstat, "fstat has portability problems - "
357 "use gnulib module fstat for portability");
363 # if @REPLACE_FSTATAT@
364 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
366 # define fstatat rpl_fstatat
368 _GL_FUNCDECL_RPL (fstatat, int,
369 (int fd, char const *name, struct stat *st, int flags)
370 _GL_ARG_NONNULL ((2, 3)));
371 _GL_CXXALIAS_RPL (fstatat, int,
372 (int fd, char const *name, struct stat *st, int flags));
375 _GL_FUNCDECL_SYS (fstatat, int,
376 (int fd, char const *name, struct stat *st, int flags)
377 _GL_ARG_NONNULL ((2, 3)));
379 _GL_CXXALIAS_SYS (fstatat, int,
380 (int fd, char const *name, struct stat *st, int flags));
382 _GL_CXXALIASWARN (fstatat);
383 #elif defined GNULIB_POSIXCHECK
385 # if HAVE_RAW_DECL_FSTATAT
386 _GL_WARN_ON_USE (fstatat, "fstatat is not portable - "
387 "use gnulib module openat for portability");
392 #if @GNULIB_FUTIMENS@
393 /* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our futimens
394 implementation relies on futimesat, which on Solaris 10 makes an invocation
395 to futimens that is meant to invoke the libc's futimens(), not gnulib's
397 # if @REPLACE_FUTIMENS@ || (!@HAVE_FUTIMENS@ && defined __sun)
398 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
400 # define futimens rpl_futimens
402 _GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2]));
403 _GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2]));
405 # if !@HAVE_FUTIMENS@
406 _GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2]));
408 _GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2]));
411 _GL_CXXALIASWARN (futimens);
413 #elif defined GNULIB_POSIXCHECK
415 # if HAVE_RAW_DECL_FUTIMENS
416 _GL_WARN_ON_USE (futimens, "futimens is not portable - "
417 "use gnulib module futimens for portability");
423 /* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
424 denotes a symbolic link. */
426 /* The lchmod replacement follows symbolic links. Callers should take
427 this into account; lchmod should be applied only to arguments that
428 are known to not be symbolic links. On hosts that lack lchmod,
429 this can lead to race conditions between the check and the
430 invocation of lchmod, but we know of no workarounds that are
431 reliable in general. You might try requesting support for lchmod
432 from your operating system supplier. */
433 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
434 # define lchmod chmod
436 /* Need to cast, because on mingw, the second parameter of chmod is
438 _GL_CXXALIAS_RPL_CAST_1 (lchmod, chmod, int,
439 (const char *filename, mode_t mode));
441 # if 0 /* assume already declared */
442 _GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode)
443 _GL_ARG_NONNULL ((1)));
445 _GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode));
448 _GL_CXXALIASWARN (lchmod);
450 #elif defined GNULIB_POSIXCHECK
452 # if HAVE_RAW_DECL_LCHMOD
453 _GL_WARN_ON_USE (lchmod, "lchmod is unportable - "
454 "use gnulib module lchmod for portability");
461 /* mingw does not support symlinks, therefore it does not have lstat. But
462 without links, stat does just fine. */
463 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
466 _GL_CXXALIAS_RPL_1 (lstat, stat, int, (const char *name, struct stat *buf));
467 # elif @REPLACE_LSTAT@
468 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
470 # define lstat rpl_lstat
472 _GL_FUNCDECL_RPL (lstat, int, (const char *name, struct stat *buf)
473 _GL_ARG_NONNULL ((1, 2)));
474 _GL_CXXALIAS_RPL (lstat, int, (const char *name, struct stat *buf));
476 _GL_CXXALIAS_SYS (lstat, int, (const char *name, struct stat *buf));
479 _GL_CXXALIASWARN (lstat);
481 #elif defined GNULIB_POSIXCHECK
483 # if HAVE_RAW_DECL_LSTAT
484 _GL_WARN_ON_USE (lstat, "lstat is unportable - "
485 "use gnulib module lstat for portability");
491 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
493 # define mkdir rpl_mkdir
495 _GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode)
496 _GL_ARG_NONNULL ((1)));
497 _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
499 /* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
500 Additionally, it declares _mkdir (and depending on compile flags, an
501 alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
502 which are included above. */
503 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
505 # if !GNULIB_defined_rpl_mkdir
507 rpl_mkdir (char const *name, mode_t mode)
509 return _mkdir (name);
511 # define GNULIB_defined_rpl_mkdir 1
514 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
515 # define mkdir rpl_mkdir
517 _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
519 _GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
522 _GL_CXXALIASWARN (mkdir);
527 _GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)
528 _GL_ARG_NONNULL ((2)));
530 _GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode));
531 _GL_CXXALIASWARN (mkdirat);
532 #elif defined GNULIB_POSIXCHECK
534 # if HAVE_RAW_DECL_MKDIRAT
535 _GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - "
536 "use gnulib module openat for portability");
542 # if @REPLACE_MKFIFO@
543 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
545 # define mkfifo rpl_mkfifo
547 _GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode)
548 _GL_ARG_NONNULL ((1)));
549 _GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode));
552 _GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode)
553 _GL_ARG_NONNULL ((1)));
555 _GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode));
557 _GL_CXXALIASWARN (mkfifo);
558 #elif defined GNULIB_POSIXCHECK
560 # if HAVE_RAW_DECL_MKFIFO
561 _GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - "
562 "use gnulib module mkfifo for portability");
567 #if @GNULIB_MKFIFOAT@
568 # if !@HAVE_MKFIFOAT@
569 _GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)
570 _GL_ARG_NONNULL ((2)));
572 _GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode));
573 _GL_CXXALIASWARN (mkfifoat);
574 #elif defined GNULIB_POSIXCHECK
576 # if HAVE_RAW_DECL_MKFIFOAT
577 _GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - "
578 "use gnulib module mkfifoat for portability");
585 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
587 # define mknod rpl_mknod
589 _GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)
590 _GL_ARG_NONNULL ((1)));
591 _GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev));
594 _GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev)
595 _GL_ARG_NONNULL ((1)));
597 /* Need to cast, because on OSF/1 5.1, the third parameter is '...'. */
598 _GL_CXXALIAS_SYS_CAST (mknod, int, (char const *file, mode_t mode, dev_t dev));
600 _GL_CXXALIASWARN (mknod);
601 #elif defined GNULIB_POSIXCHECK
603 # if HAVE_RAW_DECL_MKNOD
604 _GL_WARN_ON_USE (mknod, "mknod is not portable - "
605 "use gnulib module mknod for portability");
612 _GL_FUNCDECL_SYS (mknodat, int,
613 (int fd, char const *file, mode_t mode, dev_t dev)
614 _GL_ARG_NONNULL ((2)));
616 _GL_CXXALIAS_SYS (mknodat, int,
617 (int fd, char const *file, mode_t mode, dev_t dev));
618 _GL_CXXALIASWARN (mknodat);
619 #elif defined GNULIB_POSIXCHECK
621 # if HAVE_RAW_DECL_MKNODAT
622 _GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
623 "use gnulib module mkfifoat for portability");
630 /* We can't use the object-like #define stat rpl_stat, because of
631 struct stat. This means that rpl_stat will not be used if the user
632 does (stat)(a,b). Oh well. */
633 # if defined _AIX && defined stat && defined _LARGE_FILES
634 /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
635 so we have to replace stat64() instead of stat(). */
637 # define stat64(name, st) rpl_stat (name, st)
638 # elif @WINDOWS_64_BIT_ST_SIZE@
639 /* Above, we define stat to _stati64. */
640 # if defined __MINGW32__ && defined _stati64
641 # ifndef _USE_32BIT_TIME_T
642 /* The system headers define _stati64 to _stat64. */
644 # define _stat64(name, st) rpl_stat (name, st)
646 # elif defined _MSC_VER && defined _stati64
647 # ifdef _USE_32BIT_TIME_T
648 /* The system headers define _stati64 to _stat32i64. */
650 # define _stat32i64(name, st) rpl_stat (name, st)
652 /* The system headers define _stati64 to _stat64. */
654 # define _stat64(name, st) rpl_stat (name, st)
658 # define _stati64(name, st) rpl_stat (name, st)
660 # elif defined __MINGW32__ && defined stat
661 # ifdef _USE_32BIT_TIME_T
662 /* The system headers define stat to _stat32i64. */
664 # define _stat32i64(name, st) rpl_stat (name, st)
666 /* The system headers define stat to _stat64. */
668 # define _stat64(name, st) rpl_stat (name, st)
670 # elif defined _MSC_VER && defined stat
671 # ifdef _USE_32BIT_TIME_T
672 /* The system headers define stat to _stat32. */
674 # define _stat32(name, st) rpl_stat (name, st)
676 /* The system headers define stat to _stat64i32. */
678 # define _stat64i32(name, st) rpl_stat (name, st)
680 # else /* !(_AIX ||__MINGW32__ || _MSC_VER) */
682 # define stat(name, st) rpl_stat (name, st)
683 # endif /* !_LARGE_FILES */
684 _GL_EXTERN_C int stat (const char *name, struct stat *buf)
685 _GL_ARG_NONNULL ((1, 2));
687 #elif defined GNULIB_POSIXCHECK
689 # if HAVE_RAW_DECL_STAT
690 _GL_WARN_ON_USE (stat, "stat is unportable - "
691 "use gnulib module stat for portability");
696 #if @GNULIB_UTIMENSAT@
697 /* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat
698 implementation relies on futimesat, which on Solaris 10 makes an invocation
699 to utimensat that is meant to invoke the libc's utimensat(), not gnulib's
701 # if @REPLACE_UTIMENSAT@ || (!@HAVE_UTIMENSAT@ && defined __sun)
702 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
704 # define utimensat rpl_utimensat
706 _GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name,
707 struct timespec const times[2], int flag)
708 _GL_ARG_NONNULL ((2)));
709 _GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name,
710 struct timespec const times[2], int flag));
712 # if !@HAVE_UTIMENSAT@
713 _GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name,
714 struct timespec const times[2], int flag)
715 _GL_ARG_NONNULL ((2)));
717 _GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name,
718 struct timespec const times[2], int flag));
720 # if @HAVE_UTIMENSAT@
721 _GL_CXXALIASWARN (utimensat);
723 #elif defined GNULIB_POSIXCHECK
725 # if HAVE_RAW_DECL_UTIMENSAT
726 _GL_WARN_ON_USE (utimensat, "utimensat is not portable - "
727 "use gnulib module utimensat for portability");
732 #endif /* _@GUARD_PREFIX@_SYS_STAT_H */
733 #endif /* _@GUARD_PREFIX@_SYS_STAT_H */