unistd.in.h 49 KB

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