Debian Codegraph @

lib/sys_stat.in.h

raw
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_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 # undef chmod
455 # if HAVE_RAW_DECL_CHMOD
456 _GL_WARN_ON_USE (chmod, "chmod has portability problems - "
457 "use gnulib module chmod for portability");
458 # endif
459 #elif @GNULIB_MDA_CHMOD@
460 /* On native Windows, map 'chmod' to '_chmod', so that -loldnames is not
461 required. In C++ with GNULIB_NAMESPACE, avoid differences between
462 platforms by defining GNULIB_NAMESPACE::chmod always. */
463 # if defined _WIN32 && !defined __CYGWIN__
464 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
465 # undef chmod
466 # define chmod _chmod
467 # endif
468 /* Need to cast, because in mingw the last argument is 'int mode'. */
469 _GL_CXXALIAS_MDA_CAST (chmod, int, (const char *filename, mode_t mode));
470 # else
471 _GL_CXXALIAS_SYS (chmod, int, (const char *filename, mode_t mode));
472 # endif
473 _GL_CXXALIASWARN (chmod);
474 #endif
475
476
477 #if @GNULIB_FCHMODAT@
478 # if @REPLACE_FCHMODAT@
479 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
480 # undef fchmodat
481 # define fchmodat rpl_fchmodat
482 # endif
483 _GL_FUNCDECL_RPL (fchmodat, int,
484 (int fd, char const *file, mode_t mode, int flag),
485 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
486 _GL_CXXALIAS_RPL (fchmodat, int,
487 (int fd, char const *file, mode_t mode, int flag));
488 # else
489 # if !@HAVE_FCHMODAT@
490 _GL_FUNCDECL_SYS (fchmodat, int,
491 (int fd, char const *file, mode_t mode, int flag),
492 _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_NODISCARD);
493 # endif
494 _GL_CXXALIAS_SYS (fchmodat, int,
495 (int fd, char const *file, mode_t mode, int flag));
496 # endif
497 _GL_CXXALIASWARN (fchmodat);
498 #elif defined GNULIB_POSIXCHECK
499 # undef fchmodat
500 # if HAVE_RAW_DECL_FCHMODAT
501 _GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - "
502 "use gnulib module openat for portability");
503 # endif
504 #endif
505
506
507 #if @GNULIB_FSTAT@
508 # if @REPLACE_FSTAT@
509 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
510 # undef fstat
511 # define fstat rpl_fstat
512 # endif
513 _GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf),
514 _GL_ARG_NONNULL ((2)));
515 _GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
516 # else
517 _GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
518 # endif
519 # if __GLIBC__ >= 2
520 _GL_CXXALIASWARN (fstat);
521 # endif
522 #elif @GNULIB_OVERRIDES_STRUCT_STAT@
523 # if !GNULIB_FSTAT
524 # undef fstat
525 # define fstat fstat_used_without_requesting_gnulib_module_fstat
526 # endif
527 #elif @WINDOWS_64_BIT_ST_SIZE@
528 /* Above, we define stat to _stati64. */
529 # define fstat _fstati64
530 #elif defined GNULIB_POSIXCHECK
531 # undef fstat
532 # if HAVE_RAW_DECL_FSTAT
533 _GL_WARN_ON_USE (fstat, "fstat has portability problems - "
534 "use gnulib module fstat for portability");
535 # endif
536 #endif
537
538
539 #if @GNULIB_FSTATAT@
540 # if @REPLACE_FSTATAT@
541 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
542 # undef fstatat
543 # define fstatat rpl_fstatat
544 # endif
545 _GL_FUNCDECL_RPL (fstatat, int,
546 (int fd, char const *restrict name, struct stat *restrict st,
547 int flags),
548 _GL_ARG_NONNULL ((2, 3)));
549 _GL_CXXALIAS_RPL (fstatat, int,
550 (int fd, char const *restrict name, struct stat *restrict st,
551 int flags));
552 # else
553 # if !@HAVE_FSTATAT@
554 _GL_FUNCDECL_SYS (fstatat, int,
555 (int fd, char const *restrict name, struct stat *restrict st,
556 int flags),
557 _GL_ARG_NONNULL ((2, 3)));
558 # endif
559 _GL_CXXALIAS_SYS (fstatat, int,
560 (int fd, char const *restrict name, struct stat *restrict st,
561 int flags));
562 # endif
563 _GL_CXXALIASWARN (fstatat);
564 #elif @GNULIB_OVERRIDES_STRUCT_STAT@
565 # if !GNULIB_FSTATAT
566 # undef fstatat
567 # define fstatat fstatat_used_without_requesting_gnulib_module_fstatat
568 # endif
569 #elif defined GNULIB_POSIXCHECK
570 # undef fstatat
571 # if HAVE_RAW_DECL_FSTATAT
572 _GL_WARN_ON_USE (fstatat, "fstatat is not portable - "
573 "use gnulib module openat for portability");
574 # endif
575 #endif
576
577
578 #if @GNULIB_FUTIMENS@
579 /* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our futimens
580 implementation relies on futimesat, which on Solaris 10 makes an invocation
581 to futimens that is meant to invoke the libc's futimens(), not gnulib's
582 futimens(). */
583 # if @REPLACE_FUTIMENS@ || (!@HAVE_FUTIMENS@ && defined __sun)
584 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
585 # undef futimens
586 # define futimens rpl_futimens
587 # endif
588 _GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2]), );
589 _GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2]));
590 # else
591 # if !@HAVE_FUTIMENS@
592 _GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2]), );
593 # endif
594 _GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2]));
595 # endif
596 # if __GLIBC__ >= 2 && @HAVE_FUTIMENS@
597 _GL_CXXALIASWARN (futimens);
598 # endif
599 #elif defined GNULIB_POSIXCHECK
600 # undef futimens
601 # if HAVE_RAW_DECL_FUTIMENS
602 _GL_WARN_ON_USE (futimens, "futimens is not portable - "
603 "use gnulib module futimens for portability");
604 # endif
605 #endif
606
607
608 #if @GNULIB_GETUMASK@
609 # if !@HAVE_GETUMASK@
610 # if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
611 _GL_FUNCDECL_SYS (getumask, mode_t, (void), ) _GL_ATTRIBUTE_NOTHROW;
612 # else
613 _GL_FUNCDECL_SYS (getumask, mode_t, (void), );
614 # endif
615 # endif
616 _GL_CXXALIAS_SYS (getumask, mode_t, (void));
617 # if @HAVE_GETUMASK@
618 _GL_CXXALIASWARN (getumask);
619 # endif
620 #elif defined GNULIB_POSIXCHECK
621 # undef getumask
622 # if HAVE_RAW_DECL_GETUMASK
623 _GL_WARN_ON_USE (getumask, "getumask is not portable - "
624 "use gnulib module getumask for portability");
625 # endif
626 #endif
627
628
629 #if @GNULIB_LCHMOD@
630 /* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
631 denotes a symbolic link. */
632 # if !@HAVE_LCHMOD@ || defined __hpux
633 _GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode),
634 _GL_ARG_NONNULL ((1)));
635 # endif
636 _GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode));
637 _GL_CXXALIASWARN (lchmod);
638 #elif defined GNULIB_POSIXCHECK
639 # undef lchmod
640 # if HAVE_RAW_DECL_LCHMOD
641 _GL_WARN_ON_USE (lchmod, "lchmod is unportable - "
642 "use gnulib module lchmod for portability");
643 # endif
644 #endif
645
646
647 #if @GNULIB_MKDIR@
648 # if @REPLACE_MKDIR@
649 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
650 # undef mkdir
651 # define mkdir rpl_mkdir
652 # endif
653 _GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode),
654 _GL_ARG_NONNULL ((1)));
655 _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
656 # elif defined _WIN32 && !defined __CYGWIN__
657 /* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
658 Additionally, it declares _mkdir (and depending on compile flags, an
659 alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
660 which are included above. */
661 # if !GNULIB_defined_rpl_mkdir
662 static int
663 rpl_mkdir (char const *name, mode_t mode)
664 {
665 return _mkdir (name);
666 }
667 # define GNULIB_defined_rpl_mkdir 1
668 # endif
669 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
670 # undef mkdir
671 # define mkdir rpl_mkdir
672 # endif
673 _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
674 # else
675 _GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
676 # endif
677 _GL_CXXALIASWARN (mkdir);
678 #elif @GNULIB_MDA_MKDIR@
679 /* On native Windows, map 'mkdir' to '_mkdir', so that -loldnames is not
680 required. In C++ with GNULIB_NAMESPACE, avoid differences between
681 platforms by defining GNULIB_NAMESPACE::mkdir always. */
682 # if defined _WIN32 && !defined __CYGWIN__
683 # if !GNULIB_defined_rpl_mkdir
684 static int
685 rpl_mkdir (char const *name, mode_t mode)
686 {
687 return _mkdir (name);
688 }
689 # define GNULIB_defined_rpl_mkdir 1
690 # endif
691 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
692 # undef mkdir
693 # define mkdir rpl_mkdir
694 # endif
695 _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
696 # else
697 _GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
698 # endif
699 _GL_CXXALIASWARN (mkdir);
700 #elif defined GNULIB_POSIXCHECK
701 # undef mkdir
702 # if HAVE_RAW_DECL_MKDIR
703 _GL_WARN_ON_USE (mkdir, "mkdir does not always support two parameters - "
704 "use gnulib module mkdir for portability");
705 # endif
706 #endif
707
708
709 #if @GNULIB_MKDIRAT@
710 # if !@HAVE_MKDIRAT@
711 _GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode),
712 _GL_ARG_NONNULL ((2)));
713 # endif
714 _GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode));
715 _GL_CXXALIASWARN (mkdirat);
716 #elif defined GNULIB_POSIXCHECK
717 # undef mkdirat
718 # if HAVE_RAW_DECL_MKDIRAT
719 _GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - "
720 "use gnulib module openat for portability");
721 # endif
722 #endif
723
724
725 #if @GNULIB_MKFIFO@
726 # if @REPLACE_MKFIFO@
727 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
728 # undef mkfifo
729 # define mkfifo rpl_mkfifo
730 # endif
731 _GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode),
732 _GL_ARG_NONNULL ((1)));
733 _GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode));
734 # else
735 # if !@HAVE_MKFIFO@
736 _GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode),
737 _GL_ARG_NONNULL ((1)));
738 # endif
739 _GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode));
740 # endif
741 _GL_CXXALIASWARN (mkfifo);
742 #elif defined GNULIB_POSIXCHECK
743 # undef mkfifo
744 # if HAVE_RAW_DECL_MKFIFO
745 _GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - "
746 "use gnulib module mkfifo for portability");
747 # endif
748 #endif
749
750
751 #if @GNULIB_MKFIFOAT@
752 # if @REPLACE_MKFIFOAT@
753 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
754 # undef mkfifoat
755 # define mkfifoat rpl_mkfifoat
756 # endif
757 _GL_FUNCDECL_RPL (mkfifoat, int, (int fd, char const *file, mode_t mode),
758 _GL_ARG_NONNULL ((2)));
759 _GL_CXXALIAS_RPL (mkfifoat, int, (int fd, char const *file, mode_t mode));
760 # else
761 # if !@HAVE_MKFIFOAT@
762 _GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode),
763 _GL_ARG_NONNULL ((2)));
764 # endif
765 _GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode));
766 # endif
767 # if __GLIBC__ >= 2
768 _GL_CXXALIASWARN (mkfifoat);
769 # endif
770 #elif defined GNULIB_POSIXCHECK
771 # undef mkfifoat
772 # if HAVE_RAW_DECL_MKFIFOAT
773 _GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - "
774 "use gnulib module mkfifoat for portability");
775 # endif
776 #endif
777
778
779 #if @GNULIB_MKNOD@
780 # if @REPLACE_MKNOD@
781 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
782 # undef mknod
783 # define mknod rpl_mknod
784 # endif
785 _GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev),
786 _GL_ARG_NONNULL ((1)));
787 _GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev));
788 # else
789 # if !@HAVE_MKNOD@
790 _GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev),
791 _GL_ARG_NONNULL ((1)));
792 # endif
793 /* Need to cast, because on OSF/1 5.1, the third parameter is '...'. */
794 _GL_CXXALIAS_SYS_CAST (mknod, int, (char const *file, mode_t mode, dev_t dev));
795 # endif
796 _GL_CXXALIASWARN (mknod);
797 #elif defined GNULIB_POSIXCHECK
798 # undef mknod
799 # if HAVE_RAW_DECL_MKNOD
800 _GL_WARN_ON_USE (mknod, "mknod is not portable - "
801 "use gnulib module mknod for portability");
802 # endif
803 #endif
804
805
806 #if @GNULIB_MKNODAT@
807 # if @REPLACE_MKNODAT@
808 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
809 # undef mknodat
810 # define mknodat rpl_mknodat
811 # endif
812 _GL_FUNCDECL_RPL (mknodat, int,
813 (int fd, char const *file, mode_t mode, dev_t dev),
814 _GL_ARG_NONNULL ((2)));
815 _GL_CXXALIAS_RPL (mknodat, int,
816 (int fd, char const *file, mode_t mode, dev_t dev));
817 # else
818 # if !@HAVE_MKNODAT@
819 _GL_FUNCDECL_SYS (mknodat, int,
820 (int fd, char const *file, mode_t mode, dev_t dev),
821 _GL_ARG_NONNULL ((2)));
822 # endif
823 _GL_CXXALIAS_SYS (mknodat, int,
824 (int fd, char const *file, mode_t mode, dev_t dev));
825 # endif
826 # if __GLIBC__ >= 2
827 _GL_CXXALIASWARN (mknodat);
828 # endif
829 #elif defined GNULIB_POSIXCHECK
830 # undef mknodat
831 # if HAVE_RAW_DECL_MKNODAT
832 _GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
833 "use gnulib module mkfifoat for portability");
834 # endif
835 #endif
836
837
838 #if @GNULIB_STAT@
839 # if @REPLACE_STAT@
840 # if !@GNULIB_OVERRIDES_STRUCT_STAT@
841 /* We can't use the object-like #define stat rpl_stat, because of
842 struct stat. This means that rpl_stat will not be used if the user
843 does (stat)(a,b). Oh well. */
844 # if defined _AIX && defined stat && defined _LARGE_FILES
845 /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
846 so we have to replace stat64() instead of stat(). */
847 # undef stat64
848 # define stat64(name, st) rpl_stat (name, st)
849 # elif @WINDOWS_64_BIT_ST_SIZE@
850 /* Above, we define stat to _stati64. */
851 # if defined __MINGW32__ && defined _stati64
852 # ifndef _USE_32BIT_TIME_T
853 /* The system headers define _stati64 to _stat64. */
854 # undef _stat64
855 # define _stat64(name, st) rpl_stat (name, st)
856 # endif
857 # elif defined _MSC_VER && defined _stati64
858 # ifdef _USE_32BIT_TIME_T
859 /* The system headers define _stati64 to _stat32i64. */
860 # undef _stat32i64
861 # define _stat32i64(name, st) rpl_stat (name, st)
862 # else
863 /* The system headers define _stati64 to _stat64. */
864 # undef _stat64
865 # define _stat64(name, st) rpl_stat (name, st)
866 # endif
867 # else
868 # undef _stati64
869 # define _stati64(name, st) rpl_stat (name, st)
870 # endif
871 # elif defined __MINGW32__ && defined stat
872 # ifdef _USE_32BIT_TIME_T
873 /* The system headers define stat to _stat32i64. */
874 # undef _stat32i64
875 # define _stat32i64(name, st) rpl_stat (name, st)
876 # else
877 /* The system headers define stat to _stat64. */
878 # undef _stat64
879 # define _stat64(name, st) rpl_stat (name, st)
880 # endif
881 # elif defined _MSC_VER && defined stat
882 # ifdef _USE_32BIT_TIME_T
883 /* The system headers define stat to _stat32. */
884 # undef _stat32
885 # define _stat32(name, st) rpl_stat (name, st)
886 # else
887 /* The system headers define stat to _stat64i32. */
888 # undef _stat64i32
889 # define _stat64i32(name, st) rpl_stat (name, st)
890 # endif
891 # else /* !(_AIX || __MINGW32__ || _MSC_VER) */
892 # undef stat
893 # define stat(name, st) rpl_stat (name, st)
894 # endif /* !_LARGE_FILES */
895 # endif /* !@GNULIB_OVERRIDES_STRUCT_STAT@ */
896 _GL_EXTERN_C int stat (const char *restrict name, struct stat *restrict buf)
897 _GL_ARG_NONNULL ((1, 2));
898 # endif
899 #elif @GNULIB_OVERRIDES_STRUCT_STAT@
900 /* see above:
901 #define stat stat_used_without_requesting_gnulib_module_stat
902 */
903 #elif defined GNULIB_POSIXCHECK
904 # undef stat
905 # if HAVE_RAW_DECL_STAT
906 _GL_WARN_ON_USE (stat, "stat is unportable - "
907 "use gnulib module stat for portability");
908 # endif
909 #endif
910
911
912 #if @GNULIB_LSTAT@
913 # if ! @HAVE_LSTAT@
914 /* mingw does not support symlinks, therefore it does not have lstat. But
915 without links, stat does just fine. */
916 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
917 # define lstat stat
918 # endif
919 _GL_CXXALIAS_RPL_1 (lstat, stat, int,
920 (const char *restrict name, struct stat *restrict buf));
921 # elif @REPLACE_LSTAT@
922 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
923 # undef lstat
924 # define lstat rpl_lstat
925 # endif
926 _GL_FUNCDECL_RPL (lstat, int,
927 (const char *restrict name, struct stat *restrict buf),
928 _GL_ARG_NONNULL ((1, 2)));
929 _GL_CXXALIAS_RPL (lstat, int,
930 (const char *restrict name, struct stat *restrict buf));
931 # else
932 _GL_CXXALIAS_SYS (lstat, int,
933 (const char *restrict name, struct stat *restrict buf));
934 # endif
935 # if @HAVE_LSTAT@
936 _GL_CXXALIASWARN (lstat);
937 # endif
938 #elif @GNULIB_OVERRIDES_STRUCT_STAT@
939 # if !GNULIB_LSTAT
940 # undef lstat
941 # define lstat lstat_used_without_requesting_gnulib_module_lstat
942 # endif
943 #elif defined GNULIB_POSIXCHECK
944 # undef lstat
945 # if HAVE_RAW_DECL_LSTAT
946 _GL_WARN_ON_USE (lstat, "lstat is unportable - "
947 "use gnulib module lstat for portability");
948 # endif
949 #endif
950
951
952 #if @GNULIB_MDA_UMASK@
953 /* On native Windows, map 'umask' to '_umask', so that -loldnames is not
954 required. In C++ with GNULIB_NAMESPACE, avoid differences between
955 platforms by defining GNULIB_NAMESPACE::umask always. */
956 # if defined _WIN32 && !defined __CYGWIN__
957 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
958 # undef umask
959 # define umask _umask
960 # endif
961 /* Need to cast, because in mingw the last argument is 'int mode'. */
962 _GL_CXXALIAS_MDA_CAST (umask, mode_t, (mode_t mask));
963 # else
964 _GL_CXXALIAS_SYS (umask, mode_t, (mode_t mask));
965 # endif
966 _GL_CXXALIASWARN (umask);
967 #endif
968
969
970 #if @GNULIB_UTIMENSAT@
971 /* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat
972 implementation relies on futimesat, which on Solaris 10 makes an invocation
973 to utimensat that is meant to invoke the libc's utimensat(), not gnulib's
974 utimensat(). */
975 # if @REPLACE_UTIMENSAT@ || (!@HAVE_UTIMENSAT@ && defined __sun)
976 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
977 # undef utimensat
978 # define utimensat rpl_utimensat
979 # endif
980 _GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name,
981 struct timespec const times[2], int flag),
982 _GL_ARG_NONNULL ((2)));
983 _GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name,
984 struct timespec const times[2], int flag));
985 # else
986 # if !@HAVE_UTIMENSAT@
987 _GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name,
988 struct timespec const times[2], int flag),
989 _GL_ARG_NONNULL ((2)));
990 # endif
991 _GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name,
992 struct timespec const times[2], int flag));
993 # endif
994 # if __GLIBC__ >= 2 && @HAVE_UTIMENSAT@
995 _GL_CXXALIASWARN (utimensat);
996 # endif
997 #elif defined GNULIB_POSIXCHECK
998 # undef utimensat
999 # if HAVE_RAW_DECL_UTIMENSAT
1000 _GL_WARN_ON_USE (utimensat, "utimensat is not portable - "
1001 "use gnulib module utimensat for portability");
1002 # endif
1003 #endif
1004
1005
1006 #endif /* _@GUARD_PREFIX@_SYS_STAT_H */
1007 #endif /* _@GUARD_PREFIX@_SYS_STAT_H */
1008 #endif