25 #pragma GCC system_header
29 #if defined __need_system_sys_stat_h
32 #include_next <sys/stat.h>
37 #ifndef _GL_SYS_STAT_H
47 #include_next <sys/stat.h>
49 #ifndef _GL_SYS_STAT_H
50 #define _GL_SYS_STAT_H
117 #if defined __cplusplus
118 # define _GL_EXTERN_C extern "C"
120 # define _GL_EXTERN_C extern
130 #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
131 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
132 #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
133 _GL_EXTERN_C rettype rpl_func parameters_and_attributes
142 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
143 _GL_EXTERN_C rettype func parameters_and_attributes
151 #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
152 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
153 #if defined __cplusplus && defined GNULIB_NAMESPACE
154 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
155 namespace GNULIB_NAMESPACE \
157 rettype (*const func) parameters = ::rpl_func; \
159 _GL_EXTERN_C int _gl_cxxalias_dummy
161 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
162 _GL_EXTERN_C int _gl_cxxalias_dummy
170 #if defined __cplusplus && defined GNULIB_NAMESPACE
171 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
172 namespace GNULIB_NAMESPACE \
174 rettype (*const func) parameters = \
175 reinterpret_cast<rettype(*)parameters>(::rpl_func); \
177 _GL_EXTERN_C int _gl_cxxalias_dummy
179 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
180 _GL_EXTERN_C int _gl_cxxalias_dummy
190 #if defined __cplusplus && defined GNULIB_NAMESPACE
197 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
198 namespace GNULIB_NAMESPACE \
200 static rettype (*func) parameters = ::func; \
202 _GL_EXTERN_C int _gl_cxxalias_dummy
204 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
205 _GL_EXTERN_C int _gl_cxxalias_dummy
213 #if defined __cplusplus && defined GNULIB_NAMESPACE
214 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
215 namespace GNULIB_NAMESPACE \
217 static rettype (*func) parameters = \
218 reinterpret_cast<rettype(*)parameters>(::func); \
220 _GL_EXTERN_C int _gl_cxxalias_dummy
222 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
223 _GL_EXTERN_C int _gl_cxxalias_dummy
232 #if defined __cplusplus && defined GNULIB_NAMESPACE
238 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
239 namespace GNULIB_NAMESPACE \
241 static rettype (*func) parameters = \
242 reinterpret_cast<rettype(*)parameters>( \
243 (rettype2(*)parameters2)(::func)); \
245 _GL_EXTERN_C int _gl_cxxalias_dummy
247 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
248 _GL_EXTERN_C int _gl_cxxalias_dummy
255 #if defined __cplusplus && defined GNULIB_NAMESPACE
256 # define _GL_CXXALIASWARN(func) \
257 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
258 # define _GL_CXXALIASWARN_1(func,namespace) \
259 _GL_CXXALIASWARN_2 (func, namespace)
263 # define _GL_CXXALIASWARN_2(func,namespace) \
264 _GL_WARN_ON_USE (func, \
265 "The symbol ::" #func " refers to the system function. " \
266 "Use " #namespace "::" #func " instead.")
267 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
268 # define _GL_CXXALIASWARN_2(func,namespace) \
269 extern __typeof__ (func) func
271 # define _GL_CXXALIASWARN_2(func,namespace) \
272 _GL_EXTERN_C int _gl_cxxalias_dummy
275 # define _GL_CXXALIASWARN(func) \
276 _GL_EXTERN_C int _gl_cxxalias_dummy
282 #if defined __cplusplus && defined GNULIB_NAMESPACE
283 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
284 _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
286 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
287 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
291 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
292 _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
293 "The symbol ::" #func " refers to the system function. " \
294 "Use " #namespace "::" #func " instead.")
295 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
296 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
297 extern __typeof__ (func) func
299 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
300 _GL_EXTERN_C int _gl_cxxalias_dummy
303 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
304 _GL_EXTERN_C int _gl_cxxalias_dummy
313 #ifndef _GL_ARG_NONNULL
314 # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
315 # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
317 # define _GL_ARG_NONNULL(params)
322 #ifndef _GL_WARN_ON_USE
324 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
326 # define _GL_WARN_ON_USE(function, message) \
327 extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
328 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
330 # define _GL_WARN_ON_USE(function, message) \
331 extern __typeof__ (function) function
333 # define _GL_WARN_ON_USE(function, message) \
334 _GL_WARN_EXTERN_C int _gl_warn_on_use
344 #ifndef _GL_WARN_ON_USE_CXX
345 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
346 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
347 extern rettype function parameters_and_attributes \
348 __attribute__ ((__warning__ (msg)))
349 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
351 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
352 extern rettype function parameters_and_attributes
354 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
355 _GL_WARN_EXTERN_C int _gl_warn_on_use
361 #ifndef _GL_WARN_EXTERN_C
362 # if defined __cplusplus
363 # define _GL_WARN_EXTERN_C extern "C"
365 # define _GL_WARN_EXTERN_C extern
372 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
378 #if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
384 # define stat _stati64
389 # define S_IFIFO _S_IFIFO
394 # define S_IFMT 0170000
397 #if STAT_MACROS_BROKEN
413 # define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
415 # define S_ISBLK(m) 0
421 # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
423 # define S_ISCHR(m) 0
429 # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
431 # define S_ISDIR(m) 0
436 # define S_ISDOOR(m) 0
441 # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
443 # define S_ISFIFO(m) 0
449 # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
451 # define S_ISLNK(m) 0
457 # define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
458 # define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
460 # define S_ISMPB(m) 0
461 # define S_ISMPC(m) 0
467 # define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
469 # define S_ISNAM(m) 0
475 # define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
477 # define S_ISNWK(m) 0
482 # define S_ISPORT(m) 0
487 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
489 # define S_ISREG(m) 0
495 # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
497 # define S_ISSOCK(m) 0
503 # define S_TYPEISMQ(p) 0
507 # define S_TYPEISTMO(p) 0
513 # define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
515 # define S_TYPEISSEM(p) 0
521 # define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
523 # define S_TYPEISSHM(p) 0
529 # define S_ISCTG(p) 0
534 # define S_ISOFD(p) 0
539 # define S_ISOFL(p) 0
544 # define S_ISWHT(m) 0
550 # define S_ISUID 04000
553 # define S_ISGID 02000
558 # define S_ISVTX 01000
561 #if !S_IRUSR && S_IREAD
562 # define S_IRUSR S_IREAD
565 # define S_IRUSR 00400
568 # define S_IRGRP (S_IRUSR >> 3)
571 # define S_IROTH (S_IRUSR >> 6)
574 #if !S_IWUSR && S_IWRITE
575 # define S_IWUSR S_IWRITE
578 # define S_IWUSR 00200
581 # define S_IWGRP (S_IWUSR >> 3)
584 # define S_IWOTH (S_IWUSR >> 6)
587 #if !S_IXUSR && S_IEXEC
588 # define S_IXUSR S_IEXEC
591 # define S_IXUSR 00100
594 # define S_IXGRP (S_IXUSR >> 3)
597 # define S_IXOTH (S_IXUSR >> 6)
601 # define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
604 # define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
607 # define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
612 # define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
616 # define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
621 # define UTIME_NOW (-1)
622 # define UTIME_OMIT (-2)
629 (
int fd,
char const *file, mode_t mode,
int flag)
633 (
int fd,
char const *file, mode_t mode,
int flag));
635 #elif defined GNULIB_POSIXCHECK
637 # if HAVE_RAW_DECL_FCHMODAT
639 "use gnulib module openat for portability");
646 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
648 # define fstat rpl_fstat
658 # define fstat _fstati64
659 #elif defined GNULIB_POSIXCHECK
661 # if HAVE_RAW_DECL_FSTAT
663 "use gnulib module fstat for portability");
670 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
672 # define fstatat rpl_fstatat
675 (
int fd,
char const *name,
struct stat *st,
int flags)
678 (
int fd,
char const *name,
struct stat *st,
int flags));
682 (
int fd,
char const *name,
struct stat *st,
int flags)
686 (
int fd,
char const *name,
struct stat *st,
int flags));
689 #elif defined GNULIB_POSIXCHECK
691 # if HAVE_RAW_DECL_FSTATAT
693 "use gnulib module openat for portability");
703 # if 0 || (!1 && defined __sun)
704 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
706 # define futimens rpl_futimens
719 #elif defined GNULIB_POSIXCHECK
721 # if HAVE_RAW_DECL_FUTIMENS
723 "use gnulib module futimens for portability");
739 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
740 # define lchmod chmod
745 (
const char *filename, mode_t mode));
756 #elif defined GNULIB_POSIXCHECK
758 # if HAVE_RAW_DECL_LCHMOD
760 "use gnulib module lchmod for portability");
769 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
774 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
776 # define lstat rpl_lstat
787 #elif defined GNULIB_POSIXCHECK
789 # if HAVE_RAW_DECL_LSTAT
791 "use gnulib module lstat for portability");
797 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
799 # define mkdir rpl_mkdir
809 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
811 # if !GNULIB_defined_rpl_mkdir
813 rpl_mkdir (
char const *name, mode_t mode)
815 return _mkdir (name);
817 # define GNULIB_defined_rpl_mkdir 1
820 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
821 # define mkdir rpl_mkdir
838 #elif defined GNULIB_POSIXCHECK
840 # if HAVE_RAW_DECL_MKDIRAT
842 "use gnulib module openat for portability");
849 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
851 # define mkfifo rpl_mkfifo
864 #elif defined GNULIB_POSIXCHECK
866 # if HAVE_RAW_DECL_MKFIFO
868 "use gnulib module mkfifo for portability");
880 #elif defined GNULIB_POSIXCHECK
882 # if HAVE_RAW_DECL_MKFIFOAT
884 "use gnulib module mkfifoat for portability");
891 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
893 # define mknod rpl_mknod
907 #elif defined GNULIB_POSIXCHECK
909 # if HAVE_RAW_DECL_MKNOD
911 "use gnulib module mknod for portability");
919 (
int fd,
char const *file, mode_t mode, dev_t dev)
923 (
int fd,
char const *file, mode_t mode, dev_t dev));
925 #elif defined GNULIB_POSIXCHECK
927 # if HAVE_RAW_DECL_MKNODAT
929 "use gnulib module mkfifoat for portability");
939 # if defined _AIX && defined stat && defined _LARGE_FILES
943 # define stat64(name, st) rpl_stat (name, st)
946 # if defined __MINGW32__ && defined _stati64
947 # ifndef _USE_32BIT_TIME_T
950 # define _stat64(name, st) rpl_stat (name, st)
952 # elif defined _MSC_VER && defined _stati64
953 # ifdef _USE_32BIT_TIME_T
956 # define _stat32i64(name, st) rpl_stat (name, st)
960 # define _stat64(name, st) rpl_stat (name, st)
964 # define _stati64(name, st) rpl_stat (name, st)
966 # elif defined __MINGW32__ && defined stat
967 # ifdef _USE_32BIT_TIME_T
970 # define _stat32i64(name, st) rpl_stat (name, st)
974 # define _stat64(name, st) rpl_stat (name, st)
976 # elif defined _MSC_VER && defined stat
977 # ifdef _USE_32BIT_TIME_T
980 # define _stat32(name, st) rpl_stat (name, st)
984 # define _stat64i32(name, st) rpl_stat (name, st)
988 # define stat(name, st) rpl_stat (name, st)
990 _GL_EXTERN_C int stat (
const char *name,
struct stat *buf)
993 #elif defined GNULIB_POSIXCHECK
995 # if HAVE_RAW_DECL_STAT
997 "use gnulib module stat for portability");
1007 # if 0 || (!1 && defined __sun)
1008 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1010 # define utimensat rpl_utimensat
1013 struct timespec
const times[2],
int flag)
1016 struct timespec
const times[2],
int flag));
1020 struct timespec
const times[2],
int flag)
1024 struct timespec
const times[2],
int flag));
1029 #elif defined GNULIB_POSIXCHECK
1031 # if HAVE_RAW_DECL_UTIMENSAT
1033 "use gnulib module utimensat for portability");
#define _GL_CXXALIAS_RPL(func, rettype, parameters)
#define _GL_WARN_ON_USE(function, message)
#define _GL_ARG_NONNULL(params)
#define _GL_CXXALIAS_SYS_CAST(func, rettype, parameters)
#define _GL_FUNCDECL_SYS(func, rettype, parameters_and_attributes)
#define _GL_CXXALIAS_SYS(func, rettype, parameters)
#define _GL_CXXALIAS_RPL_1(func, rpl_func, rettype, parameters)
#define _GL_CXXALIAS_RPL_CAST_1(func, rpl_func, rettype, parameters)
#define _GL_CXXALIASWARN(func)
#define _GL_FUNCDECL_RPL(func, rettype, parameters_and_attributes)