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@
31 #if defined __need_system_sys_stat_h
32 /* Special invocation convention. */
34 #@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
37 /* Normal invocation convention. */
39 #ifndef _GL_SYS_STAT_H
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 _GL_SYS_STAT_H
51 #define _GL_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(). */
61 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
62 # include <io.h> /* mingw32, mingw64 */
63 # include <direct.h> /* mingw64 */
67 # define S_IFMT 0170000
70 #if STAT_MACROS_BROKEN
86 # define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
94 # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
102 # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
104 # define S_ISDIR(m) 0
108 #ifndef S_ISDOOR /* Solaris 2.5 and up */
109 # define S_ISDOOR(m) 0
114 # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
116 # define S_ISFIFO(m) 0
122 # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
124 # define S_ISLNK(m) 0
128 #ifndef S_ISMPB /* V7 */
130 # define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
131 # define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
133 # define S_ISMPB(m) 0
134 # define S_ISMPC(m) 0
138 #ifndef S_ISNAM /* Xenix */
140 # define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
142 # define S_ISNAM(m) 0
146 #ifndef S_ISNWK /* HP/UX */
148 # define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
150 # define S_ISNWK(m) 0
154 #ifndef S_ISPORT /* Solaris 10 and up */
155 # define S_ISPORT(m) 0
160 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
162 # define S_ISREG(m) 0
168 # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
170 # define S_ISSOCK(m) 0
176 # define S_TYPEISMQ(p) 0
180 # define S_TYPEISTMO(p) 0
186 # define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
188 # define S_TYPEISSEM(p) 0
194 # define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
196 # define S_TYPEISSHM(p) 0
200 /* high performance ("contiguous data") */
202 # define S_ISCTG(p) 0
205 /* Cray DMF (data migration facility): off line, with data */
207 # define S_ISOFD(p) 0
210 /* Cray DMF (data migration facility): off line, with no data */
212 # define S_ISOFL(p) 0
215 /* 4.4BSD whiteout */
217 # define S_ISWHT(m) 0
220 /* If any of the following are undefined,
221 define them to their de facto standard values. */
223 # define S_ISUID 04000
226 # define S_ISGID 02000
229 /* S_ISVTX is a common extension to POSIX. */
231 # define S_ISVTX 01000
234 #if !S_IRUSR && S_IREAD
235 # define S_IRUSR S_IREAD
238 # define S_IRUSR 00400
241 # define S_IRGRP (S_IRUSR >> 3)
244 # define S_IROTH (S_IRUSR >> 6)
247 #if !S_IWUSR && S_IWRITE
248 # define S_IWUSR S_IWRITE
251 # define S_IWUSR 00200
254 # define S_IWGRP (S_IWUSR >> 3)
257 # define S_IWOTH (S_IWUSR >> 6)
260 #if !S_IXUSR && S_IEXEC
261 # define S_IXUSR S_IEXEC
264 # define S_IXUSR 00100
267 # define S_IXGRP (S_IXUSR >> 3)
270 # define S_IXOTH (S_IXUSR >> 6)
274 # define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
277 # define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
280 # define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
283 /* S_IXUGO is a common extension to POSIX. */
285 # define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
289 # define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
292 /* Macros for futimens and utimensat. */
294 # define UTIME_NOW (-1)
295 # define UTIME_OMIT (-2)
299 #if @GNULIB_FCHMODAT@
300 # if !@HAVE_FCHMODAT@
301 _GL_FUNCDECL_SYS (fchmodat, int,
302 (int fd, char const *file, mode_t mode, int flag)
303 _GL_ARG_NONNULL ((2)));
305 _GL_CXXALIAS_SYS (fchmodat, int,
306 (int fd, char const *file, mode_t mode, int flag));
307 _GL_CXXALIASWARN (fchmodat);
308 #elif defined GNULIB_POSIXCHECK
310 # if HAVE_RAW_DECL_FCHMODAT
311 _GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - "
312 "use gnulib module openat for portability");
318 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
319 # define fstat rpl_fstat
321 _GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2)));
322 _GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
324 _GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
326 _GL_CXXALIASWARN (fstat);
330 # if @REPLACE_FSTATAT@
331 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
333 # define fstatat rpl_fstatat
335 _GL_FUNCDECL_RPL (fstatat, int,
336 (int fd, char const *name, struct stat *st, int flags)
337 _GL_ARG_NONNULL ((2, 3)));
338 _GL_CXXALIAS_RPL (fstatat, int,
339 (int fd, char const *name, struct stat *st, int flags));
342 _GL_FUNCDECL_SYS (fstatat, int,
343 (int fd, char const *name, struct stat *st, int flags)
344 _GL_ARG_NONNULL ((2, 3)));
346 _GL_CXXALIAS_SYS (fstatat, int,
347 (int fd, char const *name, struct stat *st, int flags));
349 _GL_CXXALIASWARN (fstatat);
350 #elif defined GNULIB_POSIXCHECK
352 # if HAVE_RAW_DECL_FSTATAT
353 _GL_WARN_ON_USE (fstatat, "fstatat is not portable - "
354 "use gnulib module openat for portability");
359 #if @GNULIB_FUTIMENS@
360 # if @REPLACE_FUTIMENS@
361 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
363 # define futimens rpl_futimens
365 _GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2]));
366 _GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2]));
368 # if !@HAVE_FUTIMENS@
369 _GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2]));
371 _GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2]));
373 _GL_CXXALIASWARN (futimens);
374 #elif defined GNULIB_POSIXCHECK
376 # if HAVE_RAW_DECL_FUTIMENS
377 _GL_WARN_ON_USE (futimens, "futimens is not portable - "
378 "use gnulib module futimens for portability");
384 /* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
385 denotes a symbolic link. */
387 /* The lchmod replacement follows symbolic links. Callers should take
388 this into account; lchmod should be applied only to arguments that
389 are known to not be symbolic links. On hosts that lack lchmod,
390 this can lead to race conditions between the check and the
391 invocation of lchmod, but we know of no workarounds that are
392 reliable in general. You might try requesting support for lchmod
393 from your operating system supplier. */
394 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
395 # define lchmod chmod
397 /* Need to cast, because on mingw, the second parameter of chmod is
399 _GL_CXXALIAS_RPL_CAST_1 (lchmod, chmod, int,
400 (const char *filename, mode_t mode));
402 # if 0 /* assume already declared */
403 _GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode)
404 _GL_ARG_NONNULL ((1)));
406 _GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode));
409 _GL_CXXALIASWARN (lchmod);
411 #elif defined GNULIB_POSIXCHECK
413 # if HAVE_RAW_DECL_LCHMOD
414 _GL_WARN_ON_USE (lchmod, "lchmod is unportable - "
415 "use gnulib module lchmod for portability");
422 /* mingw does not support symlinks, therefore it does not have lstat. But
423 without links, stat does just fine. */
424 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
427 _GL_CXXALIAS_RPL_1 (lstat, stat, int, (const char *name, struct stat *buf));
428 # elif @REPLACE_LSTAT@
429 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
431 # define lstat rpl_lstat
433 _GL_FUNCDECL_RPL (lstat, int, (const char *name, struct stat *buf)
434 _GL_ARG_NONNULL ((1, 2)));
435 _GL_CXXALIAS_RPL (lstat, int, (const char *name, struct stat *buf));
437 _GL_CXXALIAS_SYS (lstat, int, (const char *name, struct stat *buf));
440 _GL_CXXALIASWARN (lstat);
442 #elif defined GNULIB_POSIXCHECK
444 # if HAVE_RAW_DECL_LSTAT
445 _GL_WARN_ON_USE (lstat, "lstat is unportable - "
446 "use gnulib module lstat for portability");
452 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
454 # define mkdir rpl_mkdir
456 _GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode)
457 _GL_ARG_NONNULL ((1)));
458 _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
460 /* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
461 Additionally, it declares _mkdir (and depending on compile flags, an
462 alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
463 which are included above. */
464 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
467 rpl_mkdir (char const *name, mode_t mode)
469 return _mkdir (name);
472 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
473 # define mkdir rpl_mkdir
475 _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
477 _GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
480 _GL_CXXALIASWARN (mkdir);
485 _GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)
486 _GL_ARG_NONNULL ((2)));
488 _GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode));
489 _GL_CXXALIASWARN (mkdirat);
490 #elif defined GNULIB_POSIXCHECK
492 # if HAVE_RAW_DECL_MKDIRAT
493 _GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - "
494 "use gnulib module openat for portability");
500 # if @REPLACE_MKFIFO@
501 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
503 # define mkfifo rpl_mkfifo
505 _GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode)
506 _GL_ARG_NONNULL ((1)));
507 _GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode));
510 _GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode)
511 _GL_ARG_NONNULL ((1)));
513 _GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode));
515 _GL_CXXALIASWARN (mkfifo);
516 #elif defined GNULIB_POSIXCHECK
518 # if HAVE_RAW_DECL_MKFIFO
519 _GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - "
520 "use gnulib module mkfifo for portability");
525 #if @GNULIB_MKFIFOAT@
526 # if !@HAVE_MKFIFOAT@
527 _GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)
528 _GL_ARG_NONNULL ((2)));
530 _GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode));
531 _GL_CXXALIASWARN (mkfifoat);
532 #elif defined GNULIB_POSIXCHECK
534 # if HAVE_RAW_DECL_MKFIFOAT
535 _GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - "
536 "use gnulib module mkfifoat for portability");
543 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
545 # define mknod rpl_mknod
547 _GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)
548 _GL_ARG_NONNULL ((1)));
549 _GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev));
552 _GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev)
553 _GL_ARG_NONNULL ((1)));
555 _GL_CXXALIAS_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev));
557 _GL_CXXALIASWARN (mknod);
558 #elif defined GNULIB_POSIXCHECK
560 # if HAVE_RAW_DECL_MKNOD
561 _GL_WARN_ON_USE (mknod, "mknod is not portable - "
562 "use gnulib module mknod for portability");
569 _GL_FUNCDECL_SYS (mknodat, int,
570 (int fd, char const *file, mode_t mode, dev_t dev)
571 _GL_ARG_NONNULL ((2)));
573 _GL_CXXALIAS_SYS (mknodat, int,
574 (int fd, char const *file, mode_t mode, dev_t dev));
575 _GL_CXXALIASWARN (mknodat);
576 #elif defined GNULIB_POSIXCHECK
578 # if HAVE_RAW_DECL_MKNODAT
579 _GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
580 "use gnulib module mkfifoat for portability");
587 /* We can't use the object-like #define stat rpl_stat, because of
588 struct stat. This means that rpl_stat will not be used if the user
589 does (stat)(a,b). Oh well. */
592 /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
593 so we have to replace stat64() instead of stat(). */
596 # define stat64(name, st) rpl_stat (name, st)
597 # else /* !_LARGE_FILES */
598 # define stat(name, st) rpl_stat (name, st)
599 # endif /* !_LARGE_FILES */
600 _GL_EXTERN_C int stat (const char *name, struct stat *buf)
601 _GL_ARG_NONNULL ((1, 2));
603 #elif defined GNULIB_POSIXCHECK
605 # if HAVE_RAW_DECL_STAT
606 _GL_WARN_ON_USE (stat, "stat is unportable - "
607 "use gnulib module stat for portability");
612 #if @GNULIB_UTIMENSAT@
613 # if @REPLACE_UTIMENSAT@
614 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
616 # define utimensat rpl_utimensat
618 _GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name,
619 struct timespec const times[2], int flag)
620 _GL_ARG_NONNULL ((2)));
621 _GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name,
622 struct timespec const times[2], int flag));
624 # if !@HAVE_UTIMENSAT@
625 _GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name,
626 struct timespec const times[2], int flag)
627 _GL_ARG_NONNULL ((2)));
629 _GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name,
630 struct timespec const times[2], int flag));
632 _GL_CXXALIASWARN (utimensat);
633 #elif defined GNULIB_POSIXCHECK
635 # if HAVE_RAW_DECL_UTIMENSAT
636 _GL_WARN_ON_USE (utimensat, "utimensat is not portable - "
637 "use gnulib module utimensat for portability");
642 #endif /* _GL_SYS_STAT_H */
643 #endif /* _GL_SYS_STAT_H */