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-2011 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 _@GUARD_PREFIX@_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 _@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(). */
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
/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our futimens
361
implementation relies on futimesat, which on Solaris 10 makes an invocation
362
to futimens that is meant to invoke the libc's futimens(), not gnulib's
364
# if @REPLACE_FUTIMENS@ || (!@HAVE_FUTIMENS@ && defined __sun)
365
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
367
# define futimens rpl_futimens
369
_GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2]));
370
_GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2]));
372
# if !@HAVE_FUTIMENS@
373
_GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2]));
375
_GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2]));
378
_GL_CXXALIASWARN (futimens);
380
#elif defined GNULIB_POSIXCHECK
382
# if HAVE_RAW_DECL_FUTIMENS
383
_GL_WARN_ON_USE (futimens, "futimens is not portable - "
384
"use gnulib module futimens for portability");
390
/* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
391
denotes a symbolic link. */
393
/* The lchmod replacement follows symbolic links. Callers should take
394
this into account; lchmod should be applied only to arguments that
395
are known to not be symbolic links. On hosts that lack lchmod,
396
this can lead to race conditions between the check and the
397
invocation of lchmod, but we know of no workarounds that are
398
reliable in general. You might try requesting support for lchmod
399
from your operating system supplier. */
400
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
401
# define lchmod chmod
403
/* Need to cast, because on mingw, the second parameter of chmod is
405
_GL_CXXALIAS_RPL_CAST_1 (lchmod, chmod, int,
406
(const char *filename, mode_t mode));
408
# if 0 /* assume already declared */
409
_GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode)
410
_GL_ARG_NONNULL ((1)));
412
_GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode));
415
_GL_CXXALIASWARN (lchmod);
417
#elif defined GNULIB_POSIXCHECK
419
# if HAVE_RAW_DECL_LCHMOD
420
_GL_WARN_ON_USE (lchmod, "lchmod is unportable - "
421
"use gnulib module lchmod for portability");
428
/* mingw does not support symlinks, therefore it does not have lstat. But
429
without links, stat does just fine. */
430
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
433
_GL_CXXALIAS_RPL_1 (lstat, stat, int, (const char *name, struct stat *buf));
434
# elif @REPLACE_LSTAT@
435
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
437
# define lstat rpl_lstat
439
_GL_FUNCDECL_RPL (lstat, int, (const char *name, struct stat *buf)
440
_GL_ARG_NONNULL ((1, 2)));
441
_GL_CXXALIAS_RPL (lstat, int, (const char *name, struct stat *buf));
443
_GL_CXXALIAS_SYS (lstat, int, (const char *name, struct stat *buf));
446
_GL_CXXALIASWARN (lstat);
448
#elif defined GNULIB_POSIXCHECK
450
# if HAVE_RAW_DECL_LSTAT
451
_GL_WARN_ON_USE (lstat, "lstat is unportable - "
452
"use gnulib module lstat for portability");
458
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
460
# define mkdir rpl_mkdir
462
_GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode)
463
_GL_ARG_NONNULL ((1)));
464
_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
466
/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
467
Additionally, it declares _mkdir (and depending on compile flags, an
468
alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
469
which are included above. */
470
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
472
# if !GNULIB_defined_rpl_mkdir
474
rpl_mkdir (char const *name, mode_t mode)
476
return _mkdir (name);
478
# define GNULIB_defined_rpl_mkdir 1
481
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
482
# define mkdir rpl_mkdir
484
_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
486
_GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
489
_GL_CXXALIASWARN (mkdir);
494
_GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)
495
_GL_ARG_NONNULL ((2)));
497
_GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode));
498
_GL_CXXALIASWARN (mkdirat);
499
#elif defined GNULIB_POSIXCHECK
501
# if HAVE_RAW_DECL_MKDIRAT
502
_GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - "
503
"use gnulib module openat for portability");
509
# if @REPLACE_MKFIFO@
510
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
512
# define mkfifo rpl_mkfifo
514
_GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode)
515
_GL_ARG_NONNULL ((1)));
516
_GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode));
519
_GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode)
520
_GL_ARG_NONNULL ((1)));
522
_GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode));
524
_GL_CXXALIASWARN (mkfifo);
525
#elif defined GNULIB_POSIXCHECK
527
# if HAVE_RAW_DECL_MKFIFO
528
_GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - "
529
"use gnulib module mkfifo for portability");
534
#if @GNULIB_MKFIFOAT@
535
# if !@HAVE_MKFIFOAT@
536
_GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)
537
_GL_ARG_NONNULL ((2)));
539
_GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode));
540
_GL_CXXALIASWARN (mkfifoat);
541
#elif defined GNULIB_POSIXCHECK
543
# if HAVE_RAW_DECL_MKFIFOAT
544
_GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - "
545
"use gnulib module mkfifoat for portability");
552
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
554
# define mknod rpl_mknod
556
_GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)
557
_GL_ARG_NONNULL ((1)));
558
_GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev));
561
_GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev)
562
_GL_ARG_NONNULL ((1)));
564
/* Need to cast, because on OSF/1 5.1, the third parameter is '...'. */
565
_GL_CXXALIAS_SYS_CAST (mknod, int, (char const *file, mode_t mode, dev_t dev));
567
_GL_CXXALIASWARN (mknod);
568
#elif defined GNULIB_POSIXCHECK
570
# if HAVE_RAW_DECL_MKNOD
571
_GL_WARN_ON_USE (mknod, "mknod is not portable - "
572
"use gnulib module mknod for portability");
579
_GL_FUNCDECL_SYS (mknodat, int,
580
(int fd, char const *file, mode_t mode, dev_t dev)
581
_GL_ARG_NONNULL ((2)));
583
_GL_CXXALIAS_SYS (mknodat, int,
584
(int fd, char const *file, mode_t mode, dev_t dev));
585
_GL_CXXALIASWARN (mknodat);
586
#elif defined GNULIB_POSIXCHECK
588
# if HAVE_RAW_DECL_MKNODAT
589
_GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
590
"use gnulib module mkfifoat for portability");
597
/* We can't use the object-like #define stat rpl_stat, because of
598
struct stat. This means that rpl_stat will not be used if the user
599
does (stat)(a,b). Oh well. */
602
/* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
603
so we have to replace stat64() instead of stat(). */
606
# define stat64(name, st) rpl_stat (name, st)
607
# else /* !_LARGE_FILES */
608
# define stat(name, st) rpl_stat (name, st)
609
# endif /* !_LARGE_FILES */
610
_GL_EXTERN_C int stat (const char *name, struct stat *buf)
611
_GL_ARG_NONNULL ((1, 2));
613
#elif defined GNULIB_POSIXCHECK
615
# if HAVE_RAW_DECL_STAT
616
_GL_WARN_ON_USE (stat, "stat is unportable - "
617
"use gnulib module stat for portability");
622
#if @GNULIB_UTIMENSAT@
623
/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat
624
implementation relies on futimesat, which on Solaris 10 makes an invocation
625
to utimensat that is meant to invoke the libc's utimensat(), not gnulib's
627
# if @REPLACE_UTIMENSAT@ || (!@HAVE_UTIMENSAT@ && defined __sun)
628
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
630
# define utimensat rpl_utimensat
632
_GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name,
633
struct timespec const times[2], int flag)
634
_GL_ARG_NONNULL ((2)));
635
_GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name,
636
struct timespec const times[2], int flag));
638
# if !@HAVE_UTIMENSAT@
639
_GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name,
640
struct timespec const times[2], int flag)
641
_GL_ARG_NONNULL ((2)));
643
_GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name,
644
struct timespec const times[2], int flag));
646
# if @HAVE_UTIMENSAT@
647
_GL_CXXALIASWARN (utimensat);
649
#elif defined GNULIB_POSIXCHECK
651
# if HAVE_RAW_DECL_UTIMENSAT
652
_GL_WARN_ON_USE (utimensat, "utimensat is not portable - "
653
"use gnulib module utimensat for portability");
658
#endif /* _@GUARD_PREFIX@_SYS_STAT_H */
659
#endif /* _@GUARD_PREFIX@_SYS_STAT_H */