1/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2/* Provide a more complete sys/stat header file.
3   Copyright (C) 2005-2012 Free Software Foundation, Inc.
4
5   This program is free software; you can redistribute it and/or modify
6   it under the terms of the GNU General Public License as published by
7   the Free Software Foundation; either version 3, or (at your option)
8   any later version.
9
10   This program is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   GNU General Public License for more details.
14
15   You should have received a copy of the GNU General Public License
16   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
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 GCC system_header
26#endif
27
28
29#if defined __need_system_sys_stat_h
30/* Special invocation convention.  */
31
32#include_next <sys/stat.h>
33
34#else
35/* Normal invocation convention.  */
36
37#ifndef _GL_SYS_STAT_H
38
39/* Get nlink_t.
40   May also define off_t to a 64-bit type on native Windows.  */
41#include <sys/types.h>
42
43/* Get struct timespec.  */
44#include <time.h>
45
46/* The include_next requires a split double-inclusion guard.  */
47#include_next <sys/stat.h>
48
49#ifndef _GL_SYS_STAT_H
50#define _GL_SYS_STAT_H
51
52/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
53#ifndef _GL_CXXDEFS_H
54#define _GL_CXXDEFS_H
55
56/* The three most frequent use cases of these macros are:
57
58   * For providing a substitute for a function that is missing on some
59     platforms, but is declared and works fine on the platforms on which
60     it exists:
61
62       #if @GNULIB_FOO@
63       # if !@HAVE_FOO@
64       _GL_FUNCDECL_SYS (foo, ...);
65       # endif
66       _GL_CXXALIAS_SYS (foo, ...);
67       _GL_CXXALIASWARN (foo);
68       #elif defined GNULIB_POSIXCHECK
69       ...
70       #endif
71
72   * For providing a replacement for a function that exists on all platforms,
73     but is broken/insufficient and needs to be replaced on some platforms:
74
75       #if @GNULIB_FOO@
76       # if @REPLACE_FOO@
77       #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
78       #   undef foo
79       #   define foo rpl_foo
80       #  endif
81       _GL_FUNCDECL_RPL (foo, ...);
82       _GL_CXXALIAS_RPL (foo, ...);
83       # else
84       _GL_CXXALIAS_SYS (foo, ...);
85       # endif
86       _GL_CXXALIASWARN (foo);
87       #elif defined GNULIB_POSIXCHECK
88       ...
89       #endif
90
91   * For providing a replacement for a function that exists on some platforms
92     but is broken/insufficient and needs to be replaced on some of them and
93     is additionally either missing or undeclared on some other platforms:
94
95       #if @GNULIB_FOO@
96       # if @REPLACE_FOO@
97       #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
98       #   undef foo
99       #   define foo rpl_foo
100       #  endif
101       _GL_FUNCDECL_RPL (foo, ...);
102       _GL_CXXALIAS_RPL (foo, ...);
103       # else
104       #  if !@HAVE_FOO@   or   if !@HAVE_DECL_FOO@
105       _GL_FUNCDECL_SYS (foo, ...);
106       #  endif
107       _GL_CXXALIAS_SYS (foo, ...);
108       # endif
109       _GL_CXXALIASWARN (foo);
110       #elif defined GNULIB_POSIXCHECK
111       ...
112       #endif
113*/
114
115/* _GL_EXTERN_C declaration;
116   performs the declaration with C linkage.  */
117#if defined __cplusplus
118# define _GL_EXTERN_C extern "C"
119#else
120# define _GL_EXTERN_C extern
121#endif
122
123/* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
124   declares a replacement function, named rpl_func, with the given prototype,
125   consisting of return type, parameters, and attributes.
126   Example:
127     _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
128                                  _GL_ARG_NONNULL ((1)));
129 */
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
134
135/* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
136   declares the system function, named func, with the given prototype,
137   consisting of return type, parameters, and attributes.
138   Example:
139     _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
140                                  _GL_ARG_NONNULL ((1)));
141 */
142#define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
143  _GL_EXTERN_C rettype func parameters_and_attributes
144
145/* _GL_CXXALIAS_RPL (func, rettype, parameters);
146   declares a C++ alias called GNULIB_NAMESPACE::func
147   that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
148   Example:
149     _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
150 */
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                                \
156    {                                                         \
157      rettype (*const func) parameters = ::rpl_func;          \
158    }                                                         \
159    _GL_EXTERN_C int _gl_cxxalias_dummy
160#else
161# define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
162    _GL_EXTERN_C int _gl_cxxalias_dummy
163#endif
164
165/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
166   is like  _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
167   except that the C function rpl_func may have a slightly different
168   declaration.  A cast is used to silence the "invalid conversion" error
169   that would otherwise occur.  */
170#if defined __cplusplus && defined GNULIB_NAMESPACE
171# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
172    namespace GNULIB_NAMESPACE                                     \
173    {                                                              \
174      rettype (*const func) parameters =                           \
175        reinterpret_cast<rettype(*)parameters>(::rpl_func);        \
176    }                                                              \
177    _GL_EXTERN_C int _gl_cxxalias_dummy
178#else
179# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
180    _GL_EXTERN_C int _gl_cxxalias_dummy
181#endif
182
183/* _GL_CXXALIAS_SYS (func, rettype, parameters);
184   declares a C++ alias called GNULIB_NAMESPACE::func
185   that redirects to the system provided function func, if GNULIB_NAMESPACE
186   is defined.
187   Example:
188     _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
189 */
190#if defined __cplusplus && defined GNULIB_NAMESPACE
191  /* If we were to write
192       rettype (*const func) parameters = ::func;
193     like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls
194     better (remove an indirection through a 'static' pointer variable),
195     but then the _GL_CXXALIASWARN macro below would cause a warning not only
196     for uses of ::func but also for uses of GNULIB_NAMESPACE::func.  */
197# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
198    namespace GNULIB_NAMESPACE                     \
199    {                                              \
200      static rettype (*func) parameters = ::func;  \
201    }                                              \
202    _GL_EXTERN_C int _gl_cxxalias_dummy
203#else
204# define _GL_CXXALIAS_SYS(func,rettype,parameters) \
205    _GL_EXTERN_C int _gl_cxxalias_dummy
206#endif
207
208/* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
209   is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
210   except that the C function func may have a slightly different declaration.
211   A cast is used to silence the "invalid conversion" error that would
212   otherwise occur.  */
213#if defined __cplusplus && defined GNULIB_NAMESPACE
214# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
215    namespace GNULIB_NAMESPACE                          \
216    {                                                   \
217      static rettype (*func) parameters =               \
218        reinterpret_cast<rettype(*)parameters>(::func); \
219    }                                                   \
220    _GL_EXTERN_C int _gl_cxxalias_dummy
221#else
222# define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
223    _GL_EXTERN_C int _gl_cxxalias_dummy
224#endif
225
226/* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
227   is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
228   except that the C function is picked among a set of overloaded functions,
229   namely the one with rettype2 and parameters2.  Two consecutive casts
230   are used to silence the "cannot find a match" and "invalid conversion"
231   errors that would otherwise occur.  */
232#if defined __cplusplus && defined GNULIB_NAMESPACE
233  /* The outer cast must be a reinterpret_cast.
234     The inner cast: When the function is defined as a set of overloaded
235     functions, it works as a static_cast<>, choosing the designated variant.
236     When the function is defined as a single variant, it works as a
237     reinterpret_cast<>. The parenthesized cast syntax works both ways.  */
238# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
239    namespace GNULIB_NAMESPACE                                                \
240    {                                                                         \
241      static rettype (*func) parameters =                                     \
242        reinterpret_cast<rettype(*)parameters>(                               \
243          (rettype2(*)parameters2)(::func));                                  \
244    }                                                                         \
245    _GL_EXTERN_C int _gl_cxxalias_dummy
246#else
247# define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
248    _GL_EXTERN_C int _gl_cxxalias_dummy
249#endif
250
251/* _GL_CXXALIASWARN (func);
252   causes a warning to be emitted when ::func is used but not when
253   GNULIB_NAMESPACE::func is used.  func must be defined without overloaded
254   variants.  */
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)
260/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
261   we enable the warning only when not optimizing.  */
262# if !__OPTIMIZE__
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
270# else
271#  define _GL_CXXALIASWARN_2(func,namespace) \
272     _GL_EXTERN_C int _gl_cxxalias_dummy
273# endif
274#else
275# define _GL_CXXALIASWARN(func) \
276    _GL_EXTERN_C int _gl_cxxalias_dummy
277#endif
278
279/* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
280   causes a warning to be emitted when the given overloaded variant of ::func
281   is used but not when GNULIB_NAMESPACE::func is used.  */
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, \
285                        GNULIB_NAMESPACE)
286# define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
287   _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
288/* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
289   we enable the warning only when not optimizing.  */
290# if !__OPTIMIZE__
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
298# else
299#  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
300     _GL_EXTERN_C int _gl_cxxalias_dummy
301# endif
302#else
303# define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
304    _GL_EXTERN_C int _gl_cxxalias_dummy
305#endif
306
307#endif /* _GL_CXXDEFS_H */
308
309/* The definition of _GL_ARG_NONNULL is copied here.  */
310/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
311   that the values passed as arguments n, ..., m must be non-NULL pointers.
312   n = 1 stands for the first argument, n = 2 for the second argument etc.  */
313#ifndef _GL_ARG_NONNULL
314# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
315#  define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
316# else
317#  define _GL_ARG_NONNULL(params)
318# endif
319#endif
320
321/* The definition of _GL_WARN_ON_USE is copied here.  */
322#ifndef _GL_WARN_ON_USE
323
324# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
325/* A compiler attribute is available in gcc versions 4.3.0 and later.  */
326#  define _GL_WARN_ON_USE(function, message) \
327extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
328# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
329/* Verify the existence of the function.  */
330#  define _GL_WARN_ON_USE(function, message) \
331extern __typeof__ (function) function
332# else /* Unsupported.  */
333#  define _GL_WARN_ON_USE(function, message) \
334_GL_WARN_EXTERN_C int _gl_warn_on_use
335# endif
336#endif
337
338/* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
339   is like _GL_WARN_ON_USE (function, "string"), except that the function is
340   declared with the given prototype, consisting of return type, parameters,
341   and attributes.
342   This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
343   not work in this case.  */
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) \
347extern rettype function parameters_and_attributes \
348     __attribute__ ((__warning__ (msg)))
349# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
350/* Verify the existence of the function.  */
351#  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
352extern rettype function parameters_and_attributes
353# else /* Unsupported.  */
354#  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
355_GL_WARN_EXTERN_C int _gl_warn_on_use
356# endif
357#endif
358
359/* _GL_WARN_EXTERN_C declaration;
360   performs the declaration with C linkage.  */
361#ifndef _GL_WARN_EXTERN_C
362# if defined __cplusplus
363#  define _GL_WARN_EXTERN_C extern "C"
364# else
365#  define _GL_WARN_EXTERN_C extern
366# endif
367#endif
368
369/* Before doing "#define mkdir rpl_mkdir" below, we need to include all
370   headers that may declare mkdir().  Native Windows platforms declare mkdir
371   in <io.h> and/or <direct.h>, not in <unistd.h>.  */
372#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
373# include <io.h>     /* mingw32, mingw64 */
374# include <direct.h> /* mingw64, MSVC 9 */
375#endif
376
377/* Native Windows platforms declare umask() in <io.h>.  */
378#if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
379# include <io.h>
380#endif
381
382/* Large File Support on native Windows.  */
383#if 0
384# define stat _stati64
385#endif
386
387#ifndef S_IFIFO
388# ifdef _S_IFIFO
389#  define S_IFIFO _S_IFIFO
390# endif
391#endif
392
393#ifndef S_IFMT
394# define S_IFMT 0170000
395#endif
396
397#if STAT_MACROS_BROKEN
398# undef S_ISBLK
399# undef S_ISCHR
400# undef S_ISDIR
401# undef S_ISFIFO
402# undef S_ISLNK
403# undef S_ISNAM
404# undef S_ISMPB
405# undef S_ISMPC
406# undef S_ISNWK
407# undef S_ISREG
408# undef S_ISSOCK
409#endif
410
411#ifndef S_ISBLK
412# ifdef S_IFBLK
413#  define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
414# else
415#  define S_ISBLK(m) 0
416# endif
417#endif
418
419#ifndef S_ISCHR
420# ifdef S_IFCHR
421#  define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
422# else
423#  define S_ISCHR(m) 0
424# endif
425#endif
426
427#ifndef S_ISDIR
428# ifdef S_IFDIR
429#  define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
430# else
431#  define S_ISDIR(m) 0
432# endif
433#endif
434
435#ifndef S_ISDOOR /* Solaris 2.5 and up */
436# define S_ISDOOR(m) 0
437#endif
438
439#ifndef S_ISFIFO
440# ifdef S_IFIFO
441#  define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
442# else
443#  define S_ISFIFO(m) 0
444# endif
445#endif
446
447#ifndef S_ISLNK
448# ifdef S_IFLNK
449#  define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
450# else
451#  define S_ISLNK(m) 0
452# endif
453#endif
454
455#ifndef S_ISMPB /* V7 */
456# ifdef S_IFMPB
457#  define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
458#  define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
459# else
460#  define S_ISMPB(m) 0
461#  define S_ISMPC(m) 0
462# endif
463#endif
464
465#ifndef S_ISNAM /* Xenix */
466# ifdef S_IFNAM
467#  define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
468# else
469#  define S_ISNAM(m) 0
470# endif
471#endif
472
473#ifndef S_ISNWK /* HP/UX */
474# ifdef S_IFNWK
475#  define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
476# else
477#  define S_ISNWK(m) 0
478# endif
479#endif
480
481#ifndef S_ISPORT /* Solaris 10 and up */
482# define S_ISPORT(m) 0
483#endif
484
485#ifndef S_ISREG
486# ifdef S_IFREG
487#  define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
488# else
489#  define S_ISREG(m) 0
490# endif
491#endif
492
493#ifndef S_ISSOCK
494# ifdef S_IFSOCK
495#  define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
496# else
497#  define S_ISSOCK(m) 0
498# endif
499#endif
500
501
502#ifndef S_TYPEISMQ
503# define S_TYPEISMQ(p) 0
504#endif
505
506#ifndef S_TYPEISTMO
507# define S_TYPEISTMO(p) 0
508#endif
509
510
511#ifndef S_TYPEISSEM
512# ifdef S_INSEM
513#  define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
514# else
515#  define S_TYPEISSEM(p) 0
516# endif
517#endif
518
519#ifndef S_TYPEISSHM
520# ifdef S_INSHD
521#  define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
522# else
523#  define S_TYPEISSHM(p) 0
524# endif
525#endif
526
527/* high performance ("contiguous data") */
528#ifndef S_ISCTG
529# define S_ISCTG(p) 0
530#endif
531
532/* Cray DMF (data migration facility): off line, with data  */
533#ifndef S_ISOFD
534# define S_ISOFD(p) 0
535#endif
536
537/* Cray DMF (data migration facility): off line, with no data  */
538#ifndef S_ISOFL
539# define S_ISOFL(p) 0
540#endif
541
542/* 4.4BSD whiteout */
543#ifndef S_ISWHT
544# define S_ISWHT(m) 0
545#endif
546
547/* If any of the following are undefined,
548   define them to their de facto standard values.  */
549#if !S_ISUID
550# define S_ISUID 04000
551#endif
552#if !S_ISGID
553# define S_ISGID 02000
554#endif
555
556/* S_ISVTX is a common extension to POSIX.  */
557#ifndef S_ISVTX
558# define S_ISVTX 01000
559#endif
560
561#if !S_IRUSR && S_IREAD
562# define S_IRUSR S_IREAD
563#endif
564#if !S_IRUSR
565# define S_IRUSR 00400
566#endif
567#if !S_IRGRP
568# define S_IRGRP (S_IRUSR >> 3)
569#endif
570#if !S_IROTH
571# define S_IROTH (S_IRUSR >> 6)
572#endif
573
574#if !S_IWUSR && S_IWRITE
575# define S_IWUSR S_IWRITE
576#endif
577#if !S_IWUSR
578# define S_IWUSR 00200
579#endif
580#if !S_IWGRP
581# define S_IWGRP (S_IWUSR >> 3)
582#endif
583#if !S_IWOTH
584# define S_IWOTH (S_IWUSR >> 6)
585#endif
586
587#if !S_IXUSR && S_IEXEC
588# define S_IXUSR S_IEXEC
589#endif
590#if !S_IXUSR
591# define S_IXUSR 00100
592#endif
593#if !S_IXGRP
594# define S_IXGRP (S_IXUSR >> 3)
595#endif
596#if !S_IXOTH
597# define S_IXOTH (S_IXUSR >> 6)
598#endif
599
600#if !S_IRWXU
601# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
602#endif
603#if !S_IRWXG
604# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
605#endif
606#if !S_IRWXO
607# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
608#endif
609
610/* S_IXUGO is a common extension to POSIX.  */
611#if !S_IXUGO
612# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
613#endif
614
615#ifndef S_IRWXUGO
616# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
617#endif
618
619/* Macros for futimens and utimensat.  */
620#ifndef UTIME_NOW
621# define UTIME_NOW (-1)
622# define UTIME_OMIT (-2)
623#endif
624
625
626#if 0
627# if !1
628_GL_FUNCDECL_SYS (fchmodat, int,
629                  (int fd, char const *file, mode_t mode, int flag)
630                  _GL_ARG_NONNULL ((2)));
631# endif
632_GL_CXXALIAS_SYS (fchmodat, int,
633                  (int fd, char const *file, mode_t mode, int flag));
634_GL_CXXALIASWARN (fchmodat);
635#elif defined GNULIB_POSIXCHECK
636# undef fchmodat
637# if HAVE_RAW_DECL_FCHMODAT
638_GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - "
639                 "use gnulib module openat for portability");
640# endif
641#endif
642
643
644#if 1
645# if 0
646#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
647#   undef fstat
648#   define fstat rpl_fstat
649#  endif
650_GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2)));
651_GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
652# else
653_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
654# endif
655_GL_CXXALIASWARN (fstat);
656#elif 0
657/* Above, we define stat to _stati64.  */
658# define fstat _fstati64
659#elif defined GNULIB_POSIXCHECK
660# undef fstat
661# if HAVE_RAW_DECL_FSTAT
662_GL_WARN_ON_USE (fstat, "fstat has portability problems - "
663                 "use gnulib module fstat for portability");
664# endif
665#endif
666
667
668#if 0
669# if 0
670#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
671#   undef fstatat
672#   define fstatat rpl_fstatat
673#  endif
674_GL_FUNCDECL_RPL (fstatat, int,
675                  (int fd, char const *name, struct stat *st, int flags)
676                  _GL_ARG_NONNULL ((2, 3)));
677_GL_CXXALIAS_RPL (fstatat, int,
678                  (int fd, char const *name, struct stat *st, int flags));
679# else
680#  if !1
681_GL_FUNCDECL_SYS (fstatat, int,
682                  (int fd, char const *name, struct stat *st, int flags)
683                  _GL_ARG_NONNULL ((2, 3)));
684#  endif
685_GL_CXXALIAS_SYS (fstatat, int,
686                  (int fd, char const *name, struct stat *st, int flags));
687# endif
688_GL_CXXALIASWARN (fstatat);
689#elif defined GNULIB_POSIXCHECK
690# undef fstatat
691# if HAVE_RAW_DECL_FSTATAT
692_GL_WARN_ON_USE (fstatat, "fstatat is not portable - "
693                 "use gnulib module openat for portability");
694# endif
695#endif
696
697
698#if 0
699/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our futimens
700   implementation relies on futimesat, which on Solaris 10 makes an invocation
701   to futimens that is meant to invoke the libc's futimens(), not gnulib's
702   futimens().  */
703# if 0 || (!1 && defined __sun)
704#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
705#   undef futimens
706#   define futimens rpl_futimens
707#  endif
708_GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2]));
709_GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2]));
710# else
711#  if !1
712_GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2]));
713#  endif
714_GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2]));
715# endif
716# if 1
717_GL_CXXALIASWARN (futimens);
718# endif
719#elif defined GNULIB_POSIXCHECK
720# undef futimens
721# if HAVE_RAW_DECL_FUTIMENS
722_GL_WARN_ON_USE (futimens, "futimens is not portable - "
723                 "use gnulib module futimens for portability");
724# endif
725#endif
726
727
728#if 0
729/* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
730   denotes a symbolic link.  */
731# if !1
732/* The lchmod replacement follows symbolic links.  Callers should take
733   this into account; lchmod should be applied only to arguments that
734   are known to not be symbolic links.  On hosts that lack lchmod,
735   this can lead to race conditions between the check and the
736   invocation of lchmod, but we know of no workarounds that are
737   reliable in general.  You might try requesting support for lchmod
738   from your operating system supplier.  */
739#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
740#   define lchmod chmod
741#  endif
742/* Need to cast, because on mingw, the second parameter of chmod is
743                                                int mode.  */
744_GL_CXXALIAS_RPL_CAST_1 (lchmod, chmod, int,
745                         (const char *filename, mode_t mode));
746# else
747#  if 0 /* assume already declared */
748_GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode)
749                               _GL_ARG_NONNULL ((1)));
750#  endif
751_GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode));
752# endif
753# if 1
754_GL_CXXALIASWARN (lchmod);
755# endif
756#elif defined GNULIB_POSIXCHECK
757# undef lchmod
758# if HAVE_RAW_DECL_LCHMOD
759_GL_WARN_ON_USE (lchmod, "lchmod is unportable - "
760                 "use gnulib module lchmod for portability");
761# endif
762#endif
763
764
765#if 0
766# if ! 1
767/* mingw does not support symlinks, therefore it does not have lstat.  But
768   without links, stat does just fine.  */
769#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
770#   define lstat stat
771#  endif
772_GL_CXXALIAS_RPL_1 (lstat, stat, int, (const char *name, struct stat *buf));
773# elif 0
774#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
775#   undef lstat
776#   define lstat rpl_lstat
777#  endif
778_GL_FUNCDECL_RPL (lstat, int, (const char *name, struct stat *buf)
779                              _GL_ARG_NONNULL ((1, 2)));
780_GL_CXXALIAS_RPL (lstat, int, (const char *name, struct stat *buf));
781# else
782_GL_CXXALIAS_SYS (lstat, int, (const char *name, struct stat *buf));
783# endif
784# if 1
785_GL_CXXALIASWARN (lstat);
786# endif
787#elif defined GNULIB_POSIXCHECK
788# undef lstat
789# if HAVE_RAW_DECL_LSTAT
790_GL_WARN_ON_USE (lstat, "lstat is unportable - "
791                 "use gnulib module lstat for portability");
792# endif
793#endif
794
795
796#if 0
797# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
798#  undef mkdir
799#  define mkdir rpl_mkdir
800# endif
801_GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode)
802                              _GL_ARG_NONNULL ((1)));
803_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
804#else
805/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
806   Additionally, it declares _mkdir (and depending on compile flags, an
807   alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
808   which are included above.  */
809# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
810
811#  if !GNULIB_defined_rpl_mkdir
812static int
813rpl_mkdir (char const *name, mode_t mode)
814{
815  return _mkdir (name);
816}
817#   define GNULIB_defined_rpl_mkdir 1
818#  endif
819
820#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
821#   define mkdir rpl_mkdir
822#  endif
823_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
824# else
825_GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
826# endif
827#endif
828_GL_CXXALIASWARN (mkdir);
829
830
831#if 0
832# if !1
833_GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)
834                                _GL_ARG_NONNULL ((2)));
835# endif
836_GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode));
837_GL_CXXALIASWARN (mkdirat);
838#elif defined GNULIB_POSIXCHECK
839# undef mkdirat
840# if HAVE_RAW_DECL_MKDIRAT
841_GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - "
842                 "use gnulib module openat for portability");
843# endif
844#endif
845
846
847#if 0
848# if 0
849#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
850#   undef mkfifo
851#   define mkfifo rpl_mkfifo
852#  endif
853_GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode)
854                               _GL_ARG_NONNULL ((1)));
855_GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode));
856# else
857#  if !1
858_GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode)
859                               _GL_ARG_NONNULL ((1)));
860#  endif
861_GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode));
862# endif
863_GL_CXXALIASWARN (mkfifo);
864#elif defined GNULIB_POSIXCHECK
865# undef mkfifo
866# if HAVE_RAW_DECL_MKFIFO
867_GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - "
868                 "use gnulib module mkfifo for portability");
869# endif
870#endif
871
872
873#if 0
874# if !1
875_GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)
876                                 _GL_ARG_NONNULL ((2)));
877# endif
878_GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode));
879_GL_CXXALIASWARN (mkfifoat);
880#elif defined GNULIB_POSIXCHECK
881# undef mkfifoat
882# if HAVE_RAW_DECL_MKFIFOAT
883_GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - "
884                 "use gnulib module mkfifoat for portability");
885# endif
886#endif
887
888
889#if 0
890# if 0
891#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
892#   undef mknod
893#   define mknod rpl_mknod
894#  endif
895_GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)
896                              _GL_ARG_NONNULL ((1)));
897_GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev));
898# else
899#  if !1
900_GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev)
901                              _GL_ARG_NONNULL ((1)));
902#  endif
903/* Need to cast, because on OSF/1 5.1, the third parameter is '...'.  */
904_GL_CXXALIAS_SYS_CAST (mknod, int, (char const *file, mode_t mode, dev_t dev));
905# endif
906_GL_CXXALIASWARN (mknod);
907#elif defined GNULIB_POSIXCHECK
908# undef mknod
909# if HAVE_RAW_DECL_MKNOD
910_GL_WARN_ON_USE (mknod, "mknod is not portable - "
911                 "use gnulib module mknod for portability");
912# endif
913#endif
914
915
916#if 0
917# if !1
918_GL_FUNCDECL_SYS (mknodat, int,
919                  (int fd, char const *file, mode_t mode, dev_t dev)
920                  _GL_ARG_NONNULL ((2)));
921# endif
922_GL_CXXALIAS_SYS (mknodat, int,
923                  (int fd, char const *file, mode_t mode, dev_t dev));
924_GL_CXXALIASWARN (mknodat);
925#elif defined GNULIB_POSIXCHECK
926# undef mknodat
927# if HAVE_RAW_DECL_MKNODAT
928_GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
929                 "use gnulib module mkfifoat for portability");
930# endif
931#endif
932
933
934#if 1
935# if 1
936/* We can't use the object-like #define stat rpl_stat, because of
937   struct stat.  This means that rpl_stat will not be used if the user
938   does (stat)(a,b).  Oh well.  */
939#  if defined _AIX && defined stat && defined _LARGE_FILES
940    /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
941       so we have to replace stat64() instead of stat(). */
942#   undef stat64
943#   define stat64(name, st) rpl_stat (name, st)
944#  elif 0
945    /* Above, we define stat to _stati64.  */
946#   if defined __MINGW32__ && defined _stati64
947#    ifndef _USE_32BIT_TIME_T
948      /* The system headers define _stati64 to _stat64.  */
949#     undef _stat64
950#     define _stat64(name, st) rpl_stat (name, st)
951#    endif
952#   elif defined _MSC_VER && defined _stati64
953#    ifdef _USE_32BIT_TIME_T
954      /* The system headers define _stati64 to _stat32i64.  */
955#     undef _stat32i64
956#     define _stat32i64(name, st) rpl_stat (name, st)
957#    else
958      /* The system headers define _stati64 to _stat64.  */
959#     undef _stat64
960#     define _stat64(name, st) rpl_stat (name, st)
961#    endif
962#   else
963#    undef _stati64
964#    define _stati64(name, st) rpl_stat (name, st)
965#   endif
966#  elif defined __MINGW32__ && defined stat
967#   ifdef _USE_32BIT_TIME_T
968     /* The system headers define stat to _stat32i64.  */
969#    undef _stat32i64
970#    define _stat32i64(name, st) rpl_stat (name, st)
971#   else
972     /* The system headers define stat to _stat64.  */
973#    undef _stat64
974#    define _stat64(name, st) rpl_stat (name, st)
975#   endif
976#  elif defined _MSC_VER && defined stat
977#   ifdef _USE_32BIT_TIME_T
978     /* The system headers define stat to _stat32.  */
979#    undef _stat32
980#    define _stat32(name, st) rpl_stat (name, st)
981#   else
982     /* The system headers define stat to _stat64i32.  */
983#    undef _stat64i32
984#    define _stat64i32(name, st) rpl_stat (name, st)
985#   endif
986#  else /* !(_AIX ||__MINGW32__ ||  _MSC_VER) */
987#   undef stat
988#   define stat(name, st) rpl_stat (name, st)
989#  endif /* !_LARGE_FILES */
990_GL_EXTERN_C int stat (const char *name, struct stat *buf)
991                      _GL_ARG_NONNULL ((1, 2));
992# endif
993#elif defined GNULIB_POSIXCHECK
994# undef stat
995# if HAVE_RAW_DECL_STAT
996_GL_WARN_ON_USE (stat, "stat is unportable - "
997                 "use gnulib module stat for portability");
998# endif
999#endif
1000
1001
1002#if 0
1003/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat
1004   implementation relies on futimesat, which on Solaris 10 makes an invocation
1005   to utimensat that is meant to invoke the libc's utimensat(), not gnulib's
1006   utimensat().  */
1007# if 0 || (!1 && defined __sun)
1008#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1009#   undef utimensat
1010#   define utimensat rpl_utimensat
1011#  endif
1012_GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name,
1013                                   struct timespec const times[2], int flag)
1014                                  _GL_ARG_NONNULL ((2)));
1015_GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name,
1016                                   struct timespec const times[2], int flag));
1017# else
1018#  if !1
1019_GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name,
1020                                   struct timespec const times[2], int flag)
1021                                  _GL_ARG_NONNULL ((2)));
1022#  endif
1023_GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name,
1024                                   struct timespec const times[2], int flag));
1025# endif
1026# if 1
1027_GL_CXXALIASWARN (utimensat);
1028# endif
1029#elif defined GNULIB_POSIXCHECK
1030# undef utimensat
1031# if HAVE_RAW_DECL_UTIMENSAT
1032_GL_WARN_ON_USE (utimensat, "utimensat is not portable - "
1033                 "use gnulib module utimensat for portability");
1034# endif
1035#endif
1036
1037
1038#endif /* _GL_SYS_STAT_H */
1039#endif /* _GL_SYS_STAT_H */
1040#endif
1041