stdlib.in.h 31 KB

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