1 /* Provide a more complete sys/stat.h header file.
2 Copyright (C) 2005-2024 Free Software Foundation, Inc.
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
9 This file 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 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Eric Blake, Paul Eggert, and Jim Meyering. */
19 /* This file is supposed to be used on platforms where <sys/stat.h> is
20 incomplete. It is intended to provide definitions and prototypes
21 needed by an application. Start with what the system provides. */
24 @PRAGMA_SYSTEM_HEADER@
28 /* This file uses #include_next of a system file that defines time_t.
29 For the 'year2038' module to work right, <config.h> needs to have been
31 #if !_GL_CONFIG_H_INCLUDED
32 #error "Please include config.h first."
35 #if defined __need_system_sys_stat_h
36 /* Special invocation convention. */
38 #@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
41 /* Normal invocation convention. */
43 #ifndef _@GUARD_PREFIX@_SYS_STAT_H
46 May also define off_t to a 64-bit type on native Windows. */
47 #include <sys/types.h>
49 /* Get struct timespec. */
52 /* The include_next requires a split double-inclusion guard. */
53 #@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
55 #ifndef _@GUARD_PREFIX@_SYS_STAT_H
56 #define _@GUARD_PREFIX@_SYS_STAT_H
58 /* This file uses _GL_ATTRIBUTE_NOTHROW, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
59 #if !_GL_CONFIG_H_INCLUDED
60 #error "Please include config.h first."
64 /* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
66 #ifndef _GL_ATTRIBUTE_NOTHROW
67 # if defined __cplusplus
68 # if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major >= 4
69 # if __cplusplus >= 201103L
70 # define _GL_ATTRIBUTE_NOTHROW noexcept (true)
72 # define _GL_ATTRIBUTE_NOTHROW throw ()
75 # define _GL_ATTRIBUTE_NOTHROW
78 # if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
79 # define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
81 # define _GL_ATTRIBUTE_NOTHROW
86 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
88 /* The definition of _GL_ARG_NONNULL is copied here. */
90 /* The definition of _GL_WARN_ON_USE is copied here. */
93 /* Before doing "#define mknod rpl_mknod" below, we need to include all
94 headers that may declare mknod(). OS/2 kLIBC declares mknod() in
95 <unistd.h>, not in <sys/stat.h>. */
100 /* Before doing "#define mkdir rpl_mkdir" below, we need to include all
101 headers that may declare mkdir(). Native Windows platforms declare mkdir
102 in <io.h> and/or <direct.h>, not in <sys/stat.h>. */
103 #if defined _WIN32 && ! defined __CYGWIN__
104 # include <io.h> /* mingw32, mingw64 */
105 # include <direct.h> /* mingw64, MSVC 9 */
108 /* Native Windows platforms declare umask() in <io.h>. */
109 #if 0 && (defined _WIN32 && ! defined __CYGWIN__)
113 /* Large File Support on native Windows. */
114 #if @WINDOWS_64_BIT_ST_SIZE@
115 # define stat _stati64
118 /* Optionally, override 'struct stat' on native Windows. */
119 #if @GNULIB_OVERRIDES_STRUCT_STAT@
123 # define stat rpl_stat
125 /* Provoke a clear link error if stat() is used as a function and
126 module 'stat' is not in use. */
127 # define stat stat_used_without_requesting_gnulib_module_stat
130 # if !GNULIB_defined_struct_stat
139 # else /* uid_t is not defined by default on native Windows. */
144 # else /* gid_t is not defined by default on native Windows. */
150 blksize_t st_blksize
;
154 # if @WINDOWS_STAT_TIMESPEC@
155 struct timespec st_atim
;
156 struct timespec st_mtim
;
157 struct timespec st_ctim
;
164 # if @WINDOWS_STAT_TIMESPEC@
165 # define st_atime st_atim.tv_sec
166 # define st_mtime st_mtim.tv_sec
167 # define st_ctime st_ctim.tv_sec
168 /* Indicator, for gnulib internal purposes. */
169 # define _GL_WINDOWS_STAT_TIMESPEC 1
171 # define GNULIB_defined_struct_stat 1
174 /* Other possible values of st_mode. */
176 # define _S_IFBLK 0x6000
179 # define _S_IFLNK 0xA000
182 # define _S_IFSOCK 0xC000
189 # define S_IFIFO _S_IFIFO
194 # define S_IFMT 0170000
197 #if STAT_MACROS_BROKEN
213 # define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
215 # define S_ISBLK(m) 0
221 # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
223 # define S_ISCHR(m) 0
229 # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
231 # define S_ISDIR(m) 0
235 #ifndef S_ISDOOR /* Solaris 2.5 and up */
236 # define S_ISDOOR(m) 0
241 # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
243 # define S_ISFIFO(m) 0
249 # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
251 # define S_ISLNK(m) 0
255 #ifndef S_ISMPB /* V7 */
257 # define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
258 # define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
260 # define S_ISMPB(m) 0
261 # define S_ISMPC(m) 0
265 #ifndef S_ISMPX /* AIX */
266 # define S_ISMPX(m) 0
269 #ifndef S_ISNAM /* Xenix */
271 # define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
273 # define S_ISNAM(m) 0
277 #ifndef S_ISNWK /* HP/UX */
279 # define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
281 # define S_ISNWK(m) 0
285 #ifndef S_ISPORT /* Solaris 10 and up */
286 # define S_ISPORT(m) 0
291 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
293 # define S_ISREG(m) 0
299 # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
301 # define S_ISSOCK(m) 0
307 # define S_TYPEISMQ(p) 0
311 # define S_TYPEISTMO(p) 0
317 # define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
319 # define S_TYPEISSEM(p) 0
325 # define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
327 # define S_TYPEISSHM(p) 0
331 /* high performance ("contiguous data") */
333 # define S_ISCTG(p) 0
336 /* Cray DMF (data migration facility): off line, with data */
338 # define S_ISOFD(p) 0
341 /* Cray DMF (data migration facility): off line, with no data */
343 # define S_ISOFL(p) 0
346 /* 4.4BSD whiteout */
348 # define S_ISWHT(m) 0
351 /* If any of the following are undefined,
352 define them to their de facto standard values. */
354 # define S_ISUID 04000
357 # define S_ISGID 02000
360 /* S_ISVTX is a common extension to POSIX. */
362 # define S_ISVTX 01000
365 #if !S_IRUSR && S_IREAD
366 # define S_IRUSR S_IREAD
369 # define S_IRUSR 00400
372 # define S_IRGRP (S_IRUSR >> 3)
375 # define S_IROTH (S_IRUSR >> 6)
378 #if !S_IWUSR && S_IWRITE
379 # define S_IWUSR S_IWRITE
382 # define S_IWUSR 00200
385 # define S_IWGRP (S_IWUSR >> 3)
388 # define S_IWOTH (S_IWUSR >> 6)
391 #if !S_IXUSR && S_IEXEC
392 # define S_IXUSR S_IEXEC
395 # define S_IXUSR 00100
398 # define S_IXGRP (S_IXUSR >> 3)
401 # define S_IXOTH (S_IXUSR >> 6)
405 # define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
408 # define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
411 # define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
414 /* Although S_IXUGO and S_IRWXUGO are not specified by POSIX and are
415 not implemented in GNU/Linux, some Gnulib-using apps use the macros. */
417 # define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
420 # define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
423 /* Macros for futimens and utimensat. */
425 # define UTIME_NOW (-1)
426 # define UTIME_OMIT (-2)
432 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
434 # define chmod rpl_chmod
436 _GL_FUNCDECL_RPL (chmod
, int, (const char *filename
, mode_t mode
)
437 _GL_ARG_NONNULL ((1)));
438 _GL_CXXALIAS_RPL (chmod
, int, (const char *filename
, mode_t mode
));
439 # elif defined _WIN32 && !defined __CYGWIN__
440 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
442 # define chmod _chmod
444 /* Need to cast, because in mingw the last argument is 'int mode'. */
445 _GL_CXXALIAS_MDA_CAST (chmod
, int, (const char *filename
, mode_t mode
));
447 _GL_CXXALIAS_SYS (chmod
, int, (const char *filename
, mode_t mode
));
449 _GL_CXXALIASWARN (chmod
);
450 #elif defined GNULIB_POSIXCHECK
452 # if HAVE_RAW_DECL_CHMOD
453 _GL_WARN_ON_USE (chmod
, "chmod has portability problems - "
454 "use gnulib module chmod for portability");
456 #elif @GNULIB_MDA_CHMOD@
457 /* On native Windows, map 'chmod' to '_chmod', so that -loldnames is not
458 required. In C++ with GNULIB_NAMESPACE, avoid differences between
459 platforms by defining GNULIB_NAMESPACE::chmod always. */
460 # if defined _WIN32 && !defined __CYGWIN__
461 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
463 # define chmod _chmod
465 /* Need to cast, because in mingw the last argument is 'int mode'. */
466 _GL_CXXALIAS_MDA_CAST (chmod
, int, (const char *filename
, mode_t mode
));
468 _GL_CXXALIAS_SYS (chmod
, int, (const char *filename
, mode_t mode
));
470 _GL_CXXALIASWARN (chmod
);
474 #if @GNULIB_FCHMODAT@
475 # if @REPLACE_FCHMODAT@
476 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
478 # define fchmodat rpl_fchmodat
480 _GL_FUNCDECL_RPL (fchmodat
, int,
481 (int fd
, char const *file
, mode_t mode
, int flag
)
482 _GL_ARG_NONNULL ((2)));
483 _GL_CXXALIAS_RPL (fchmodat
, int,
484 (int fd
, char const *file
, mode_t mode
, int flag
));
486 # if !@HAVE_FCHMODAT@
487 _GL_FUNCDECL_SYS (fchmodat
, int,
488 (int fd
, char const *file
, mode_t mode
, int flag
)
489 _GL_ARG_NONNULL ((2)));
491 _GL_CXXALIAS_SYS (fchmodat
, int,
492 (int fd
, char const *file
, mode_t mode
, int flag
));
494 _GL_CXXALIASWARN (fchmodat
);
495 #elif defined GNULIB_POSIXCHECK
497 # if HAVE_RAW_DECL_FCHMODAT
498 _GL_WARN_ON_USE (fchmodat
, "fchmodat is not portable - "
499 "use gnulib module openat for portability");
506 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
508 # define fstat rpl_fstat
510 _GL_FUNCDECL_RPL (fstat
, int, (int fd
, struct stat
*buf
) _GL_ARG_NONNULL ((2)));
511 _GL_CXXALIAS_RPL (fstat
, int, (int fd
, struct stat
*buf
));
513 _GL_CXXALIAS_SYS (fstat
, int, (int fd
, struct stat
*buf
));
516 _GL_CXXALIASWARN (fstat
);
518 #elif @GNULIB_OVERRIDES_STRUCT_STAT@
520 # define fstat fstat_used_without_requesting_gnulib_module_fstat
521 #elif @WINDOWS_64_BIT_ST_SIZE@
522 /* Above, we define stat to _stati64. */
523 # define fstat _fstati64
524 #elif defined GNULIB_POSIXCHECK
526 # if HAVE_RAW_DECL_FSTAT
527 _GL_WARN_ON_USE (fstat
, "fstat has portability problems - "
528 "use gnulib module fstat for portability");
534 # if @REPLACE_FSTATAT@
535 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
537 # define fstatat rpl_fstatat
539 _GL_FUNCDECL_RPL (fstatat
, int,
540 (int fd
, char const *restrict name
, struct stat
*restrict st
,
542 _GL_ARG_NONNULL ((2, 3)));
543 _GL_CXXALIAS_RPL (fstatat
, int,
544 (int fd
, char const *restrict name
, struct stat
*restrict st
,
548 _GL_FUNCDECL_SYS (fstatat
, int,
549 (int fd
, char const *restrict name
, struct stat
*restrict st
,
551 _GL_ARG_NONNULL ((2, 3)));
553 _GL_CXXALIAS_SYS (fstatat
, int,
554 (int fd
, char const *restrict name
, struct stat
*restrict st
,
557 _GL_CXXALIASWARN (fstatat
);
558 #elif @GNULIB_OVERRIDES_STRUCT_STAT@
560 # define fstatat fstatat_used_without_requesting_gnulib_module_fstatat
561 #elif defined GNULIB_POSIXCHECK
563 # if HAVE_RAW_DECL_FSTATAT
564 _GL_WARN_ON_USE (fstatat
, "fstatat is not portable - "
565 "use gnulib module openat for portability");
570 #if @GNULIB_FUTIMENS@
571 /* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our futimens
572 implementation relies on futimesat, which on Solaris 10 makes an invocation
573 to futimens that is meant to invoke the libc's futimens(), not gnulib's
575 # if @REPLACE_FUTIMENS@ || (!@HAVE_FUTIMENS@ && defined __sun)
576 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
578 # define futimens rpl_futimens
580 _GL_FUNCDECL_RPL (futimens
, int, (int fd
, struct timespec
const times
[2]));
581 _GL_CXXALIAS_RPL (futimens
, int, (int fd
, struct timespec
const times
[2]));
583 # if !@HAVE_FUTIMENS@
584 _GL_FUNCDECL_SYS (futimens
, int, (int fd
, struct timespec
const times
[2]));
586 _GL_CXXALIAS_SYS (futimens
, int, (int fd
, struct timespec
const times
[2]));
588 # if __GLIBC__ >= 2 && @HAVE_FUTIMENS@
589 _GL_CXXALIASWARN (futimens
);
591 #elif defined GNULIB_POSIXCHECK
593 # if HAVE_RAW_DECL_FUTIMENS
594 _GL_WARN_ON_USE (futimens
, "futimens is not portable - "
595 "use gnulib module futimens for portability");
600 #if @GNULIB_GETUMASK@
601 # if !@HAVE_GETUMASK@
602 # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
603 _GL_FUNCDECL_SYS (getumask
, mode_t
, (void) _GL_ATTRIBUTE_NOTHROW
);
605 _GL_FUNCDECL_SYS (getumask
, mode_t
, (void));
608 _GL_CXXALIAS_SYS (getumask
, mode_t
, (void));
610 _GL_CXXALIASWARN (getumask
);
612 #elif defined GNULIB_POSIXCHECK
614 # if HAVE_RAW_DECL_GETUMASK
615 _GL_WARN_ON_USE (getumask
, "getumask is not portable - "
616 "use gnulib module getumask for portability");
622 /* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
623 denotes a symbolic link. */
624 # if !@HAVE_LCHMOD@ || defined __hpux
625 _GL_FUNCDECL_SYS (lchmod
, int, (const char *filename
, mode_t mode
)
626 _GL_ARG_NONNULL ((1)));
628 _GL_CXXALIAS_SYS (lchmod
, int, (const char *filename
, mode_t mode
));
629 _GL_CXXALIASWARN (lchmod
);
630 #elif defined GNULIB_POSIXCHECK
632 # if HAVE_RAW_DECL_LCHMOD
633 _GL_WARN_ON_USE (lchmod
, "lchmod is unportable - "
634 "use gnulib module lchmod for portability");
641 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
643 # define mkdir rpl_mkdir
645 _GL_FUNCDECL_RPL (mkdir
, int, (char const *name
, mode_t mode
)
646 _GL_ARG_NONNULL ((1)));
647 _GL_CXXALIAS_RPL (mkdir
, int, (char const *name
, mode_t mode
));
648 # elif defined _WIN32 && !defined __CYGWIN__
649 /* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
650 Additionally, it declares _mkdir (and depending on compile flags, an
651 alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
652 which are included above. */
653 # if !GNULIB_defined_rpl_mkdir
655 rpl_mkdir (char const *name
, mode_t mode
)
657 return _mkdir (name
);
659 # define GNULIB_defined_rpl_mkdir 1
661 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
663 # define mkdir rpl_mkdir
665 _GL_CXXALIAS_RPL (mkdir
, int, (char const *name
, mode_t mode
));
667 _GL_CXXALIAS_SYS (mkdir
, int, (char const *name
, mode_t mode
));
669 _GL_CXXALIASWARN (mkdir
);
670 #elif defined GNULIB_POSIXCHECK
672 # if HAVE_RAW_DECL_MKDIR
673 _GL_WARN_ON_USE (mkdir
, "mkdir does not always support two parameters - "
674 "use gnulib module mkdir for portability");
676 #elif @GNULIB_MDA_MKDIR@
677 /* On native Windows, map 'mkdir' to '_mkdir', so that -loldnames is not
678 required. In C++ with GNULIB_NAMESPACE, avoid differences between
679 platforms by defining GNULIB_NAMESPACE::mkdir always. */
680 # if defined _WIN32 && !defined __CYGWIN__
681 # if !GNULIB_defined_rpl_mkdir
683 rpl_mkdir (char const *name
, mode_t mode
)
685 return _mkdir (name
);
687 # define GNULIB_defined_rpl_mkdir 1
689 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
691 # define mkdir rpl_mkdir
693 _GL_CXXALIAS_RPL (mkdir
, int, (char const *name
, mode_t mode
));
695 _GL_CXXALIAS_SYS (mkdir
, int, (char const *name
, mode_t mode
));
697 _GL_CXXALIASWARN (mkdir
);
703 _GL_FUNCDECL_SYS (mkdirat
, int, (int fd
, char const *file
, mode_t mode
)
704 _GL_ARG_NONNULL ((2)));
706 _GL_CXXALIAS_SYS (mkdirat
, int, (int fd
, char const *file
, mode_t mode
));
707 _GL_CXXALIASWARN (mkdirat
);
708 #elif defined GNULIB_POSIXCHECK
710 # if HAVE_RAW_DECL_MKDIRAT
711 _GL_WARN_ON_USE (mkdirat
, "mkdirat is not portable - "
712 "use gnulib module openat for portability");
718 # if @REPLACE_MKFIFO@
719 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
721 # define mkfifo rpl_mkfifo
723 _GL_FUNCDECL_RPL (mkfifo
, int, (char const *file
, mode_t mode
)
724 _GL_ARG_NONNULL ((1)));
725 _GL_CXXALIAS_RPL (mkfifo
, int, (char const *file
, mode_t mode
));
728 _GL_FUNCDECL_SYS (mkfifo
, int, (char const *file
, mode_t mode
)
729 _GL_ARG_NONNULL ((1)));
731 _GL_CXXALIAS_SYS (mkfifo
, int, (char const *file
, mode_t mode
));
733 _GL_CXXALIASWARN (mkfifo
);
734 #elif defined GNULIB_POSIXCHECK
736 # if HAVE_RAW_DECL_MKFIFO
737 _GL_WARN_ON_USE (mkfifo
, "mkfifo is not portable - "
738 "use gnulib module mkfifo for portability");
743 #if @GNULIB_MKFIFOAT@
744 # if @REPLACE_MKFIFOAT@
745 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
747 # define mkfifoat rpl_mkfifoat
749 _GL_FUNCDECL_RPL (mkfifoat
, int, (int fd
, char const *file
, mode_t mode
)
750 _GL_ARG_NONNULL ((2)));
751 _GL_CXXALIAS_RPL (mkfifoat
, int, (int fd
, char const *file
, mode_t mode
));
753 # if !@HAVE_MKFIFOAT@
754 _GL_FUNCDECL_SYS (mkfifoat
, int, (int fd
, char const *file
, mode_t mode
)
755 _GL_ARG_NONNULL ((2)));
757 _GL_CXXALIAS_SYS (mkfifoat
, int, (int fd
, char const *file
, mode_t mode
));
760 _GL_CXXALIASWARN (mkfifoat
);
762 #elif defined GNULIB_POSIXCHECK
764 # if HAVE_RAW_DECL_MKFIFOAT
765 _GL_WARN_ON_USE (mkfifoat
, "mkfifoat is not portable - "
766 "use gnulib module mkfifoat for portability");
773 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
775 # define mknod rpl_mknod
777 _GL_FUNCDECL_RPL (mknod
, int, (char const *file
, mode_t mode
, dev_t dev
)
778 _GL_ARG_NONNULL ((1)));
779 _GL_CXXALIAS_RPL (mknod
, int, (char const *file
, mode_t mode
, dev_t dev
));
782 _GL_FUNCDECL_SYS (mknod
, int, (char const *file
, mode_t mode
, dev_t dev
)
783 _GL_ARG_NONNULL ((1)));
785 /* Need to cast, because on OSF/1 5.1, the third parameter is '...'. */
786 _GL_CXXALIAS_SYS_CAST (mknod
, int, (char const *file
, mode_t mode
, dev_t dev
));
788 _GL_CXXALIASWARN (mknod
);
789 #elif defined GNULIB_POSIXCHECK
791 # if HAVE_RAW_DECL_MKNOD
792 _GL_WARN_ON_USE (mknod
, "mknod is not portable - "
793 "use gnulib module mknod for portability");
799 # if @REPLACE_MKNODAT@
800 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
802 # define mknodat rpl_mknodat
804 _GL_FUNCDECL_RPL (mknodat
, int,
805 (int fd
, char const *file
, mode_t mode
, dev_t dev
)
806 _GL_ARG_NONNULL ((2)));
807 _GL_CXXALIAS_RPL (mknodat
, int,
808 (int fd
, char const *file
, mode_t mode
, dev_t dev
));
811 _GL_FUNCDECL_SYS (mknodat
, int,
812 (int fd
, char const *file
, mode_t mode
, dev_t dev
)
813 _GL_ARG_NONNULL ((2)));
815 _GL_CXXALIAS_SYS (mknodat
, int,
816 (int fd
, char const *file
, mode_t mode
, dev_t dev
));
819 _GL_CXXALIASWARN (mknodat
);
821 #elif defined GNULIB_POSIXCHECK
823 # if HAVE_RAW_DECL_MKNODAT
824 _GL_WARN_ON_USE (mknodat
, "mknodat is not portable - "
825 "use gnulib module mkfifoat for portability");
832 # if !@GNULIB_OVERRIDES_STRUCT_STAT@
833 /* We can't use the object-like #define stat rpl_stat, because of
834 struct stat. This means that rpl_stat will not be used if the user
835 does (stat)(a,b). Oh well. */
836 # if defined _AIX && defined stat && defined _LARGE_FILES
837 /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
838 so we have to replace stat64() instead of stat(). */
840 # define stat64(name, st) rpl_stat (name, st)
841 # elif @WINDOWS_64_BIT_ST_SIZE@
842 /* Above, we define stat to _stati64. */
843 # if defined __MINGW32__ && defined _stati64
844 # ifndef _USE_32BIT_TIME_T
845 /* The system headers define _stati64 to _stat64. */
847 # define _stat64(name, st) rpl_stat (name, st)
849 # elif defined _MSC_VER && defined _stati64
850 # ifdef _USE_32BIT_TIME_T
851 /* The system headers define _stati64 to _stat32i64. */
853 # define _stat32i64(name, st) rpl_stat (name, st)
855 /* The system headers define _stati64 to _stat64. */
857 # define _stat64(name, st) rpl_stat (name, st)
861 # define _stati64(name, st) rpl_stat (name, st)
863 # elif defined __MINGW32__ && defined stat
864 # ifdef _USE_32BIT_TIME_T
865 /* The system headers define stat to _stat32i64. */
867 # define _stat32i64(name, st) rpl_stat (name, st)
869 /* The system headers define stat to _stat64. */
871 # define _stat64(name, st) rpl_stat (name, st)
873 # elif defined _MSC_VER && defined stat
874 # ifdef _USE_32BIT_TIME_T
875 /* The system headers define stat to _stat32. */
877 # define _stat32(name, st) rpl_stat (name, st)
879 /* The system headers define stat to _stat64i32. */
881 # define _stat64i32(name, st) rpl_stat (name, st)
883 # else /* !(_AIX || __MINGW32__ || _MSC_VER) */
885 # define stat(name, st) rpl_stat (name, st)
886 # endif /* !_LARGE_FILES */
887 # endif /* !@GNULIB_OVERRIDES_STRUCT_STAT@ */
888 _GL_EXTERN_C
int stat (const char *restrict name
, struct stat
*restrict buf
)
889 _GL_ARG_NONNULL ((1, 2));
891 #elif @GNULIB_OVERRIDES_STRUCT_STAT@
893 #define stat stat_used_without_requesting_gnulib_module_stat
895 #elif defined GNULIB_POSIXCHECK
897 # if HAVE_RAW_DECL_STAT
898 _GL_WARN_ON_USE (stat
, "stat is unportable - "
899 "use gnulib module stat for portability");
906 /* mingw does not support symlinks, therefore it does not have lstat. But
907 without links, stat does just fine. */
908 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
911 _GL_CXXALIAS_RPL_1 (lstat
, stat
, int,
912 (const char *restrict name
, struct stat
*restrict buf
));
913 # elif @REPLACE_LSTAT@
914 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
916 # define lstat rpl_lstat
918 _GL_FUNCDECL_RPL (lstat
, int,
919 (const char *restrict name
, struct stat
*restrict buf
)
920 _GL_ARG_NONNULL ((1, 2)));
921 _GL_CXXALIAS_RPL (lstat
, int,
922 (const char *restrict name
, struct stat
*restrict buf
));
924 _GL_CXXALIAS_SYS (lstat
, int,
925 (const char *restrict name
, struct stat
*restrict buf
));
928 _GL_CXXALIASWARN (lstat
);
930 #elif @GNULIB_OVERRIDES_STRUCT_STAT@
932 # define lstat lstat_used_without_requesting_gnulib_module_lstat
933 #elif defined GNULIB_POSIXCHECK
935 # if HAVE_RAW_DECL_LSTAT
936 _GL_WARN_ON_USE (lstat
, "lstat is unportable - "
937 "use gnulib module lstat for portability");
942 #if @GNULIB_MDA_UMASK@
943 /* On native Windows, map 'umask' to '_umask', so that -loldnames is not
944 required. In C++ with GNULIB_NAMESPACE, avoid differences between
945 platforms by defining GNULIB_NAMESPACE::umask always. */
946 # if defined _WIN32 && !defined __CYGWIN__
947 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
949 # define umask _umask
951 /* Need to cast, because in mingw the last argument is 'int mode'. */
952 _GL_CXXALIAS_MDA_CAST (umask
, mode_t
, (mode_t mask
));
954 _GL_CXXALIAS_SYS (umask
, mode_t
, (mode_t mask
));
956 _GL_CXXALIASWARN (umask
);
960 #if @GNULIB_UTIMENSAT@
961 /* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat
962 implementation relies on futimesat, which on Solaris 10 makes an invocation
963 to utimensat that is meant to invoke the libc's utimensat(), not gnulib's
965 # if @REPLACE_UTIMENSAT@ || (!@HAVE_UTIMENSAT@ && defined __sun)
966 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
968 # define utimensat rpl_utimensat
970 _GL_FUNCDECL_RPL (utimensat
, int, (int fd
, char const *name
,
971 struct timespec
const times
[2], int flag
)
972 _GL_ARG_NONNULL ((2)));
973 _GL_CXXALIAS_RPL (utimensat
, int, (int fd
, char const *name
,
974 struct timespec
const times
[2], int flag
));
976 # if !@HAVE_UTIMENSAT@
977 _GL_FUNCDECL_SYS (utimensat
, int, (int fd
, char const *name
,
978 struct timespec
const times
[2], int flag
)
979 _GL_ARG_NONNULL ((2)));
981 _GL_CXXALIAS_SYS (utimensat
, int, (int fd
, char const *name
,
982 struct timespec
const times
[2], int flag
));
984 # if __GLIBC__ >= 2 && @HAVE_UTIMENSAT@
985 _GL_CXXALIASWARN (utimensat
);
987 #elif defined GNULIB_POSIXCHECK
989 # if HAVE_RAW_DECL_UTIMENSAT
990 _GL_WARN_ON_USE (utimensat
, "utimensat is not portable - "
991 "use gnulib module utimensat for portability");
996 #endif /* _@GUARD_PREFIX@_SYS_STAT_H */
997 #endif /* _@GUARD_PREFIX@_SYS_STAT_H */