unistd.in.h 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326
  1. /* Substitute for and wrapper around <unistd.h>.
  2. Copyright (C) 2003-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, or (at your option)
  6. 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, write to the Free Software Foundation,
  13. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
  14. #if __GNUC__ >= 3
  15. @PRAGMA_SYSTEM_HEADER@
  16. #endif
  17. /* Special invocation convention:
  18. - On mingw, several headers, including <winsock2.h>, include <unistd.h>,
  19. but we need to ensure that both the system <unistd.h> and <winsock2.h>
  20. are completely included before we replace gethostname. */
  21. #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
  22. && !defined _GL_WINSOCK2_H_WITNESS && defined _WINSOCK2_H
  23. /* <unistd.h> is being indirectly included for the first time from
  24. <winsock2.h>; avoid declaring any overrides. */
  25. # if @HAVE_UNISTD_H@
  26. # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
  27. # else
  28. # error unexpected; report this to bug-gnulib@gnu.org
  29. # endif
  30. # define _GL_WINSOCK2_H_WITNESS
  31. /* Normal invocation. */
  32. #elif !defined _GL_UNISTD_H
  33. /* The include_next requires a split double-inclusion guard. */
  34. #if @HAVE_UNISTD_H@
  35. # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
  36. #endif
  37. /* Get all possible declarations of gethostname(). */
  38. #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
  39. && !defined _GL_INCLUDING_WINSOCK2_H
  40. # define _GL_INCLUDING_WINSOCK2_H
  41. # include <winsock2.h>
  42. # undef _GL_INCLUDING_WINSOCK2_H
  43. #endif
  44. #if !defined _GL_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
  45. #define _GL_UNISTD_H
  46. /* NetBSD 5.0 mis-defines NULL. Also get size_t. */
  47. #include <stddef.h>
  48. /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
  49. /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
  50. /* But avoid namespace pollution on glibc systems. */
  51. #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
  52. || (@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK)) \
  53. && ! defined __GLIBC__
  54. # include <stdio.h>
  55. #endif
  56. /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
  57. /* But avoid namespace pollution on glibc systems. */
  58. #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__
  59. # include <fcntl.h>
  60. #endif
  61. /* mingw fails to declare _exit in <unistd.h>. */
  62. /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */
  63. /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
  64. /* But avoid namespace pollution on glibc systems. */
  65. #ifndef __GLIBC__
  66. # include <stdlib.h>
  67. #endif
  68. /* mingw declares getcwd in <io.h>, not in <unistd.h>. */
  69. #if ((@GNULIB_GETCWD@ || defined GNULIB_POSIXCHECK) \
  70. && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
  71. # include <io.h>
  72. #endif
  73. #if (@GNULIB_WRITE@ || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
  74. || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
  75. /* Get ssize_t. */
  76. # include <sys/types.h>
  77. #endif
  78. /* Get getopt(), optarg, optind, opterr, optopt.
  79. But avoid namespace pollution on glibc systems. */
  80. #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
  81. # include <getopt.h>
  82. #endif
  83. /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
  84. /* The definition of _GL_ARG_NONNULL is copied here. */
  85. /* The definition of _GL_WARN_ON_USE is copied here. */
  86. #if @GNULIB_GETHOSTNAME@
  87. /* Get all possible declarations of gethostname(). */
  88. # if @UNISTD_H_HAVE_WINSOCK2_H@
  89. # if !defined _GL_SYS_SOCKET_H
  90. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  91. # undef socket
  92. # define socket socket_used_without_including_sys_socket_h
  93. # undef connect
  94. # define connect connect_used_without_including_sys_socket_h
  95. # undef accept
  96. # define accept accept_used_without_including_sys_socket_h
  97. # undef bind
  98. # define bind bind_used_without_including_sys_socket_h
  99. # undef getpeername
  100. # define getpeername getpeername_used_without_including_sys_socket_h
  101. # undef getsockname
  102. # define getsockname getsockname_used_without_including_sys_socket_h
  103. # undef getsockopt
  104. # define getsockopt getsockopt_used_without_including_sys_socket_h
  105. # undef listen
  106. # define listen listen_used_without_including_sys_socket_h
  107. # undef recv
  108. # define recv recv_used_without_including_sys_socket_h
  109. # undef send
  110. # define send send_used_without_including_sys_socket_h
  111. # undef recvfrom
  112. # define recvfrom recvfrom_used_without_including_sys_socket_h
  113. # undef sendto
  114. # define sendto sendto_used_without_including_sys_socket_h
  115. # undef setsockopt
  116. # define setsockopt setsockopt_used_without_including_sys_socket_h
  117. # undef shutdown
  118. # define shutdown shutdown_used_without_including_sys_socket_h
  119. # else
  120. _GL_WARN_ON_USE (socket,
  121. "socket() used without including <sys/socket.h>");
  122. _GL_WARN_ON_USE (connect,
  123. "connect() used without including <sys/socket.h>");
  124. _GL_WARN_ON_USE (accept,
  125. "accept() used without including <sys/socket.h>");
  126. _GL_WARN_ON_USE (bind,
  127. "bind() used without including <sys/socket.h>");
  128. _GL_WARN_ON_USE (getpeername,
  129. "getpeername() used without including <sys/socket.h>");
  130. _GL_WARN_ON_USE (getsockname,
  131. "getsockname() used without including <sys/socket.h>");
  132. _GL_WARN_ON_USE (getsockopt,
  133. "getsockopt() used without including <sys/socket.h>");
  134. _GL_WARN_ON_USE (listen,
  135. "listen() used without including <sys/socket.h>");
  136. _GL_WARN_ON_USE (recv,
  137. "recv() used without including <sys/socket.h>");
  138. _GL_WARN_ON_USE (send,
  139. "send() used without including <sys/socket.h>");
  140. _GL_WARN_ON_USE (recvfrom,
  141. "recvfrom() used without including <sys/socket.h>");
  142. _GL_WARN_ON_USE (sendto,
  143. "sendto() used without including <sys/socket.h>");
  144. _GL_WARN_ON_USE (setsockopt,
  145. "setsockopt() used without including <sys/socket.h>");
  146. _GL_WARN_ON_USE (shutdown,
  147. "shutdown() used without including <sys/socket.h>");
  148. # endif
  149. # endif
  150. # if !defined _GL_SYS_SELECT_H
  151. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  152. # undef select
  153. # define select select_used_without_including_sys_select_h
  154. # else
  155. _GL_WARN_ON_USE (select,
  156. "select() used without including <sys/select.h>");
  157. # endif
  158. # endif
  159. # endif
  160. #endif
  161. /* OS/2 EMX lacks these macros. */
  162. #ifndef STDIN_FILENO
  163. # define STDIN_FILENO 0
  164. #endif
  165. #ifndef STDOUT_FILENO
  166. # define STDOUT_FILENO 1
  167. #endif
  168. #ifndef STDERR_FILENO
  169. # define STDERR_FILENO 2
  170. #endif
  171. /* Ensure *_OK macros exist. */
  172. #ifndef F_OK
  173. # define F_OK 0
  174. # define X_OK 1
  175. # define W_OK 2
  176. # define R_OK 4
  177. #endif
  178. /* Declare overridden functions. */
  179. #if defined GNULIB_POSIXCHECK
  180. /* The access() function is a security risk. */
  181. _GL_WARN_ON_USE (access, "the access function is a security risk - "
  182. "use the gnulib module faccessat instead");
  183. #endif
  184. #if @GNULIB_CHOWN@
  185. /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
  186. to GID (if GID is not -1). Follow symbolic links.
  187. Return 0 if successful, otherwise -1 and errno set.
  188. See the POSIX:2001 specification
  189. <http://www.opengroup.org/susv3xsh/chown.html>. */
  190. # if @REPLACE_CHOWN@
  191. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  192. # undef chown
  193. # define chown rpl_chown
  194. # endif
  195. _GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid)
  196. _GL_ARG_NONNULL ((1)));
  197. _GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid));
  198. # else
  199. # if !@HAVE_CHOWN@
  200. _GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid)
  201. _GL_ARG_NONNULL ((1)));
  202. # endif
  203. _GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid));
  204. # endif
  205. _GL_CXXALIASWARN (chown);
  206. #elif defined GNULIB_POSIXCHECK
  207. # undef chown
  208. # if HAVE_RAW_DECL_CHOWN
  209. _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
  210. "doesn't treat a uid or gid of -1 on some systems - "
  211. "use gnulib module chown for portability");
  212. # endif
  213. #endif
  214. #if @GNULIB_CLOSE@
  215. # if @REPLACE_CLOSE@
  216. /* Automatically included by modules that need a replacement for close. */
  217. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  218. # undef close
  219. # define close rpl_close
  220. # endif
  221. _GL_FUNCDECL_RPL (close, int, (int fd));
  222. _GL_CXXALIAS_RPL (close, int, (int fd));
  223. # else
  224. _GL_CXXALIAS_SYS (close, int, (int fd));
  225. # endif
  226. _GL_CXXALIASWARN (close);
  227. #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
  228. # undef close
  229. # define close close_used_without_requesting_gnulib_module_close
  230. #elif defined GNULIB_POSIXCHECK
  231. # undef close
  232. /* Assume close is always declared. */
  233. _GL_WARN_ON_USE (close, "close does not portably work on sockets - "
  234. "use gnulib module close for portability");
  235. #endif
  236. #if @REPLACE_DUP@
  237. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  238. # define dup rpl_dup
  239. # endif
  240. _GL_FUNCDECL_RPL (dup, int, (int oldfd));
  241. _GL_CXXALIAS_RPL (dup, int, (int oldfd));
  242. #else
  243. _GL_CXXALIAS_SYS (dup, int, (int oldfd));
  244. #endif
  245. _GL_CXXALIASWARN (dup);
  246. #if @GNULIB_DUP2@
  247. /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
  248. NEWFD = OLDFD, otherwise close NEWFD first if it is open.
  249. Return newfd if successful, otherwise -1 and errno set.
  250. See the POSIX:2001 specification
  251. <http://www.opengroup.org/susv3xsh/dup2.html>. */
  252. # if @REPLACE_DUP2@
  253. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  254. # define dup2 rpl_dup2
  255. # endif
  256. _GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
  257. _GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
  258. # else
  259. # if !@HAVE_DUP2@
  260. _GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd));
  261. # endif
  262. _GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
  263. # endif
  264. _GL_CXXALIASWARN (dup2);
  265. #elif defined GNULIB_POSIXCHECK
  266. # undef dup2
  267. # if HAVE_RAW_DECL_DUP2
  268. _GL_WARN_ON_USE (dup2, "dup2 is unportable - "
  269. "use gnulib module dup2 for portability");
  270. # endif
  271. #endif
  272. #if @GNULIB_DUP3@
  273. /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
  274. specified flags.
  275. The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
  276. and O_TEXT, O_BINARY (defined in "binary-io.h").
  277. Close NEWFD first if it is open.
  278. Return newfd if successful, otherwise -1 and errno set.
  279. See the Linux man page at
  280. <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
  281. # if @HAVE_DUP3@
  282. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  283. # define dup3 rpl_dup3
  284. # endif
  285. _GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags));
  286. _GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags));
  287. # else
  288. _GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags));
  289. _GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags));
  290. # endif
  291. _GL_CXXALIASWARN (dup3);
  292. #elif defined GNULIB_POSIXCHECK
  293. # undef dup3
  294. # if HAVE_RAW_DECL_DUP3
  295. _GL_WARN_ON_USE (dup3, "dup3 is unportable - "
  296. "use gnulib module dup3 for portability");
  297. # endif
  298. #endif
  299. #if @GNULIB_ENVIRON@
  300. # if !@HAVE_DECL_ENVIRON@
  301. /* Set of environment variables and values. An array of strings of the form
  302. "VARIABLE=VALUE", terminated with a NULL. */
  303. # if defined __APPLE__ && defined __MACH__
  304. # include <crt_externs.h>
  305. # define environ (*_NSGetEnviron ())
  306. # else
  307. # ifdef __cplusplus
  308. extern "C" {
  309. # endif
  310. extern char **environ;
  311. # ifdef __cplusplus
  312. }
  313. # endif
  314. # endif
  315. # endif
  316. #elif defined GNULIB_POSIXCHECK
  317. # if HAVE_RAW_DECL_ENVIRON
  318. static inline char ***
  319. rpl_environ (void)
  320. {
  321. return &environ;
  322. }
  323. _GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
  324. "use gnulib module environ for portability");
  325. # undef environ
  326. # define environ (*rpl_environ ())
  327. # endif
  328. #endif
  329. #if @GNULIB_EUIDACCESS@
  330. /* Like access(), except that it uses the effective user id and group id of
  331. the current process. */
  332. # if !@HAVE_EUIDACCESS@
  333. _GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode)
  334. _GL_ARG_NONNULL ((1)));
  335. # endif
  336. _GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode));
  337. _GL_CXXALIASWARN (euidaccess);
  338. # if defined GNULIB_POSIXCHECK
  339. /* Like access(), this function is a security risk. */
  340. _GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - "
  341. "use the gnulib module faccessat instead");
  342. # endif
  343. #elif defined GNULIB_POSIXCHECK
  344. # undef euidaccess
  345. # if HAVE_RAW_DECL_EUIDACCESS
  346. _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
  347. "use gnulib module euidaccess for portability");
  348. # endif
  349. #endif
  350. #if @GNULIB_FACCESSAT@
  351. # if !@HAVE_FACCESSAT@
  352. _GL_FUNCDECL_SYS (faccessat, int,
  353. (int fd, char const *file, int mode, int flag)
  354. _GL_ARG_NONNULL ((2)));
  355. # endif
  356. _GL_CXXALIAS_SYS (faccessat, int,
  357. (int fd, char const *file, int mode, int flag));
  358. _GL_CXXALIASWARN (faccessat);
  359. #elif defined GNULIB_POSIXCHECK
  360. # undef faccessat
  361. # if HAVE_RAW_DECL_FACCESSAT
  362. _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
  363. "use gnulib module faccessat for portability");
  364. # endif
  365. #endif
  366. #if @GNULIB_FCHDIR@
  367. /* Change the process' current working directory to the directory on which
  368. the given file descriptor is open.
  369. Return 0 if successful, otherwise -1 and errno set.
  370. See the POSIX:2001 specification
  371. <http://www.opengroup.org/susv3xsh/fchdir.html>. */
  372. # if ! @HAVE_FCHDIR@
  373. _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
  374. /* Gnulib internal hooks needed to maintain the fchdir metadata. */
  375. _GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)
  376. _GL_ARG_NONNULL ((2));
  377. _GL_EXTERN_C void _gl_unregister_fd (int fd);
  378. _GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
  379. _GL_EXTERN_C const char *_gl_directory_name (int fd);
  380. # endif
  381. _GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
  382. _GL_CXXALIASWARN (fchdir);
  383. #elif defined GNULIB_POSIXCHECK
  384. # undef fchdir
  385. # if HAVE_RAW_DECL_FCHDIR
  386. _GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
  387. "use gnulib module fchdir for portability");
  388. # endif
  389. #endif
  390. #if @GNULIB_FCHOWNAT@
  391. # if @REPLACE_FCHOWNAT@
  392. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  393. # undef fchownat
  394. # define fchownat rpl_fchownat
  395. # endif
  396. _GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file,
  397. uid_t owner, gid_t group, int flag)
  398. _GL_ARG_NONNULL ((2)));
  399. _GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file,
  400. uid_t owner, gid_t group, int flag));
  401. # else
  402. # if !@HAVE_FCHOWNAT@
  403. _GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file,
  404. uid_t owner, gid_t group, int flag)
  405. _GL_ARG_NONNULL ((2)));
  406. # endif
  407. _GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file,
  408. uid_t owner, gid_t group, int flag));
  409. # endif
  410. _GL_CXXALIASWARN (fchownat);
  411. #elif defined GNULIB_POSIXCHECK
  412. # undef fchownat
  413. # if HAVE_RAW_DECL_FCHOWNAT
  414. _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
  415. "use gnulib module openat for portability");
  416. # endif
  417. #endif
  418. #if @GNULIB_FSYNC@
  419. /* Synchronize changes to a file.
  420. Return 0 if successful, otherwise -1 and errno set.
  421. See POSIX:2001 specification
  422. <http://www.opengroup.org/susv3xsh/fsync.html>. */
  423. # if !@HAVE_FSYNC@
  424. _GL_FUNCDECL_SYS (fsync, int, (int fd));
  425. # endif
  426. _GL_CXXALIAS_SYS (fsync, int, (int fd));
  427. _GL_CXXALIASWARN (fsync);
  428. #elif defined GNULIB_POSIXCHECK
  429. # undef fsync
  430. # if HAVE_RAW_DECL_FSYNC
  431. _GL_WARN_ON_USE (fsync, "fsync is unportable - "
  432. "use gnulib module fsync for portability");
  433. # endif
  434. #endif
  435. #if @GNULIB_FTRUNCATE@
  436. /* Change the size of the file to which FD is opened to become equal to LENGTH.
  437. Return 0 if successful, otherwise -1 and errno set.
  438. See the POSIX:2001 specification
  439. <http://www.opengroup.org/susv3xsh/ftruncate.html>. */
  440. # if !@HAVE_FTRUNCATE@
  441. _GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
  442. # endif
  443. _GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
  444. _GL_CXXALIASWARN (ftruncate);
  445. #elif defined GNULIB_POSIXCHECK
  446. # undef ftruncate
  447. # if HAVE_RAW_DECL_FTRUNCATE
  448. _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
  449. "use gnulib module ftruncate for portability");
  450. # endif
  451. #endif
  452. #if @GNULIB_GETCWD@
  453. /* Get the name of the current working directory, and put it in SIZE bytes
  454. of BUF.
  455. Return BUF if successful, or NULL if the directory couldn't be determined
  456. or SIZE was too small.
  457. See the POSIX:2001 specification
  458. <http://www.opengroup.org/susv3xsh/getcwd.html>.
  459. Additionally, the gnulib module 'getcwd' guarantees the following GNU
  460. extension: If BUF is NULL, an array is allocated with 'malloc'; the array
  461. is SIZE bytes long, unless SIZE == 0, in which case it is as big as
  462. necessary. */
  463. # if @REPLACE_GETCWD@
  464. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  465. # define getcwd rpl_getcwd
  466. # endif
  467. _GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
  468. _GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
  469. # else
  470. /* Need to cast, because on mingw, the second parameter is
  471. int size. */
  472. _GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
  473. # endif
  474. _GL_CXXALIASWARN (getcwd);
  475. #elif defined GNULIB_POSIXCHECK
  476. # undef getcwd
  477. # if HAVE_RAW_DECL_GETCWD
  478. _GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
  479. "use gnulib module getcwd for portability");
  480. # endif
  481. #endif
  482. #if @GNULIB_GETDOMAINNAME@
  483. /* Return the NIS domain name of the machine.
  484. WARNING! The NIS domain name is unrelated to the fully qualified host name
  485. of the machine. It is also unrelated to email addresses.
  486. WARNING! The NIS domain name is usually the empty string or "(none)" when
  487. not using NIS.
  488. Put up to LEN bytes of the NIS domain name into NAME.
  489. Null terminate it if the name is shorter than LEN.
  490. If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
  491. Return 0 if successful, otherwise set errno and return -1. */
  492. # if !@HAVE_GETDOMAINNAME@
  493. _GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
  494. _GL_ARG_NONNULL ((1)));
  495. # endif
  496. /* Need to cast, because on MacOS X 10.5 systems, the second parameter is
  497. int len. */
  498. _GL_CXXALIAS_SYS_CAST (getdomainname, int, (char *name, size_t len));
  499. _GL_CXXALIASWARN (getdomainname);
  500. #elif defined GNULIB_POSIXCHECK
  501. # undef getdomainname
  502. # if HAVE_RAW_DECL_GETDOMAINNAME
  503. _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
  504. "use gnulib module getdomainname for portability");
  505. # endif
  506. #endif
  507. #if @GNULIB_GETDTABLESIZE@
  508. /* Return the maximum number of file descriptors in the current process.
  509. In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
  510. # if !@HAVE_GETDTABLESIZE@
  511. _GL_FUNCDECL_SYS (getdtablesize, int, (void));
  512. # endif
  513. _GL_CXXALIAS_SYS (getdtablesize, int, (void));
  514. _GL_CXXALIASWARN (getdtablesize);
  515. #elif defined GNULIB_POSIXCHECK
  516. # undef getdtablesize
  517. # if HAVE_RAW_DECL_GETDTABLESIZE
  518. _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
  519. "use gnulib module getdtablesize for portability");
  520. # endif
  521. #endif
  522. #if @GNULIB_GETGROUPS@
  523. /* Return the supplemental groups that the current process belongs to.
  524. It is unspecified whether the effective group id is in the list.
  525. If N is 0, return the group count; otherwise, N describes how many
  526. entries are available in GROUPS. Return -1 and set errno if N is
  527. not 0 and not large enough. Fails with ENOSYS on some systems. */
  528. # if @REPLACE_GETGROUPS@
  529. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  530. # undef getgroups
  531. # define getgroups rpl_getgroups
  532. # endif
  533. _GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups));
  534. _GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups));
  535. # else
  536. # if !@HAVE_GETGROUPS@
  537. _GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups));
  538. # endif
  539. _GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups));
  540. # endif
  541. _GL_CXXALIASWARN (getgroups);
  542. #elif defined GNULIB_POSIXCHECK
  543. # undef getgroups
  544. # if HAVE_RAW_DECL_GETGROUPS
  545. _GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
  546. "use gnulib module getgroups for portability");
  547. # endif
  548. #endif
  549. #if @GNULIB_GETHOSTNAME@
  550. /* Return the standard host name of the machine.
  551. WARNING! The host name may or may not be fully qualified.
  552. Put up to LEN bytes of the host name into NAME.
  553. Null terminate it if the name is shorter than LEN.
  554. If the host name is longer than LEN, set errno = EINVAL and return -1.
  555. Return 0 if successful, otherwise set errno and return -1. */
  556. # if @UNISTD_H_HAVE_WINSOCK2_H@
  557. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  558. # undef gethostname
  559. # define gethostname rpl_gethostname
  560. # endif
  561. _GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len)
  562. _GL_ARG_NONNULL ((1)));
  563. _GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
  564. # else
  565. # if !@HAVE_GETHOSTNAME@
  566. _GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len)
  567. _GL_ARG_NONNULL ((1)));
  568. # endif
  569. /* Need to cast, because on Solaris 10 systems, the second parameter is
  570. int len. */
  571. _GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
  572. # endif
  573. _GL_CXXALIASWARN (gethostname);
  574. #elif @UNISTD_H_HAVE_WINSOCK2_H@
  575. # undef gethostname
  576. # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
  577. #elif defined GNULIB_POSIXCHECK
  578. # undef gethostname
  579. # if HAVE_RAW_DECL_GETHOSTNAME
  580. _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
  581. "use gnulib module gethostname for portability");
  582. # endif
  583. #endif
  584. #if @GNULIB_GETLOGIN@
  585. /* Returns the user's login name, or NULL if it cannot be found. Upon error,
  586. returns NULL with errno set.
  587. See <http://www.opengroup.org/susv3xsh/getlogin.html>.
  588. Most programs don't need to use this function, because the information is
  589. available through environment variables:
  590. ${LOGNAME-$USER} on Unix platforms,
  591. $USERNAME on native Windows platforms.
  592. */
  593. # if !@HAVE_GETLOGIN@
  594. _GL_FUNCDECL_SYS (getlogin, char *, (void));
  595. # endif
  596. _GL_CXXALIAS_SYS (getlogin, char *, (void));
  597. _GL_CXXALIASWARN (getlogin);
  598. #elif defined GNULIB_POSIXCHECK
  599. # undef getlogin
  600. # if HAVE_RAW_DECL_GETLOGIN
  601. _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
  602. "use gnulib module getlogin for portability");
  603. # endif
  604. #endif
  605. #if @GNULIB_GETLOGIN_R@
  606. /* Copies the user's login name to NAME.
  607. The array pointed to by NAME has room for SIZE bytes.
  608. Returns 0 if successful. Upon error, an error number is returned, or -1 in
  609. the case that the login name cannot be found but no specific error is
  610. provided (this case is hopefully rare but is left open by the POSIX spec).
  611. See <http://www.opengroup.org/susv3xsh/getlogin.html>.
  612. Most programs don't need to use this function, because the information is
  613. available through environment variables:
  614. ${LOGNAME-$USER} on Unix platforms,
  615. $USERNAME on native Windows platforms.
  616. */
  617. # if !@HAVE_DECL_GETLOGIN_R@
  618. _GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size)
  619. _GL_ARG_NONNULL ((1)));
  620. # endif
  621. /* Need to cast, because on Solaris 10 systems, the second argument is
  622. int size. */
  623. _GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
  624. _GL_CXXALIASWARN (getlogin_r);
  625. #elif defined GNULIB_POSIXCHECK
  626. # undef getlogin_r
  627. # if HAVE_RAW_DECL_GETLOGIN_R
  628. _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
  629. "use gnulib module getlogin_r for portability");
  630. # endif
  631. #endif
  632. #if @GNULIB_GETPAGESIZE@
  633. # if @REPLACE_GETPAGESIZE@
  634. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  635. # define getpagesize rpl_getpagesize
  636. # endif
  637. _GL_FUNCDECL_RPL (getpagesize, int, (void));
  638. _GL_CXXALIAS_RPL (getpagesize, int, (void));
  639. # else
  640. # if !@HAVE_GETPAGESIZE@
  641. # if !defined getpagesize
  642. /* This is for POSIX systems. */
  643. # if !defined _gl_getpagesize && defined _SC_PAGESIZE
  644. # if ! (defined __VMS && __VMS_VER < 70000000)
  645. # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
  646. # endif
  647. # endif
  648. /* This is for older VMS. */
  649. # if !defined _gl_getpagesize && defined __VMS
  650. # ifdef __ALPHA
  651. # define _gl_getpagesize() 8192
  652. # else
  653. # define _gl_getpagesize() 512
  654. # endif
  655. # endif
  656. /* This is for BeOS. */
  657. # if !defined _gl_getpagesize && @HAVE_OS_H@
  658. # include <OS.h>
  659. # if defined B_PAGE_SIZE
  660. # define _gl_getpagesize() B_PAGE_SIZE
  661. # endif
  662. # endif
  663. /* This is for AmigaOS4.0. */
  664. # if !defined _gl_getpagesize && defined __amigaos4__
  665. # define _gl_getpagesize() 2048
  666. # endif
  667. /* This is for older Unix systems. */
  668. # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
  669. # include <sys/param.h>
  670. # ifdef EXEC_PAGESIZE
  671. # define _gl_getpagesize() EXEC_PAGESIZE
  672. # else
  673. # ifdef NBPG
  674. # ifndef CLSIZE
  675. # define CLSIZE 1
  676. # endif
  677. # define _gl_getpagesize() (NBPG * CLSIZE)
  678. # else
  679. # ifdef NBPC
  680. # define _gl_getpagesize() NBPC
  681. # endif
  682. # endif
  683. # endif
  684. # endif
  685. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  686. # define getpagesize() _gl_getpagesize ()
  687. # else
  688. static inline int
  689. getpagesize ()
  690. {
  691. return _gl_getpagesize ();
  692. }
  693. # endif
  694. # endif
  695. # endif
  696. /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
  697. _GL_CXXALIAS_SYS_CAST (getpagesize, int, (void));
  698. # endif
  699. # if @HAVE_DECL_GETPAGESIZE@
  700. _GL_CXXALIASWARN (getpagesize);
  701. # endif
  702. #elif defined GNULIB_POSIXCHECK
  703. # undef getpagesize
  704. # if HAVE_RAW_DECL_GETPAGESIZE
  705. _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
  706. "use gnulib module getpagesize for portability");
  707. # endif
  708. #endif
  709. #if @GNULIB_GETUSERSHELL@
  710. /* Return the next valid login shell on the system, or NULL when the end of
  711. the list has been reached. */
  712. # if !@HAVE_DECL_GETUSERSHELL@
  713. _GL_FUNCDECL_SYS (getusershell, char *, (void));
  714. # endif
  715. _GL_CXXALIAS_SYS (getusershell, char *, (void));
  716. _GL_CXXALIASWARN (getusershell);
  717. #elif defined GNULIB_POSIXCHECK
  718. # undef getusershell
  719. # if HAVE_RAW_DECL_GETUSERSHELL
  720. _GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
  721. "use gnulib module getusershell for portability");
  722. # endif
  723. #endif
  724. #if @GNULIB_GETUSERSHELL@
  725. /* Rewind to pointer that is advanced at each getusershell() call. */
  726. # if !@HAVE_DECL_GETUSERSHELL@
  727. _GL_FUNCDECL_SYS (setusershell, void, (void));
  728. # endif
  729. _GL_CXXALIAS_SYS (setusershell, void, (void));
  730. _GL_CXXALIASWARN (setusershell);
  731. #elif defined GNULIB_POSIXCHECK
  732. # undef setusershell
  733. # if HAVE_RAW_DECL_SETUSERSHELL
  734. _GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
  735. "use gnulib module getusershell for portability");
  736. # endif
  737. #endif
  738. #if @GNULIB_GETUSERSHELL@
  739. /* Free the pointer that is advanced at each getusershell() call and
  740. associated resources. */
  741. # if !@HAVE_DECL_GETUSERSHELL@
  742. _GL_FUNCDECL_SYS (endusershell, void, (void));
  743. # endif
  744. _GL_CXXALIAS_SYS (endusershell, void, (void));
  745. _GL_CXXALIASWARN (endusershell);
  746. #elif defined GNULIB_POSIXCHECK
  747. # undef endusershell
  748. # if HAVE_RAW_DECL_ENDUSERSHELL
  749. _GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
  750. "use gnulib module getusershell for portability");
  751. # endif
  752. #endif
  753. #if @GNULIB_LCHOWN@
  754. /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
  755. to GID (if GID is not -1). Do not follow symbolic links.
  756. Return 0 if successful, otherwise -1 and errno set.
  757. See the POSIX:2001 specification
  758. <http://www.opengroup.org/susv3xsh/lchown.html>. */
  759. # if @REPLACE_LCHOWN@
  760. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  761. # undef lchown
  762. # define lchown rpl_lchown
  763. # endif
  764. _GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)
  765. _GL_ARG_NONNULL ((1)));
  766. _GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group));
  767. # else
  768. # if !@HAVE_LCHOWN@
  769. _GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)
  770. _GL_ARG_NONNULL ((1)));
  771. # endif
  772. _GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group));
  773. # endif
  774. _GL_CXXALIASWARN (lchown);
  775. #elif defined GNULIB_POSIXCHECK
  776. # undef lchown
  777. # if HAVE_RAW_DECL_LCHOWN
  778. _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
  779. "use gnulib module lchown for portability");
  780. # endif
  781. #endif
  782. #if @GNULIB_LINK@
  783. /* Create a new hard link for an existing file.
  784. Return 0 if successful, otherwise -1 and errno set.
  785. See POSIX:2001 specification
  786. <http://www.opengroup.org/susv3xsh/link.html>. */
  787. # if @REPLACE_LINK@
  788. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  789. # define link rpl_link
  790. # endif
  791. _GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2)
  792. _GL_ARG_NONNULL ((1, 2)));
  793. _GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2));
  794. # else
  795. # if !@HAVE_LINK@
  796. _GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2)
  797. _GL_ARG_NONNULL ((1, 2)));
  798. # endif
  799. _GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2));
  800. # endif
  801. _GL_CXXALIASWARN (link);
  802. #elif defined GNULIB_POSIXCHECK
  803. # undef link
  804. # if HAVE_RAW_DECL_LINK
  805. _GL_WARN_ON_USE (link, "link is unportable - "
  806. "use gnulib module link for portability");
  807. # endif
  808. #endif
  809. #if @GNULIB_LINKAT@
  810. /* Create a new hard link for an existing file, relative to two
  811. directories. FLAG controls whether symlinks are followed.
  812. Return 0 if successful, otherwise -1 and errno set. */
  813. # if @REPLACE_LINKAT@
  814. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  815. # undef linkat
  816. # define linkat rpl_linkat
  817. # endif
  818. _GL_FUNCDECL_RPL (linkat, int,
  819. (int fd1, const char *path1, int fd2, const char *path2,
  820. int flag)
  821. _GL_ARG_NONNULL ((2, 4)));
  822. _GL_CXXALIAS_RPL (linkat, int,
  823. (int fd1, const char *path1, int fd2, const char *path2,
  824. int flag));
  825. # else
  826. # if !@HAVE_LINKAT@
  827. _GL_FUNCDECL_SYS (linkat, int,
  828. (int fd1, const char *path1, int fd2, const char *path2,
  829. int flag)
  830. _GL_ARG_NONNULL ((2, 4)));
  831. # endif
  832. _GL_CXXALIAS_SYS (linkat, int,
  833. (int fd1, const char *path1, int fd2, const char *path2,
  834. int flag));
  835. # endif
  836. _GL_CXXALIASWARN (linkat);
  837. #elif defined GNULIB_POSIXCHECK
  838. # undef linkat
  839. # if HAVE_RAW_DECL_LINKAT
  840. _GL_WARN_ON_USE (linkat, "linkat is unportable - "
  841. "use gnulib module linkat for portability");
  842. # endif
  843. #endif
  844. #if @GNULIB_LSEEK@
  845. /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
  846. Return the new offset if successful, otherwise -1 and errno set.
  847. See the POSIX:2001 specification
  848. <http://www.opengroup.org/susv3xsh/lseek.html>. */
  849. # if @REPLACE_LSEEK@
  850. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  851. # define lseek rpl_lseek
  852. # endif
  853. _GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
  854. _GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
  855. # else
  856. _GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
  857. # endif
  858. _GL_CXXALIASWARN (lseek);
  859. #elif defined GNULIB_POSIXCHECK
  860. # undef lseek
  861. # if HAVE_RAW_DECL_LSEEK
  862. _GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
  863. "systems - use gnulib module lseek for portability");
  864. # endif
  865. #endif
  866. #if @GNULIB_PIPE2@
  867. /* Create a pipe, applying the given flags when opening the read-end of the
  868. pipe and the write-end of the pipe.
  869. The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
  870. and O_TEXT, O_BINARY (defined in "binary-io.h").
  871. Store the read-end as fd[0] and the write-end as fd[1].
  872. Return 0 upon success, or -1 with errno set upon failure.
  873. See also the Linux man page at
  874. <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
  875. # if @HAVE_PIPE2@
  876. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  877. # define pipe2 rpl_pipe2
  878. # endif
  879. _GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
  880. _GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));
  881. # else
  882. _GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
  883. _GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));
  884. # endif
  885. _GL_CXXALIASWARN (pipe2);
  886. #elif defined GNULIB_POSIXCHECK
  887. # undef pipe2
  888. # if HAVE_RAW_DECL_PIPE2
  889. _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
  890. "use gnulib module pipe2 for portability");
  891. # endif
  892. #endif
  893. #if @GNULIB_PREAD@
  894. /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
  895. Return the number of bytes placed into BUF if successful, otherwise
  896. set errno and return -1. 0 indicates EOF. See the POSIX:2001
  897. specification <http://www.opengroup.org/susv3xsh/pread.html>. */
  898. # if @REPLACE_PREAD@
  899. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  900. # define pread rpl_pread
  901. # endif
  902. _GL_FUNCDECL_RPL (pread, ssize_t,
  903. (int fd, void *buf, size_t bufsize, off_t offset)
  904. _GL_ARG_NONNULL ((2)));
  905. _GL_CXXALIAS_RPL (pread, ssize_t,
  906. (int fd, void *buf, size_t bufsize, off_t offset));
  907. # else
  908. # if !@HAVE_PREAD@
  909. _GL_FUNCDECL_SYS (pread, ssize_t,
  910. (int fd, void *buf, size_t bufsize, off_t offset)
  911. _GL_ARG_NONNULL ((2)));
  912. # endif
  913. _GL_CXXALIAS_SYS (pread, ssize_t,
  914. (int fd, void *buf, size_t bufsize, off_t offset));
  915. # endif
  916. _GL_CXXALIASWARN (pread);
  917. #elif defined GNULIB_POSIXCHECK
  918. # undef pread
  919. # if HAVE_RAW_DECL_PREAD
  920. _GL_WARN_ON_USE (pread, "pread is unportable - "
  921. "use gnulib module pread for portability");
  922. # endif
  923. #endif
  924. #if @GNULIB_PWRITE@
  925. /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
  926. Return the number of bytes written if successful, otherwise
  927. set errno and return -1. 0 indicates nothing written. See the
  928. POSIX:2001 specification
  929. <http://www.opengroup.org/susv3xsh/pwrite.html>. */
  930. # if @REPLACE_PWRITE@
  931. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  932. # define pwrite rpl_pwrite
  933. # endif
  934. _GL_FUNCDECL_RPL (pwrite, ssize_t,
  935. (int fd, const void *buf, size_t bufsize, off_t offset)
  936. _GL_ARG_NONNULL ((2)));
  937. _GL_CXXALIAS_RPL (pwrite, ssize_t,
  938. (int fd, const void *buf, size_t bufsize, off_t offset));
  939. # else
  940. # if !@HAVE_PWRITE@
  941. _GL_FUNCDECL_SYS (pwrite, ssize_t,
  942. (int fd, const void *buf, size_t bufsize, off_t offset)
  943. _GL_ARG_NONNULL ((2)));
  944. # endif
  945. _GL_CXXALIAS_SYS (pwrite, ssize_t,
  946. (int fd, const void *buf, size_t bufsize, off_t offset));
  947. # endif
  948. _GL_CXXALIASWARN (pwrite);
  949. #elif defined GNULIB_POSIXCHECK
  950. # undef pwrite
  951. # if HAVE_RAW_DECL_PWRITE
  952. _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
  953. "use gnulib module pwrite for portability");
  954. # endif
  955. #endif
  956. #if @GNULIB_READLINK@
  957. /* Read the contents of the symbolic link FILE and place the first BUFSIZE
  958. bytes of it into BUF. Return the number of bytes placed into BUF if
  959. successful, otherwise -1 and errno set.
  960. See the POSIX:2001 specification
  961. <http://www.opengroup.org/susv3xsh/readlink.html>. */
  962. # if @REPLACE_READLINK@
  963. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  964. # define readlink rpl_readlink
  965. # endif
  966. _GL_FUNCDECL_RPL (readlink, ssize_t,
  967. (const char *file, char *buf, size_t bufsize)
  968. _GL_ARG_NONNULL ((1, 2)));
  969. _GL_CXXALIAS_RPL (readlink, ssize_t,
  970. (const char *file, char *buf, size_t bufsize));
  971. # else
  972. # if !@HAVE_READLINK@
  973. _GL_FUNCDECL_SYS (readlink, ssize_t,
  974. (const char *file, char *buf, size_t bufsize)
  975. _GL_ARG_NONNULL ((1, 2)));
  976. # endif
  977. _GL_CXXALIAS_SYS (readlink, ssize_t,
  978. (const char *file, char *buf, size_t bufsize));
  979. # endif
  980. _GL_CXXALIASWARN (readlink);
  981. #elif defined GNULIB_POSIXCHECK
  982. # undef readlink
  983. # if HAVE_RAW_DECL_READLINK
  984. _GL_WARN_ON_USE (readlink, "readlink is unportable - "
  985. "use gnulib module readlink for portability");
  986. # endif
  987. #endif
  988. #if @GNULIB_READLINKAT@
  989. # if !@HAVE_READLINKAT@
  990. _GL_FUNCDECL_SYS (readlinkat, ssize_t,
  991. (int fd, char const *file, char *buf, size_t len)
  992. _GL_ARG_NONNULL ((2, 3)));
  993. # endif
  994. _GL_CXXALIAS_SYS (readlinkat, ssize_t,
  995. (int fd, char const *file, char *buf, size_t len));
  996. _GL_CXXALIASWARN (readlinkat);
  997. #elif defined GNULIB_POSIXCHECK
  998. # undef readlinkat
  999. # if HAVE_RAW_DECL_READLINKAT
  1000. _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
  1001. "use gnulib module symlinkat for portability");
  1002. # endif
  1003. #endif
  1004. #if @GNULIB_RMDIR@
  1005. /* Remove the directory DIR. */
  1006. # if @REPLACE_RMDIR@
  1007. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1008. # define rmdir rpl_rmdir
  1009. # endif
  1010. _GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
  1011. _GL_CXXALIAS_RPL (rmdir, int, (char const *name));
  1012. # else
  1013. _GL_CXXALIAS_SYS (rmdir, int, (char const *name));
  1014. # endif
  1015. _GL_CXXALIASWARN (rmdir);
  1016. #elif defined GNULIB_POSIXCHECK
  1017. # undef rmdir
  1018. # if HAVE_RAW_DECL_RMDIR
  1019. _GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
  1020. "use gnulib module rmdir for portability");
  1021. # endif
  1022. #endif
  1023. #if @GNULIB_SLEEP@
  1024. /* Pause the execution of the current thread for N seconds.
  1025. Returns the number of seconds left to sleep.
  1026. See the POSIX:2001 specification
  1027. <http://www.opengroup.org/susv3xsh/sleep.html>. */
  1028. # if @REPLACE_SLEEP@
  1029. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1030. # undef sleep
  1031. # define sleep rpl_sleep
  1032. # endif
  1033. _GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n));
  1034. _GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n));
  1035. # else
  1036. # if !@HAVE_SLEEP@
  1037. _GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n));
  1038. # endif
  1039. _GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n));
  1040. # endif
  1041. _GL_CXXALIASWARN (sleep);
  1042. #elif defined GNULIB_POSIXCHECK
  1043. # undef sleep
  1044. # if HAVE_RAW_DECL_SLEEP
  1045. _GL_WARN_ON_USE (sleep, "sleep is unportable - "
  1046. "use gnulib module sleep for portability");
  1047. # endif
  1048. #endif
  1049. #if @GNULIB_SYMLINK@
  1050. # if @REPLACE_SYMLINK@
  1051. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1052. # undef symlink
  1053. # define symlink rpl_symlink
  1054. # endif
  1055. _GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file)
  1056. _GL_ARG_NONNULL ((1, 2)));
  1057. _GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file));
  1058. # else
  1059. # if !@HAVE_SYMLINK@
  1060. _GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file)
  1061. _GL_ARG_NONNULL ((1, 2)));
  1062. # endif
  1063. _GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file));
  1064. # endif
  1065. _GL_CXXALIASWARN (symlink);
  1066. #elif defined GNULIB_POSIXCHECK
  1067. # undef symlink
  1068. # if HAVE_RAW_DECL_SYMLINK
  1069. _GL_WARN_ON_USE (symlink, "symlink is not portable - "
  1070. "use gnulib module symlink for portability");
  1071. # endif
  1072. #endif
  1073. #if @GNULIB_SYMLINKAT@
  1074. # if !@HAVE_SYMLINKAT@
  1075. _GL_FUNCDECL_SYS (symlinkat, int,
  1076. (char const *contents, int fd, char const *file)
  1077. _GL_ARG_NONNULL ((1, 3)));
  1078. # endif
  1079. _GL_CXXALIAS_SYS (symlinkat, int,
  1080. (char const *contents, int fd, char const *file));
  1081. _GL_CXXALIASWARN (symlinkat);
  1082. #elif defined GNULIB_POSIXCHECK
  1083. # undef symlinkat
  1084. # if HAVE_RAW_DECL_SYMLINKAT
  1085. _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
  1086. "use gnulib module symlinkat for portability");
  1087. # endif
  1088. #endif
  1089. #if @GNULIB_TTYNAME_R@
  1090. /* Store at most BUFLEN characters of the pathname of the terminal FD is
  1091. open on in BUF. Return 0 on success, otherwise an error number. */
  1092. # if @REPLACE_TTYNAME_R@
  1093. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1094. # undef ttyname_r
  1095. # define ttyname_r rpl_ttyname_r
  1096. # endif
  1097. _GL_FUNCDECL_RPL (ttyname_r, int,
  1098. (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
  1099. _GL_CXXALIAS_RPL (ttyname_r, int,
  1100. (int fd, char *buf, size_t buflen));
  1101. # else
  1102. # if !@HAVE_TTYNAME_R@
  1103. _GL_FUNCDECL_SYS (ttyname_r, int,
  1104. (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
  1105. # endif
  1106. _GL_CXXALIAS_SYS (ttyname_r, int,
  1107. (int fd, char *buf, size_t buflen));
  1108. # endif
  1109. _GL_CXXALIASWARN (ttyname_r);
  1110. #elif defined GNULIB_POSIXCHECK
  1111. # undef ttyname_r
  1112. # if HAVE_RAW_DECL_TTYNAME_R
  1113. _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
  1114. "use gnulib module ttyname_r for portability");
  1115. # endif
  1116. #endif
  1117. #if @GNULIB_UNLINK@
  1118. # if @REPLACE_UNLINK@
  1119. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1120. # undef unlink
  1121. # define unlink rpl_unlink
  1122. # endif
  1123. _GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
  1124. _GL_CXXALIAS_RPL (unlink, int, (char const *file));
  1125. # else
  1126. _GL_CXXALIAS_SYS (unlink, int, (char const *file));
  1127. # endif
  1128. _GL_CXXALIASWARN (unlink);
  1129. #elif defined GNULIB_POSIXCHECK
  1130. # undef unlink
  1131. # if HAVE_RAW_DECL_UNLINK
  1132. _GL_WARN_ON_USE (unlink, "unlink is not portable - "
  1133. "use gnulib module unlink for portability");
  1134. # endif
  1135. #endif
  1136. #if @GNULIB_UNLINKAT@
  1137. # if @REPLACE_UNLINKAT@
  1138. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1139. # undef unlinkat
  1140. # define unlinkat rpl_unlinkat
  1141. # endif
  1142. _GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag)
  1143. _GL_ARG_NONNULL ((2)));
  1144. _GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag));
  1145. # else
  1146. # if !@HAVE_UNLINKAT@
  1147. _GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag)
  1148. _GL_ARG_NONNULL ((2)));
  1149. # endif
  1150. _GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag));
  1151. # endif
  1152. _GL_CXXALIASWARN (unlinkat);
  1153. #elif defined GNULIB_POSIXCHECK
  1154. # undef unlinkat
  1155. # if HAVE_RAW_DECL_UNLINKAT
  1156. _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
  1157. "use gnulib module openat for portability");
  1158. # endif
  1159. #endif
  1160. #if @GNULIB_USLEEP@
  1161. /* Pause the execution of the current thread for N microseconds.
  1162. Returns 0 on completion, or -1 on range error.
  1163. See the POSIX:2001 specification
  1164. <http://www.opengroup.org/susv3xsh/sleep.html>. */
  1165. # if @REPLACE_USLEEP@
  1166. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1167. # undef usleep
  1168. # define usleep rpl_usleep
  1169. # endif
  1170. _GL_FUNCDECL_RPL (usleep, int, (useconds_t n));
  1171. _GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
  1172. # else
  1173. # if !@HAVE_USLEEP@
  1174. _GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
  1175. # endif
  1176. _GL_CXXALIAS_SYS (usleep, int, (useconds_t n));
  1177. # endif
  1178. _GL_CXXALIASWARN (usleep);
  1179. #elif defined GNULIB_POSIXCHECK
  1180. # undef usleep
  1181. # if HAVE_RAW_DECL_USLEEP
  1182. _GL_WARN_ON_USE (usleep, "usleep is unportable - "
  1183. "use gnulib module usleep for portability");
  1184. # endif
  1185. #endif
  1186. #if @GNULIB_WRITE@
  1187. /* Write up to COUNT bytes starting at BUF to file descriptor FD.
  1188. See the POSIX:2001 specification
  1189. <http://www.opengroup.org/susv3xsh/write.html>. */
  1190. # if @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
  1191. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1192. # undef write
  1193. # define write rpl_write
  1194. # endif
  1195. _GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
  1196. _GL_ARG_NONNULL ((2)));
  1197. _GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
  1198. # else
  1199. /* Need to cast, because on mingw, the third parameter is
  1200. unsigned int count
  1201. and the return type is 'int'. */
  1202. _GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count));
  1203. # endif
  1204. _GL_CXXALIASWARN (write);
  1205. #endif
  1206. #endif /* _GL_UNISTD_H */
  1207. #endif /* _GL_UNISTD_H */