Debian Codegraph @

tools/gnulib/sys_stat.in.h

raw symbols SCIP
1 /* Provide a more complete sys/stat.h header file.
2 Copyright (C) 2005-2024 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17 /* Written by Eric Blake, Paul Eggert, and Jim Meyering. */
18
19 /* This file is supposed to be used on platforms where <sys/stat.h> is
20 incomplete. It is intended to provide definitions and prototypes
21 needed by an application. Start with what the system provides. */
22
23 #if __GNUC__ >= 3
24 @PRAGMA_SYSTEM_HEADER@
25 #endif
26 @PRAGMA_COLUMNS@
27
28 /* This file uses #include_next of a system file that defines time_t.
29 For the 'year2038' module to work right, <config.h> needs to have been
30 included before. */
31 #if !_GL_CONFIG_H_INCLUDED
32 #error "Please include config.h first."
33 #endif
34
35 #if defined __need_system_sys_stat_h
36 /* Special invocation convention. */
37
38 #@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
39
40 #else
41 /* Normal invocation convention. */
42
43 #ifndef _@GUARD_PREFIX@_SYS_STAT_H
44
45 /* Get nlink_t.
46 May also define off_t to a 64-bit type on native Windows. */
47 #include <sys/types.h>
48
49 /* Get struct timespec. */
50 #include <time.h>
51
52 /* The include_next requires a split double-inclusion guard. */
53 #@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
54
55 #ifndef _@GUARD_PREFIX@_SYS_STAT_H
56 #define _@GUARD_PREFIX@_SYS_STAT_H
57
58 /* This file uses _GL_ATTRIBUTE_NOTHROW, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
59 #if !_GL_CONFIG_H_INCLUDED
60 #error "Please include config.h first."
61 #endif
62
63
64 /* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions.
65 */
66 #ifndef _GL_ATTRIBUTE_NOTHROW
67 # if defined __cplusplus
68 # if (__GNUC__ + (__GNUC_MINOR__ >= 8) > 2) || __clang_major__ >= 4
69 # if __cplusplus >= 201103L
70 # define _GL_ATTRIBUTE_NOTHROW noexcept (true)
71 # else
72 # define _GL_ATTRIBUTE_NOTHROW throw ()
73 # endif
74 # else
75 # define _GL_ATTRIBUTE_NOTHROW
76 # endif
77 # else
78 # if (__GNUC__ + (__GNUC_MINOR__ >= 3) > 3) || defined __clang__
79 # define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__))
80 # else
81 # define _GL_ATTRIBUTE_NOTHROW
82 # endif
83 # endif
84 #endif
85
86 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
87
88 /* The definition of _GL_ARG_NONNULL is copied here. */
89
90 /* The definition of _GL_WARN_ON_USE is copied here. */
91
92
93 /* Before doing "#define mknod rpl_mknod" below, we need to include all
94 headers that may declare mknod(). OS/2 kLIBC declares mknod() in
95 <unistd.h>, not in <sys/stat.h>. */
96 #ifdef __KLIBC__
97 # include <unistd.h>
98 #endif
99
100 /* Before doing "#define mkdir rpl_mkdir" below, we need to include all
101 headers that may declare mkdir(). Native Windows platforms declare mkdir
102 in <io.h> and/or <direct.h>, not in <sys/stat.h>. */
103 #if defined _WIN32 && ! defined __CYGWIN__
104 # include <io.h> /* mingw32, mingw64 */
105 # include <direct.h> /* mingw64, MSVC 9 */
106 #endif
107
108 /* Native Windows platforms declare umask() in <io.h>. */
109 #if 0 && (defined _WIN32 && ! defined __CYGWIN__)
110 # include <io.h>
111 #endif
112
113 /* Large File Support on native Windows. */
114 #if @WINDOWS_64_BIT_ST_SIZE@
115 # define stat _stati64
116 #endif
117
118 /* Optionally, override 'struct stat' on native Windows. */
119 #if @GNULIB_OVERRIDES_STRUCT_STAT@
120
121 # undef stat
122 # if @GNULIB_STAT@
123 # define stat rpl_stat
124 # else
125 # if !GNULIB_STAT
126 /* Provoke a clear link error if stat() is used as a function and
127 module 'stat' is not in use. */
128 # define stat stat_used_without_requesting_gnulib_module_stat
129 # endif
130 # endif
131
132 # if !GNULIB_defined_struct_stat
133 struct stat
134 {
135 dev_t st_dev;
136 ino_t st_ino;
137 mode_t st_mode;
138 nlink_t st_nlink;
139 # if 0
140 uid_t st_uid;
141 # else /* uid_t is not defined by default on native Windows. */
142 short st_uid;
143 # endif
144 # if 0
145 gid_t st_gid;
146 # else /* gid_t is not defined by default on native Windows. */
147 short st_gid;
148 # endif
149 dev_t st_rdev;
150 off_t st_size;
151 # if 0
152 blksize_t st_blksize;
153 blkcnt_t st_blocks;
154 # endif
155
156 # if @WINDOWS_STAT_TIMESPEC@
157 struct timespec st_atim;
158 struct timespec st_mtim;
159 struct timespec st_ctim;
160 # else
161 time_t st_atime;
162 time_t st_mtime;
163 time_t st_ctime;
164 # endif
165 };
166 # if @WINDOWS_STAT_TIMESPEC@
167 # define st_atime st_atim.tv_sec
168 # define st_mtime st_mtim.tv_sec
169 # define st_ctime st_ctim.tv_sec
170 /* Indicator, for gnulib internal purposes. */
171 # define _GL_WINDOWS_STAT_TIMESPEC 1
172 # endif
173 # define GNULIB_defined_struct_stat 1
174 # endif
175
176 /* Other possible values of st_mode. */
177 # if 0
178 # define _S_IFBLK 0x6000
179 # endif
180 # if 0
181 # define _S_IFLNK 0xA000
182 # endif
183 # if 0
184 # define _S_IFSOCK 0xC000
185 # endif
186
187 #endif
188
189 #ifndef S_IFIFO
190 # ifdef _S_IFIFO
191 # define S_IFIFO _S_IFIFO
192 # endif
193 #endif
194
195 #ifndef S_IFMT
196 # define S_IFMT 0170000
197 #endif
198
199 #if STAT_MACROS_BROKEN
200 # undef S_ISBLK
201 # undef S_ISCHR
202 # undef S_ISDIR
203 # undef S_ISFIFO
204 # undef S_ISLNK
205 # undef S_ISNAM
206 # undef S_ISMPB
207 # undef S_ISMPC
208 # undef S_ISNWK
209 # undef S_ISREG
210 # undef S_ISSOCK
211 #endif
212
213 #ifndef S_ISBLK
214 # ifdef S_IFBLK
215 # define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
216 # else
217 # define S_ISBLK(m) 0
218 # endif
219 #endif
220
221 #ifndef S_ISCHR
222 # ifdef S_IFCHR
223 # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
224 # else
225 # define S_ISCHR(m) 0
226 # endif
227 #endif
228
229 #ifndef S_ISDIR
230 # ifdef S_IFDIR
231 # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
232 # else
233 # define S_ISDIR(m) 0
234 # endif
235 #endif
236
237 #ifndef S_ISDOOR /* Solaris 2.5 and up */
238 # define S_ISDOOR(m) 0
239 #endif
240
241 #ifndef S_ISFIFO
242 # ifdef S_IFIFO
243 # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
244 # else
245 # define S_ISFIFO(m) 0
246 # endif
247 #endif
248
249 #ifndef S_ISLNK
250 # ifdef S_IFLNK
251 # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
252 # else
253 # define S_ISLNK(m) 0
254 # endif
255 #endif
256
257 #ifndef S_ISMPB /* V7 */
258 # ifdef S_IFMPB
259 # define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
260 # define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
261 # else
262 # define S_ISMPB(m) 0
263 # define S_ISMPC(m) 0
264 # endif
265 #endif
266
267 #ifndef S_ISMPX /* AIX */
268 # define S_ISMPX(m) 0
269 #endif
270
271 #ifndef S_ISNAM /* Xenix */
272 # ifdef S_IFNAM
273 # define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
274 # else
275 # define S_ISNAM(m) 0
276 # endif
277 #endif
278
279 #ifndef S_ISNWK /* HP/UX */
280 # ifdef S_IFNWK
281 # define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
282 # else
283 # define S_ISNWK(m) 0
284 # endif
285 #endif
286
287 #ifndef S_ISPORT /* Solaris 10 and up */
288 # define S_ISPORT(m) 0
289 #endif
290
291 #ifndef S_ISREG
292 # ifdef S_IFREG
293 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
294 # else
295 # define S_ISREG(m) 0
296 # endif
297 #endif
298
299 #ifndef S_ISSOCK
300 # ifdef S_IFSOCK
301 # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
302 # else
303 # define S_ISSOCK(m) 0
304 # endif
305 #endif
306
307
308 #ifndef S_TYPEISMQ
309 # define S_TYPEISMQ(p) 0
310 #endif
311
312 #ifndef S_TYPEISTMO
313 # define S_TYPEISTMO(p) 0
314 #endif
315
316
317 #ifndef S_TYPEISSEM
318 # ifdef S_INSEM
319 # define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
320 # else
321 # define S_TYPEISSEM(p) 0
322 # endif
323 #endif
324
325 #ifndef S_TYPEISSHM
326 # ifdef S_INSHD
327 # define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
328 # else
329 # define S_TYPEISSHM(p) 0
330 # endif
331 #endif
332
333 /* high performance ("contiguous data") */
334 #ifndef S_ISCTG
335 # define S_ISCTG(p) 0
336 #endif
337
338 /* Cray DMF (data migration facility): off line, with data */
339 #ifndef S_ISOFD
340 # define S_ISOFD(p) 0
341 #endif
342
343 /* Cray DMF (data migration facility): off line, with no data */
344 #ifndef S_ISOFL
345 # define S_ISOFL(p) 0
346 #endif
347
348 /* 4.4BSD whiteout */
349 #ifndef S_ISWHT
350 # define S_ISWHT(m) 0
351 #endif
352
353 /* If any of the following are undefined,
354 define them to their de facto standard values. */
355 #if !S_ISUID
356 # define S_ISUID 04000
357 #endif
358 #if !S_ISGID
359 # define S_ISGID 02000
360 #endif
361
362 /* S_ISVTX is a common extension to POSIX. */
363 #ifndef S_ISVTX
364 # define S_ISVTX 01000
365 #endif
366
367 #if !S_IRUSR && S_IREAD
368 # define S_IRUSR S_IREAD
369 #endif
370 #if !S_IRUSR
371 # define S_IRUSR 00400
372 #endif
373 #if !S_IRGRP
374 # define S_IRGRP (S_IRUSR >> 3)
375 #endif
376 #if !S_IROTH
377 # define S_IROTH (S_IRUSR >> 6)
378 #endif
379
380 #if !S_IWUSR && S_IWRITE
381 # define S_IWUSR S_IWRITE
382 #endif
383 #if !S_IWUSR
384 # define S_IWUSR 00200
385 #endif
386 #if !S_IWGRP
387 # define S_IWGRP (S_IWUSR >> 3)
388 #endif
389 #if !S_IWOTH
390 # define S_IWOTH (S_IWUSR >> 6)
391 #endif
392
393 #if !S_IXUSR && S_IEXEC
394 # define S_IXUSR S_IEXEC
395 #endif
396 #if !S_IXUSR
397 # define S_IXUSR 00100
398 #endif
399 #if !S_IXGRP
400 # define S_IXGRP (S_IXUSR >> 3)
401 #endif
402 #if !S_IXOTH
403 # define S_IXOTH (S_IXUSR >> 6)
404 #endif
405
406 #if !S_IRWXU
407 # define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
408 #endif
409 #if !S_IRWXG
410 # define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
411 #endif
412 #if !S_IRWXO
413 # define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
414 #endif
415
416 /* Although S_IXUGO and S_IRWXUGO are not specified by POSIX and are
417 not implemented in GNU/Linux, some Gnulib-using apps use the macros. */
418 #if !S_IXUGO
419 # define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
420 #endif
421 #ifndef S_IRWXUGO
422 # define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
423 #endif
424
425 /* Macros for futimens and utimensat. */
426 #ifndef UTIME_NOW
427 # define UTIME_NOW (-1)
428 # define UTIME_OMIT (-2)
429 #endif
430
431
432 #if @GNULIB_CHMOD@
433 # if @REPLACE_CHMOD@
434 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
435 # undef chmod
436 # define chmod rpl_chmod
437 # endif
438 _GL_FUNCDECL_RPL (chmod, int, (const char *filename, mode_t mode)
439 _GL_ARG_NONNULL ((1)));
440 _GL_CXXALIAS_RPL (chmod, int, (const char *filename, mode_t mode));
441 # elif defined _WIN32 && !defined __CYGWIN__
442 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
443 # undef chmod
444 # define chmod _chmod
445 # endif
446 /* Need to cast, because in mingw the last argument is 'int mode'. */
447 _GL_CXXALIAS_MDA_CAST (chmod, int, (const char *filename, mode_t mode));
448 # else
449 _GL_CXXALIAS_SYS (chmod, int, (const char *filename, mode_t mode));
450 # endif
451 _GL_CXXALIASWARN (chmod);
452 #elif defined GNULIB_POSIXCHECK
453 # undef chmod
454 # if HAVE_RAW_DECL_CHMOD
455 _GL_WARN_ON_USE (chmod, "chmod has portability problems - "
456 "use gnulib module chmod for portability");
457 # endif
458 #elif @GNULIB_MDA_CHMOD@
459 /* On native Windows, map 'chmod' to '_chmod', so that -loldnames is not
460 required. In C++ with GNULIB_NAMESPACE, avoid differences between
461 platforms by defining GNULIB_NAMESPACE::chmod always. */
462 # if defined _WIN32 && !defined __CYGWIN__
463 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
464 # undef chmod
465 # define chmod _chmod
466 # endif
467 /* Need to cast, because in mingw the last argument is 'int mode'. */
468 _GL_CXXALIAS_MDA_CAST (chmod, int, (const char *filename, mode_t mode));
469 # else
470 _GL_CXXALIAS_SYS (chmod, int, (const char *filename, mode_t mode));
471 # endif
472 _GL_CXXALIASWARN (chmod);
473 #endif
474
475
476 #if @GNULIB_FCHMODAT@
477 # if @REPLACE_FCHMODAT@
478 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
479 # undef fchmodat
480 # define fchmodat rpl_fchmodat
481 # endif
482 _GL_FUNCDECL_RPL (fchmodat, int,
483 (int fd, char const *file, mode_t mode, int flag)
484 _GL_ARG_NONNULL ((2)));
485 _GL_CXXALIAS_RPL (fchmodat, int,
486 (int fd, char const *file, mode_t mode, int flag));
487 # else
488 # if !@HAVE_FCHMODAT@
489 _GL_FUNCDECL_SYS (fchmodat, int,
490 (int fd, char const *file, mode_t mode, int flag)
491 _GL_ARG_NONNULL ((2)));
492 # endif
493 _GL_CXXALIAS_SYS (fchmodat, int,
494 (int fd, char const *file, mode_t mode, int flag));
495 # endif
496 _GL_CXXALIASWARN (fchmodat);
497 #elif defined GNULIB_POSIXCHECK
498 # undef fchmodat
499 # if HAVE_RAW_DECL_FCHMODAT
500 _GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - "
501 "use gnulib module openat for portability");
502 # endif
503 #endif
504
505
506 #if @GNULIB_FSTAT@
507 # if @REPLACE_FSTAT@
508 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
509 # undef fstat
510 # define fstat rpl_fstat
511 # endif
512 _GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2)));
513 _GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
514 # else
515 _GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
516 # endif
517 # if __GLIBC__ >= 2
518 _GL_CXXALIASWARN (fstat);
519 # endif
520 #elif @GNULIB_OVERRIDES_STRUCT_STAT@
521 # if !GNULIB_FSTAT
522 # undef fstat
523 # define fstat fstat_used_without_requesting_gnulib_module_fstat
524 # endif
525 #elif @WINDOWS_64_BIT_ST_SIZE@
526 /* Above, we define stat to _stati64. */
527 # define fstat _fstati64
528 #elif defined GNULIB_POSIXCHECK
529 # undef fstat
530 # if HAVE_RAW_DECL_FSTAT
531 _GL_WARN_ON_USE (fstat, "fstat has portability problems - "
532 "use gnulib module fstat for portability");
533 # endif
534 #endif
535
536
537 #if @GNULIB_FSTATAT@
538 # if @REPLACE_FSTATAT@
539 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
540 # undef fstatat
541 # define fstatat rpl_fstatat
542 # endif
543 _GL_FUNCDECL_RPL (fstatat, int,
544 (int fd, char const *restrict name, struct stat *restrict st,
545 int flags)
546 _GL_ARG_NONNULL ((2, 3)));
547 _GL_CXXALIAS_RPL (fstatat, int,
548 (int fd, char const *restrict name, struct stat *restrict st,
549 int flags));
550 # else
551 # if !@HAVE_FSTATAT@
552 _GL_FUNCDECL_SYS (fstatat, int,
553 (int fd, char const *restrict name, struct stat *restrict st,
554 int flags)
555 _GL_ARG_NONNULL ((2, 3)));
556 # endif
557 _GL_CXXALIAS_SYS (fstatat, int,
558 (int fd, char const *restrict name, struct stat *restrict st,
559 int flags));
560 # endif
561 _GL_CXXALIASWARN (fstatat);
562 #elif @GNULIB_OVERRIDES_STRUCT_STAT@
563 # if !GNULIB_FSTATAT
564 # undef fstatat
565 # define fstatat fstatat_used_without_requesting_gnulib_module_fstatat
566 # endif
567 #elif defined GNULIB_POSIXCHECK
568 # undef fstatat
569 # if HAVE_RAW_DECL_FSTATAT
570 _GL_WARN_ON_USE (fstatat, "fstatat is not portable - "
571 "use gnulib module openat for portability");
572 # endif
573 #endif
574
575
576 #if @GNULIB_FUTIMENS@
577 /* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our futimens
578 implementation relies on futimesat, which on Solaris 10 makes an invocation
579 to futimens that is meant to invoke the libc's futimens(), not gnulib's
580 futimens(). */
581 # if @REPLACE_FUTIMENS@ || (!@HAVE_FUTIMENS@ && defined __sun)
582 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
583 # undef futimens
584 # define futimens rpl_futimens
585 # endif
586 _GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2]));
587 _GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2]));
588 # else
589 # if !@HAVE_FUTIMENS@
590 _GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2]));
591 # endif
592 _GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2]));
593 # endif
594 # if __GLIBC__ >= 2 && @HAVE_FUTIMENS@
595 _GL_CXXALIASWARN (futimens);
596 # endif
597 #elif defined GNULIB_POSIXCHECK
598 # undef futimens
599 # if HAVE_RAW_DECL_FUTIMENS
600 _GL_WARN_ON_USE (futimens, "futimens is not portable - "
601 "use gnulib module futimens for portability");
602 # endif
603 #endif
604
605
606 #if @GNULIB_GETUMASK@
607 # if !@HAVE_GETUMASK@
608 # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
609 _GL_FUNCDECL_SYS (getumask, mode_t, (void) _GL_ATTRIBUTE_NOTHROW);
610 # else
611 _GL_FUNCDECL_SYS (getumask, mode_t, (void));
612 # endif
613 # endif
614 _GL_CXXALIAS_SYS (getumask, mode_t, (void));
615 # if @HAVE_GETUMASK@
616 _GL_CXXALIASWARN (getumask);
617 # endif
618 #elif defined GNULIB_POSIXCHECK
619 # undef getumask
620 # if HAVE_RAW_DECL_GETUMASK
621 _GL_WARN_ON_USE (getumask, "getumask is not portable - "
622 "use gnulib module getumask for portability");
623 # endif
624 #endif
625
626
627 #if @GNULIB_LCHMOD@
628 /* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
629 denotes a symbolic link. */
630 # if !@HAVE_LCHMOD@ || defined __hpux
631 _GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode)
632 _GL_ARG_NONNULL ((1)));
633 # endif
634 _GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode));
635 _GL_CXXALIASWARN (lchmod);
636 #elif defined GNULIB_POSIXCHECK
637 # undef lchmod
638 # if HAVE_RAW_DECL_LCHMOD
639 _GL_WARN_ON_USE (lchmod, "lchmod is unportable - "
640 "use gnulib module lchmod for portability");
641 # endif
642 #endif
643
644
645 #if @GNULIB_MKDIR@
646 # if @REPLACE_MKDIR@
647 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
648 # undef mkdir
649 # define mkdir rpl_mkdir
650 # endif
651 _GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode)
652 _GL_ARG_NONNULL ((1)));
653 _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
654 # elif defined _WIN32 && !defined __CYGWIN__
655 /* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
656 Additionally, it declares _mkdir (and depending on compile flags, an
657 alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
658 which are included above. */
659 # if !GNULIB_defined_rpl_mkdir
660 static int
661 rpl_mkdir (char const *name, mode_t mode)
662 {
663 return _mkdir (name);
664 }
665 # define GNULIB_defined_rpl_mkdir 1
666 # endif
667 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
668 # undef mkdir
669 # define mkdir rpl_mkdir
670 # endif
671 _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
672 # else
673 _GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
674 # endif
675 _GL_CXXALIASWARN (mkdir);
676 #elif @GNULIB_MDA_MKDIR@
677 /* On native Windows, map 'mkdir' to '_mkdir', so that -loldnames is not
678 required. In C++ with GNULIB_NAMESPACE, avoid differences between
679 platforms by defining GNULIB_NAMESPACE::mkdir always. */
680 # if defined _WIN32 && !defined __CYGWIN__
681 # if !GNULIB_defined_rpl_mkdir
682 static int
683 rpl_mkdir (char const *name, mode_t mode)
684 {
685 return _mkdir (name);
686 }
687 # define GNULIB_defined_rpl_mkdir 1
688 # endif
689 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
690 # undef mkdir
691 # define mkdir rpl_mkdir
692 # endif
693 _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
694 # else
695 _GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
696 # endif
697 _GL_CXXALIASWARN (mkdir);
698 #elif defined GNULIB_POSIXCHECK
699 # undef mkdir
700 # if HAVE_RAW_DECL_MKDIR
701 _GL_WARN_ON_USE (mkdir, "mkdir does not always support two parameters - "
702 "use gnulib module mkdir for portability");
703 # endif
704 #endif
705
706
707 #if @GNULIB_MKDIRAT@
708 # if !@HAVE_MKDIRAT@
709 _GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)
710 _GL_ARG_NONNULL ((2)));
711 # endif
712 _GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode));
713 _GL_CXXALIASWARN (mkdirat);
714 #elif defined GNULIB_POSIXCHECK
715 # undef mkdirat
716 # if HAVE_RAW_DECL_MKDIRAT
717 _GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - "
718 "use gnulib module openat for portability");
719 # endif
720 #endif
721
722
723 #if @GNULIB_MKFIFO@
724 # if @REPLACE_MKFIFO@
725 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
726 # undef mkfifo
727 # define mkfifo rpl_mkfifo
728 # endif
729 _GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode)
730 _GL_ARG_NONNULL ((1)));
731 _GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode));
732 # else
733 # if !@HAVE_MKFIFO@
734 _GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode)
735 _GL_ARG_NONNULL ((1)));
736 # endif
737 _GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode));
738 # endif
739 _GL_CXXALIASWARN (mkfifo);
740 #elif defined GNULIB_POSIXCHECK
741 # undef mkfifo
742 # if HAVE_RAW_DECL_MKFIFO
743 _GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - "
744 "use gnulib module mkfifo for portability");
745 # endif
746 #endif
747
748
749 #if @GNULIB_MKFIFOAT@
750 # if @REPLACE_MKFIFOAT@
751 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
752 # undef mkfifoat
753 # define mkfifoat rpl_mkfifoat
754 # endif
755 _GL_FUNCDECL_RPL (mkfifoat, int, (int fd, char const *file, mode_t mode)
756 _GL_ARG_NONNULL ((2)));
757 _GL_CXXALIAS_RPL (mkfifoat, int, (int fd, char const *file, mode_t mode));
758 # else
759 # if !@HAVE_MKFIFOAT@
760 _GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)
761 _GL_ARG_NONNULL ((2)));
762 # endif
763 _GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode));
764 # endif
765 # if __GLIBC__ >= 2
766 _GL_CXXALIASWARN (mkfifoat);
767 # endif
768 #elif defined GNULIB_POSIXCHECK
769 # undef mkfifoat
770 # if HAVE_RAW_DECL_MKFIFOAT
771 _GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - "
772 "use gnulib module mkfifoat for portability");
773 # endif
774 #endif
775
776
777 #if @GNULIB_MKNOD@
778 # if @REPLACE_MKNOD@
779 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
780 # undef mknod
781 # define mknod rpl_mknod
782 # endif
783 _GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)
784 _GL_ARG_NONNULL ((1)));
785 _GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev));
786 # else
787 # if !@HAVE_MKNOD@
788 _GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev)
789 _GL_ARG_NONNULL ((1)));
790 # endif
791 /* Need to cast, because on OSF/1 5.1, the third parameter is '...'. */
792 _GL_CXXALIAS_SYS_CAST (mknod, int, (char const *file, mode_t mode, dev_t dev));
793 # endif
794 _GL_CXXALIASWARN (mknod);
795 #elif defined GNULIB_POSIXCHECK
796 # undef mknod
797 # if HAVE_RAW_DECL_MKNOD
798 _GL_WARN_ON_USE (mknod, "mknod is not portable - "
799 "use gnulib module mknod for portability");
800 # endif
801 #endif
802
803
804 #if @GNULIB_MKNODAT@
805 # if @REPLACE_MKNODAT@
806 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
807 # undef mknodat
808 # define mknodat rpl_mknodat
809 # endif
810 _GL_FUNCDECL_RPL (mknodat, int,
811 (int fd, char const *file, mode_t mode, dev_t dev)
812 _GL_ARG_NONNULL ((2)));
813 _GL_CXXALIAS_RPL (mknodat, int,
814 (int fd, char const *file, mode_t mode, dev_t dev));
815 # else
816 # if !@HAVE_MKNODAT@
817 _GL_FUNCDECL_SYS (mknodat, int,
818 (int fd, char const *file, mode_t mode, dev_t dev)
819 _GL_ARG_NONNULL ((2)));
820 # endif
821 _GL_CXXALIAS_SYS (mknodat, int,
822 (int fd, char const *file, mode_t mode, dev_t dev));
823 # endif
824 # if __GLIBC__ >= 2
825 _GL_CXXALIASWARN (mknodat);
826 # endif
827 #elif defined GNULIB_POSIXCHECK
828 # undef mknodat
829 # if HAVE_RAW_DECL_MKNODAT
830 _GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
831 "use gnulib module mkfifoat for portability");
832 # endif
833 #endif
834
835
836 #if @GNULIB_STAT@
837 # if @REPLACE_STAT@
838 # if !@GNULIB_OVERRIDES_STRUCT_STAT@
839 /* We can't use the object-like #define stat rpl_stat, because of
840 struct stat. This means that rpl_stat will not be used if the user
841 does (stat)(a,b). Oh well. */
842 # if defined _AIX && defined stat && defined _LARGE_FILES
843 /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
844 so we have to replace stat64() instead of stat(). */
845 # undef stat64
846 # define stat64(name, st) rpl_stat (name, st)
847 # elif @WINDOWS_64_BIT_ST_SIZE@
848 /* Above, we define stat to _stati64. */
849 # if defined __MINGW32__ && defined _stati64
850 # ifndef _USE_32BIT_TIME_T
851 /* The system headers define _stati64 to _stat64. */
852 # undef _stat64
853 # define _stat64(name, st) rpl_stat (name, st)
854 # endif
855 # elif defined _MSC_VER && defined _stati64
856 # ifdef _USE_32BIT_TIME_T
857 /* The system headers define _stati64 to _stat32i64. */
858 # undef _stat32i64
859 # define _stat32i64(name, st) rpl_stat (name, st)
860 # else
861 /* The system headers define _stati64 to _stat64. */
862 # undef _stat64
863 # define _stat64(name, st) rpl_stat (name, st)
864 # endif
865 # else
866 # undef _stati64
867 # define _stati64(name, st) rpl_stat (name, st)
868 # endif
869 # elif defined __MINGW32__ && defined stat
870 # ifdef _USE_32BIT_TIME_T
871 /* The system headers define stat to _stat32i64. */
872 # undef _stat32i64
873 # define _stat32i64(name, st) rpl_stat (name, st)
874 # else
875 /* The system headers define stat to _stat64. */
876 # undef _stat64
877 # define _stat64(name, st) rpl_stat (name, st)
878 # endif
879 # elif defined _MSC_VER && defined stat
880 # ifdef _USE_32BIT_TIME_T
881 /* The system headers define stat to _stat32. */
882 # undef _stat32
883 # define _stat32(name, st) rpl_stat (name, st)
884 # else
885 /* The system headers define stat to _stat64i32. */
886 # undef _stat64i32
887 # define _stat64i32(name, st) rpl_stat (name, st)
888 # endif
889 # else /* !(_AIX || __MINGW32__ || _MSC_VER) */
890 # undef stat
891 # define stat(name, st) rpl_stat (name, st)
892 # endif /* !_LARGE_FILES */
893 # endif /* !@GNULIB_OVERRIDES_STRUCT_STAT@ */
894 _GL_EXTERN_C int stat (const char *restrict name, struct stat *restrict buf)
895 _GL_ARG_NONNULL ((1, 2));
896 # endif
897 #elif @GNULIB_OVERRIDES_STRUCT_STAT@
898 /* see above:
899 #define stat stat_used_without_requesting_gnulib_module_stat
900 */
901 #elif defined GNULIB_POSIXCHECK
902 # undef stat
903 # if HAVE_RAW_DECL_STAT
904 _GL_WARN_ON_USE (stat, "stat is unportable - "
905 "use gnulib module stat for portability");
906 # endif
907 #endif
908
909
910 #if @GNULIB_LSTAT@
911 # if ! @HAVE_LSTAT@
912 /* mingw does not support symlinks, therefore it does not have lstat. But
913 without links, stat does just fine. */
914 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
915 # define lstat stat
916 # endif
917 _GL_CXXALIAS_RPL_1 (lstat, stat, int,
918 (const char *restrict name, struct stat *restrict buf));
919 # elif @REPLACE_LSTAT@
920 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
921 # undef lstat
922 # define lstat rpl_lstat
923 # endif
924 _GL_FUNCDECL_RPL (lstat, int,
925 (const char *restrict name, struct stat *restrict buf)
926 _GL_ARG_NONNULL ((1, 2)));
927 _GL_CXXALIAS_RPL (lstat, int,
928 (const char *restrict name, struct stat *restrict buf));
929 # else
930 _GL_CXXALIAS_SYS (lstat, int,
931 (const char *restrict name, struct stat *restrict buf));
932 # endif
933 # if @HAVE_LSTAT@
934 _GL_CXXALIASWARN (lstat);
935 # endif
936 #elif @GNULIB_OVERRIDES_STRUCT_STAT@
937 # if !GNULIB_LSTAT
938 # undef lstat
939 # define lstat lstat_used_without_requesting_gnulib_module_lstat
940 # endif
941 #elif defined GNULIB_POSIXCHECK
942 # undef lstat
943 # if HAVE_RAW_DECL_LSTAT
944 _GL_WARN_ON_USE (lstat, "lstat is unportable - "
945 "use gnulib module lstat for portability");
946 # endif
947 #endif
948
949
950 #if @GNULIB_MDA_UMASK@
951 /* On native Windows, map 'umask' to '_umask', so that -loldnames is not
952 required. In C++ with GNULIB_NAMESPACE, avoid differences between
953 platforms by defining GNULIB_NAMESPACE::umask always. */
954 # if defined _WIN32 && !defined __CYGWIN__
955 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
956 # undef umask
957 # define umask _umask
958 # endif
959 /* Need to cast, because in mingw the last argument is 'int mode'. */
960 _GL_CXXALIAS_MDA_CAST (umask, mode_t, (mode_t mask));
961 # else
962 _GL_CXXALIAS_SYS (umask, mode_t, (mode_t mask));
963 # endif
964 _GL_CXXALIASWARN (umask);
965 #endif
966
967
968 #if @GNULIB_UTIMENSAT@
969 /* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat
970 implementation relies on futimesat, which on Solaris 10 makes an invocation
971 to utimensat that is meant to invoke the libc's utimensat(), not gnulib's
972 utimensat(). */
973 # if @REPLACE_UTIMENSAT@ || (!@HAVE_UTIMENSAT@ && defined __sun)
974 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
975 # undef utimensat
976 # define utimensat rpl_utimensat
977 # endif
978 _GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name,
979 struct timespec const times[2], int flag)
980 _GL_ARG_NONNULL ((2)));
981 _GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name,
982 struct timespec const times[2], int flag));
983 # else
984 # if !@HAVE_UTIMENSAT@
985 _GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name,
986 struct timespec const times[2], int flag)
987 _GL_ARG_NONNULL ((2)));
988 # endif
989 _GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name,
990 struct timespec const times[2], int flag));
991 # endif
992 # if __GLIBC__ >= 2 && @HAVE_UTIMENSAT@
993 _GL_CXXALIASWARN (utimensat);
994 # endif
995 #elif defined GNULIB_POSIXCHECK
996 # undef utimensat
997 # if HAVE_RAW_DECL_UTIMENSAT
998 _GL_WARN_ON_USE (utimensat, "utimensat is not portable - "
999 "use gnulib module utimensat for portability");
1000 # endif
1001 #endif
1002
1003
1004 #endif /* _@GUARD_PREFIX@_SYS_STAT_H */
1005 #endif /* _@GUARD_PREFIX@_SYS_STAT_H */
1006 #endif