fcntl.in.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. /* Like <fcntl.h>, but with non-working flags defined to 0.
  2. Copyright (C) 2006-2010 Free Software Foundation, Inc.
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program 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 General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  13. /* written by Paul Eggert */
  14. #if __GNUC__ >= 3
  15. @PRAGMA_SYSTEM_HEADER@
  16. #endif
  17. #if defined __need_system_fcntl_h
  18. /* Special invocation convention. */
  19. #include <sys/types.h>
  20. #ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */
  21. # include <sys/stat.h>
  22. #endif
  23. #@INCLUDE_NEXT@ @NEXT_FCNTL_H@
  24. #else
  25. /* Normal invocation convention. */
  26. #ifndef _GL_FCNTL_H
  27. #include <sys/types.h>
  28. #ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */
  29. # include <sys/stat.h>
  30. #endif
  31. /* The include_next requires a split double-inclusion guard. */
  32. #@INCLUDE_NEXT@ @NEXT_FCNTL_H@
  33. #ifndef _GL_FCNTL_H
  34. #define _GL_FCNTL_H
  35. #ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */
  36. # include <unistd.h>
  37. #endif
  38. /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
  39. /* The definition of _GL_ARG_NONNULL is copied here. */
  40. /* The definition of _GL_WARN_ON_USE is copied here. */
  41. /* Declare overridden functions. */
  42. #if @GNULIB_FCNTL@
  43. # if @REPLACE_FCNTL@
  44. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  45. # undef fcntl
  46. # define fcntl rpl_fcntl
  47. # endif
  48. _GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...));
  49. _GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...));
  50. # else
  51. # if !@HAVE_FCNTL@
  52. _GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...));
  53. # endif
  54. _GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...));
  55. # endif
  56. _GL_CXXALIASWARN (fcntl);
  57. #elif defined GNULIB_POSIXCHECK
  58. # undef fcntl
  59. # if HAVE_RAW_DECL_FCNTL
  60. _GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - "
  61. "use gnulib module fcntl for portability");
  62. # endif
  63. #endif
  64. #if @GNULIB_OPEN@
  65. # if @REPLACE_OPEN@
  66. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  67. # undef open
  68. # define open rpl_open
  69. # endif
  70. _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
  71. _GL_ARG_NONNULL ((1)));
  72. _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
  73. # else
  74. _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
  75. # endif
  76. _GL_CXXALIASWARN (open);
  77. #elif defined GNULIB_POSIXCHECK
  78. # undef open
  79. /* Assume open is always declared. */
  80. _GL_WARN_ON_USE (open, "open is not always POSIX compliant - "
  81. "use gnulib module open for portability");
  82. #endif
  83. #if @GNULIB_OPENAT@
  84. # if @REPLACE_OPENAT@
  85. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  86. # undef openat
  87. # define openat rpl_openat
  88. # endif
  89. _GL_FUNCDECL_RPL (openat, int,
  90. (int fd, char const *file, int flags, /* mode_t mode */ ...)
  91. _GL_ARG_NONNULL ((2)));
  92. _GL_CXXALIAS_RPL (openat, int,
  93. (int fd, char const *file, int flags, /* mode_t mode */ ...));
  94. # else
  95. # if !@HAVE_OPENAT@
  96. _GL_FUNCDECL_SYS (openat, int,
  97. (int fd, char const *file, int flags, /* mode_t mode */ ...)
  98. _GL_ARG_NONNULL ((2)));
  99. # endif
  100. _GL_CXXALIAS_SYS (openat, int,
  101. (int fd, char const *file, int flags, /* mode_t mode */ ...));
  102. # endif
  103. _GL_CXXALIASWARN (openat);
  104. #elif defined GNULIB_POSIXCHECK
  105. # undef openat
  106. # if HAVE_RAW_DECL_OPENAT
  107. _GL_WARN_ON_USE (openat, "openat is not portable - "
  108. "use gnulib module openat for portability");
  109. # endif
  110. #endif
  111. /* Fix up the FD_* macros, only known to be missing on mingw. */
  112. #ifndef FD_CLOEXEC
  113. # define FD_CLOEXEC 1
  114. #endif
  115. /* Fix up the supported F_* macros. Intentionally leave other F_*
  116. macros undefined. Only known to be missing on mingw. */
  117. #ifndef F_DUPFD_CLOEXEC
  118. # define F_DUPFD_CLOEXEC 0x40000000
  119. /* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise. */
  120. # define GNULIB_defined_F_DUPFD_CLOEXEC 1
  121. #else
  122. # define GNULIB_defined_F_DUPFD_CLOEXEC 0
  123. #endif
  124. #ifndef F_DUPFD
  125. # define F_DUPFD 1
  126. #endif
  127. #ifndef F_GETFD
  128. # define F_GETFD 2
  129. #endif
  130. /* Fix up the O_* macros. */
  131. #if !defined O_DIRECT && defined O_DIRECTIO
  132. /* Tru64 spells it `O_DIRECTIO'. */
  133. # define O_DIRECT O_DIRECTIO
  134. #endif
  135. #if !defined O_CLOEXEC && defined O_NOINHERIT
  136. /* Mingw spells it `O_NOINHERIT'. Intentionally leave it
  137. undefined if not available. */
  138. # define O_CLOEXEC O_NOINHERIT
  139. #endif
  140. #ifndef O_DIRECT
  141. # define O_DIRECT 0
  142. #endif
  143. #ifndef O_DIRECTORY
  144. # define O_DIRECTORY 0
  145. #endif
  146. #ifndef O_DSYNC
  147. # define O_DSYNC 0
  148. #endif
  149. #ifndef O_NDELAY
  150. # define O_NDELAY 0
  151. #endif
  152. #ifndef O_NOATIME
  153. # define O_NOATIME 0
  154. #endif
  155. #ifndef O_NONBLOCK
  156. # define O_NONBLOCK O_NDELAY
  157. #endif
  158. #ifndef O_NOCTTY
  159. # define O_NOCTTY 0
  160. #endif
  161. #ifndef O_NOFOLLOW
  162. # define O_NOFOLLOW 0
  163. #endif
  164. #ifndef O_NOLINKS
  165. # define O_NOLINKS 0
  166. #endif
  167. #ifndef O_RSYNC
  168. # define O_RSYNC 0
  169. #endif
  170. #ifndef O_SYNC
  171. # define O_SYNC 0
  172. #endif
  173. #ifndef O_TTY_INIT
  174. # define O_TTY_INIT 0
  175. #endif
  176. /* For systems that distinguish between text and binary I/O.
  177. O_BINARY is usually declared in fcntl.h */
  178. #if !defined O_BINARY && defined _O_BINARY
  179. /* For MSC-compatible compilers. */
  180. # define O_BINARY _O_BINARY
  181. # define O_TEXT _O_TEXT
  182. #endif
  183. #if defined __BEOS__ || defined __HAIKU__
  184. /* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect. */
  185. # undef O_BINARY
  186. # undef O_TEXT
  187. #endif
  188. #ifndef O_BINARY
  189. # define O_BINARY 0
  190. # define O_TEXT 0
  191. #endif
  192. /* Fix up the AT_* macros. */
  193. /* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its
  194. value exceeds INT_MAX, so its use as an int doesn't conform to the
  195. C standard, and GCC and Sun C complain in some cases. If the bug
  196. is present, undef AT_FDCWD here, so it can be redefined below. */
  197. #if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553
  198. # undef AT_FDCWD
  199. #endif
  200. /* Use the same bit pattern as Solaris 9, but with the proper
  201. signedness. The bit pattern is important, in case this actually is
  202. Solaris with the above workaround. */
  203. #ifndef AT_FDCWD
  204. # define AT_FDCWD (-3041965)
  205. #endif
  206. /* Use the same values as Solaris 9. This shouldn't matter, but
  207. there's no real reason to differ. */
  208. #ifndef AT_SYMLINK_NOFOLLOW
  209. # define AT_SYMLINK_NOFOLLOW 4096
  210. #endif
  211. #ifndef AT_REMOVEDIR
  212. # define AT_REMOVEDIR 1
  213. #endif
  214. /* Solaris 9 lacks these two, so just pick unique values. */
  215. #ifndef AT_SYMLINK_FOLLOW
  216. # define AT_SYMLINK_FOLLOW 2
  217. #endif
  218. #ifndef AT_EACCESS
  219. # define AT_EACCESS 4
  220. #endif
  221. #endif /* _GL_FCNTL_H */
  222. #endif /* _GL_FCNTL_H */
  223. #endif