Debian Codegraph @

lib/sys_stat.in.h

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