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