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