fcntl.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
  2. /* Like <fcntl.h>, but with non-working flags defined to 0.
  3. Copyright (C) 2006-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 of the License, or
  7. (at your option) 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 Paul Eggert */
  15. #if __GNUC__ >= 3
  16. #pragma GCC system_header
  17. #endif
  18. #if defined __need_system_fcntl_h
  19. /* Special invocation convention. */
  20. /* Needed before <sys/stat.h>.
  21. May also define off_t to a 64-bit type on native Windows. */
  22. #include <sys/types.h>
  23. /* On some systems other than glibc, <sys/stat.h> is a prerequisite of
  24. <fcntl.h>. On glibc systems, we would like to avoid namespace pollution.
  25. But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
  26. extern "C" { ... } block, which leads to errors in C++ mode with the
  27. overridden <sys/stat.h> from gnulib. These errors are known to be gone
  28. with g++ version >= 4.3. */
  29. #if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
  30. # include <sys/stat.h>
  31. #endif
  32. #include_next <fcntl.h>
  33. #else
  34. /* Normal invocation convention. */
  35. #ifndef _GL_M4_FCNTL_H
  36. /* Needed before <sys/stat.h>.
  37. May also define off_t to a 64-bit type on native Windows. */
  38. #include <sys/types.h>
  39. /* On some systems other than glibc, <sys/stat.h> is a prerequisite of
  40. <fcntl.h>. On glibc systems, we would like to avoid namespace pollution.
  41. But on glibc systems, <fcntl.h> includes <sys/stat.h> inside an
  42. extern "C" { ... } block, which leads to errors in C++ mode with the
  43. overridden <sys/stat.h> from gnulib. These errors are known to be gone
  44. with g++ version >= 4.3. */
  45. #if !(defined __GLIBC__ || defined __UCLIBC__) || (defined __cplusplus && defined GNULIB_NAMESPACE && !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
  46. # include <sys/stat.h>
  47. #endif
  48. /* The include_next requires a split double-inclusion guard. */
  49. #include_next <fcntl.h>
  50. #ifndef _GL_M4_FCNTL_H
  51. #define _GL_M4_FCNTL_H
  52. #ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */
  53. # include <unistd.h>
  54. #endif
  55. /* Native Windows platforms declare open(), creat() in <io.h>. */
  56. #if (1 || defined GNULIB_POSIXCHECK) \
  57. && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
  58. # include <io.h>
  59. #endif
  60. /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
  61. #ifndef _GL_CXXDEFS_H
  62. #define _GL_CXXDEFS_H
  63. /* The three most frequent use cases of these macros are:
  64. * For providing a substitute for a function that is missing on some
  65. platforms, but is declared and works fine on the platforms on which
  66. it exists:
  67. #if @GNULIB_FOO@
  68. # if !@HAVE_FOO@
  69. _GL_FUNCDECL_SYS (foo, ...);
  70. # endif
  71. _GL_CXXALIAS_SYS (foo, ...);
  72. _GL_CXXALIASWARN (foo);
  73. #elif defined GNULIB_POSIXCHECK
  74. ...
  75. #endif
  76. * For providing a replacement for a function that exists on all platforms,
  77. but is broken/insufficient and needs to be replaced on some platforms:
  78. #if @GNULIB_FOO@
  79. # if @REPLACE_FOO@
  80. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  81. # undef foo
  82. # define foo rpl_foo
  83. # endif
  84. _GL_FUNCDECL_RPL (foo, ...);
  85. _GL_CXXALIAS_RPL (foo, ...);
  86. # else
  87. _GL_CXXALIAS_SYS (foo, ...);
  88. # endif
  89. _GL_CXXALIASWARN (foo);
  90. #elif defined GNULIB_POSIXCHECK
  91. ...
  92. #endif
  93. * For providing a replacement for a function that exists on some platforms
  94. but is broken/insufficient and needs to be replaced on some of them and
  95. is additionally either missing or undeclared on some other platforms:
  96. #if @GNULIB_FOO@
  97. # if @REPLACE_FOO@
  98. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  99. # undef foo
  100. # define foo rpl_foo
  101. # endif
  102. _GL_FUNCDECL_RPL (foo, ...);
  103. _GL_CXXALIAS_RPL (foo, ...);
  104. # else
  105. # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
  106. _GL_FUNCDECL_SYS (foo, ...);
  107. # endif
  108. _GL_CXXALIAS_SYS (foo, ...);
  109. # endif
  110. _GL_CXXALIASWARN (foo);
  111. #elif defined GNULIB_POSIXCHECK
  112. ...
  113. #endif
  114. */
  115. /* _GL_EXTERN_C declaration;
  116. performs the declaration with C linkage. */
  117. #if defined __cplusplus
  118. # define _GL_EXTERN_C extern "C"
  119. #else
  120. # define _GL_EXTERN_C extern
  121. #endif
  122. /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
  123. declares a replacement function, named rpl_func, with the given prototype,
  124. consisting of return type, parameters, and attributes.
  125. Example:
  126. _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
  127. _GL_ARG_NONNULL ((1)));
  128. */
  129. #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
  130. _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
  131. #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
  132. _GL_EXTERN_C rettype rpl_func parameters_and_attributes
  133. /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
  134. declares the system function, named func, with the given prototype,
  135. consisting of return type, parameters, and attributes.
  136. Example:
  137. _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
  138. _GL_ARG_NONNULL ((1)));
  139. */
  140. #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
  141. _GL_EXTERN_C rettype func parameters_and_attributes
  142. /* _GL_CXXALIAS_RPL (func, rettype, parameters);
  143. declares a C++ alias called GNULIB_NAMESPACE::func
  144. that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
  145. Example:
  146. _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
  147. */
  148. #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
  149. _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
  150. #if defined __cplusplus && defined GNULIB_NAMESPACE
  151. # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
  152. namespace GNULIB_NAMESPACE \
  153. { \
  154. rettype (*const func) parameters = ::rpl_func; \
  155. } \
  156. _GL_EXTERN_C int _gl_cxxalias_dummy
  157. #else
  158. # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
  159. _GL_EXTERN_C int _gl_cxxalias_dummy
  160. #endif
  161. /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
  162. is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
  163. except that the C function rpl_func may have a slightly different
  164. declaration. A cast is used to silence the "invalid conversion" error
  165. that would otherwise occur. */
  166. #if defined __cplusplus && defined GNULIB_NAMESPACE
  167. # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
  168. namespace GNULIB_NAMESPACE \
  169. { \
  170. rettype (*const func) parameters = \
  171. reinterpret_cast<rettype(*)parameters>(::rpl_func); \
  172. } \
  173. _GL_EXTERN_C int _gl_cxxalias_dummy
  174. #else
  175. # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
  176. _GL_EXTERN_C int _gl_cxxalias_dummy
  177. #endif
  178. /* _GL_CXXALIAS_SYS (func, rettype, parameters);
  179. declares a C++ alias called GNULIB_NAMESPACE::func
  180. that redirects to the system provided function func, if GNULIB_NAMESPACE
  181. is defined.
  182. Example:
  183. _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
  184. */
  185. #if defined __cplusplus && defined GNULIB_NAMESPACE
  186. /* If we were to write
  187. rettype (*const func) parameters = ::func;
  188. like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls
  189. better (remove an indirection through a 'static' pointer variable),
  190. but then the _GL_CXXALIASWARN macro below would cause a warning not only
  191. for uses of ::func but also for uses of GNULIB_NAMESPACE::func. */
  192. # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
  193. namespace GNULIB_NAMESPACE \
  194. { \
  195. static rettype (*func) parameters = ::func; \
  196. } \
  197. _GL_EXTERN_C int _gl_cxxalias_dummy
  198. #else
  199. # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
  200. _GL_EXTERN_C int _gl_cxxalias_dummy
  201. #endif
  202. /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
  203. is like _GL_CXXALIAS_SYS (func, rettype, parameters);
  204. except that the C function func may have a slightly different declaration.
  205. A cast is used to silence the "invalid conversion" error that would
  206. otherwise occur. */
  207. #if defined __cplusplus && defined GNULIB_NAMESPACE
  208. # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
  209. namespace GNULIB_NAMESPACE \
  210. { \
  211. static rettype (*func) parameters = \
  212. reinterpret_cast<rettype(*)parameters>(::func); \
  213. } \
  214. _GL_EXTERN_C int _gl_cxxalias_dummy
  215. #else
  216. # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
  217. _GL_EXTERN_C int _gl_cxxalias_dummy
  218. #endif
  219. /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
  220. is like _GL_CXXALIAS_SYS (func, rettype, parameters);
  221. except that the C function is picked among a set of overloaded functions,
  222. namely the one with rettype2 and parameters2. Two consecutive casts
  223. are used to silence the "cannot find a match" and "invalid conversion"
  224. errors that would otherwise occur. */
  225. #if defined __cplusplus && defined GNULIB_NAMESPACE
  226. /* The outer cast must be a reinterpret_cast.
  227. The inner cast: When the function is defined as a set of overloaded
  228. functions, it works as a static_cast<>, choosing the designated variant.
  229. When the function is defined as a single variant, it works as a
  230. reinterpret_cast<>. The parenthesized cast syntax works both ways. */
  231. # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
  232. namespace GNULIB_NAMESPACE \
  233. { \
  234. static rettype (*func) parameters = \
  235. reinterpret_cast<rettype(*)parameters>( \
  236. (rettype2(*)parameters2)(::func)); \
  237. } \
  238. _GL_EXTERN_C int _gl_cxxalias_dummy
  239. #else
  240. # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
  241. _GL_EXTERN_C int _gl_cxxalias_dummy
  242. #endif
  243. /* _GL_CXXALIASWARN (func);
  244. causes a warning to be emitted when ::func is used but not when
  245. GNULIB_NAMESPACE::func is used. func must be defined without overloaded
  246. variants. */
  247. #if defined __cplusplus && defined GNULIB_NAMESPACE
  248. # define _GL_CXXALIASWARN(func) \
  249. _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
  250. # define _GL_CXXALIASWARN_1(func,namespace) \
  251. _GL_CXXALIASWARN_2 (func, namespace)
  252. /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
  253. we enable the warning only when not optimizing. */
  254. # if !__OPTIMIZE__
  255. # define _GL_CXXALIASWARN_2(func,namespace) \
  256. _GL_WARN_ON_USE (func, \
  257. "The symbol ::" #func " refers to the system function. " \
  258. "Use " #namespace "::" #func " instead.")
  259. # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
  260. # define _GL_CXXALIASWARN_2(func,namespace) \
  261. extern __typeof__ (func) func
  262. # else
  263. # define _GL_CXXALIASWARN_2(func,namespace) \
  264. _GL_EXTERN_C int _gl_cxxalias_dummy
  265. # endif
  266. #else
  267. # define _GL_CXXALIASWARN(func) \
  268. _GL_EXTERN_C int _gl_cxxalias_dummy
  269. #endif
  270. /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
  271. causes a warning to be emitted when the given overloaded variant of ::func
  272. is used but not when GNULIB_NAMESPACE::func is used. */
  273. #if defined __cplusplus && defined GNULIB_NAMESPACE
  274. # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
  275. _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
  276. GNULIB_NAMESPACE)
  277. # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
  278. _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
  279. /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
  280. we enable the warning only when not optimizing. */
  281. # if !__OPTIMIZE__
  282. # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
  283. _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
  284. "The symbol ::" #func " refers to the system function. " \
  285. "Use " #namespace "::" #func " instead.")
  286. # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
  287. # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
  288. extern __typeof__ (func) func
  289. # else
  290. # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
  291. _GL_EXTERN_C int _gl_cxxalias_dummy
  292. # endif
  293. #else
  294. # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
  295. _GL_EXTERN_C int _gl_cxxalias_dummy
  296. #endif
  297. #endif /* _GL_CXXDEFS_H */
  298. /* The definition of _GL_ARG_NONNULL is copied here. */
  299. /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
  300. that the values passed as arguments n, ..., m must be non-NULL pointers.
  301. n = 1 stands for the first argument, n = 2 for the second argument etc. */
  302. #ifndef _GL_ARG_NONNULL
  303. # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
  304. # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
  305. # else
  306. # define _GL_ARG_NONNULL(params)
  307. # endif
  308. #endif
  309. /* The definition of _GL_WARN_ON_USE is copied here. */
  310. #ifndef _GL_WARN_ON_USE
  311. # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
  312. /* A compiler attribute is available in gcc versions 4.3.0 and later. */
  313. # define _GL_WARN_ON_USE(function, message) \
  314. extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
  315. # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
  316. /* Verify the existence of the function. */
  317. # define _GL_WARN_ON_USE(function, message) \
  318. extern __typeof__ (function) function
  319. # else /* Unsupported. */
  320. # define _GL_WARN_ON_USE(function, message) \
  321. _GL_WARN_EXTERN_C int _gl_warn_on_use
  322. # endif
  323. #endif
  324. /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
  325. is like _GL_WARN_ON_USE (function, "string"), except that the function is
  326. declared with the given prototype, consisting of return type, parameters,
  327. and attributes.
  328. This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
  329. not work in this case. */
  330. #ifndef _GL_WARN_ON_USE_CXX
  331. # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
  332. # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
  333. extern rettype function parameters_and_attributes \
  334. __attribute__ ((__warning__ (msg)))
  335. # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
  336. /* Verify the existence of the function. */
  337. # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
  338. extern rettype function parameters_and_attributes
  339. # else /* Unsupported. */
  340. # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
  341. _GL_WARN_EXTERN_C int _gl_warn_on_use
  342. # endif
  343. #endif
  344. /* _GL_WARN_EXTERN_C declaration;
  345. performs the declaration with C linkage. */
  346. #ifndef _GL_WARN_EXTERN_C
  347. # if defined __cplusplus
  348. # define _GL_WARN_EXTERN_C extern "C"
  349. # else
  350. # define _GL_WARN_EXTERN_C extern
  351. # endif
  352. #endif
  353. /* Declare overridden functions. */
  354. #if 1
  355. # if 1
  356. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  357. # undef fcntl
  358. # define fcntl rpl_fcntl
  359. # endif
  360. _GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...));
  361. _GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...));
  362. # else
  363. # if !1
  364. _GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...));
  365. # endif
  366. _GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...));
  367. # endif
  368. _GL_CXXALIASWARN (fcntl);
  369. #elif defined GNULIB_POSIXCHECK
  370. # undef fcntl
  371. # if HAVE_RAW_DECL_FCNTL
  372. _GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - "
  373. "use gnulib module fcntl for portability");
  374. # endif
  375. #endif
  376. #if 1
  377. # if 0
  378. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  379. # undef open
  380. # define open rpl_open
  381. # endif
  382. _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
  383. _GL_ARG_NONNULL ((1)));
  384. _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
  385. # else
  386. _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
  387. # endif
  388. /* On HP-UX 11, in C++ mode, open() is defined as an inline function with a
  389. default argument. _GL_CXXALIASWARN does not work in this case. */
  390. # if !defined __hpux
  391. _GL_CXXALIASWARN (open);
  392. # endif
  393. #elif defined GNULIB_POSIXCHECK
  394. # undef open
  395. /* Assume open is always declared. */
  396. _GL_WARN_ON_USE (open, "open is not always POSIX compliant - "
  397. "use gnulib module open for portability");
  398. #endif
  399. #if 0
  400. # if 0
  401. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  402. # undef openat
  403. # define openat rpl_openat
  404. # endif
  405. _GL_FUNCDECL_RPL (openat, int,
  406. (int fd, char const *file, int flags, /* mode_t mode */ ...)
  407. _GL_ARG_NONNULL ((2)));
  408. _GL_CXXALIAS_RPL (openat, int,
  409. (int fd, char const *file, int flags, /* mode_t mode */ ...));
  410. # else
  411. # if !1
  412. _GL_FUNCDECL_SYS (openat, int,
  413. (int fd, char const *file, int flags, /* mode_t mode */ ...)
  414. _GL_ARG_NONNULL ((2)));
  415. # endif
  416. _GL_CXXALIAS_SYS (openat, int,
  417. (int fd, char const *file, int flags, /* mode_t mode */ ...));
  418. # endif
  419. _GL_CXXALIASWARN (openat);
  420. #elif defined GNULIB_POSIXCHECK
  421. # undef openat
  422. # if HAVE_RAW_DECL_OPENAT
  423. _GL_WARN_ON_USE (openat, "openat is not portable - "
  424. "use gnulib module openat for portability");
  425. # endif
  426. #endif
  427. /* Fix up the FD_* macros, only known to be missing on mingw. */
  428. #ifndef FD_CLOEXEC
  429. # define FD_CLOEXEC 1
  430. #endif
  431. /* Fix up the supported F_* macros. Intentionally leave other F_*
  432. macros undefined. Only known to be missing on mingw. */
  433. #ifndef F_DUPFD_CLOEXEC
  434. # define F_DUPFD_CLOEXEC 0x40000000
  435. /* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise. */
  436. # define GNULIB_defined_F_DUPFD_CLOEXEC 1
  437. #else
  438. # define GNULIB_defined_F_DUPFD_CLOEXEC 0
  439. #endif
  440. #ifndef F_DUPFD
  441. # define F_DUPFD 1
  442. #endif
  443. #ifndef F_GETFD
  444. # define F_GETFD 2
  445. #endif
  446. /* Fix up the O_* macros. */
  447. #if !defined O_DIRECT && defined O_DIRECTIO
  448. /* Tru64 spells it 'O_DIRECTIO'. */
  449. # define O_DIRECT O_DIRECTIO
  450. #endif
  451. #if !defined O_CLOEXEC && defined O_NOINHERIT
  452. /* Mingw spells it 'O_NOINHERIT'. */
  453. # define O_CLOEXEC O_NOINHERIT
  454. #endif
  455. #ifndef O_CLOEXEC
  456. # define O_CLOEXEC 0
  457. #endif
  458. #ifndef O_DIRECT
  459. # define O_DIRECT 0
  460. #endif
  461. #ifndef O_DIRECTORY
  462. # define O_DIRECTORY 0
  463. #endif
  464. #ifndef O_DSYNC
  465. # define O_DSYNC 0
  466. #endif
  467. #ifndef O_EXEC
  468. # define O_EXEC O_RDONLY /* This is often close enough in older systems. */
  469. #endif
  470. #ifndef O_IGNORE_CTTY
  471. # define O_IGNORE_CTTY 0
  472. #endif
  473. #ifndef O_NDELAY
  474. # define O_NDELAY 0
  475. #endif
  476. #ifndef O_NOATIME
  477. # define O_NOATIME 0
  478. #endif
  479. #ifndef O_NONBLOCK
  480. # define O_NONBLOCK O_NDELAY
  481. #endif
  482. /* If the gnulib module 'nonblocking' is in use, guarantee a working non-zero
  483. value of O_NONBLOCK. Otherwise, O_NONBLOCK is defined (above) to O_NDELAY
  484. or to 0 as fallback. */
  485. #if 0
  486. # if O_NONBLOCK
  487. # define GNULIB_defined_O_NONBLOCK 0
  488. # else
  489. # define GNULIB_defined_O_NONBLOCK 1
  490. # undef O_NONBLOCK
  491. # define O_NONBLOCK 0x40000000
  492. # endif
  493. #endif
  494. #ifndef O_NOCTTY
  495. # define O_NOCTTY 0
  496. #endif
  497. #ifndef O_NOFOLLOW
  498. # define O_NOFOLLOW 0
  499. #endif
  500. #ifndef O_NOLINK
  501. # define O_NOLINK 0
  502. #endif
  503. #ifndef O_NOLINKS
  504. # define O_NOLINKS 0
  505. #endif
  506. #ifndef O_NOTRANS
  507. # define O_NOTRANS 0
  508. #endif
  509. #ifndef O_RSYNC
  510. # define O_RSYNC 0
  511. #endif
  512. #ifndef O_SEARCH
  513. # define O_SEARCH O_RDONLY /* This is often close enough in older systems. */
  514. #endif
  515. #ifndef O_SYNC
  516. # define O_SYNC 0
  517. #endif
  518. #ifndef O_TTY_INIT
  519. # define O_TTY_INIT 0
  520. #endif
  521. #if ~O_ACCMODE & (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
  522. # undef O_ACCMODE
  523. # define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH)
  524. #endif
  525. /* For systems that distinguish between text and binary I/O.
  526. O_BINARY is usually declared in fcntl.h */
  527. #if !defined O_BINARY && defined _O_BINARY
  528. /* For MSC-compatible compilers. */
  529. # define O_BINARY _O_BINARY
  530. # define O_TEXT _O_TEXT
  531. #endif
  532. #if defined __BEOS__ || defined __HAIKU__
  533. /* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect. */
  534. # undef O_BINARY
  535. # undef O_TEXT
  536. #endif
  537. #ifndef O_BINARY
  538. # define O_BINARY 0
  539. # define O_TEXT 0
  540. #endif
  541. /* Fix up the AT_* macros. */
  542. /* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its
  543. value exceeds INT_MAX, so its use as an int doesn't conform to the
  544. C standard, and GCC and Sun C complain in some cases. If the bug
  545. is present, undef AT_FDCWD here, so it can be redefined below. */
  546. #if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553
  547. # undef AT_FDCWD
  548. #endif
  549. /* Use the same bit pattern as Solaris 9, but with the proper
  550. signedness. The bit pattern is important, in case this actually is
  551. Solaris with the above workaround. */
  552. #ifndef AT_FDCWD
  553. # define AT_FDCWD (-3041965)
  554. #endif
  555. /* Use the same values as Solaris 9. This shouldn't matter, but
  556. there's no real reason to differ. */
  557. #ifndef AT_SYMLINK_NOFOLLOW
  558. # define AT_SYMLINK_NOFOLLOW 4096
  559. #endif
  560. #ifndef AT_REMOVEDIR
  561. # define AT_REMOVEDIR 1
  562. #endif
  563. /* Solaris 9 lacks these two, so just pick unique values. */
  564. #ifndef AT_SYMLINK_FOLLOW
  565. # define AT_SYMLINK_FOLLOW 2
  566. #endif
  567. #ifndef AT_EACCESS
  568. # define AT_EACCESS 4
  569. #endif
  570. #endif /* _GL_M4_FCNTL_H */
  571. #endif /* _GL_M4_FCNTL_H */
  572. #endif