stdlib.in.h 32 KB

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