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