sys_stat.in.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955
  1. /* Provide a more complete sys/stat.h header file.
  2. Copyright (C) 2005-2022 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_LSTAT@
  523. # if ! @HAVE_LSTAT@
  524. /* mingw does not support symlinks, therefore it does not have lstat. But
  525. without links, stat does just fine. */
  526. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  527. # define lstat stat
  528. # endif
  529. _GL_CXXALIAS_RPL_1 (lstat, stat, int,
  530. (const char *restrict name, struct stat *restrict buf));
  531. # elif @REPLACE_LSTAT@
  532. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  533. # undef lstat
  534. # define lstat rpl_lstat
  535. # endif
  536. _GL_FUNCDECL_RPL (lstat, int,
  537. (const char *restrict name, struct stat *restrict buf)
  538. _GL_ARG_NONNULL ((1, 2)));
  539. _GL_CXXALIAS_RPL (lstat, int,
  540. (const char *restrict name, struct stat *restrict buf));
  541. # else
  542. _GL_CXXALIAS_SYS (lstat, int,
  543. (const char *restrict name, struct stat *restrict buf));
  544. # endif
  545. # if @HAVE_LSTAT@
  546. _GL_CXXALIASWARN (lstat);
  547. # endif
  548. #elif @GNULIB_OVERRIDES_STRUCT_STAT@
  549. # undef lstat
  550. # define lstat lstat_used_without_requesting_gnulib_module_lstat
  551. #elif defined GNULIB_POSIXCHECK
  552. # undef lstat
  553. # if HAVE_RAW_DECL_LSTAT
  554. _GL_WARN_ON_USE (lstat, "lstat is unportable - "
  555. "use gnulib module lstat for portability");
  556. # endif
  557. #endif
  558. #if @GNULIB_MKDIR@
  559. # if @REPLACE_MKDIR@
  560. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  561. # undef mkdir
  562. # define mkdir rpl_mkdir
  563. # endif
  564. _GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode)
  565. _GL_ARG_NONNULL ((1)));
  566. _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
  567. # elif defined _WIN32 && !defined __CYGWIN__
  568. /* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
  569. Additionally, it declares _mkdir (and depending on compile flags, an
  570. alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
  571. which are included above. */
  572. # if !GNULIB_defined_rpl_mkdir
  573. static int
  574. rpl_mkdir (char const *name, mode_t mode)
  575. {
  576. return _mkdir (name);
  577. }
  578. # define GNULIB_defined_rpl_mkdir 1
  579. # endif
  580. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  581. # undef mkdir
  582. # define mkdir rpl_mkdir
  583. # endif
  584. _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
  585. # else
  586. _GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
  587. # endif
  588. _GL_CXXALIASWARN (mkdir);
  589. #elif defined GNULIB_POSIXCHECK
  590. # undef mkdir
  591. # if HAVE_RAW_DECL_MKDIR
  592. _GL_WARN_ON_USE (mkdir, "mkdir does not always support two parameters - "
  593. "use gnulib module mkdir for portability");
  594. # endif
  595. #elif @GNULIB_MDA_MKDIR@
  596. /* On native Windows, map 'mkdir' to '_mkdir', so that -loldnames is not
  597. required. In C++ with GNULIB_NAMESPACE, avoid differences between
  598. platforms by defining GNULIB_NAMESPACE::mkdir always. */
  599. # if defined _WIN32 && !defined __CYGWIN__
  600. # if !GNULIB_defined_rpl_mkdir
  601. static int
  602. rpl_mkdir (char const *name, mode_t mode)
  603. {
  604. return _mkdir (name);
  605. }
  606. # define GNULIB_defined_rpl_mkdir 1
  607. # endif
  608. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  609. # undef mkdir
  610. # define mkdir rpl_mkdir
  611. # endif
  612. _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
  613. # else
  614. _GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
  615. # endif
  616. _GL_CXXALIASWARN (mkdir);
  617. #endif
  618. #if @GNULIB_MKDIRAT@
  619. # if !@HAVE_MKDIRAT@
  620. _GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)
  621. _GL_ARG_NONNULL ((2)));
  622. # endif
  623. _GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode));
  624. _GL_CXXALIASWARN (mkdirat);
  625. #elif defined GNULIB_POSIXCHECK
  626. # undef mkdirat
  627. # if HAVE_RAW_DECL_MKDIRAT
  628. _GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - "
  629. "use gnulib module openat for portability");
  630. # endif
  631. #endif
  632. #if @GNULIB_MKFIFO@
  633. # if @REPLACE_MKFIFO@
  634. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  635. # undef mkfifo
  636. # define mkfifo rpl_mkfifo
  637. # endif
  638. _GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode)
  639. _GL_ARG_NONNULL ((1)));
  640. _GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode));
  641. # else
  642. # if !@HAVE_MKFIFO@
  643. _GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode)
  644. _GL_ARG_NONNULL ((1)));
  645. # endif
  646. _GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode));
  647. # endif
  648. _GL_CXXALIASWARN (mkfifo);
  649. #elif defined GNULIB_POSIXCHECK
  650. # undef mkfifo
  651. # if HAVE_RAW_DECL_MKFIFO
  652. _GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - "
  653. "use gnulib module mkfifo for portability");
  654. # endif
  655. #endif
  656. #if @GNULIB_MKFIFOAT@
  657. # if @REPLACE_MKFIFOAT@
  658. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  659. # undef mkfifoat
  660. # define mkfifoat rpl_mkfifoat
  661. # endif
  662. _GL_FUNCDECL_RPL (mkfifoat, int, (int fd, char const *file, mode_t mode)
  663. _GL_ARG_NONNULL ((2)));
  664. _GL_CXXALIAS_RPL (mkfifoat, int, (int fd, char const *file, mode_t mode));
  665. # else
  666. # if !@HAVE_MKFIFOAT@
  667. _GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)
  668. _GL_ARG_NONNULL ((2)));
  669. # endif
  670. _GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode));
  671. # endif
  672. _GL_CXXALIASWARN (mkfifoat);
  673. #elif defined GNULIB_POSIXCHECK
  674. # undef mkfifoat
  675. # if HAVE_RAW_DECL_MKFIFOAT
  676. _GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - "
  677. "use gnulib module mkfifoat for portability");
  678. # endif
  679. #endif
  680. #if @GNULIB_MKNOD@
  681. # if @REPLACE_MKNOD@
  682. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  683. # undef mknod
  684. # define mknod rpl_mknod
  685. # endif
  686. _GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)
  687. _GL_ARG_NONNULL ((1)));
  688. _GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev));
  689. # else
  690. # if !@HAVE_MKNOD@
  691. _GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev)
  692. _GL_ARG_NONNULL ((1)));
  693. # endif
  694. /* Need to cast, because on OSF/1 5.1, the third parameter is '...'. */
  695. _GL_CXXALIAS_SYS_CAST (mknod, int, (char const *file, mode_t mode, dev_t dev));
  696. # endif
  697. _GL_CXXALIASWARN (mknod);
  698. #elif defined GNULIB_POSIXCHECK
  699. # undef mknod
  700. # if HAVE_RAW_DECL_MKNOD
  701. _GL_WARN_ON_USE (mknod, "mknod is not portable - "
  702. "use gnulib module mknod for portability");
  703. # endif
  704. #endif
  705. #if @GNULIB_MKNODAT@
  706. # if @REPLACE_MKNODAT@
  707. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  708. # undef mknodat
  709. # define mknodat rpl_mknodat
  710. # endif
  711. _GL_FUNCDECL_RPL (mknodat, int,
  712. (int fd, char const *file, mode_t mode, dev_t dev)
  713. _GL_ARG_NONNULL ((2)));
  714. _GL_CXXALIAS_RPL (mknodat, int,
  715. (int fd, char const *file, mode_t mode, dev_t dev));
  716. # else
  717. # if !@HAVE_MKNODAT@
  718. _GL_FUNCDECL_SYS (mknodat, int,
  719. (int fd, char const *file, mode_t mode, dev_t dev)
  720. _GL_ARG_NONNULL ((2)));
  721. # endif
  722. _GL_CXXALIAS_SYS (mknodat, int,
  723. (int fd, char const *file, mode_t mode, dev_t dev));
  724. # endif
  725. _GL_CXXALIASWARN (mknodat);
  726. #elif defined GNULIB_POSIXCHECK
  727. # undef mknodat
  728. # if HAVE_RAW_DECL_MKNODAT
  729. _GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
  730. "use gnulib module mkfifoat for portability");
  731. # endif
  732. #endif
  733. #if @GNULIB_STAT@
  734. # if @REPLACE_STAT@
  735. # if !@GNULIB_OVERRIDES_STRUCT_STAT@
  736. /* We can't use the object-like #define stat rpl_stat, because of
  737. struct stat. This means that rpl_stat will not be used if the user
  738. does (stat)(a,b). Oh well. */
  739. # if defined _AIX && defined stat && defined _LARGE_FILES
  740. /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
  741. so we have to replace stat64() instead of stat(). */
  742. # undef stat64
  743. # define stat64(name, st) rpl_stat (name, st)
  744. # elif @WINDOWS_64_BIT_ST_SIZE@
  745. /* Above, we define stat to _stati64. */
  746. # if defined __MINGW32__ && defined _stati64
  747. # ifndef _USE_32BIT_TIME_T
  748. /* The system headers define _stati64 to _stat64. */
  749. # undef _stat64
  750. # define _stat64(name, st) rpl_stat (name, st)
  751. # endif
  752. # elif defined _MSC_VER && defined _stati64
  753. # ifdef _USE_32BIT_TIME_T
  754. /* The system headers define _stati64 to _stat32i64. */
  755. # undef _stat32i64
  756. # define _stat32i64(name, st) rpl_stat (name, st)
  757. # else
  758. /* The system headers define _stati64 to _stat64. */
  759. # undef _stat64
  760. # define _stat64(name, st) rpl_stat (name, st)
  761. # endif
  762. # else
  763. # undef _stati64
  764. # define _stati64(name, st) rpl_stat (name, st)
  765. # endif
  766. # elif defined __MINGW32__ && defined stat
  767. # ifdef _USE_32BIT_TIME_T
  768. /* The system headers define stat to _stat32i64. */
  769. # undef _stat32i64
  770. # define _stat32i64(name, st) rpl_stat (name, st)
  771. # else
  772. /* The system headers define stat to _stat64. */
  773. # undef _stat64
  774. # define _stat64(name, st) rpl_stat (name, st)
  775. # endif
  776. # elif defined _MSC_VER && defined stat
  777. # ifdef _USE_32BIT_TIME_T
  778. /* The system headers define stat to _stat32. */
  779. # undef _stat32
  780. # define _stat32(name, st) rpl_stat (name, st)
  781. # else
  782. /* The system headers define stat to _stat64i32. */
  783. # undef _stat64i32
  784. # define _stat64i32(name, st) rpl_stat (name, st)
  785. # endif
  786. # else /* !(_AIX || __MINGW32__ || _MSC_VER) */
  787. # undef stat
  788. # define stat(name, st) rpl_stat (name, st)
  789. # endif /* !_LARGE_FILES */
  790. # endif /* !@GNULIB_OVERRIDES_STRUCT_STAT@ */
  791. _GL_EXTERN_C int stat (const char *restrict name, struct stat *restrict buf)
  792. _GL_ARG_NONNULL ((1, 2));
  793. # endif
  794. #elif @GNULIB_OVERRIDES_STRUCT_STAT@
  795. /* see above:
  796. #define stat stat_used_without_requesting_gnulib_module_stat
  797. */
  798. #elif defined GNULIB_POSIXCHECK
  799. # undef stat
  800. # if HAVE_RAW_DECL_STAT
  801. _GL_WARN_ON_USE (stat, "stat is unportable - "
  802. "use gnulib module stat 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