stdlib.in.h 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938
  1. /* A GNU-like <stdlib.h>.
  2. Copyright (C) 1995, 2001-2004, 2006-2012 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 Lesser General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  13. #if __GNUC__ >= 3
  14. @PRAGMA_SYSTEM_HEADER@
  15. #endif
  16. @PRAGMA_COLUMNS@
  17. #if defined __need_malloc_and_calloc
  18. /* Special invocation convention inside glibc header files. */
  19. #@INCLUDE_NEXT@ @NEXT_STDLIB_H@
  20. #else
  21. /* Normal invocation convention. */
  22. #ifndef _@GUARD_PREFIX@_STDLIB_H
  23. /* The include_next requires a split double-inclusion guard. */
  24. #@INCLUDE_NEXT@ @NEXT_STDLIB_H@
  25. #ifndef _@GUARD_PREFIX@_STDLIB_H
  26. #define _@GUARD_PREFIX@_STDLIB_H
  27. /* NetBSD 5.0 mis-defines NULL. */
  28. #include <stddef.h>
  29. /* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>. */
  30. #if @GNULIB_SYSTEM_POSIX@ && !defined WEXITSTATUS
  31. # include <sys/wait.h>
  32. #endif
  33. /* Solaris declares getloadavg() in <sys/loadavg.h>. */
  34. #if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@
  35. # include <sys/loadavg.h>
  36. #endif
  37. /* Native Windows platforms declare mktemp() in <io.h>. */
  38. #if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
  39. # include <io.h>
  40. #endif
  41. #if @GNULIB_RANDOM_R@
  42. /* OSF/1 5.1 declares 'struct random_data' in <random.h>, which is included
  43. from <stdlib.h> if _REENTRANT is defined. Include it whenever we need
  44. 'struct random_data'. */
  45. # if @HAVE_RANDOM_H@
  46. # include <random.h>
  47. # endif
  48. # if !@HAVE_STRUCT_RANDOM_DATA@ || @REPLACE_RANDOM_R@ || !@HAVE_RANDOM_R@
  49. # include <stdint.h>
  50. # endif
  51. # if !@HAVE_STRUCT_RANDOM_DATA@
  52. /* Define 'struct random_data'.
  53. But allow multiple gnulib generated <stdlib.h> replacements to coexist. */
  54. # if !GNULIB_defined_struct_random_data
  55. struct random_data
  56. {
  57. int32_t *fptr; /* Front pointer. */
  58. int32_t *rptr; /* Rear pointer. */
  59. int32_t *state; /* Array of state values. */
  60. int rand_type; /* Type of random number generator. */
  61. int rand_deg; /* Degree of random number generator. */
  62. int rand_sep; /* Distance between front and rear. */
  63. int32_t *end_ptr; /* Pointer behind state table. */
  64. };
  65. # define GNULIB_defined_struct_random_data 1
  66. # endif
  67. # endif
  68. #endif
  69. #if (@GNULIB_MKSTEMP@ || @GNULIB_MKSTEMPS@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
  70. /* On Mac OS X 10.3, only <unistd.h> declares mkstemp. */
  71. /* On Mac OS X 10.5, only <unistd.h> declares mkstemps. */
  72. /* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */
  73. /* But avoid namespace pollution on glibc systems and native Windows. */
  74. # include <unistd.h>
  75. #endif
  76. /* The __attribute__ feature is available in gcc versions 2.5 and later.
  77. The attribute __pure__ was added in gcc 2.96. */
  78. #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
  79. # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
  80. #else
  81. # define _GL_ATTRIBUTE_PURE /* empty */
  82. #endif
  83. /* The definition of _Noreturn is copied here. */
  84. /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
  85. /* The definition of _GL_ARG_NONNULL is copied here. */
  86. /* The definition of _GL_WARN_ON_USE is copied here. */
  87. /* Some systems do not define EXIT_*, despite otherwise supporting C89. */
  88. #ifndef EXIT_SUCCESS
  89. # define EXIT_SUCCESS 0
  90. #endif
  91. /* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere
  92. with proper operation of xargs. */
  93. #ifndef EXIT_FAILURE
  94. # define EXIT_FAILURE 1
  95. #elif EXIT_FAILURE != 1
  96. # undef EXIT_FAILURE
  97. # define EXIT_FAILURE 1
  98. #endif
  99. #if @GNULIB__EXIT@
  100. /* Terminate the current process with the given return code, without running
  101. the 'atexit' handlers. */
  102. # if !@HAVE__EXIT@
  103. _GL_FUNCDECL_SYS (_Exit, _Noreturn void, (int status));
  104. # endif
  105. _GL_CXXALIAS_SYS (_Exit, void, (int status));
  106. _GL_CXXALIASWARN (_Exit);
  107. #elif defined GNULIB_POSIXCHECK
  108. # undef _Exit
  109. # if HAVE_RAW_DECL__EXIT
  110. _GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
  111. "use gnulib module _Exit for portability");
  112. # endif
  113. #endif
  114. #if @GNULIB_ATOLL@
  115. /* Parse a signed decimal integer.
  116. Returns the value of the integer. Errors are not detected. */
  117. # if !@HAVE_ATOLL@
  118. _GL_FUNCDECL_SYS (atoll, long long, (const char *string)
  119. _GL_ATTRIBUTE_PURE
  120. _GL_ARG_NONNULL ((1)));
  121. # endif
  122. _GL_CXXALIAS_SYS (atoll, long long, (const char *string));
  123. _GL_CXXALIASWARN (atoll);
  124. #elif defined GNULIB_POSIXCHECK
  125. # undef atoll
  126. # if HAVE_RAW_DECL_ATOLL
  127. _GL_WARN_ON_USE (atoll, "atoll is unportable - "
  128. "use gnulib module atoll for portability");
  129. # endif
  130. #endif
  131. #if @GNULIB_CALLOC_POSIX@
  132. # if @REPLACE_CALLOC@
  133. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  134. # undef calloc
  135. # define calloc rpl_calloc
  136. # endif
  137. _GL_FUNCDECL_RPL (calloc, void *, (size_t nmemb, size_t size));
  138. _GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size));
  139. # else
  140. _GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size));
  141. # endif
  142. _GL_CXXALIASWARN (calloc);
  143. #elif defined GNULIB_POSIXCHECK
  144. # undef calloc
  145. /* Assume calloc is always declared. */
  146. _GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - "
  147. "use gnulib module calloc-posix for portability");
  148. #endif
  149. #if @GNULIB_CANONICALIZE_FILE_NAME@
  150. # if @REPLACE_CANONICALIZE_FILE_NAME@
  151. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  152. # define canonicalize_file_name rpl_canonicalize_file_name
  153. # endif
  154. _GL_FUNCDECL_RPL (canonicalize_file_name, char *, (const char *name)
  155. _GL_ARG_NONNULL ((1)));
  156. _GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name));
  157. # else
  158. # if !@HAVE_CANONICALIZE_FILE_NAME@
  159. _GL_FUNCDECL_SYS (canonicalize_file_name, char *, (const char *name)
  160. _GL_ARG_NONNULL ((1)));
  161. # endif
  162. _GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name));
  163. # endif
  164. _GL_CXXALIASWARN (canonicalize_file_name);
  165. #elif defined GNULIB_POSIXCHECK
  166. # undef canonicalize_file_name
  167. # if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
  168. _GL_WARN_ON_USE (canonicalize_file_name,
  169. "canonicalize_file_name is unportable - "
  170. "use gnulib module canonicalize-lgpl for portability");
  171. # endif
  172. #endif
  173. #if @GNULIB_GETLOADAVG@
  174. /* Store max(NELEM,3) load average numbers in LOADAVG[].
  175. The three numbers are the load average of the last 1 minute, the last 5
  176. minutes, and the last 15 minutes, respectively.
  177. LOADAVG is an array of NELEM numbers. */
  178. # if !@HAVE_DECL_GETLOADAVG@
  179. _GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem)
  180. _GL_ARG_NONNULL ((1)));
  181. # endif
  182. _GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem));
  183. _GL_CXXALIASWARN (getloadavg);
  184. #elif defined GNULIB_POSIXCHECK
  185. # undef getloadavg
  186. # if HAVE_RAW_DECL_GETLOADAVG
  187. _GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - "
  188. "use gnulib module getloadavg for portability");
  189. # endif
  190. #endif
  191. #if @GNULIB_GETSUBOPT@
  192. /* Assuming *OPTIONP is a comma separated list of elements of the form
  193. "token" or "token=value", getsubopt parses the first of these elements.
  194. If the first element refers to a "token" that is member of the given
  195. NULL-terminated array of tokens:
  196. - It replaces the comma with a NUL byte, updates *OPTIONP to point past
  197. the first option and the comma, sets *VALUEP to the value of the
  198. element (or NULL if it doesn't contain an "=" sign),
  199. - It returns the index of the "token" in the given array of tokens.
  200. Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
  201. For more details see the POSIX:2001 specification.
  202. http://www.opengroup.org/susv3xsh/getsubopt.html */
  203. # if !@HAVE_GETSUBOPT@
  204. _GL_FUNCDECL_SYS (getsubopt, int,
  205. (char **optionp, char *const *tokens, char **valuep)
  206. _GL_ARG_NONNULL ((1, 2, 3)));
  207. # endif
  208. _GL_CXXALIAS_SYS (getsubopt, int,
  209. (char **optionp, char *const *tokens, char **valuep));
  210. _GL_CXXALIASWARN (getsubopt);
  211. #elif defined GNULIB_POSIXCHECK
  212. # undef getsubopt
  213. # if HAVE_RAW_DECL_GETSUBOPT
  214. _GL_WARN_ON_USE (getsubopt, "getsubopt is unportable - "
  215. "use gnulib module getsubopt for portability");
  216. # endif
  217. #endif
  218. #if @GNULIB_GRANTPT@
  219. /* Change the ownership and access permission of the slave side of the
  220. pseudo-terminal whose master side is specified by FD. */
  221. # if !@HAVE_GRANTPT@
  222. _GL_FUNCDECL_SYS (grantpt, int, (int fd));
  223. # endif
  224. _GL_CXXALIAS_SYS (grantpt, int, (int fd));
  225. _GL_CXXALIASWARN (grantpt);
  226. #elif defined GNULIB_POSIXCHECK
  227. # undef grantpt
  228. # if HAVE_RAW_DECL_GRANTPT
  229. _GL_WARN_ON_USE (grantpt, "grantpt is not portable - "
  230. "use gnulib module grantpt for portability");
  231. # endif
  232. #endif
  233. /* If _GL_USE_STDLIB_ALLOC is nonzero, the including module does not
  234. rely on GNU or POSIX semantics for malloc and realloc (for example,
  235. by never specifying a zero size), so it does not need malloc or
  236. realloc to be redefined. */
  237. #if @GNULIB_MALLOC_POSIX@
  238. # if @REPLACE_MALLOC@
  239. # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
  240. || _GL_USE_STDLIB_ALLOC)
  241. # undef malloc
  242. # define malloc rpl_malloc
  243. # endif
  244. _GL_FUNCDECL_RPL (malloc, void *, (size_t size));
  245. _GL_CXXALIAS_RPL (malloc, void *, (size_t size));
  246. # else
  247. _GL_CXXALIAS_SYS (malloc, void *, (size_t size));
  248. # endif
  249. _GL_CXXALIASWARN (malloc);
  250. #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
  251. # undef malloc
  252. /* Assume malloc is always declared. */
  253. _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - "
  254. "use gnulib module malloc-posix for portability");
  255. #endif
  256. /* Convert a multibyte character to a wide character. */
  257. #if @GNULIB_MBTOWC@
  258. # if @REPLACE_MBTOWC@
  259. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  260. # undef mbtowc
  261. # define mbtowc rpl_mbtowc
  262. # endif
  263. _GL_FUNCDECL_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
  264. _GL_CXXALIAS_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
  265. # else
  266. _GL_CXXALIAS_SYS (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
  267. # endif
  268. _GL_CXXALIASWARN (mbtowc);
  269. #endif
  270. #if @GNULIB_MKDTEMP@
  271. /* Create a unique temporary directory from TEMPLATE.
  272. The last six characters of TEMPLATE must be "XXXXXX";
  273. they are replaced with a string that makes the directory name unique.
  274. Returns TEMPLATE, or a null pointer if it cannot get a unique name.
  275. The directory is created mode 700. */
  276. # if !@HAVE_MKDTEMP@
  277. _GL_FUNCDECL_SYS (mkdtemp, char *, (char * /*template*/) _GL_ARG_NONNULL ((1)));
  278. # endif
  279. _GL_CXXALIAS_SYS (mkdtemp, char *, (char * /*template*/));
  280. _GL_CXXALIASWARN (mkdtemp);
  281. #elif defined GNULIB_POSIXCHECK
  282. # undef mkdtemp
  283. # if HAVE_RAW_DECL_MKDTEMP
  284. _GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - "
  285. "use gnulib module mkdtemp for portability");
  286. # endif
  287. #endif
  288. #if @GNULIB_MKOSTEMP@
  289. /* Create a unique temporary file from TEMPLATE.
  290. The last six characters of TEMPLATE must be "XXXXXX";
  291. they are replaced with a string that makes the file name unique.
  292. The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
  293. and O_TEXT, O_BINARY (defined in "binary-io.h").
  294. The file is then created, with the specified flags, ensuring it didn't exist
  295. before.
  296. The file is created read-write (mask at least 0600 & ~umask), but it may be
  297. world-readable and world-writable (mask 0666 & ~umask), depending on the
  298. implementation.
  299. Returns the open file descriptor if successful, otherwise -1 and errno
  300. set. */
  301. # if !@HAVE_MKOSTEMP@
  302. _GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)
  303. _GL_ARG_NONNULL ((1)));
  304. # endif
  305. _GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/));
  306. _GL_CXXALIASWARN (mkostemp);
  307. #elif defined GNULIB_POSIXCHECK
  308. # undef mkostemp
  309. # if HAVE_RAW_DECL_MKOSTEMP
  310. _GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - "
  311. "use gnulib module mkostemp for portability");
  312. # endif
  313. #endif
  314. #if @GNULIB_MKOSTEMPS@
  315. /* Create a unique temporary file from TEMPLATE.
  316. The last six characters of TEMPLATE before a suffix of length
  317. SUFFIXLEN must be "XXXXXX";
  318. they are replaced with a string that makes the file name unique.
  319. The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
  320. and O_TEXT, O_BINARY (defined in "binary-io.h").
  321. The file is then created, with the specified flags, ensuring it didn't exist
  322. before.
  323. The file is created read-write (mask at least 0600 & ~umask), but it may be
  324. world-readable and world-writable (mask 0666 & ~umask), depending on the
  325. implementation.
  326. Returns the open file descriptor if successful, otherwise -1 and errno
  327. set. */
  328. # if !@HAVE_MKOSTEMPS@
  329. _GL_FUNCDECL_SYS (mkostemps, int,
  330. (char * /*template*/, int /*suffixlen*/, int /*flags*/)
  331. _GL_ARG_NONNULL ((1)));
  332. # endif
  333. _GL_CXXALIAS_SYS (mkostemps, int,
  334. (char * /*template*/, int /*suffixlen*/, int /*flags*/));
  335. _GL_CXXALIASWARN (mkostemps);
  336. #elif defined GNULIB_POSIXCHECK
  337. # undef mkostemps
  338. # if HAVE_RAW_DECL_MKOSTEMPS
  339. _GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - "
  340. "use gnulib module mkostemps for portability");
  341. # endif
  342. #endif
  343. #if @GNULIB_MKSTEMP@
  344. /* Create a unique temporary file from TEMPLATE.
  345. The last six characters of TEMPLATE must be "XXXXXX";
  346. they are replaced with a string that makes the file name unique.
  347. The file is then created, ensuring it didn't exist before.
  348. The file is created read-write (mask at least 0600 & ~umask), but it may be
  349. world-readable and world-writable (mask 0666 & ~umask), depending on the
  350. implementation.
  351. Returns the open file descriptor if successful, otherwise -1 and errno
  352. set. */
  353. # if @REPLACE_MKSTEMP@
  354. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  355. # define mkstemp rpl_mkstemp
  356. # endif
  357. _GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
  358. _GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/));
  359. # else
  360. # if ! @HAVE_MKSTEMP@
  361. _GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
  362. # endif
  363. _GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/));
  364. # endif
  365. _GL_CXXALIASWARN (mkstemp);
  366. #elif defined GNULIB_POSIXCHECK
  367. # undef mkstemp
  368. # if HAVE_RAW_DECL_MKSTEMP
  369. _GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - "
  370. "use gnulib module mkstemp for portability");
  371. # endif
  372. #endif
  373. #if @GNULIB_MKSTEMPS@
  374. /* Create a unique temporary file from TEMPLATE.
  375. The last six characters of TEMPLATE prior to a suffix of length
  376. SUFFIXLEN must be "XXXXXX";
  377. they are replaced with a string that makes the file name unique.
  378. The file is then created, ensuring it didn't exist before.
  379. The file is created read-write (mask at least 0600 & ~umask), but it may be
  380. world-readable and world-writable (mask 0666 & ~umask), depending on the
  381. implementation.
  382. Returns the open file descriptor if successful, otherwise -1 and errno
  383. set. */
  384. # if !@HAVE_MKSTEMPS@
  385. _GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/)
  386. _GL_ARG_NONNULL ((1)));
  387. # endif
  388. _GL_CXXALIAS_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/));
  389. _GL_CXXALIASWARN (mkstemps);
  390. #elif defined GNULIB_POSIXCHECK
  391. # undef mkstemps
  392. # if HAVE_RAW_DECL_MKSTEMPS
  393. _GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - "
  394. "use gnulib module mkstemps for portability");
  395. # endif
  396. #endif
  397. #if @GNULIB_POSIX_OPENPT@
  398. /* Return an FD open to the master side of a pseudo-terminal. Flags should
  399. include O_RDWR, and may also include O_NOCTTY. */
  400. # if !@HAVE_POSIX_OPENPT@
  401. _GL_FUNCDECL_SYS (posix_openpt, int, (int flags));
  402. # endif
  403. _GL_CXXALIAS_SYS (posix_openpt, int, (int flags));
  404. _GL_CXXALIASWARN (posix_openpt);
  405. #elif defined GNULIB_POSIXCHECK
  406. # undef posix_openpt
  407. # if HAVE_RAW_DECL_POSIX_OPENPT
  408. _GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - "
  409. "use gnulib module posix_openpt for portability");
  410. # endif
  411. #endif
  412. #if @GNULIB_PTSNAME@
  413. /* Return the pathname of the pseudo-terminal slave associated with
  414. the master FD is open on, or NULL on errors. */
  415. # if @REPLACE_PTSNAME@
  416. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  417. # undef ptsname
  418. # define ptsname rpl_ptsname
  419. # endif
  420. _GL_FUNCDECL_RPL (ptsname, char *, (int fd));
  421. _GL_CXXALIAS_RPL (ptsname, char *, (int fd));
  422. # else
  423. # if !@HAVE_PTSNAME@
  424. _GL_FUNCDECL_SYS (ptsname, char *, (int fd));
  425. # endif
  426. _GL_CXXALIAS_SYS (ptsname, char *, (int fd));
  427. # endif
  428. _GL_CXXALIASWARN (ptsname);
  429. #elif defined GNULIB_POSIXCHECK
  430. # undef ptsname
  431. # if HAVE_RAW_DECL_PTSNAME
  432. _GL_WARN_ON_USE (ptsname, "ptsname is not portable - "
  433. "use gnulib module ptsname for portability");
  434. # endif
  435. #endif
  436. #if @GNULIB_PTSNAME_R@
  437. /* Set the pathname of the pseudo-terminal slave associated with
  438. the master FD is open on and return 0, or set errno and return
  439. non-zero on errors. */
  440. # if @REPLACE_PTSNAME_R@
  441. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  442. # undef ptsname_r
  443. # define ptsname_r rpl_ptsname_r
  444. # endif
  445. _GL_FUNCDECL_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
  446. _GL_CXXALIAS_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
  447. # else
  448. # if !@HAVE_PTSNAME_R@
  449. _GL_FUNCDECL_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
  450. # endif
  451. _GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
  452. # endif
  453. _GL_CXXALIASWARN (ptsname_r);
  454. #elif defined GNULIB_POSIXCHECK
  455. # undef ptsname_r
  456. # if HAVE_RAW_DECL_PTSNAME_R
  457. _GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - "
  458. "use gnulib module ptsname_r for portability");
  459. # endif
  460. #endif
  461. #if @GNULIB_PUTENV@
  462. # if @REPLACE_PUTENV@
  463. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  464. # undef putenv
  465. # define putenv rpl_putenv
  466. # endif
  467. _GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1)));
  468. _GL_CXXALIAS_RPL (putenv, int, (char *string));
  469. # else
  470. _GL_CXXALIAS_SYS (putenv, int, (char *string));
  471. # endif
  472. _GL_CXXALIASWARN (putenv);
  473. #endif
  474. #if @GNULIB_RANDOM_R@
  475. # if !@HAVE_RANDOM_R@
  476. # ifndef RAND_MAX
  477. # define RAND_MAX 2147483647
  478. # endif
  479. # endif
  480. #endif
  481. #if @GNULIB_RANDOM@
  482. # if !@HAVE_RANDOM@
  483. _GL_FUNCDECL_SYS (random, long, (void));
  484. # endif
  485. _GL_CXXALIAS_SYS (random, long, (void));
  486. _GL_CXXALIASWARN (random);
  487. #elif defined GNULIB_POSIXCHECK
  488. # undef random
  489. # if HAVE_RAW_DECL_RANDOM
  490. _GL_WARN_ON_USE (random, "random is unportable - "
  491. "use gnulib module random for portability");
  492. # endif
  493. #endif
  494. #if @GNULIB_RANDOM@
  495. # if !@HAVE_RANDOM@
  496. _GL_FUNCDECL_SYS (srandom, void, (unsigned int seed));
  497. # endif
  498. _GL_CXXALIAS_SYS (srandom, void, (unsigned int seed));
  499. _GL_CXXALIASWARN (srandom);
  500. #elif defined GNULIB_POSIXCHECK
  501. # undef srandom
  502. # if HAVE_RAW_DECL_SRANDOM
  503. _GL_WARN_ON_USE (srandom, "srandom is unportable - "
  504. "use gnulib module random for portability");
  505. # endif
  506. #endif
  507. #if @GNULIB_RANDOM@
  508. # if !@HAVE_RANDOM@
  509. _GL_FUNCDECL_SYS (initstate, char *,
  510. (unsigned int seed, char *buf, size_t buf_size)
  511. _GL_ARG_NONNULL ((2)));
  512. # endif
  513. _GL_CXXALIAS_SYS (initstate, char *,
  514. (unsigned int seed, char *buf, size_t buf_size));
  515. _GL_CXXALIASWARN (initstate);
  516. #elif defined GNULIB_POSIXCHECK
  517. # undef initstate
  518. # if HAVE_RAW_DECL_INITSTATE_R
  519. _GL_WARN_ON_USE (initstate, "initstate is unportable - "
  520. "use gnulib module random for portability");
  521. # endif
  522. #endif
  523. #if @GNULIB_RANDOM@
  524. # if !@HAVE_RANDOM@
  525. _GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
  526. # endif
  527. _GL_CXXALIAS_SYS (setstate, char *, (char *arg_state));
  528. _GL_CXXALIASWARN (setstate);
  529. #elif defined GNULIB_POSIXCHECK
  530. # undef setstate
  531. # if HAVE_RAW_DECL_SETSTATE_R
  532. _GL_WARN_ON_USE (setstate, "setstate is unportable - "
  533. "use gnulib module random for portability");
  534. # endif
  535. #endif
  536. #if @GNULIB_RANDOM_R@
  537. # if @REPLACE_RANDOM_R@
  538. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  539. # undef random_r
  540. # define random_r rpl_random_r
  541. # endif
  542. _GL_FUNCDECL_RPL (random_r, int, (struct random_data *buf, int32_t *result)
  543. _GL_ARG_NONNULL ((1, 2)));
  544. _GL_CXXALIAS_RPL (random_r, int, (struct random_data *buf, int32_t *result));
  545. # else
  546. # if !@HAVE_RANDOM_R@
  547. _GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result)
  548. _GL_ARG_NONNULL ((1, 2)));
  549. # endif
  550. _GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result));
  551. # endif
  552. _GL_CXXALIASWARN (random_r);
  553. #elif defined GNULIB_POSIXCHECK
  554. # undef random_r
  555. # if HAVE_RAW_DECL_RANDOM_R
  556. _GL_WARN_ON_USE (random_r, "random_r is unportable - "
  557. "use gnulib module random_r for portability");
  558. # endif
  559. #endif
  560. #if @GNULIB_RANDOM_R@
  561. # if @REPLACE_RANDOM_R@
  562. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  563. # undef srandom_r
  564. # define srandom_r rpl_srandom_r
  565. # endif
  566. _GL_FUNCDECL_RPL (srandom_r, int,
  567. (unsigned int seed, struct random_data *rand_state)
  568. _GL_ARG_NONNULL ((2)));
  569. _GL_CXXALIAS_RPL (srandom_r, int,
  570. (unsigned int seed, struct random_data *rand_state));
  571. # else
  572. # if !@HAVE_RANDOM_R@
  573. _GL_FUNCDECL_SYS (srandom_r, int,
  574. (unsigned int seed, struct random_data *rand_state)
  575. _GL_ARG_NONNULL ((2)));
  576. # endif
  577. _GL_CXXALIAS_SYS (srandom_r, int,
  578. (unsigned int seed, struct random_data *rand_state));
  579. # endif
  580. _GL_CXXALIASWARN (srandom_r);
  581. #elif defined GNULIB_POSIXCHECK
  582. # undef srandom_r
  583. # if HAVE_RAW_DECL_SRANDOM_R
  584. _GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - "
  585. "use gnulib module random_r for portability");
  586. # endif
  587. #endif
  588. #if @GNULIB_RANDOM_R@
  589. # if @REPLACE_RANDOM_R@
  590. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  591. # undef initstate_r
  592. # define initstate_r rpl_initstate_r
  593. # endif
  594. _GL_FUNCDECL_RPL (initstate_r, int,
  595. (unsigned int seed, char *buf, size_t buf_size,
  596. struct random_data *rand_state)
  597. _GL_ARG_NONNULL ((2, 4)));
  598. _GL_CXXALIAS_RPL (initstate_r, int,
  599. (unsigned int seed, char *buf, size_t buf_size,
  600. struct random_data *rand_state));
  601. # else
  602. # if !@HAVE_RANDOM_R@
  603. _GL_FUNCDECL_SYS (initstate_r, int,
  604. (unsigned int seed, char *buf, size_t buf_size,
  605. struct random_data *rand_state)
  606. _GL_ARG_NONNULL ((2, 4)));
  607. # endif
  608. _GL_CXXALIAS_SYS (initstate_r, int,
  609. (unsigned int seed, char *buf, size_t buf_size,
  610. struct random_data *rand_state));
  611. # endif
  612. _GL_CXXALIASWARN (initstate_r);
  613. #elif defined GNULIB_POSIXCHECK
  614. # undef initstate_r
  615. # if HAVE_RAW_DECL_INITSTATE_R
  616. _GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - "
  617. "use gnulib module random_r for portability");
  618. # endif
  619. #endif
  620. #if @GNULIB_RANDOM_R@
  621. # if @REPLACE_RANDOM_R@
  622. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  623. # undef setstate_r
  624. # define setstate_r rpl_setstate_r
  625. # endif
  626. _GL_FUNCDECL_RPL (setstate_r, int,
  627. (char *arg_state, struct random_data *rand_state)
  628. _GL_ARG_NONNULL ((1, 2)));
  629. _GL_CXXALIAS_RPL (setstate_r, int,
  630. (char *arg_state, struct random_data *rand_state));
  631. # else
  632. # if !@HAVE_RANDOM_R@
  633. _GL_FUNCDECL_SYS (setstate_r, int,
  634. (char *arg_state, struct random_data *rand_state)
  635. _GL_ARG_NONNULL ((1, 2)));
  636. # endif
  637. _GL_CXXALIAS_SYS (setstate_r, int,
  638. (char *arg_state, struct random_data *rand_state));
  639. # endif
  640. _GL_CXXALIASWARN (setstate_r);
  641. #elif defined GNULIB_POSIXCHECK
  642. # undef setstate_r
  643. # if HAVE_RAW_DECL_SETSTATE_R
  644. _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
  645. "use gnulib module random_r for portability");
  646. # endif
  647. #endif
  648. #if @GNULIB_REALLOC_POSIX@
  649. # if @REPLACE_REALLOC@
  650. # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
  651. || _GL_USE_STDLIB_ALLOC)
  652. # undef realloc
  653. # define realloc rpl_realloc
  654. # endif
  655. _GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size));
  656. _GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size));
  657. # else
  658. _GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size));
  659. # endif
  660. _GL_CXXALIASWARN (realloc);
  661. #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
  662. # undef realloc
  663. /* Assume realloc is always declared. */
  664. _GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - "
  665. "use gnulib module realloc-posix for portability");
  666. #endif
  667. #if @GNULIB_REALPATH@
  668. # if @REPLACE_REALPATH@
  669. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  670. # define realpath rpl_realpath
  671. # endif
  672. _GL_FUNCDECL_RPL (realpath, char *, (const char *name, char *resolved)
  673. _GL_ARG_NONNULL ((1)));
  674. _GL_CXXALIAS_RPL (realpath, char *, (const char *name, char *resolved));
  675. # else
  676. # if !@HAVE_REALPATH@
  677. _GL_FUNCDECL_SYS (realpath, char *, (const char *name, char *resolved)
  678. _GL_ARG_NONNULL ((1)));
  679. # endif
  680. _GL_CXXALIAS_SYS (realpath, char *, (const char *name, char *resolved));
  681. # endif
  682. _GL_CXXALIASWARN (realpath);
  683. #elif defined GNULIB_POSIXCHECK
  684. # undef realpath
  685. # if HAVE_RAW_DECL_REALPATH
  686. _GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module "
  687. "canonicalize or canonicalize-lgpl for portability");
  688. # endif
  689. #endif
  690. #if @GNULIB_RPMATCH@
  691. /* Test a user response to a question.
  692. Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
  693. # if !@HAVE_RPMATCH@
  694. _GL_FUNCDECL_SYS (rpmatch, int, (const char *response) _GL_ARG_NONNULL ((1)));
  695. # endif
  696. _GL_CXXALIAS_SYS (rpmatch, int, (const char *response));
  697. _GL_CXXALIASWARN (rpmatch);
  698. #elif defined GNULIB_POSIXCHECK
  699. # undef rpmatch
  700. # if HAVE_RAW_DECL_RPMATCH
  701. _GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - "
  702. "use gnulib module rpmatch for portability");
  703. # endif
  704. #endif
  705. #if @GNULIB_SETENV@
  706. /* Set NAME to VALUE in the environment.
  707. If REPLACE is nonzero, overwrite an existing value. */
  708. # if @REPLACE_SETENV@
  709. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  710. # undef setenv
  711. # define setenv rpl_setenv
  712. # endif
  713. _GL_FUNCDECL_RPL (setenv, int,
  714. (const char *name, const char *value, int replace)
  715. _GL_ARG_NONNULL ((1)));
  716. _GL_CXXALIAS_RPL (setenv, int,
  717. (const char *name, const char *value, int replace));
  718. # else
  719. # if !@HAVE_DECL_SETENV@
  720. _GL_FUNCDECL_SYS (setenv, int,
  721. (const char *name, const char *value, int replace)
  722. _GL_ARG_NONNULL ((1)));
  723. # endif
  724. _GL_CXXALIAS_SYS (setenv, int,
  725. (const char *name, const char *value, int replace));
  726. # endif
  727. # if !(@REPLACE_SETENV@ && !@HAVE_DECL_SETENV@)
  728. _GL_CXXALIASWARN (setenv);
  729. # endif
  730. #elif defined GNULIB_POSIXCHECK
  731. # undef setenv
  732. # if HAVE_RAW_DECL_SETENV
  733. _GL_WARN_ON_USE (setenv, "setenv is unportable - "
  734. "use gnulib module setenv for portability");
  735. # endif
  736. #endif
  737. #if @GNULIB_STRTOD@
  738. /* Parse a double from STRING, updating ENDP if appropriate. */
  739. # if @REPLACE_STRTOD@
  740. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  741. # define strtod rpl_strtod
  742. # endif
  743. _GL_FUNCDECL_RPL (strtod, double, (const char *str, char **endp)
  744. _GL_ARG_NONNULL ((1)));
  745. _GL_CXXALIAS_RPL (strtod, double, (const char *str, char **endp));
  746. # else
  747. # if !@HAVE_STRTOD@
  748. _GL_FUNCDECL_SYS (strtod, double, (const char *str, char **endp)
  749. _GL_ARG_NONNULL ((1)));
  750. # endif
  751. _GL_CXXALIAS_SYS (strtod, double, (const char *str, char **endp));
  752. # endif
  753. _GL_CXXALIASWARN (strtod);
  754. #elif defined GNULIB_POSIXCHECK
  755. # undef strtod
  756. # if HAVE_RAW_DECL_STRTOD
  757. _GL_WARN_ON_USE (strtod, "strtod is unportable - "
  758. "use gnulib module strtod for portability");
  759. # endif
  760. #endif
  761. #if @GNULIB_STRTOLL@
  762. /* Parse a signed integer whose textual representation starts at STRING.
  763. The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
  764. it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
  765. "0x").
  766. If ENDPTR is not NULL, the address of the first byte after the integer is
  767. stored in *ENDPTR.
  768. Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
  769. to ERANGE. */
  770. # if !@HAVE_STRTOLL@
  771. _GL_FUNCDECL_SYS (strtoll, long long,
  772. (const char *string, char **endptr, int base)
  773. _GL_ARG_NONNULL ((1)));
  774. # endif
  775. _GL_CXXALIAS_SYS (strtoll, long long,
  776. (const char *string, char **endptr, int base));
  777. _GL_CXXALIASWARN (strtoll);
  778. #elif defined GNULIB_POSIXCHECK
  779. # undef strtoll
  780. # if HAVE_RAW_DECL_STRTOLL
  781. _GL_WARN_ON_USE (strtoll, "strtoll is unportable - "
  782. "use gnulib module strtoll for portability");
  783. # endif
  784. #endif
  785. #if @GNULIB_STRTOULL@
  786. /* Parse an unsigned integer whose textual representation starts at STRING.
  787. The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
  788. it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
  789. "0x").
  790. If ENDPTR is not NULL, the address of the first byte after the integer is
  791. stored in *ENDPTR.
  792. Upon overflow, the return value is ULLONG_MAX, and errno is set to
  793. ERANGE. */
  794. # if !@HAVE_STRTOULL@
  795. _GL_FUNCDECL_SYS (strtoull, unsigned long long,
  796. (const char *string, char **endptr, int base)
  797. _GL_ARG_NONNULL ((1)));
  798. # endif
  799. _GL_CXXALIAS_SYS (strtoull, unsigned long long,
  800. (const char *string, char **endptr, int base));
  801. _GL_CXXALIASWARN (strtoull);
  802. #elif defined GNULIB_POSIXCHECK
  803. # undef strtoull
  804. # if HAVE_RAW_DECL_STRTOULL
  805. _GL_WARN_ON_USE (strtoull, "strtoull is unportable - "
  806. "use gnulib module strtoull for portability");
  807. # endif
  808. #endif
  809. #if @GNULIB_UNLOCKPT@
  810. /* Unlock the slave side of the pseudo-terminal whose master side is specified
  811. by FD, so that it can be opened. */
  812. # if !@HAVE_UNLOCKPT@
  813. _GL_FUNCDECL_SYS (unlockpt, int, (int fd));
  814. # endif
  815. _GL_CXXALIAS_SYS (unlockpt, int, (int fd));
  816. _GL_CXXALIASWARN (unlockpt);
  817. #elif defined GNULIB_POSIXCHECK
  818. # undef unlockpt
  819. # if HAVE_RAW_DECL_UNLOCKPT
  820. _GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - "
  821. "use gnulib module unlockpt for portability");
  822. # endif
  823. #endif
  824. #if @GNULIB_UNSETENV@
  825. /* Remove the variable NAME from the environment. */
  826. # if @REPLACE_UNSETENV@
  827. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  828. # undef unsetenv
  829. # define unsetenv rpl_unsetenv
  830. # endif
  831. _GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
  832. _GL_CXXALIAS_RPL (unsetenv, int, (const char *name));
  833. # else
  834. # if !@HAVE_DECL_UNSETENV@
  835. _GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
  836. # endif
  837. _GL_CXXALIAS_SYS (unsetenv, int, (const char *name));
  838. # endif
  839. # if !(@REPLACE_UNSETENV@ && !@HAVE_DECL_UNSETENV@)
  840. _GL_CXXALIASWARN (unsetenv);
  841. # endif
  842. #elif defined GNULIB_POSIXCHECK
  843. # undef unsetenv
  844. # if HAVE_RAW_DECL_UNSETENV
  845. _GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - "
  846. "use gnulib module unsetenv for portability");
  847. # endif
  848. #endif
  849. /* Convert a wide character to a multibyte character. */
  850. #if @GNULIB_WCTOMB@
  851. # if @REPLACE_WCTOMB@
  852. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  853. # undef wctomb
  854. # define wctomb rpl_wctomb
  855. # endif
  856. _GL_FUNCDECL_RPL (wctomb, int, (char *s, wchar_t wc));
  857. _GL_CXXALIAS_RPL (wctomb, int, (char *s, wchar_t wc));
  858. # else
  859. _GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc));
  860. # endif
  861. _GL_CXXALIASWARN (wctomb);
  862. #endif
  863. #endif /* _@GUARD_PREFIX@_STDLIB_H */
  864. #endif /* _@GUARD_PREFIX@_STDLIB_H */
  865. #endif