sys_stat.in.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955
  1. /* Provide a more complete sys/stat.h header file.
  2. Copyright (C) 2005-2023 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_CHMOD@
  332. # if @REPLACE_CHMOD@
  333. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  334. # undef chmod
  335. # define chmod rpl_chmod
  336. # endif
  337. _GL_FUNCDECL_RPL (chmod, int, (const char *filename, mode_t mode)
  338. _GL_ARG_NONNULL ((1)));
  339. _GL_CXXALIAS_RPL (chmod, int, (const char *filename, mode_t mode));
  340. # elif defined _WIN32 && !defined __CYGWIN__
  341. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  342. # undef chmod
  343. # define chmod _chmod
  344. # endif
  345. /* Need to cast, because in mingw the last argument is 'int mode'. */
  346. _GL_CXXALIAS_MDA_CAST (chmod, int, (const char *filename, mode_t mode));
  347. # else
  348. _GL_CXXALIAS_SYS (chmod, int, (const char *filename, mode_t mode));
  349. # endif
  350. _GL_CXXALIASWARN (chmod);
  351. #elif defined GNULIB_POSIXCHECK
  352. # undef chmod
  353. # if HAVE_RAW_DECL_CHMOD
  354. _GL_WARN_ON_USE (chmod, "chmod has portability problems - "
  355. "use gnulib module chmod for portability");
  356. # endif
  357. #elif @GNULIB_MDA_CHMOD@
  358. /* On native Windows, map 'chmod' to '_chmod', so that -loldnames is not
  359. required. In C++ with GNULIB_NAMESPACE, avoid differences between
  360. platforms by defining GNULIB_NAMESPACE::chmod always. */
  361. # if defined _WIN32 && !defined __CYGWIN__
  362. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  363. # undef chmod
  364. # define chmod _chmod
  365. # endif
  366. /* Need to cast, because in mingw the last argument is 'int mode'. */
  367. _GL_CXXALIAS_MDA_CAST (chmod, int, (const char *filename, mode_t mode));
  368. # else
  369. _GL_CXXALIAS_SYS (chmod, int, (const char *filename, mode_t mode));
  370. # endif
  371. _GL_CXXALIASWARN (chmod);
  372. #endif
  373. #if @GNULIB_FCHMODAT@
  374. # if @REPLACE_FCHMODAT@
  375. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  376. # undef fchmodat
  377. # define fchmodat rpl_fchmodat
  378. # endif
  379. _GL_FUNCDECL_RPL (fchmodat, int,
  380. (int fd, char const *file, mode_t mode, int flag)
  381. _GL_ARG_NONNULL ((2)));
  382. _GL_CXXALIAS_RPL (fchmodat, int,
  383. (int fd, char const *file, mode_t mode, int flag));
  384. # else
  385. # if !@HAVE_FCHMODAT@
  386. _GL_FUNCDECL_SYS (fchmodat, int,
  387. (int fd, char const *file, mode_t mode, int flag)
  388. _GL_ARG_NONNULL ((2)));
  389. # endif
  390. _GL_CXXALIAS_SYS (fchmodat, int,
  391. (int fd, char const *file, mode_t mode, int flag));
  392. # endif
  393. _GL_CXXALIASWARN (fchmodat);
  394. #elif defined GNULIB_POSIXCHECK
  395. # undef fchmodat
  396. # if HAVE_RAW_DECL_FCHMODAT
  397. _GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - "
  398. "use gnulib module openat for portability");
  399. # endif
  400. #endif
  401. #if @GNULIB_FSTAT@
  402. # if @REPLACE_FSTAT@
  403. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  404. # undef fstat
  405. # define fstat rpl_fstat
  406. # endif
  407. _GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2)));
  408. _GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
  409. # else
  410. _GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
  411. # endif
  412. # if __GLIBC__ >= 2
  413. _GL_CXXALIASWARN (fstat);
  414. # endif
  415. #elif @GNULIB_OVERRIDES_STRUCT_STAT@
  416. # undef fstat
  417. # define fstat fstat_used_without_requesting_gnulib_module_fstat
  418. #elif @WINDOWS_64_BIT_ST_SIZE@
  419. /* Above, we define stat to _stati64. */
  420. # define fstat _fstati64
  421. #elif defined GNULIB_POSIXCHECK
  422. # undef fstat
  423. # if HAVE_RAW_DECL_FSTAT
  424. _GL_WARN_ON_USE (fstat, "fstat has portability problems - "
  425. "use gnulib module fstat for portability");
  426. # endif
  427. #endif
  428. #if @GNULIB_FSTATAT@
  429. # if @REPLACE_FSTATAT@
  430. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  431. # undef fstatat
  432. # define fstatat rpl_fstatat
  433. # endif
  434. _GL_FUNCDECL_RPL (fstatat, int,
  435. (int fd, char const *restrict name, struct stat *restrict st,
  436. int flags)
  437. _GL_ARG_NONNULL ((2, 3)));
  438. _GL_CXXALIAS_RPL (fstatat, int,
  439. (int fd, char const *restrict name, struct stat *restrict st,
  440. int flags));
  441. # else
  442. # if !@HAVE_FSTATAT@
  443. _GL_FUNCDECL_SYS (fstatat, int,
  444. (int fd, char const *restrict name, struct stat *restrict st,
  445. int flags)
  446. _GL_ARG_NONNULL ((2, 3)));
  447. # endif
  448. _GL_CXXALIAS_SYS (fstatat, int,
  449. (int fd, char const *restrict name, struct stat *restrict st,
  450. int flags));
  451. # endif
  452. _GL_CXXALIASWARN (fstatat);
  453. #elif @GNULIB_OVERRIDES_STRUCT_STAT@
  454. # undef fstatat
  455. # define fstatat fstatat_used_without_requesting_gnulib_module_fstatat
  456. #elif defined GNULIB_POSIXCHECK
  457. # undef fstatat
  458. # if HAVE_RAW_DECL_FSTATAT
  459. _GL_WARN_ON_USE (fstatat, "fstatat is not portable - "
  460. "use gnulib module openat for portability");
  461. # endif
  462. #endif
  463. #if @GNULIB_FUTIMENS@
  464. /* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our futimens
  465. implementation relies on futimesat, which on Solaris 10 makes an invocation
  466. to futimens that is meant to invoke the libc's futimens(), not gnulib's
  467. futimens(). */
  468. # if @REPLACE_FUTIMENS@ || (!@HAVE_FUTIMENS@ && defined __sun)
  469. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  470. # undef futimens
  471. # define futimens rpl_futimens
  472. # endif
  473. _GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2]));
  474. _GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2]));
  475. # else
  476. # if !@HAVE_FUTIMENS@
  477. _GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2]));
  478. # endif
  479. _GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2]));
  480. # endif
  481. # if @HAVE_FUTIMENS@
  482. _GL_CXXALIASWARN (futimens);
  483. # endif
  484. #elif defined GNULIB_POSIXCHECK
  485. # undef futimens
  486. # if HAVE_RAW_DECL_FUTIMENS
  487. _GL_WARN_ON_USE (futimens, "futimens is not portable - "
  488. "use gnulib module futimens for portability");
  489. # endif
  490. #endif
  491. #if @GNULIB_GETUMASK@
  492. # if !@HAVE_GETUMASK@
  493. _GL_FUNCDECL_SYS (getumask, mode_t, (void));
  494. # endif
  495. _GL_CXXALIAS_SYS (getumask, mode_t, (void));
  496. # if @HAVE_GETUMASK@
  497. _GL_CXXALIASWARN (getumask);
  498. # endif
  499. #elif defined GNULIB_POSIXCHECK
  500. # undef getumask
  501. # if HAVE_RAW_DECL_GETUMASK
  502. _GL_WARN_ON_USE (getumask, "getumask is not portable - "
  503. "use gnulib module getumask for portability");
  504. # endif
  505. #endif
  506. #if @GNULIB_LCHMOD@
  507. /* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
  508. denotes a symbolic link. */
  509. # if !@HAVE_LCHMOD@ || defined __hpux
  510. _GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode)
  511. _GL_ARG_NONNULL ((1)));
  512. # endif
  513. _GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode));
  514. _GL_CXXALIASWARN (lchmod);
  515. #elif defined GNULIB_POSIXCHECK
  516. # undef lchmod
  517. # if HAVE_RAW_DECL_LCHMOD
  518. _GL_WARN_ON_USE (lchmod, "lchmod is unportable - "
  519. "use gnulib module lchmod for portability");
  520. # endif
  521. #endif
  522. #if @GNULIB_MKDIR@
  523. # if @REPLACE_MKDIR@
  524. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  525. # undef mkdir
  526. # define mkdir rpl_mkdir
  527. # endif
  528. _GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode)
  529. _GL_ARG_NONNULL ((1)));
  530. _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
  531. # elif defined _WIN32 && !defined __CYGWIN__
  532. /* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
  533. Additionally, it declares _mkdir (and depending on compile flags, an
  534. alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
  535. which are included above. */
  536. # if !GNULIB_defined_rpl_mkdir
  537. static int
  538. rpl_mkdir (char const *name, mode_t mode)
  539. {
  540. return _mkdir (name);
  541. }
  542. # define GNULIB_defined_rpl_mkdir 1
  543. # endif
  544. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  545. # undef mkdir
  546. # define mkdir rpl_mkdir
  547. # endif
  548. _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
  549. # else
  550. _GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
  551. # endif
  552. _GL_CXXALIASWARN (mkdir);
  553. #elif defined GNULIB_POSIXCHECK
  554. # undef mkdir
  555. # if HAVE_RAW_DECL_MKDIR
  556. _GL_WARN_ON_USE (mkdir, "mkdir does not always support two parameters - "
  557. "use gnulib module mkdir for portability");
  558. # endif
  559. #elif @GNULIB_MDA_MKDIR@
  560. /* On native Windows, map 'mkdir' to '_mkdir', so that -loldnames is not
  561. required. In C++ with GNULIB_NAMESPACE, avoid differences between
  562. platforms by defining GNULIB_NAMESPACE::mkdir always. */
  563. # if defined _WIN32 && !defined __CYGWIN__
  564. # if !GNULIB_defined_rpl_mkdir
  565. static int
  566. rpl_mkdir (char const *name, mode_t mode)
  567. {
  568. return _mkdir (name);
  569. }
  570. # define GNULIB_defined_rpl_mkdir 1
  571. # endif
  572. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  573. # undef mkdir
  574. # define mkdir rpl_mkdir
  575. # endif
  576. _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
  577. # else
  578. _GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
  579. # endif
  580. _GL_CXXALIASWARN (mkdir);
  581. #endif
  582. #if @GNULIB_MKDIRAT@
  583. # if !@HAVE_MKDIRAT@
  584. _GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)
  585. _GL_ARG_NONNULL ((2)));
  586. # endif
  587. _GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode));
  588. _GL_CXXALIASWARN (mkdirat);
  589. #elif defined GNULIB_POSIXCHECK
  590. # undef mkdirat
  591. # if HAVE_RAW_DECL_MKDIRAT
  592. _GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - "
  593. "use gnulib module openat for portability");
  594. # endif
  595. #endif
  596. #if @GNULIB_MKFIFO@
  597. # if @REPLACE_MKFIFO@
  598. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  599. # undef mkfifo
  600. # define mkfifo rpl_mkfifo
  601. # endif
  602. _GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode)
  603. _GL_ARG_NONNULL ((1)));
  604. _GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode));
  605. # else
  606. # if !@HAVE_MKFIFO@
  607. _GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode)
  608. _GL_ARG_NONNULL ((1)));
  609. # endif
  610. _GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode));
  611. # endif
  612. _GL_CXXALIASWARN (mkfifo);
  613. #elif defined GNULIB_POSIXCHECK
  614. # undef mkfifo
  615. # if HAVE_RAW_DECL_MKFIFO
  616. _GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - "
  617. "use gnulib module mkfifo for portability");
  618. # endif
  619. #endif
  620. #if @GNULIB_MKFIFOAT@
  621. # if @REPLACE_MKFIFOAT@
  622. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  623. # undef mkfifoat
  624. # define mkfifoat rpl_mkfifoat
  625. # endif
  626. _GL_FUNCDECL_RPL (mkfifoat, int, (int fd, char const *file, mode_t mode)
  627. _GL_ARG_NONNULL ((2)));
  628. _GL_CXXALIAS_RPL (mkfifoat, int, (int fd, char const *file, mode_t mode));
  629. # else
  630. # if !@HAVE_MKFIFOAT@
  631. _GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)
  632. _GL_ARG_NONNULL ((2)));
  633. # endif
  634. _GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode));
  635. # endif
  636. _GL_CXXALIASWARN (mkfifoat);
  637. #elif defined GNULIB_POSIXCHECK
  638. # undef mkfifoat
  639. # if HAVE_RAW_DECL_MKFIFOAT
  640. _GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - "
  641. "use gnulib module mkfifoat for portability");
  642. # endif
  643. #endif
  644. #if @GNULIB_MKNOD@
  645. # if @REPLACE_MKNOD@
  646. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  647. # undef mknod
  648. # define mknod rpl_mknod
  649. # endif
  650. _GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)
  651. _GL_ARG_NONNULL ((1)));
  652. _GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev));
  653. # else
  654. # if !@HAVE_MKNOD@
  655. _GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev)
  656. _GL_ARG_NONNULL ((1)));
  657. # endif
  658. /* Need to cast, because on OSF/1 5.1, the third parameter is '...'. */
  659. _GL_CXXALIAS_SYS_CAST (mknod, int, (char const *file, mode_t mode, dev_t dev));
  660. # endif
  661. _GL_CXXALIASWARN (mknod);
  662. #elif defined GNULIB_POSIXCHECK
  663. # undef mknod
  664. # if HAVE_RAW_DECL_MKNOD
  665. _GL_WARN_ON_USE (mknod, "mknod is not portable - "
  666. "use gnulib module mknod for portability");
  667. # endif
  668. #endif
  669. #if @GNULIB_MKNODAT@
  670. # if @REPLACE_MKNODAT@
  671. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  672. # undef mknodat
  673. # define mknodat rpl_mknodat
  674. # endif
  675. _GL_FUNCDECL_RPL (mknodat, int,
  676. (int fd, char const *file, mode_t mode, dev_t dev)
  677. _GL_ARG_NONNULL ((2)));
  678. _GL_CXXALIAS_RPL (mknodat, int,
  679. (int fd, char const *file, mode_t mode, dev_t dev));
  680. # else
  681. # if !@HAVE_MKNODAT@
  682. _GL_FUNCDECL_SYS (mknodat, int,
  683. (int fd, char const *file, mode_t mode, dev_t dev)
  684. _GL_ARG_NONNULL ((2)));
  685. # endif
  686. _GL_CXXALIAS_SYS (mknodat, int,
  687. (int fd, char const *file, mode_t mode, dev_t dev));
  688. # endif
  689. _GL_CXXALIASWARN (mknodat);
  690. #elif defined GNULIB_POSIXCHECK
  691. # undef mknodat
  692. # if HAVE_RAW_DECL_MKNODAT
  693. _GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
  694. "use gnulib module mkfifoat for portability");
  695. # endif
  696. #endif
  697. #if @GNULIB_STAT@
  698. # if @REPLACE_STAT@
  699. # if !@GNULIB_OVERRIDES_STRUCT_STAT@
  700. /* We can't use the object-like #define stat rpl_stat, because of
  701. struct stat. This means that rpl_stat will not be used if the user
  702. does (stat)(a,b). Oh well. */
  703. # if defined _AIX && defined stat && defined _LARGE_FILES
  704. /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
  705. so we have to replace stat64() instead of stat(). */
  706. # undef stat64
  707. # define stat64(name, st) rpl_stat (name, st)
  708. # elif @WINDOWS_64_BIT_ST_SIZE@
  709. /* Above, we define stat to _stati64. */
  710. # if defined __MINGW32__ && defined _stati64
  711. # ifndef _USE_32BIT_TIME_T
  712. /* The system headers define _stati64 to _stat64. */
  713. # undef _stat64
  714. # define _stat64(name, st) rpl_stat (name, st)
  715. # endif
  716. # elif defined _MSC_VER && defined _stati64
  717. # ifdef _USE_32BIT_TIME_T
  718. /* The system headers define _stati64 to _stat32i64. */
  719. # undef _stat32i64
  720. # define _stat32i64(name, st) rpl_stat (name, st)
  721. # else
  722. /* The system headers define _stati64 to _stat64. */
  723. # undef _stat64
  724. # define _stat64(name, st) rpl_stat (name, st)
  725. # endif
  726. # else
  727. # undef _stati64
  728. # define _stati64(name, st) rpl_stat (name, st)
  729. # endif
  730. # elif defined __MINGW32__ && defined stat
  731. # ifdef _USE_32BIT_TIME_T
  732. /* The system headers define stat to _stat32i64. */
  733. # undef _stat32i64
  734. # define _stat32i64(name, st) rpl_stat (name, st)
  735. # else
  736. /* The system headers define stat to _stat64. */
  737. # undef _stat64
  738. # define _stat64(name, st) rpl_stat (name, st)
  739. # endif
  740. # elif defined _MSC_VER && defined stat
  741. # ifdef _USE_32BIT_TIME_T
  742. /* The system headers define stat to _stat32. */
  743. # undef _stat32
  744. # define _stat32(name, st) rpl_stat (name, st)
  745. # else
  746. /* The system headers define stat to _stat64i32. */
  747. # undef _stat64i32
  748. # define _stat64i32(name, st) rpl_stat (name, st)
  749. # endif
  750. # else /* !(_AIX || __MINGW32__ || _MSC_VER) */
  751. # undef stat
  752. # define stat(name, st) rpl_stat (name, st)
  753. # endif /* !_LARGE_FILES */
  754. # endif /* !@GNULIB_OVERRIDES_STRUCT_STAT@ */
  755. _GL_EXTERN_C int stat (const char *restrict name, struct stat *restrict buf)
  756. _GL_ARG_NONNULL ((1, 2));
  757. # endif
  758. #elif @GNULIB_OVERRIDES_STRUCT_STAT@
  759. /* see above:
  760. #define stat stat_used_without_requesting_gnulib_module_stat
  761. */
  762. #elif defined GNULIB_POSIXCHECK
  763. # undef stat
  764. # if HAVE_RAW_DECL_STAT
  765. _GL_WARN_ON_USE (stat, "stat is unportable - "
  766. "use gnulib module stat for portability");
  767. # endif
  768. #endif
  769. #if @GNULIB_LSTAT@
  770. # if ! @HAVE_LSTAT@
  771. /* mingw does not support symlinks, therefore it does not have lstat. But
  772. without links, stat does just fine. */
  773. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  774. # define lstat stat
  775. # endif
  776. _GL_CXXALIAS_RPL_1 (lstat, stat, int,
  777. (const char *restrict name, struct stat *restrict buf));
  778. # elif @REPLACE_LSTAT@
  779. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  780. # undef lstat
  781. # define lstat rpl_lstat
  782. # endif
  783. _GL_FUNCDECL_RPL (lstat, int,
  784. (const char *restrict name, struct stat *restrict buf)
  785. _GL_ARG_NONNULL ((1, 2)));
  786. _GL_CXXALIAS_RPL (lstat, int,
  787. (const char *restrict name, struct stat *restrict buf));
  788. # else
  789. _GL_CXXALIAS_SYS (lstat, int,
  790. (const char *restrict name, struct stat *restrict buf));
  791. # endif
  792. # if @HAVE_LSTAT@
  793. _GL_CXXALIASWARN (lstat);
  794. # endif
  795. #elif @GNULIB_OVERRIDES_STRUCT_STAT@
  796. # undef lstat
  797. # define lstat lstat_used_without_requesting_gnulib_module_lstat
  798. #elif defined GNULIB_POSIXCHECK
  799. # undef lstat
  800. # if HAVE_RAW_DECL_LSTAT
  801. _GL_WARN_ON_USE (lstat, "lstat is unportable - "
  802. "use gnulib module lstat for portability");
  803. # endif
  804. #endif
  805. #if @GNULIB_MDA_UMASK@
  806. /* On native Windows, map 'umask' to '_umask', so that -loldnames is not
  807. required. In C++ with GNULIB_NAMESPACE, avoid differences between
  808. platforms by defining GNULIB_NAMESPACE::umask always. */
  809. # if defined _WIN32 && !defined __CYGWIN__
  810. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  811. # undef umask
  812. # define umask _umask
  813. # endif
  814. /* Need to cast, because in mingw the last argument is 'int mode'. */
  815. _GL_CXXALIAS_MDA_CAST (umask, mode_t, (mode_t mask));
  816. # else
  817. _GL_CXXALIAS_SYS (umask, mode_t, (mode_t mask));
  818. # endif
  819. _GL_CXXALIASWARN (umask);
  820. #endif
  821. #if @GNULIB_UTIMENSAT@
  822. /* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat
  823. implementation relies on futimesat, which on Solaris 10 makes an invocation
  824. to utimensat that is meant to invoke the libc's utimensat(), not gnulib's
  825. utimensat(). */
  826. # if @REPLACE_UTIMENSAT@ || (!@HAVE_UTIMENSAT@ && defined __sun)
  827. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  828. # undef utimensat
  829. # define utimensat rpl_utimensat
  830. # endif
  831. _GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name,
  832. struct timespec const times[2], int flag)
  833. _GL_ARG_NONNULL ((2)));
  834. _GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name,
  835. struct timespec const times[2], int flag));
  836. # else
  837. # if !@HAVE_UTIMENSAT@
  838. _GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name,
  839. struct timespec const times[2], int flag)
  840. _GL_ARG_NONNULL ((2)));
  841. # endif
  842. _GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name,
  843. struct timespec const times[2], int flag));
  844. # endif
  845. # if @HAVE_UTIMENSAT@
  846. _GL_CXXALIASWARN (utimensat);
  847. # endif
  848. #elif defined GNULIB_POSIXCHECK
  849. # undef utimensat
  850. # if HAVE_RAW_DECL_UTIMENSAT
  851. _GL_WARN_ON_USE (utimensat, "utimensat is not portable - "
  852. "use gnulib module utimensat for portability");
  853. # endif
  854. #endif
  855. #endif /* _@GUARD_PREFIX@_SYS_STAT_H */
  856. #endif /* _@GUARD_PREFIX@_SYS_STAT_H */
  857. #endif