stat.h 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052
  1. /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
  2. /* Provide a more complete sys/stat header file.
  3. Copyright (C) 2005-2013 Free Software Foundation, Inc.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3, or (at your option)
  7. any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, see <http://www.gnu.org/licenses/>. */
  14. /* Written by Eric Blake, Paul Eggert, and Jim Meyering. */
  15. /* This file is supposed to be used on platforms where <sys/stat.h> is
  16. incomplete. It is intended to provide definitions and prototypes
  17. needed by an application. Start with what the system provides. */
  18. #if __GNUC__ >= 3
  19. #endif
  20. #if defined __need_system_sys_stat_h
  21. /* Special invocation convention. */
  22. #if _MSC_VER >= 1900
  23. #include <../ucrt/sys/stat.h>
  24. #else
  25. #error #include <../include/sys/stat.h>
  26. #endif
  27. #else
  28. /* Normal invocation convention. */
  29. #ifndef _GL_M4_SYS_STAT_H
  30. /* Get nlink_t.
  31. May also define off_t to a 64-bit type on native Windows. */
  32. #include <sys/types.h>
  33. /* Get struct timespec. */
  34. #include <time.h>
  35. /* The include_next requires a split double-inclusion guard. */
  36. #if _MSC_VER >= 1900
  37. #include <../ucrt/sys/stat.h>
  38. #else
  39. #error #include <../include/sys/stat.h>
  40. #endif
  41. #ifndef _GL_M4_SYS_STAT_H
  42. #define _GL_M4_SYS_STAT_H
  43. /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
  44. #ifndef _GL_CXXDEFS_H
  45. #define _GL_CXXDEFS_H
  46. /* The three most frequent use cases of these macros are:
  47. * For providing a substitute for a function that is missing on some
  48. platforms, but is declared and works fine on the platforms on which
  49. it exists:
  50. #if @GNULIB_FOO@
  51. # if !@HAVE_FOO@
  52. _GL_FUNCDECL_SYS (foo, ...);
  53. # endif
  54. _GL_CXXALIAS_SYS (foo, ...);
  55. _GL_CXXALIASWARN (foo);
  56. #elif defined GNULIB_POSIXCHECK
  57. ...
  58. #endif
  59. * For providing a replacement for a function that exists on all platforms,
  60. but is broken/insufficient and needs to be replaced on some platforms:
  61. #if @GNULIB_FOO@
  62. # if @REPLACE_FOO@
  63. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  64. # undef foo
  65. # define foo rpl_foo
  66. # endif
  67. _GL_FUNCDECL_RPL (foo, ...);
  68. _GL_CXXALIAS_RPL (foo, ...);
  69. # else
  70. _GL_CXXALIAS_SYS (foo, ...);
  71. # endif
  72. _GL_CXXALIASWARN (foo);
  73. #elif defined GNULIB_POSIXCHECK
  74. ...
  75. #endif
  76. * For providing a replacement for a function that exists on some platforms
  77. but is broken/insufficient and needs to be replaced on some of them and
  78. is additionally either missing or undeclared on some other platforms:
  79. #if @GNULIB_FOO@
  80. # if @REPLACE_FOO@
  81. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  82. # undef foo
  83. # define foo rpl_foo
  84. # endif
  85. _GL_FUNCDECL_RPL (foo, ...);
  86. _GL_CXXALIAS_RPL (foo, ...);
  87. # else
  88. # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
  89. _GL_FUNCDECL_SYS (foo, ...);
  90. # endif
  91. _GL_CXXALIAS_SYS (foo, ...);
  92. # endif
  93. _GL_CXXALIASWARN (foo);
  94. #elif defined GNULIB_POSIXCHECK
  95. ...
  96. #endif
  97. */
  98. /* _GL_EXTERN_C declaration;
  99. performs the declaration with C linkage. */
  100. #if defined __cplusplus
  101. # define _GL_EXTERN_C extern "C"
  102. #else
  103. # define _GL_EXTERN_C extern
  104. #endif
  105. /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
  106. declares a replacement function, named rpl_func, with the given prototype,
  107. consisting of return type, parameters, and attributes.
  108. Example:
  109. _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
  110. _GL_ARG_NONNULL ((1)));
  111. */
  112. #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
  113. _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
  114. #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
  115. _GL_EXTERN_C rettype rpl_func parameters_and_attributes
  116. /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
  117. declares the system function, named func, with the given prototype,
  118. consisting of return type, parameters, and attributes.
  119. Example:
  120. _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
  121. _GL_ARG_NONNULL ((1)));
  122. */
  123. #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
  124. _GL_EXTERN_C rettype func parameters_and_attributes
  125. /* _GL_CXXALIAS_RPL (func, rettype, parameters);
  126. declares a C++ alias called GNULIB_NAMESPACE::func
  127. that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
  128. Example:
  129. _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
  130. */
  131. #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
  132. _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
  133. #if defined __cplusplus && defined GNULIB_NAMESPACE
  134. # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
  135. namespace GNULIB_NAMESPACE \
  136. { \
  137. rettype (*const func) parameters = ::rpl_func; \
  138. } \
  139. _GL_EXTERN_C int _gl_cxxalias_dummy
  140. #else
  141. # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
  142. _GL_EXTERN_C int _gl_cxxalias_dummy
  143. #endif
  144. /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
  145. is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
  146. except that the C function rpl_func may have a slightly different
  147. declaration. A cast is used to silence the "invalid conversion" error
  148. that would otherwise occur. */
  149. #if defined __cplusplus && defined GNULIB_NAMESPACE
  150. # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
  151. namespace GNULIB_NAMESPACE \
  152. { \
  153. rettype (*const func) parameters = \
  154. reinterpret_cast<rettype(*)parameters>(::rpl_func); \
  155. } \
  156. _GL_EXTERN_C int _gl_cxxalias_dummy
  157. #else
  158. # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
  159. _GL_EXTERN_C int _gl_cxxalias_dummy
  160. #endif
  161. /* _GL_CXXALIAS_SYS (func, rettype, parameters);
  162. declares a C++ alias called GNULIB_NAMESPACE::func
  163. that redirects to the system provided function func, if GNULIB_NAMESPACE
  164. is defined.
  165. Example:
  166. _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
  167. */
  168. #if defined __cplusplus && defined GNULIB_NAMESPACE
  169. /* If we were to write
  170. rettype (*const func) parameters = ::func;
  171. like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls
  172. better (remove an indirection through a 'static' pointer variable),
  173. but then the _GL_CXXALIASWARN macro below would cause a warning not only
  174. for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */
  175. # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
  176. namespace GNULIB_NAMESPACE \
  177. { \
  178. static rettype (*func) parameters = ::func; \
  179. } \
  180. _GL_EXTERN_C int _gl_cxxalias_dummy
  181. #else
  182. # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
  183. _GL_EXTERN_C int _gl_cxxalias_dummy
  184. #endif
  185. /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
  186. is like _GL_CXXALIAS_SYS (func, rettype, parameters);
  187. except that the C function func may have a slightly different declaration.
  188. A cast is used to silence the "invalid conversion" error that would
  189. otherwise occur. */
  190. #if defined __cplusplus && defined GNULIB_NAMESPACE
  191. # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
  192. namespace GNULIB_NAMESPACE \
  193. { \
  194. static rettype (*func) parameters = \
  195. reinterpret_cast<rettype(*)parameters>(::func); \
  196. } \
  197. _GL_EXTERN_C int _gl_cxxalias_dummy
  198. #else
  199. # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
  200. _GL_EXTERN_C int _gl_cxxalias_dummy
  201. #endif
  202. /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
  203. is like _GL_CXXALIAS_SYS (func, rettype, parameters);
  204. except that the C function is picked among a set of overloaded functions,
  205. namely the one with rettype2 and parameters2. Two consecutive casts
  206. are used to silence the "cannot find a match" and "invalid conversion"
  207. errors that would otherwise occur. */
  208. #if defined __cplusplus && defined GNULIB_NAMESPACE
  209. /* The outer cast must be a reinterpret_cast.
  210. The inner cast: When the function is defined as a set of overloaded
  211. functions, it works as a static_cast<>, choosing the designated variant.
  212. When the function is defined as a single variant, it works as a
  213. reinterpret_cast<>. The parenthesized cast syntax works both ways. */
  214. # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
  215. namespace GNULIB_NAMESPACE \
  216. { \
  217. static rettype (*func) parameters = \
  218. reinterpret_cast<rettype(*)parameters>( \
  219. (rettype2(*)parameters2)(::func)); \
  220. } \
  221. _GL_EXTERN_C int _gl_cxxalias_dummy
  222. #else
  223. # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
  224. _GL_EXTERN_C int _gl_cxxalias_dummy
  225. #endif
  226. /* _GL_CXXALIASWARN (func);
  227. causes a warning to be emitted when ::func is used but not when
  228. GNULIB_NAMESPACE::func is used. func must be defined without overloaded
  229. variants. */
  230. #if defined __cplusplus && defined GNULIB_NAMESPACE
  231. # define _GL_CXXALIASWARN(func) \
  232. _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
  233. # define _GL_CXXALIASWARN_1(func,namespace) \
  234. _GL_CXXALIASWARN_2 (func, namespace)
  235. /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
  236. we enable the warning only when not optimizing. */
  237. # if !__OPTIMIZE__
  238. # define _GL_CXXALIASWARN_2(func,namespace) \
  239. _GL_WARN_ON_USE (func, \
  240. "The symbol ::" #func " refers to the system function. " \
  241. "Use " #namespace "::" #func " instead.")
  242. # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
  243. # define _GL_CXXALIASWARN_2(func,namespace) \
  244. extern __typeof__ (func) func
  245. # else
  246. # define _GL_CXXALIASWARN_2(func,namespace) \
  247. _GL_EXTERN_C int _gl_cxxalias_dummy
  248. # endif
  249. #else
  250. # define _GL_CXXALIASWARN(func) \
  251. _GL_EXTERN_C int _gl_cxxalias_dummy
  252. #endif
  253. /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
  254. causes a warning to be emitted when the given overloaded variant of ::func
  255. is used but not when GNULIB_NAMESPACE::func is used. */
  256. #if defined __cplusplus && defined GNULIB_NAMESPACE
  257. # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
  258. _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
  259. GNULIB_NAMESPACE)
  260. # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
  261. _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
  262. /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
  263. we enable the warning only when not optimizing. */
  264. # if !__OPTIMIZE__
  265. # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
  266. _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
  267. "The symbol ::" #func " refers to the system function. " \
  268. "Use " #namespace "::" #func " instead.")
  269. # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
  270. # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
  271. extern __typeof__ (func) func
  272. # else
  273. # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
  274. _GL_EXTERN_C int _gl_cxxalias_dummy
  275. # endif
  276. #else
  277. # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
  278. _GL_EXTERN_C int _gl_cxxalias_dummy
  279. #endif
  280. #endif /* _GL_CXXDEFS_H */
  281. /* The definition of _GL_ARG_NONNULL is copied here. */
  282. /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
  283. that the values passed as arguments n, ..., m must be non-NULL pointers.
  284. n = 1 stands for the first argument, n = 2 for the second argument etc. */
  285. #ifndef _GL_ARG_NONNULL
  286. # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
  287. # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
  288. # else
  289. # define _GL_ARG_NONNULL(params)
  290. # endif
  291. #endif
  292. /* The definition of _GL_WARN_ON_USE is copied here. */
  293. #ifndef _GL_WARN_ON_USE
  294. # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
  295. /* A compiler attribute is available in gcc versions 4.3.0 and later. */
  296. # define _GL_WARN_ON_USE(function, message) \
  297. extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
  298. # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
  299. /* Verify the existence of the function. */
  300. # define _GL_WARN_ON_USE(function, message) \
  301. extern __typeof__ (function) function
  302. # else /* Unsupported. */
  303. # define _GL_WARN_ON_USE(function, message) \
  304. _GL_WARN_EXTERN_C int _gl_warn_on_use
  305. # endif
  306. #endif
  307. /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
  308. is like _GL_WARN_ON_USE (function, "string"), except that the function is
  309. declared with the given prototype, consisting of return type, parameters,
  310. and attributes.
  311. This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
  312. not work in this case. */
  313. #ifndef _GL_WARN_ON_USE_CXX
  314. # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
  315. # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
  316. extern rettype function parameters_and_attributes \
  317. __attribute__ ((__warning__ (msg)))
  318. # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
  319. /* Verify the existence of the function. */
  320. # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
  321. extern rettype function parameters_and_attributes
  322. # else /* Unsupported. */
  323. # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
  324. _GL_WARN_EXTERN_C int _gl_warn_on_use
  325. # endif
  326. #endif
  327. /* _GL_WARN_EXTERN_C declaration;
  328. performs the declaration with C linkage. */
  329. #ifndef _GL_WARN_EXTERN_C
  330. # if defined __cplusplus
  331. # define _GL_WARN_EXTERN_C extern "C"
  332. # else
  333. # define _GL_WARN_EXTERN_C extern
  334. # endif
  335. #endif
  336. /* Before doing "#define mkdir rpl_mkdir" below, we need to include all
  337. headers that may declare mkdir(). Native Windows platforms declare mkdir
  338. in <io.h> and/or <direct.h>, not in <unistd.h>. */
  339. #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
  340. # include <io.h> /* mingw32, mingw64 */
  341. # include <direct.h> /* mingw64, MSVC 9 */
  342. #endif
  343. /* Native Windows platforms declare umask() in <io.h>. */
  344. #if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
  345. # include <io.h>
  346. #endif
  347. /* Large File Support on native Windows. */
  348. #if 1
  349. # define stat _stati64
  350. #endif
  351. #ifndef S_IFIFO
  352. # ifdef _S_IFIFO
  353. # define S_IFIFO _S_IFIFO
  354. # endif
  355. #endif
  356. #ifndef S_IFMT
  357. # define S_IFMT 0170000
  358. #endif
  359. #if STAT_MACROS_BROKEN
  360. # undef S_ISBLK
  361. # undef S_ISCHR
  362. # undef S_ISDIR
  363. # undef S_ISFIFO
  364. # undef S_ISLNK
  365. # undef S_ISNAM
  366. # undef S_ISMPB
  367. # undef S_ISMPC
  368. # undef S_ISNWK
  369. # undef S_ISREG
  370. # undef S_ISSOCK
  371. #endif
  372. #ifndef S_ISBLK
  373. # ifdef S_IFBLK
  374. # define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
  375. # else
  376. # define S_ISBLK(m) 0
  377. # endif
  378. #endif
  379. #ifndef S_ISCHR
  380. # ifdef S_IFCHR
  381. # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
  382. # else
  383. # define S_ISCHR(m) 0
  384. # endif
  385. #endif
  386. #ifndef S_ISDIR
  387. # ifdef S_IFDIR
  388. # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
  389. # else
  390. # define S_ISDIR(m) 0
  391. # endif
  392. #endif
  393. #ifndef S_ISDOOR /* Solaris 2.5 and up */
  394. # define S_ISDOOR(m) 0
  395. #endif
  396. #ifndef S_ISFIFO
  397. # ifdef S_IFIFO
  398. # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
  399. # else
  400. # define S_ISFIFO(m) 0
  401. # endif
  402. #endif
  403. #ifndef S_ISLNK
  404. # ifdef S_IFLNK
  405. # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
  406. # else
  407. # define S_ISLNK(m) 0
  408. # endif
  409. #endif
  410. #ifndef S_ISMPB /* V7 */
  411. # ifdef S_IFMPB
  412. # define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
  413. # define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
  414. # else
  415. # define S_ISMPB(m) 0
  416. # define S_ISMPC(m) 0
  417. # endif
  418. #endif
  419. #ifndef S_ISMPX /* AIX */
  420. # define S_ISMPX(m) 0
  421. #endif
  422. #ifndef S_ISNAM /* Xenix */
  423. # ifdef S_IFNAM
  424. # define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
  425. # else
  426. # define S_ISNAM(m) 0
  427. # endif
  428. #endif
  429. #ifndef S_ISNWK /* HP/UX */
  430. # ifdef S_IFNWK
  431. # define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
  432. # else
  433. # define S_ISNWK(m) 0
  434. # endif
  435. #endif
  436. #ifndef S_ISPORT /* Solaris 10 and up */
  437. # define S_ISPORT(m) 0
  438. #endif
  439. #ifndef S_ISREG
  440. # ifdef S_IFREG
  441. # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
  442. # else
  443. # define S_ISREG(m) 0
  444. # endif
  445. #endif
  446. #ifndef S_ISSOCK
  447. # ifdef S_IFSOCK
  448. # define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
  449. # else
  450. # define S_ISSOCK(m) 0
  451. # endif
  452. #endif
  453. #ifndef S_TYPEISMQ
  454. # define S_TYPEISMQ(p) 0
  455. #endif
  456. #ifndef S_TYPEISTMO
  457. # define S_TYPEISTMO(p) 0
  458. #endif
  459. #ifndef S_TYPEISSEM
  460. # ifdef S_INSEM
  461. # define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
  462. # else
  463. # define S_TYPEISSEM(p) 0
  464. # endif
  465. #endif
  466. #ifndef S_TYPEISSHM
  467. # ifdef S_INSHD
  468. # define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
  469. # else
  470. # define S_TYPEISSHM(p) 0
  471. # endif
  472. #endif
  473. /* high performance ("contiguous data") */
  474. #ifndef S_ISCTG
  475. # define S_ISCTG(p) 0
  476. #endif
  477. /* Cray DMF (data migration facility): off line, with data */
  478. #ifndef S_ISOFD
  479. # define S_ISOFD(p) 0
  480. #endif
  481. /* Cray DMF (data migration facility): off line, with no data */
  482. #ifndef S_ISOFL
  483. # define S_ISOFL(p) 0
  484. #endif
  485. /* 4.4BSD whiteout */
  486. #ifndef S_ISWHT
  487. # define S_ISWHT(m) 0
  488. #endif
  489. /* If any of the following are undefined,
  490. define them to their de facto standard values. */
  491. #if !S_ISUID
  492. # define S_ISUID 04000
  493. #endif
  494. #if !S_ISGID
  495. # define S_ISGID 02000
  496. #endif
  497. /* S_ISVTX is a common extension to POSIX. */
  498. #ifndef S_ISVTX
  499. # define S_ISVTX 01000
  500. #endif
  501. #if !S_IRUSR && S_IREAD
  502. # define S_IRUSR S_IREAD
  503. #endif
  504. #if !S_IRUSR
  505. # define S_IRUSR 00400
  506. #endif
  507. #if !S_IRGRP
  508. # define S_IRGRP (S_IRUSR >> 3)
  509. #endif
  510. #if !S_IROTH
  511. # define S_IROTH (S_IRUSR >> 6)
  512. #endif
  513. #if !S_IWUSR && S_IWRITE
  514. # define S_IWUSR S_IWRITE
  515. #endif
  516. #if !S_IWUSR
  517. # define S_IWUSR 00200
  518. #endif
  519. #if !S_IWGRP
  520. # define S_IWGRP (S_IWUSR >> 3)
  521. #endif
  522. #if !S_IWOTH
  523. # define S_IWOTH (S_IWUSR >> 6)
  524. #endif
  525. #if !S_IXUSR && S_IEXEC
  526. # define S_IXUSR S_IEXEC
  527. #endif
  528. #if !S_IXUSR
  529. # define S_IXUSR 00100
  530. #endif
  531. #if !S_IXGRP
  532. # define S_IXGRP (S_IXUSR >> 3)
  533. #endif
  534. #if !S_IXOTH
  535. # define S_IXOTH (S_IXUSR >> 6)
  536. #endif
  537. #if !S_IRWXU
  538. # define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
  539. #endif
  540. #if !S_IRWXG
  541. # define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
  542. #endif
  543. #if !S_IRWXO
  544. # define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
  545. #endif
  546. /* S_IXUGO is a common extension to POSIX. */
  547. #if !S_IXUGO
  548. # define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
  549. #endif
  550. #ifndef S_IRWXUGO
  551. # define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
  552. #endif
  553. /* Macros for futimens and utimensat. */
  554. #ifndef UTIME_NOW
  555. # define UTIME_NOW (-1)
  556. # define UTIME_OMIT (-2)
  557. #endif
  558. #if 0
  559. # if !1
  560. _GL_FUNCDECL_SYS (fchmodat, int,
  561. (int fd, char const *file, mode_t mode, int flag)
  562. _GL_ARG_NONNULL ((2)));
  563. # endif
  564. _GL_CXXALIAS_SYS (fchmodat, int,
  565. (int fd, char const *file, mode_t mode, int flag));
  566. _GL_CXXALIASWARN (fchmodat);
  567. #elif defined GNULIB_POSIXCHECK
  568. # undef fchmodat
  569. # if HAVE_RAW_DECL_FCHMODAT
  570. _GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - "
  571. "use gnulib module openat for portability");
  572. # endif
  573. #endif
  574. #if 1
  575. # if 1
  576. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  577. # undef fstat
  578. # define fstat rpl_fstat
  579. # endif
  580. _GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2)));
  581. _GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
  582. # else
  583. _GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
  584. # endif
  585. _GL_CXXALIASWARN (fstat);
  586. #elif 1
  587. /* Above, we define stat to _stati64. */
  588. # define fstat _fstati64
  589. #elif defined GNULIB_POSIXCHECK
  590. # undef fstat
  591. # if HAVE_RAW_DECL_FSTAT
  592. _GL_WARN_ON_USE (fstat, "fstat has portability problems - "
  593. "use gnulib module fstat for portability");
  594. # endif
  595. #endif
  596. #if 0
  597. # if 0
  598. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  599. # undef fstatat
  600. # define fstatat rpl_fstatat
  601. # endif
  602. _GL_FUNCDECL_RPL (fstatat, int,
  603. (int fd, char const *name, struct stat *st, int flags)
  604. _GL_ARG_NONNULL ((2, 3)));
  605. _GL_CXXALIAS_RPL (fstatat, int,
  606. (int fd, char const *name, struct stat *st, int flags));
  607. # else
  608. # if !1
  609. _GL_FUNCDECL_SYS (fstatat, int,
  610. (int fd, char const *name, struct stat *st, int flags)
  611. _GL_ARG_NONNULL ((2, 3)));
  612. # endif
  613. _GL_CXXALIAS_SYS (fstatat, int,
  614. (int fd, char const *name, struct stat *st, int flags));
  615. # endif
  616. _GL_CXXALIASWARN (fstatat);
  617. #elif defined GNULIB_POSIXCHECK
  618. # undef fstatat
  619. # if HAVE_RAW_DECL_FSTATAT
  620. _GL_WARN_ON_USE (fstatat, "fstatat is not portable - "
  621. "use gnulib module openat for portability");
  622. # endif
  623. #endif
  624. #if 0
  625. /* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our futimens
  626. implementation relies on futimesat, which on Solaris 10 makes an invocation
  627. to futimens that is meant to invoke the libc's futimens(), not gnulib's
  628. futimens(). */
  629. # if 0 || (!1 && defined __sun)
  630. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  631. # undef futimens
  632. # define futimens rpl_futimens
  633. # endif
  634. _GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2]));
  635. _GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2]));
  636. # else
  637. # if !1
  638. _GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2]));
  639. # endif
  640. _GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2]));
  641. # endif
  642. # if 1
  643. _GL_CXXALIASWARN (futimens);
  644. # endif
  645. #elif defined GNULIB_POSIXCHECK
  646. # undef futimens
  647. # if HAVE_RAW_DECL_FUTIMENS
  648. _GL_WARN_ON_USE (futimens, "futimens is not portable - "
  649. "use gnulib module futimens for portability");
  650. # endif
  651. #endif
  652. #if 0
  653. /* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
  654. denotes a symbolic link. */
  655. # if !1
  656. /* The lchmod replacement follows symbolic links. Callers should take
  657. this into account; lchmod should be applied only to arguments that
  658. are known to not be symbolic links. On hosts that lack lchmod,
  659. this can lead to race conditions between the check and the
  660. invocation of lchmod, but we know of no workarounds that are
  661. reliable in general. You might try requesting support for lchmod
  662. from your operating system supplier. */
  663. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  664. # define lchmod chmod
  665. # endif
  666. /* Need to cast, because on mingw, the second parameter of chmod is
  667. int mode. */
  668. _GL_CXXALIAS_RPL_CAST_1 (lchmod, chmod, int,
  669. (const char *filename, mode_t mode));
  670. # else
  671. # if 0 /* assume already declared */
  672. _GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode)
  673. _GL_ARG_NONNULL ((1)));
  674. # endif
  675. _GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode));
  676. # endif
  677. # if 1
  678. _GL_CXXALIASWARN (lchmod);
  679. # endif
  680. #elif defined GNULIB_POSIXCHECK
  681. # undef lchmod
  682. # if HAVE_RAW_DECL_LCHMOD
  683. _GL_WARN_ON_USE (lchmod, "lchmod is unportable - "
  684. "use gnulib module lchmod for portability");
  685. # endif
  686. #endif
  687. #if 1
  688. # if ! 0
  689. /* mingw does not support symlinks, therefore it does not have lstat. But
  690. without links, stat does just fine. */
  691. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  692. # define lstat stat
  693. # endif
  694. _GL_CXXALIAS_RPL_1 (lstat, stat, int, (const char *name, struct stat *buf));
  695. # elif 0
  696. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  697. # undef lstat
  698. # define lstat rpl_lstat
  699. # endif
  700. _GL_FUNCDECL_RPL (lstat, int, (const char *name, struct stat *buf)
  701. _GL_ARG_NONNULL ((1, 2)));
  702. _GL_CXXALIAS_RPL (lstat, int, (const char *name, struct stat *buf));
  703. # else
  704. _GL_CXXALIAS_SYS (lstat, int, (const char *name, struct stat *buf));
  705. # endif
  706. # if 0
  707. _GL_CXXALIASWARN (lstat);
  708. # endif
  709. #elif defined GNULIB_POSIXCHECK
  710. # undef lstat
  711. # if HAVE_RAW_DECL_LSTAT
  712. _GL_WARN_ON_USE (lstat, "lstat is unportable - "
  713. "use gnulib module lstat for portability");
  714. # endif
  715. #endif
  716. #if 0
  717. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  718. # undef mkdir
  719. # define mkdir rpl_mkdir
  720. # endif
  721. _GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode)
  722. _GL_ARG_NONNULL ((1)));
  723. _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
  724. #else
  725. /* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
  726. Additionally, it declares _mkdir (and depending on compile flags, an
  727. alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
  728. which are included above. */
  729. # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
  730. # if !GNULIB_defined_rpl_mkdir
  731. static int
  732. rpl_mkdir (char const *name, mode_t mode)
  733. {
  734. return _mkdir (name);
  735. }
  736. # define GNULIB_defined_rpl_mkdir 1
  737. # endif
  738. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  739. # define mkdir rpl_mkdir
  740. # endif
  741. _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
  742. # else
  743. _GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
  744. # endif
  745. #endif
  746. _GL_CXXALIASWARN (mkdir);
  747. #if 0
  748. # if !1
  749. _GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)
  750. _GL_ARG_NONNULL ((2)));
  751. # endif
  752. _GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode));
  753. _GL_CXXALIASWARN (mkdirat);
  754. #elif defined GNULIB_POSIXCHECK
  755. # undef mkdirat
  756. # if HAVE_RAW_DECL_MKDIRAT
  757. _GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - "
  758. "use gnulib module openat for portability");
  759. # endif
  760. #endif
  761. #if 0
  762. # if 0
  763. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  764. # undef mkfifo
  765. # define mkfifo rpl_mkfifo
  766. # endif
  767. _GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode)
  768. _GL_ARG_NONNULL ((1)));
  769. _GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode));
  770. # else
  771. # if !1
  772. _GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode)
  773. _GL_ARG_NONNULL ((1)));
  774. # endif
  775. _GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode));
  776. # endif
  777. _GL_CXXALIASWARN (mkfifo);
  778. #elif defined GNULIB_POSIXCHECK
  779. # undef mkfifo
  780. # if HAVE_RAW_DECL_MKFIFO
  781. _GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - "
  782. "use gnulib module mkfifo for portability");
  783. # endif
  784. #endif
  785. #if 0
  786. # if !1
  787. _GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)
  788. _GL_ARG_NONNULL ((2)));
  789. # endif
  790. _GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode));
  791. _GL_CXXALIASWARN (mkfifoat);
  792. #elif defined GNULIB_POSIXCHECK
  793. # undef mkfifoat
  794. # if HAVE_RAW_DECL_MKFIFOAT
  795. _GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - "
  796. "use gnulib module mkfifoat for portability");
  797. # endif
  798. #endif
  799. #if 0
  800. # if 0
  801. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  802. # undef mknod
  803. # define mknod rpl_mknod
  804. # endif
  805. _GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)
  806. _GL_ARG_NONNULL ((1)));
  807. _GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev));
  808. # else
  809. # if !1
  810. _GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev)
  811. _GL_ARG_NONNULL ((1)));
  812. # endif
  813. /* Need to cast, because on OSF/1 5.1, the third parameter is '...'. */
  814. _GL_CXXALIAS_SYS_CAST (mknod, int, (char const *file, mode_t mode, dev_t dev));
  815. # endif
  816. _GL_CXXALIASWARN (mknod);
  817. #elif defined GNULIB_POSIXCHECK
  818. # undef mknod
  819. # if HAVE_RAW_DECL_MKNOD
  820. _GL_WARN_ON_USE (mknod, "mknod is not portable - "
  821. "use gnulib module mknod for portability");
  822. # endif
  823. #endif
  824. #if 0
  825. # if !1
  826. _GL_FUNCDECL_SYS (mknodat, int,
  827. (int fd, char const *file, mode_t mode, dev_t dev)
  828. _GL_ARG_NONNULL ((2)));
  829. # endif
  830. _GL_CXXALIAS_SYS (mknodat, int,
  831. (int fd, char const *file, mode_t mode, dev_t dev));
  832. _GL_CXXALIASWARN (mknodat);
  833. #elif defined GNULIB_POSIXCHECK
  834. # undef mknodat
  835. # if HAVE_RAW_DECL_MKNODAT
  836. _GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
  837. "use gnulib module mkfifoat for portability");
  838. # endif
  839. #endif
  840. #if 1
  841. # if 1
  842. /* We can't use the object-like #define stat rpl_stat, because of
  843. struct stat. This means that rpl_stat will not be used if the user
  844. does (stat)(a,b). Oh well. */
  845. # if defined _AIX && defined stat && defined _LARGE_FILES
  846. /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
  847. so we have to replace stat64() instead of stat(). */
  848. # undef stat64
  849. # define stat64(name, st) rpl_stat (name, st)
  850. # elif 1
  851. /* Above, we define stat to _stati64. */
  852. # if defined __MINGW32__ && defined _stati64
  853. # ifndef _USE_32BIT_TIME_T
  854. /* The system headers define _stati64 to _stat64. */
  855. # undef _stat64
  856. # define _stat64(name, st) rpl_stat (name, st)
  857. # endif
  858. # elif defined _MSC_VER && defined _stati64
  859. # ifdef _USE_32BIT_TIME_T
  860. /* The system headers define _stati64 to _stat32i64. */
  861. # undef _stat32i64
  862. # define _stat32i64(name, st) rpl_stat (name, st)
  863. # else
  864. /* The system headers define _stati64 to _stat64. */
  865. # undef _stat64
  866. # define _stat64(name, st) rpl_stat (name, st)
  867. # endif
  868. # else
  869. # undef _stati64
  870. # define _stati64(name, st) rpl_stat (name, st)
  871. # endif
  872. # elif defined __MINGW32__ && defined stat
  873. # ifdef _USE_32BIT_TIME_T
  874. /* The system headers define stat to _stat32i64. */
  875. # undef _stat32i64
  876. # define _stat32i64(name, st) rpl_stat (name, st)
  877. # else
  878. /* The system headers define stat to _stat64. */
  879. # undef _stat64
  880. # define _stat64(name, st) rpl_stat (name, st)
  881. # endif
  882. # elif defined _MSC_VER && defined stat
  883. # ifdef _USE_32BIT_TIME_T
  884. /* The system headers define stat to _stat32. */
  885. # undef _stat32
  886. # define _stat32(name, st) rpl_stat (name, st)
  887. # else
  888. /* The system headers define stat to _stat64i32. */
  889. # undef _stat64i32
  890. # define _stat64i32(name, st) rpl_stat (name, st)
  891. # endif
  892. # else /* !(_AIX ||__MINGW32__ || _MSC_VER) */
  893. # undef stat
  894. # define stat(name, st) rpl_stat (name, st)
  895. # endif /* !_LARGE_FILES */
  896. _GL_EXTERN_C int stat (const char *name, struct stat *buf)
  897. _GL_ARG_NONNULL ((1, 2));
  898. # endif
  899. #elif defined GNULIB_POSIXCHECK
  900. # undef stat
  901. # if HAVE_RAW_DECL_STAT
  902. _GL_WARN_ON_USE (stat, "stat is unportable - "
  903. "use gnulib module stat for portability");
  904. # endif
  905. #endif
  906. #if 0
  907. /* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat
  908. implementation relies on futimesat, which on Solaris 10 makes an invocation
  909. to utimensat that is meant to invoke the libc's utimensat(), not gnulib's
  910. utimensat(). */
  911. # if 0 || (!1 && defined __sun)
  912. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  913. # undef utimensat
  914. # define utimensat rpl_utimensat
  915. # endif
  916. _GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name,
  917. struct timespec const times[2], int flag)
  918. _GL_ARG_NONNULL ((2)));
  919. _GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name,
  920. struct timespec const times[2], int flag));
  921. # else
  922. # if !1
  923. _GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name,
  924. struct timespec const times[2], int flag)
  925. _GL_ARG_NONNULL ((2)));
  926. # endif
  927. _GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name,
  928. struct timespec const times[2], int flag));
  929. # endif
  930. # if 1
  931. _GL_CXXALIASWARN (utimensat);
  932. # endif
  933. #elif defined GNULIB_POSIXCHECK
  934. # undef utimensat
  935. # if HAVE_RAW_DECL_UTIMENSAT
  936. _GL_WARN_ON_USE (utimensat, "utimensat is not portable - "
  937. "use gnulib module utimensat for portability");
  938. # endif
  939. #endif
  940. #endif /* _GL_M4_SYS_STAT_H */
  941. #endif /* _GL_M4_SYS_STAT_H */
  942. #endif