summaryrefslogtreecommitdiffstats
path: root/gl/sys_stat.in.h
diff options
context:
space:
mode:
Diffstat (limited to 'gl/sys_stat.in.h')
-rw-r--r--gl/sys_stat.in.h638
1 files changed, 638 insertions, 0 deletions
diff --git a/gl/sys_stat.in.h b/gl/sys_stat.in.h
new file mode 100644
index 0000000..a64bf02
--- /dev/null
+++ b/gl/sys_stat.in.h
@@ -0,0 +1,638 @@
1/* Provide a more complete sys/stat header file.
2 Copyright (C) 2005-2010 Free Software Foundation, Inc.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
7 any later version.
8
9 This program 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 General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17
18/* Written by Eric Blake, Paul Eggert, and Jim Meyering. */
19
20/* This file is supposed to be used on platforms where <sys/stat.h> is
21 incomplete. It is intended to provide definitions and prototypes
22 needed by an application. Start with what the system provides. */
23
24#if __GNUC__ >= 3
25@PRAGMA_SYSTEM_HEADER@
26#endif
27
28#if defined __need_system_sys_stat_h
29/* Special invocation convention. */
30
31#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
32
33#else
34/* Normal invocation convention. */
35
36#ifndef _GL_SYS_STAT_H
37
38/* Get nlink_t. */
39#include <sys/types.h>
40
41/* Get struct timespec. */
42#include <time.h>
43
44/* The include_next requires a split double-inclusion guard. */
45#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
46
47#ifndef _GL_SYS_STAT_H
48#define _GL_SYS_STAT_H
49
50/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
51
52/* The definition of _GL_ARG_NONNULL is copied here. */
53
54/* The definition of _GL_WARN_ON_USE is copied here. */
55
56/* Before doing "#define mkdir rpl_mkdir" below, we need to include all
57 headers that may declare mkdir(). */
58#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
59# include <io.h>
60#endif
61
62#ifndef S_IFMT
63# define S_IFMT 0170000
64#endif
65
66#if STAT_MACROS_BROKEN
67# undef S_ISBLK
68# undef S_ISCHR
69# undef S_ISDIR
70# undef S_ISFIFO
71# undef S_ISLNK
72# undef S_ISNAM
73# undef S_ISMPB
74# undef S_ISMPC
75# undef S_ISNWK
76# undef S_ISREG
77# undef S_ISSOCK
78#endif
79
80#ifndef S_ISBLK
81# ifdef S_IFBLK
82# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
83# else
84# define S_ISBLK(m) 0
85# endif
86#endif
87
88#ifndef S_ISCHR
89# ifdef S_IFCHR
90# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
91# else
92# define S_ISCHR(m) 0
93# endif
94#endif
95
96#ifndef S_ISDIR
97# ifdef S_IFDIR
98# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
99# else
100# define S_ISDIR(m) 0
101# endif
102#endif
103
104#ifndef S_ISDOOR /* Solaris 2.5 and up */
105# define S_ISDOOR(m) 0
106#endif
107
108#ifndef S_ISFIFO
109# ifdef S_IFIFO
110# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
111# else
112# define S_ISFIFO(m) 0
113# endif
114#endif
115
116#ifndef S_ISLNK
117# ifdef S_IFLNK
118# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
119# else
120# define S_ISLNK(m) 0
121# endif
122#endif
123
124#ifndef S_ISMPB /* V7 */
125# ifdef S_IFMPB
126# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
127# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
128# else
129# define S_ISMPB(m) 0
130# define S_ISMPC(m) 0
131# endif
132#endif
133
134#ifndef S_ISNAM /* Xenix */
135# ifdef S_IFNAM
136# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
137# else
138# define S_ISNAM(m) 0
139# endif
140#endif
141
142#ifndef S_ISNWK /* HP/UX */
143# ifdef S_IFNWK
144# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
145# else
146# define S_ISNWK(m) 0
147# endif
148#endif
149
150#ifndef S_ISPORT /* Solaris 10 and up */
151# define S_ISPORT(m) 0
152#endif
153
154#ifndef S_ISREG
155# ifdef S_IFREG
156# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
157# else
158# define S_ISREG(m) 0
159# endif
160#endif
161
162#ifndef S_ISSOCK
163# ifdef S_IFSOCK
164# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
165# else
166# define S_ISSOCK(m) 0
167# endif
168#endif
169
170
171#ifndef S_TYPEISMQ
172# define S_TYPEISMQ(p) 0
173#endif
174
175#ifndef S_TYPEISTMO
176# define S_TYPEISTMO(p) 0
177#endif
178
179
180#ifndef S_TYPEISSEM
181# ifdef S_INSEM
182# define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
183# else
184# define S_TYPEISSEM(p) 0
185# endif
186#endif
187
188#ifndef S_TYPEISSHM
189# ifdef S_INSHD
190# define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
191# else
192# define S_TYPEISSHM(p) 0
193# endif
194#endif
195
196/* high performance ("contiguous data") */
197#ifndef S_ISCTG
198# define S_ISCTG(p) 0
199#endif
200
201/* Cray DMF (data migration facility): off line, with data */
202#ifndef S_ISOFD
203# define S_ISOFD(p) 0
204#endif
205
206/* Cray DMF (data migration facility): off line, with no data */
207#ifndef S_ISOFL
208# define S_ISOFL(p) 0
209#endif
210
211/* 4.4BSD whiteout */
212#ifndef S_ISWHT
213# define S_ISWHT(m) 0
214#endif
215
216/* If any of the following are undefined,
217 define them to their de facto standard values. */
218#if !S_ISUID
219# define S_ISUID 04000
220#endif
221#if !S_ISGID
222# define S_ISGID 02000
223#endif
224
225/* S_ISVTX is a common extension to POSIX. */
226#ifndef S_ISVTX
227# define S_ISVTX 01000
228#endif
229
230#if !S_IRUSR && S_IREAD
231# define S_IRUSR S_IREAD
232#endif
233#if !S_IRUSR
234# define S_IRUSR 00400
235#endif
236#if !S_IRGRP
237# define S_IRGRP (S_IRUSR >> 3)
238#endif
239#if !S_IROTH
240# define S_IROTH (S_IRUSR >> 6)
241#endif
242
243#if !S_IWUSR && S_IWRITE
244# define S_IWUSR S_IWRITE
245#endif
246#if !S_IWUSR
247# define S_IWUSR 00200
248#endif
249#if !S_IWGRP
250# define S_IWGRP (S_IWUSR >> 3)
251#endif
252#if !S_IWOTH
253# define S_IWOTH (S_IWUSR >> 6)
254#endif
255
256#if !S_IXUSR && S_IEXEC
257# define S_IXUSR S_IEXEC
258#endif
259#if !S_IXUSR
260# define S_IXUSR 00100
261#endif
262#if !S_IXGRP
263# define S_IXGRP (S_IXUSR >> 3)
264#endif
265#if !S_IXOTH
266# define S_IXOTH (S_IXUSR >> 6)
267#endif
268
269#if !S_IRWXU
270# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
271#endif
272#if !S_IRWXG
273# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
274#endif
275#if !S_IRWXO
276# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
277#endif
278
279/* S_IXUGO is a common extension to POSIX. */
280#if !S_IXUGO
281# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
282#endif
283
284#ifndef S_IRWXUGO
285# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
286#endif
287
288/* Macros for futimens and utimensat. */
289#ifndef UTIME_NOW
290# define UTIME_NOW (-1)
291# define UTIME_OMIT (-2)
292#endif
293
294
295#if @GNULIB_FCHMODAT@
296# if !@HAVE_FCHMODAT@
297_GL_FUNCDECL_SYS (fchmodat, int,
298 (int fd, char const *file, mode_t mode, int flag)
299 _GL_ARG_NONNULL ((2)));
300# endif
301_GL_CXXALIAS_SYS (fchmodat, int,
302 (int fd, char const *file, mode_t mode, int flag));
303_GL_CXXALIASWARN (fchmodat);
304#elif defined GNULIB_POSIXCHECK
305# undef fchmodat
306# if HAVE_RAW_DECL_FCHMODAT
307_GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - "
308 "use gnulib module openat for portability");
309# endif
310#endif
311
312
313#if @REPLACE_FSTAT@
314# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
315# define fstat rpl_fstat
316# endif
317_GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2)));
318_GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
319#else
320_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
321#endif
322_GL_CXXALIASWARN (fstat);
323
324
325#if @GNULIB_FSTATAT@
326# if @REPLACE_FSTATAT@
327# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
328# undef fstatat
329# define fstatat rpl_fstatat
330# endif
331_GL_FUNCDECL_RPL (fstatat, int,
332 (int fd, char const *name, struct stat *st, int flags)
333 _GL_ARG_NONNULL ((2, 3)));
334_GL_CXXALIAS_RPL (fstatat, int,
335 (int fd, char const *name, struct stat *st, int flags));
336# else
337# if !@HAVE_FSTATAT@
338_GL_FUNCDECL_SYS (fstatat, int,
339 (int fd, char const *name, struct stat *st, int flags)
340 _GL_ARG_NONNULL ((2, 3)));
341# endif
342_GL_CXXALIAS_SYS (fstatat, int,
343 (int fd, char const *name, struct stat *st, int flags));
344# endif
345_GL_CXXALIASWARN (fstatat);
346#elif defined GNULIB_POSIXCHECK
347# undef fstatat
348# if HAVE_RAW_DECL_FSTATAT
349_GL_WARN_ON_USE (fstatat, "fstatat is not portable - "
350 "use gnulib module openat for portability");
351# endif
352#endif
353
354
355#if @GNULIB_FUTIMENS@
356# if @REPLACE_FUTIMENS@
357# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
358# undef futimens
359# define futimens rpl_futimens
360# endif
361_GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2]));
362_GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2]));
363# else
364# if !@HAVE_FUTIMENS@
365_GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2]));
366# endif
367_GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2]));
368# endif
369_GL_CXXALIASWARN (futimens);
370#elif defined GNULIB_POSIXCHECK
371# undef futimens
372# if HAVE_RAW_DECL_FUTIMENS
373_GL_WARN_ON_USE (futimens, "futimens is not portable - "
374 "use gnulib module futimens for portability");
375# endif
376#endif
377
378
379#if @GNULIB_LCHMOD@
380/* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
381 denotes a symbolic link. */
382# if !@HAVE_LCHMOD@
383/* The lchmod replacement follows symbolic links. Callers should take
384 this into account; lchmod should be applied only to arguments that
385 are known to not be symbolic links. On hosts that lack lchmod,
386 this can lead to race conditions between the check and the
387 invocation of lchmod, but we know of no workarounds that are
388 reliable in general. You might try requesting support for lchmod
389 from your operating system supplier. */
390# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
391# define lchmod chmod
392# endif
393/* Need to cast, because on mingw, the second parameter of chmod is
394 int mode. */
395_GL_CXXALIAS_RPL_CAST_1 (lchmod, chmod, int,
396 (const char *filename, mode_t mode));
397# else
398# if 0 /* assume already declared */
399_GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode)
400 _GL_ARG_NONNULL ((1)));
401# endif
402_GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode));
403# endif
404# if @HAVE_LCHMOD@
405_GL_CXXALIASWARN (lchmod);
406# endif
407#elif defined GNULIB_POSIXCHECK
408# undef lchmod
409# if HAVE_RAW_DECL_LCHMOD
410_GL_WARN_ON_USE (lchmod, "lchmod is unportable - "
411 "use gnulib module lchmod for portability");
412# endif
413#endif
414
415
416#if @GNULIB_LSTAT@
417# if ! @HAVE_LSTAT@
418/* mingw does not support symlinks, therefore it does not have lstat. But
419 without links, stat does just fine. */
420# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
421# define lstat stat
422# endif
423_GL_CXXALIAS_RPL_1 (lstat, stat, int, (const char *name, struct stat *buf));
424# elif @REPLACE_LSTAT@
425# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
426# undef lstat
427# define lstat rpl_lstat
428# endif
429_GL_FUNCDECL_RPL (lstat, int, (const char *name, struct stat *buf)
430 _GL_ARG_NONNULL ((1, 2)));
431_GL_CXXALIAS_RPL (lstat, int, (const char *name, struct stat *buf));
432# else
433_GL_CXXALIAS_SYS (lstat, int, (const char *name, struct stat *buf));
434# endif
435# if @HAVE_LSTAT@
436_GL_CXXALIASWARN (lstat);
437# endif
438#elif defined GNULIB_POSIXCHECK
439# undef lstat
440# if HAVE_RAW_DECL_LSTAT
441_GL_WARN_ON_USE (lstat, "lstat is unportable - "
442 "use gnulib module lstat for portability");
443# endif
444#endif
445
446
447#if @REPLACE_MKDIR@
448# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
449# undef mkdir
450# define mkdir rpl_mkdir
451# endif
452_GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode)
453 _GL_ARG_NONNULL ((1)));
454_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
455#else
456/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
457 Additionally, it declares _mkdir (and depending on compile flags, an
458 alias mkdir), only in the nonstandard <io.h>, which is included above. */
459# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
460
461static inline int
462rpl_mkdir (char const *name, mode_t mode)
463{
464 return _mkdir (name);
465}
466
467# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
468# define mkdir rpl_mkdir
469# endif
470_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
471# else
472_GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
473# endif
474#endif
475_GL_CXXALIASWARN (mkdir);
476
477
478#if @GNULIB_MKDIRAT@
479# if !@HAVE_MKDIRAT@
480_GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)
481 _GL_ARG_NONNULL ((2)));
482# endif
483_GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode));
484_GL_CXXALIASWARN (mkdirat);
485#elif defined GNULIB_POSIXCHECK
486# undef mkdirat
487# if HAVE_RAW_DECL_MKDIRAT
488_GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - "
489 "use gnulib module openat for portability");
490# endif
491#endif
492
493
494#if @GNULIB_MKFIFO@
495# if @REPLACE_MKFIFO@
496# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
497# undef mkfifo
498# define mkfifo rpl_mkfifo
499# endif
500_GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode)
501 _GL_ARG_NONNULL ((1)));
502_GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode));
503# else
504# if !@HAVE_MKFIFO@
505_GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode)
506 _GL_ARG_NONNULL ((1)));
507# endif
508_GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode));
509# endif
510_GL_CXXALIASWARN (mkfifo);
511#elif defined GNULIB_POSIXCHECK
512# undef mkfifo
513# if HAVE_RAW_DECL_MKFIFO
514_GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - "
515 "use gnulib module mkfifo for portability");
516# endif
517#endif
518
519
520#if @GNULIB_MKFIFOAT@
521# if !@HAVE_MKFIFOAT@
522_GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)
523 _GL_ARG_NONNULL ((2)));
524# endif
525_GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode));
526_GL_CXXALIASWARN (mkfifoat);
527#elif defined GNULIB_POSIXCHECK
528# undef mkfifoat
529# if HAVE_RAW_DECL_MKFIFOAT
530_GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - "
531 "use gnulib module mkfifoat for portability");
532# endif
533#endif
534
535
536#if @GNULIB_MKNOD@
537# if @REPLACE_MKNOD@
538# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
539# undef mknod
540# define mknod rpl_mknod
541# endif
542_GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)
543 _GL_ARG_NONNULL ((1)));
544_GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev));
545# else
546# if !@HAVE_MKNOD@
547_GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev)
548 _GL_ARG_NONNULL ((1)));
549# endif
550_GL_CXXALIAS_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev));
551# endif
552_GL_CXXALIASWARN (mknod);
553#elif defined GNULIB_POSIXCHECK
554# undef mknod
555# if HAVE_RAW_DECL_MKNOD
556_GL_WARN_ON_USE (mknod, "mknod is not portable - "
557 "use gnulib module mknod for portability");
558# endif
559#endif
560
561
562#if @GNULIB_MKNODAT@
563# if !@HAVE_MKNODAT@
564_GL_FUNCDECL_SYS (mknodat, int,
565 (int fd, char const *file, mode_t mode, dev_t dev)
566 _GL_ARG_NONNULL ((2)));
567# endif
568_GL_CXXALIAS_SYS (mknodat, int,
569 (int fd, char const *file, mode_t mode, dev_t dev));
570_GL_CXXALIASWARN (mknodat);
571#elif defined GNULIB_POSIXCHECK
572# undef mknodat
573# if HAVE_RAW_DECL_MKNODAT
574_GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
575 "use gnulib module mkfifoat for portability");
576# endif
577#endif
578
579
580#if @GNULIB_STAT@
581# if @REPLACE_STAT@
582/* We can't use the object-like #define stat rpl_stat, because of
583 struct stat. This means that rpl_stat will not be used if the user
584 does (stat)(a,b). Oh well. */
585# undef stat
586# ifdef _LARGE_FILES
587 /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
588 so we have to replace stat64() instead of stat(). */
589# define stat stat64
590# undef stat64
591# define stat64(name, st) rpl_stat (name, st)
592# else /* !_LARGE_FILES */
593# define stat(name, st) rpl_stat (name, st)
594# endif /* !_LARGE_FILES */
595_GL_EXTERN_C int stat (const char *name, struct stat *buf) _GL_ARG_NONNULL ((1, 2));
596# endif
597#elif defined GNULIB_POSIXCHECK
598# undef stat
599# if HAVE_RAW_DECL_STAT
600_GL_WARN_ON_USE (stat, "stat is unportable - "
601 "use gnulib module stat for portability");
602# endif
603#endif
604
605
606#if @GNULIB_UTIMENSAT@
607# if @REPLACE_UTIMENSAT@
608# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
609# undef utimensat
610# define utimensat rpl_utimensat
611# endif
612_GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name,
613 struct timespec const times[2], int flag)
614 _GL_ARG_NONNULL ((2)));
615_GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name,
616 struct timespec const times[2], int flag));
617# else
618# if !@HAVE_UTIMENSAT@
619_GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name,
620 struct timespec const times[2], int flag)
621 _GL_ARG_NONNULL ((2)));
622# endif
623_GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name,
624 struct timespec const times[2], int flag));
625# endif
626_GL_CXXALIASWARN (utimensat);
627#elif defined GNULIB_POSIXCHECK
628# undef utimensat
629# if HAVE_RAW_DECL_UTIMENSAT
630_GL_WARN_ON_USE (utimensat, "utimensat is not portable - "
631 "use gnulib module utimensat for portability");
632# endif
633#endif
634
635
636#endif /* _GL_SYS_STAT_H */
637#endif /* _GL_SYS_STAT_H */
638#endif