sys_stat.in.h 25 KB

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