diff utils: Update from version 3.2 to 3.3
[dragonfly.git] / gnu / usr.bin / diff / libdiffutils / sys / stat.h
1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* Provide a more complete sys/stat header file.
3    Copyright (C) 2005-2013 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) \
327 extern __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) \
331 extern __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) \
347 extern 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) \
352 extern 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_ISMPX /* AIX */
466 # define S_ISMPX(m) 0
467 #endif
468
469 #ifndef S_ISNAM /* Xenix */
470 # ifdef S_IFNAM
471 #  define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
472 # else
473 #  define S_ISNAM(m) 0
474 # endif
475 #endif
476
477 #ifndef S_ISNWK /* HP/UX */
478 # ifdef S_IFNWK
479 #  define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
480 # else
481 #  define S_ISNWK(m) 0
482 # endif
483 #endif
484
485 #ifndef S_ISPORT /* Solaris 10 and up */
486 # define S_ISPORT(m) 0
487 #endif
488
489 #ifndef S_ISREG
490 # ifdef S_IFREG
491 #  define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
492 # else
493 #  define S_ISREG(m) 0
494 # endif
495 #endif
496
497 #ifndef S_ISSOCK
498 # ifdef S_IFSOCK
499 #  define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
500 # else
501 #  define S_ISSOCK(m) 0
502 # endif
503 #endif
504
505
506 #ifndef S_TYPEISMQ
507 # define S_TYPEISMQ(p) 0
508 #endif
509
510 #ifndef S_TYPEISTMO
511 # define S_TYPEISTMO(p) 0
512 #endif
513
514
515 #ifndef S_TYPEISSEM
516 # ifdef S_INSEM
517 #  define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
518 # else
519 #  define S_TYPEISSEM(p) 0
520 # endif
521 #endif
522
523 #ifndef S_TYPEISSHM
524 # ifdef S_INSHD
525 #  define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
526 # else
527 #  define S_TYPEISSHM(p) 0
528 # endif
529 #endif
530
531 /* high performance ("contiguous data") */
532 #ifndef S_ISCTG
533 # define S_ISCTG(p) 0
534 #endif
535
536 /* Cray DMF (data migration facility): off line, with data  */
537 #ifndef S_ISOFD
538 # define S_ISOFD(p) 0
539 #endif
540
541 /* Cray DMF (data migration facility): off line, with no data  */
542 #ifndef S_ISOFL
543 # define S_ISOFL(p) 0
544 #endif
545
546 /* 4.4BSD whiteout */
547 #ifndef S_ISWHT
548 # define S_ISWHT(m) 0
549 #endif
550
551 /* If any of the following are undefined,
552    define them to their de facto standard values.  */
553 #if !S_ISUID
554 # define S_ISUID 04000
555 #endif
556 #if !S_ISGID
557 # define S_ISGID 02000
558 #endif
559
560 /* S_ISVTX is a common extension to POSIX.  */
561 #ifndef S_ISVTX
562 # define S_ISVTX 01000
563 #endif
564
565 #if !S_IRUSR && S_IREAD
566 # define S_IRUSR S_IREAD
567 #endif
568 #if !S_IRUSR
569 # define S_IRUSR 00400
570 #endif
571 #if !S_IRGRP
572 # define S_IRGRP (S_IRUSR >> 3)
573 #endif
574 #if !S_IROTH
575 # define S_IROTH (S_IRUSR >> 6)
576 #endif
577
578 #if !S_IWUSR && S_IWRITE
579 # define S_IWUSR S_IWRITE
580 #endif
581 #if !S_IWUSR
582 # define S_IWUSR 00200
583 #endif
584 #if !S_IWGRP
585 # define S_IWGRP (S_IWUSR >> 3)
586 #endif
587 #if !S_IWOTH
588 # define S_IWOTH (S_IWUSR >> 6)
589 #endif
590
591 #if !S_IXUSR && S_IEXEC
592 # define S_IXUSR S_IEXEC
593 #endif
594 #if !S_IXUSR
595 # define S_IXUSR 00100
596 #endif
597 #if !S_IXGRP
598 # define S_IXGRP (S_IXUSR >> 3)
599 #endif
600 #if !S_IXOTH
601 # define S_IXOTH (S_IXUSR >> 6)
602 #endif
603
604 #if !S_IRWXU
605 # define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
606 #endif
607 #if !S_IRWXG
608 # define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
609 #endif
610 #if !S_IRWXO
611 # define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
612 #endif
613
614 /* S_IXUGO is a common extension to POSIX.  */
615 #if !S_IXUGO
616 # define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
617 #endif
618
619 #ifndef S_IRWXUGO
620 # define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
621 #endif
622
623 /* Macros for futimens and utimensat.  */
624 #ifndef UTIME_NOW
625 # define UTIME_NOW (-1)
626 # define UTIME_OMIT (-2)
627 #endif
628
629
630 #if 0
631 # if !1
632 _GL_FUNCDECL_SYS (fchmodat, int,
633                   (int fd, char const *file, mode_t mode, int flag)
634                   _GL_ARG_NONNULL ((2)));
635 # endif
636 _GL_CXXALIAS_SYS (fchmodat, int,
637                   (int fd, char const *file, mode_t mode, int flag));
638 _GL_CXXALIASWARN (fchmodat);
639 #elif defined GNULIB_POSIXCHECK
640 # undef fchmodat
641 # if HAVE_RAW_DECL_FCHMODAT
642 _GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - "
643                  "use gnulib module openat for portability");
644 # endif
645 #endif
646
647
648 #if 1
649 # if 0
650 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
651 #   undef fstat
652 #   define fstat rpl_fstat
653 #  endif
654 _GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2)));
655 _GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
656 # else
657 _GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
658 # endif
659 _GL_CXXALIASWARN (fstat);
660 #elif 0
661 /* Above, we define stat to _stati64.  */
662 # define fstat _fstati64
663 #elif defined GNULIB_POSIXCHECK
664 # undef fstat
665 # if HAVE_RAW_DECL_FSTAT
666 _GL_WARN_ON_USE (fstat, "fstat has portability problems - "
667                  "use gnulib module fstat for portability");
668 # endif
669 #endif
670
671
672 #if 0
673 # if 0
674 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
675 #   undef fstatat
676 #   define fstatat rpl_fstatat
677 #  endif
678 _GL_FUNCDECL_RPL (fstatat, int,
679                   (int fd, char const *name, struct stat *st, int flags)
680                   _GL_ARG_NONNULL ((2, 3)));
681 _GL_CXXALIAS_RPL (fstatat, int,
682                   (int fd, char const *name, struct stat *st, int flags));
683 # else
684 #  if !1
685 _GL_FUNCDECL_SYS (fstatat, int,
686                   (int fd, char const *name, struct stat *st, int flags)
687                   _GL_ARG_NONNULL ((2, 3)));
688 #  endif
689 _GL_CXXALIAS_SYS (fstatat, int,
690                   (int fd, char const *name, struct stat *st, int flags));
691 # endif
692 _GL_CXXALIASWARN (fstatat);
693 #elif defined GNULIB_POSIXCHECK
694 # undef fstatat
695 # if HAVE_RAW_DECL_FSTATAT
696 _GL_WARN_ON_USE (fstatat, "fstatat is not portable - "
697                  "use gnulib module openat for portability");
698 # endif
699 #endif
700
701
702 #if 0
703 /* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our futimens
704    implementation relies on futimesat, which on Solaris 10 makes an invocation
705    to futimens that is meant to invoke the libc's futimens(), not gnulib's
706    futimens().  */
707 # if 0 || (!1 && defined __sun)
708 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
709 #   undef futimens
710 #   define futimens rpl_futimens
711 #  endif
712 _GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2]));
713 _GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2]));
714 # else
715 #  if !1
716 _GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2]));
717 #  endif
718 _GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2]));
719 # endif
720 # if 1
721 _GL_CXXALIASWARN (futimens);
722 # endif
723 #elif defined GNULIB_POSIXCHECK
724 # undef futimens
725 # if HAVE_RAW_DECL_FUTIMENS
726 _GL_WARN_ON_USE (futimens, "futimens is not portable - "
727                  "use gnulib module futimens for portability");
728 # endif
729 #endif
730
731
732 #if 0
733 /* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
734    denotes a symbolic link.  */
735 # if !1
736 /* The lchmod replacement follows symbolic links.  Callers should take
737    this into account; lchmod should be applied only to arguments that
738    are known to not be symbolic links.  On hosts that lack lchmod,
739    this can lead to race conditions between the check and the
740    invocation of lchmod, but we know of no workarounds that are
741    reliable in general.  You might try requesting support for lchmod
742    from your operating system supplier.  */
743 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
744 #   define lchmod chmod
745 #  endif
746 /* Need to cast, because on mingw, the second parameter of chmod is
747                                                 int mode.  */
748 _GL_CXXALIAS_RPL_CAST_1 (lchmod, chmod, int,
749                          (const char *filename, mode_t mode));
750 # else
751 #  if 0 /* assume already declared */
752 _GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode)
753                                _GL_ARG_NONNULL ((1)));
754 #  endif
755 _GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode));
756 # endif
757 # if 1
758 _GL_CXXALIASWARN (lchmod);
759 # endif
760 #elif defined GNULIB_POSIXCHECK
761 # undef lchmod
762 # if HAVE_RAW_DECL_LCHMOD
763 _GL_WARN_ON_USE (lchmod, "lchmod is unportable - "
764                  "use gnulib module lchmod for portability");
765 # endif
766 #endif
767
768
769 #if 1
770 # if ! 1
771 /* mingw does not support symlinks, therefore it does not have lstat.  But
772    without links, stat does just fine.  */
773 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
774 #   define lstat stat
775 #  endif
776 _GL_CXXALIAS_RPL_1 (lstat, stat, int, (const char *name, struct stat *buf));
777 # elif 0
778 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
779 #   undef lstat
780 #   define lstat rpl_lstat
781 #  endif
782 _GL_FUNCDECL_RPL (lstat, int, (const char *name, struct stat *buf)
783                               _GL_ARG_NONNULL ((1, 2)));
784 _GL_CXXALIAS_RPL (lstat, int, (const char *name, struct stat *buf));
785 # else
786 _GL_CXXALIAS_SYS (lstat, int, (const char *name, struct stat *buf));
787 # endif
788 # if 1
789 _GL_CXXALIASWARN (lstat);
790 # endif
791 #elif defined GNULIB_POSIXCHECK
792 # undef lstat
793 # if HAVE_RAW_DECL_LSTAT
794 _GL_WARN_ON_USE (lstat, "lstat is unportable - "
795                  "use gnulib module lstat for portability");
796 # endif
797 #endif
798
799
800 #if 0
801 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
802 #  undef mkdir
803 #  define mkdir rpl_mkdir
804 # endif
805 _GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode)
806                               _GL_ARG_NONNULL ((1)));
807 _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
808 #else
809 /* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
810    Additionally, it declares _mkdir (and depending on compile flags, an
811    alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
812    which are included above.  */
813 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
814
815 #  if !GNULIB_defined_rpl_mkdir
816 static int
817 rpl_mkdir (char const *name, mode_t mode)
818 {
819   return _mkdir (name);
820 }
821 #   define GNULIB_defined_rpl_mkdir 1
822 #  endif
823
824 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
825 #   define mkdir rpl_mkdir
826 #  endif
827 _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
828 # else
829 _GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
830 # endif
831 #endif
832 _GL_CXXALIASWARN (mkdir);
833
834
835 #if 0
836 # if !1
837 _GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)
838                                 _GL_ARG_NONNULL ((2)));
839 # endif
840 _GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode));
841 _GL_CXXALIASWARN (mkdirat);
842 #elif defined GNULIB_POSIXCHECK
843 # undef mkdirat
844 # if HAVE_RAW_DECL_MKDIRAT
845 _GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - "
846                  "use gnulib module openat for portability");
847 # endif
848 #endif
849
850
851 #if 0
852 # if 0
853 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
854 #   undef mkfifo
855 #   define mkfifo rpl_mkfifo
856 #  endif
857 _GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode)
858                                _GL_ARG_NONNULL ((1)));
859 _GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode));
860 # else
861 #  if !1
862 _GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode)
863                                _GL_ARG_NONNULL ((1)));
864 #  endif
865 _GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode));
866 # endif
867 _GL_CXXALIASWARN (mkfifo);
868 #elif defined GNULIB_POSIXCHECK
869 # undef mkfifo
870 # if HAVE_RAW_DECL_MKFIFO
871 _GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - "
872                  "use gnulib module mkfifo for portability");
873 # endif
874 #endif
875
876
877 #if 0
878 # if !1
879 _GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)
880                                  _GL_ARG_NONNULL ((2)));
881 # endif
882 _GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode));
883 _GL_CXXALIASWARN (mkfifoat);
884 #elif defined GNULIB_POSIXCHECK
885 # undef mkfifoat
886 # if HAVE_RAW_DECL_MKFIFOAT
887 _GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - "
888                  "use gnulib module mkfifoat for portability");
889 # endif
890 #endif
891
892
893 #if 0
894 # if 0
895 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
896 #   undef mknod
897 #   define mknod rpl_mknod
898 #  endif
899 _GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)
900                               _GL_ARG_NONNULL ((1)));
901 _GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev));
902 # else
903 #  if !1
904 _GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev)
905                               _GL_ARG_NONNULL ((1)));
906 #  endif
907 /* Need to cast, because on OSF/1 5.1, the third parameter is '...'.  */
908 _GL_CXXALIAS_SYS_CAST (mknod, int, (char const *file, mode_t mode, dev_t dev));
909 # endif
910 _GL_CXXALIASWARN (mknod);
911 #elif defined GNULIB_POSIXCHECK
912 # undef mknod
913 # if HAVE_RAW_DECL_MKNOD
914 _GL_WARN_ON_USE (mknod, "mknod is not portable - "
915                  "use gnulib module mknod for portability");
916 # endif
917 #endif
918
919
920 #if 0
921 # if !1
922 _GL_FUNCDECL_SYS (mknodat, int,
923                   (int fd, char const *file, mode_t mode, dev_t dev)
924                   _GL_ARG_NONNULL ((2)));
925 # endif
926 _GL_CXXALIAS_SYS (mknodat, int,
927                   (int fd, char const *file, mode_t mode, dev_t dev));
928 _GL_CXXALIASWARN (mknodat);
929 #elif defined GNULIB_POSIXCHECK
930 # undef mknodat
931 # if HAVE_RAW_DECL_MKNODAT
932 _GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
933                  "use gnulib module mkfifoat for portability");
934 # endif
935 #endif
936
937
938 #if 1
939 # if 0
940 /* We can't use the object-like #define stat rpl_stat, because of
941    struct stat.  This means that rpl_stat will not be used if the user
942    does (stat)(a,b).  Oh well.  */
943 #  if defined _AIX && defined stat && defined _LARGE_FILES
944     /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
945        so we have to replace stat64() instead of stat(). */
946 #   undef stat64
947 #   define stat64(name, st) rpl_stat (name, st)
948 #  elif 0
949     /* Above, we define stat to _stati64.  */
950 #   if defined __MINGW32__ && defined _stati64
951 #    ifndef _USE_32BIT_TIME_T
952       /* The system headers define _stati64 to _stat64.  */
953 #     undef _stat64
954 #     define _stat64(name, st) rpl_stat (name, st)
955 #    endif
956 #   elif defined _MSC_VER && defined _stati64
957 #    ifdef _USE_32BIT_TIME_T
958       /* The system headers define _stati64 to _stat32i64.  */
959 #     undef _stat32i64
960 #     define _stat32i64(name, st) rpl_stat (name, st)
961 #    else
962       /* The system headers define _stati64 to _stat64.  */
963 #     undef _stat64
964 #     define _stat64(name, st) rpl_stat (name, st)
965 #    endif
966 #   else
967 #    undef _stati64
968 #    define _stati64(name, st) rpl_stat (name, st)
969 #   endif
970 #  elif defined __MINGW32__ && defined stat
971 #   ifdef _USE_32BIT_TIME_T
972      /* The system headers define stat to _stat32i64.  */
973 #    undef _stat32i64
974 #    define _stat32i64(name, st) rpl_stat (name, st)
975 #   else
976      /* The system headers define stat to _stat64.  */
977 #    undef _stat64
978 #    define _stat64(name, st) rpl_stat (name, st)
979 #   endif
980 #  elif defined _MSC_VER && defined stat
981 #   ifdef _USE_32BIT_TIME_T
982      /* The system headers define stat to _stat32.  */
983 #    undef _stat32
984 #    define _stat32(name, st) rpl_stat (name, st)
985 #   else
986      /* The system headers define stat to _stat64i32.  */
987 #    undef _stat64i32
988 #    define _stat64i32(name, st) rpl_stat (name, st)
989 #   endif
990 #  else /* !(_AIX ||__MINGW32__ ||  _MSC_VER) */
991 #   undef stat
992 #   define stat(name, st) rpl_stat (name, st)
993 #  endif /* !_LARGE_FILES */
994 _GL_EXTERN_C int stat (const char *name, struct stat *buf)
995                       _GL_ARG_NONNULL ((1, 2));
996 # endif
997 #elif defined GNULIB_POSIXCHECK
998 # undef stat
999 # if HAVE_RAW_DECL_STAT
1000 _GL_WARN_ON_USE (stat, "stat is unportable - "
1001                  "use gnulib module stat for portability");
1002 # endif
1003 #endif
1004
1005
1006 #if 0
1007 /* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat
1008    implementation relies on futimesat, which on Solaris 10 makes an invocation
1009    to utimensat that is meant to invoke the libc's utimensat(), not gnulib's
1010    utimensat().  */
1011 # if 0 || (!1 && defined __sun)
1012 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1013 #   undef utimensat
1014 #   define utimensat rpl_utimensat
1015 #  endif
1016 _GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name,
1017                                    struct timespec const times[2], int flag)
1018                                   _GL_ARG_NONNULL ((2)));
1019 _GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name,
1020                                    struct timespec const times[2], int flag));
1021 # else
1022 #  if !1
1023 _GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name,
1024                                    struct timespec const times[2], int flag)
1025                                   _GL_ARG_NONNULL ((2)));
1026 #  endif
1027 _GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name,
1028                                    struct timespec const times[2], int flag));
1029 # endif
1030 # if 1
1031 _GL_CXXALIASWARN (utimensat);
1032 # endif
1033 #elif defined GNULIB_POSIXCHECK
1034 # undef utimensat
1035 # if HAVE_RAW_DECL_UTIMENSAT
1036 _GL_WARN_ON_USE (utimensat, "utimensat is not portable - "
1037                  "use gnulib module utimensat for portability");
1038 # endif
1039 #endif
1040
1041
1042 #endif /* _GL_SYS_STAT_H */
1043 #endif /* _GL_SYS_STAT_H */
1044 #endif