stdlib.in.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978
  1. /* A GNU-like <stdlib.h>.
  2. Copyright (C) 1995, 2001-2004, 2006-2016 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_QSORT_R@
  476. # if @REPLACE_QSORT_R@
  477. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  478. # undef qsort_r
  479. # define qsort_r rpl_qsort_r
  480. # endif
  481. _GL_FUNCDECL_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
  482. int (*compare) (void const *, void const *,
  483. void *),
  484. void *arg) _GL_ARG_NONNULL ((1, 4)));
  485. _GL_CXXALIAS_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
  486. int (*compare) (void const *, void const *,
  487. void *),
  488. void *arg));
  489. # else
  490. _GL_CXXALIAS_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
  491. int (*compare) (void const *, void const *,
  492. void *),
  493. void *arg));
  494. # endif
  495. _GL_CXXALIASWARN (qsort_r);
  496. #endif
  497. #if @GNULIB_RANDOM_R@
  498. # if !@HAVE_RANDOM_R@
  499. # ifndef RAND_MAX
  500. # define RAND_MAX 2147483647
  501. # endif
  502. # endif
  503. #endif
  504. #if @GNULIB_RANDOM@
  505. # if !@HAVE_RANDOM@
  506. _GL_FUNCDECL_SYS (random, long, (void));
  507. # endif
  508. _GL_CXXALIAS_SYS (random, long, (void));
  509. _GL_CXXALIASWARN (random);
  510. #elif defined GNULIB_POSIXCHECK
  511. # undef random
  512. # if HAVE_RAW_DECL_RANDOM
  513. _GL_WARN_ON_USE (random, "random is unportable - "
  514. "use gnulib module random for portability");
  515. # endif
  516. #endif
  517. #if @GNULIB_RANDOM@
  518. # if !@HAVE_RANDOM@
  519. _GL_FUNCDECL_SYS (srandom, void, (unsigned int seed));
  520. # endif
  521. _GL_CXXALIAS_SYS (srandom, void, (unsigned int seed));
  522. _GL_CXXALIASWARN (srandom);
  523. #elif defined GNULIB_POSIXCHECK
  524. # undef srandom
  525. # if HAVE_RAW_DECL_SRANDOM
  526. _GL_WARN_ON_USE (srandom, "srandom is unportable - "
  527. "use gnulib module random for portability");
  528. # endif
  529. #endif
  530. #if @GNULIB_RANDOM@
  531. # if !@HAVE_RANDOM@
  532. _GL_FUNCDECL_SYS (initstate, char *,
  533. (unsigned int seed, char *buf, size_t buf_size)
  534. _GL_ARG_NONNULL ((2)));
  535. # endif
  536. _GL_CXXALIAS_SYS (initstate, char *,
  537. (unsigned int seed, char *buf, size_t buf_size));
  538. _GL_CXXALIASWARN (initstate);
  539. #elif defined GNULIB_POSIXCHECK
  540. # undef initstate
  541. # if HAVE_RAW_DECL_INITSTATE_R
  542. _GL_WARN_ON_USE (initstate, "initstate is unportable - "
  543. "use gnulib module random for portability");
  544. # endif
  545. #endif
  546. #if @GNULIB_RANDOM@
  547. # if !@HAVE_RANDOM@
  548. _GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
  549. # endif
  550. _GL_CXXALIAS_SYS (setstate, char *, (char *arg_state));
  551. _GL_CXXALIASWARN (setstate);
  552. #elif defined GNULIB_POSIXCHECK
  553. # undef setstate
  554. # if HAVE_RAW_DECL_SETSTATE_R
  555. _GL_WARN_ON_USE (setstate, "setstate is unportable - "
  556. "use gnulib module random for portability");
  557. # endif
  558. #endif
  559. #if @GNULIB_RANDOM_R@
  560. # if @REPLACE_RANDOM_R@
  561. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  562. # undef random_r
  563. # define random_r rpl_random_r
  564. # endif
  565. _GL_FUNCDECL_RPL (random_r, int, (struct random_data *buf, int32_t *result)
  566. _GL_ARG_NONNULL ((1, 2)));
  567. _GL_CXXALIAS_RPL (random_r, int, (struct random_data *buf, int32_t *result));
  568. # else
  569. # if !@HAVE_RANDOM_R@
  570. _GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result)
  571. _GL_ARG_NONNULL ((1, 2)));
  572. # endif
  573. _GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result));
  574. # endif
  575. _GL_CXXALIASWARN (random_r);
  576. #elif defined GNULIB_POSIXCHECK
  577. # undef random_r
  578. # if HAVE_RAW_DECL_RANDOM_R
  579. _GL_WARN_ON_USE (random_r, "random_r is unportable - "
  580. "use gnulib module random_r for portability");
  581. # endif
  582. #endif
  583. #if @GNULIB_RANDOM_R@
  584. # if @REPLACE_RANDOM_R@
  585. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  586. # undef srandom_r
  587. # define srandom_r rpl_srandom_r
  588. # endif
  589. _GL_FUNCDECL_RPL (srandom_r, int,
  590. (unsigned int seed, struct random_data *rand_state)
  591. _GL_ARG_NONNULL ((2)));
  592. _GL_CXXALIAS_RPL (srandom_r, int,
  593. (unsigned int seed, struct random_data *rand_state));
  594. # else
  595. # if !@HAVE_RANDOM_R@
  596. _GL_FUNCDECL_SYS (srandom_r, int,
  597. (unsigned int seed, struct random_data *rand_state)
  598. _GL_ARG_NONNULL ((2)));
  599. # endif
  600. _GL_CXXALIAS_SYS (srandom_r, int,
  601. (unsigned int seed, struct random_data *rand_state));
  602. # endif
  603. _GL_CXXALIASWARN (srandom_r);
  604. #elif defined GNULIB_POSIXCHECK
  605. # undef srandom_r
  606. # if HAVE_RAW_DECL_SRANDOM_R
  607. _GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - "
  608. "use gnulib module random_r for portability");
  609. # endif
  610. #endif
  611. #if @GNULIB_RANDOM_R@
  612. # if @REPLACE_RANDOM_R@
  613. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  614. # undef initstate_r
  615. # define initstate_r rpl_initstate_r
  616. # endif
  617. _GL_FUNCDECL_RPL (initstate_r, int,
  618. (unsigned int seed, char *buf, size_t buf_size,
  619. struct random_data *rand_state)
  620. _GL_ARG_NONNULL ((2, 4)));
  621. _GL_CXXALIAS_RPL (initstate_r, int,
  622. (unsigned int seed, char *buf, size_t buf_size,
  623. struct random_data *rand_state));
  624. # else
  625. # if !@HAVE_RANDOM_R@
  626. _GL_FUNCDECL_SYS (initstate_r, int,
  627. (unsigned int seed, char *buf, size_t buf_size,
  628. struct random_data *rand_state)
  629. _GL_ARG_NONNULL ((2, 4)));
  630. # endif
  631. _GL_CXXALIAS_SYS (initstate_r, int,
  632. (unsigned int seed, char *buf, size_t buf_size,
  633. struct random_data *rand_state));
  634. # endif
  635. _GL_CXXALIASWARN (initstate_r);
  636. #elif defined GNULIB_POSIXCHECK
  637. # undef initstate_r
  638. # if HAVE_RAW_DECL_INITSTATE_R
  639. _GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - "
  640. "use gnulib module random_r for portability");
  641. # endif
  642. #endif
  643. #if @GNULIB_RANDOM_R@
  644. # if @REPLACE_RANDOM_R@
  645. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  646. # undef setstate_r
  647. # define setstate_r rpl_setstate_r
  648. # endif
  649. _GL_FUNCDECL_RPL (setstate_r, int,
  650. (char *arg_state, struct random_data *rand_state)
  651. _GL_ARG_NONNULL ((1, 2)));
  652. _GL_CXXALIAS_RPL (setstate_r, int,
  653. (char *arg_state, struct random_data *rand_state));
  654. # else
  655. # if !@HAVE_RANDOM_R@
  656. _GL_FUNCDECL_SYS (setstate_r, int,
  657. (char *arg_state, struct random_data *rand_state)
  658. _GL_ARG_NONNULL ((1, 2)));
  659. # endif
  660. _GL_CXXALIAS_SYS (setstate_r, int,
  661. (char *arg_state, struct random_data *rand_state));
  662. # endif
  663. _GL_CXXALIASWARN (setstate_r);
  664. #elif defined GNULIB_POSIXCHECK
  665. # undef setstate_r
  666. # if HAVE_RAW_DECL_SETSTATE_R
  667. _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
  668. "use gnulib module random_r for portability");
  669. # endif
  670. #endif
  671. #if @GNULIB_REALLOC_POSIX@
  672. # if @REPLACE_REALLOC@
  673. # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
  674. || _GL_USE_STDLIB_ALLOC)
  675. # undef realloc
  676. # define realloc rpl_realloc
  677. # endif
  678. _GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size));
  679. _GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size));
  680. # else
  681. _GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size));
  682. # endif
  683. _GL_CXXALIASWARN (realloc);
  684. #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
  685. # undef realloc
  686. /* Assume realloc is always declared. */
  687. _GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - "
  688. "use gnulib module realloc-posix for portability");
  689. #endif
  690. #if @GNULIB_REALPATH@
  691. # if @REPLACE_REALPATH@
  692. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  693. # define realpath rpl_realpath
  694. # endif
  695. _GL_FUNCDECL_RPL (realpath, char *, (const char *name, char *resolved)
  696. _GL_ARG_NONNULL ((1)));
  697. _GL_CXXALIAS_RPL (realpath, char *, (const char *name, char *resolved));
  698. # else
  699. # if !@HAVE_REALPATH@
  700. _GL_FUNCDECL_SYS (realpath, char *, (const char *name, char *resolved)
  701. _GL_ARG_NONNULL ((1)));
  702. # endif
  703. _GL_CXXALIAS_SYS (realpath, char *, (const char *name, char *resolved));
  704. # endif
  705. _GL_CXXALIASWARN (realpath);
  706. #elif defined GNULIB_POSIXCHECK
  707. # undef realpath
  708. # if HAVE_RAW_DECL_REALPATH
  709. _GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module "
  710. "canonicalize or canonicalize-lgpl for portability");
  711. # endif
  712. #endif
  713. #if @GNULIB_RPMATCH@
  714. /* Test a user response to a question.
  715. Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
  716. # if !@HAVE_RPMATCH@
  717. _GL_FUNCDECL_SYS (rpmatch, int, (const char *response) _GL_ARG_NONNULL ((1)));
  718. # endif
  719. _GL_CXXALIAS_SYS (rpmatch, int, (const char *response));
  720. _GL_CXXALIASWARN (rpmatch);
  721. #elif defined GNULIB_POSIXCHECK
  722. # undef rpmatch
  723. # if HAVE_RAW_DECL_RPMATCH
  724. _GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - "
  725. "use gnulib module rpmatch for portability");
  726. # endif
  727. #endif
  728. #if @GNULIB_SECURE_GETENV@
  729. /* Look up NAME in the environment, returning 0 in insecure situations. */
  730. # if !@HAVE_SECURE_GETENV@
  731. _GL_FUNCDECL_SYS (secure_getenv, char *,
  732. (char const *name) _GL_ARG_NONNULL ((1)));
  733. # endif
  734. _GL_CXXALIAS_SYS (secure_getenv, char *, (char const *name));
  735. _GL_CXXALIASWARN (secure_getenv);
  736. #elif defined GNULIB_POSIXCHECK
  737. # undef secure_getenv
  738. # if HAVE_RAW_DECL_SECURE_GETENV
  739. _GL_WARN_ON_USE (secure_getenv, "secure_getenv is unportable - "
  740. "use gnulib module secure_getenv for portability");
  741. # endif
  742. #endif
  743. #if @GNULIB_SETENV@
  744. /* Set NAME to VALUE in the environment.
  745. If REPLACE is nonzero, overwrite an existing value. */
  746. # if @REPLACE_SETENV@
  747. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  748. # undef setenv
  749. # define setenv rpl_setenv
  750. # endif
  751. _GL_FUNCDECL_RPL (setenv, int,
  752. (const char *name, const char *value, int replace)
  753. _GL_ARG_NONNULL ((1)));
  754. _GL_CXXALIAS_RPL (setenv, int,
  755. (const char *name, const char *value, int replace));
  756. # else
  757. # if !@HAVE_DECL_SETENV@
  758. _GL_FUNCDECL_SYS (setenv, int,
  759. (const char *name, const char *value, int replace)
  760. _GL_ARG_NONNULL ((1)));
  761. # endif
  762. _GL_CXXALIAS_SYS (setenv, int,
  763. (const char *name, const char *value, int replace));
  764. # endif
  765. # if !(@REPLACE_SETENV@ && !@HAVE_DECL_SETENV@)
  766. _GL_CXXALIASWARN (setenv);
  767. # endif
  768. #elif defined GNULIB_POSIXCHECK
  769. # undef setenv
  770. # if HAVE_RAW_DECL_SETENV
  771. _GL_WARN_ON_USE (setenv, "setenv is unportable - "
  772. "use gnulib module setenv for portability");
  773. # endif
  774. #endif
  775. #if @GNULIB_STRTOD@
  776. /* Parse a double from STRING, updating ENDP if appropriate. */
  777. # if @REPLACE_STRTOD@
  778. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  779. # define strtod rpl_strtod
  780. # endif
  781. _GL_FUNCDECL_RPL (strtod, double, (const char *str, char **endp)
  782. _GL_ARG_NONNULL ((1)));
  783. _GL_CXXALIAS_RPL (strtod, double, (const char *str, char **endp));
  784. # else
  785. # if !@HAVE_STRTOD@
  786. _GL_FUNCDECL_SYS (strtod, double, (const char *str, char **endp)
  787. _GL_ARG_NONNULL ((1)));
  788. # endif
  789. _GL_CXXALIAS_SYS (strtod, double, (const char *str, char **endp));
  790. # endif
  791. _GL_CXXALIASWARN (strtod);
  792. #elif defined GNULIB_POSIXCHECK
  793. # undef strtod
  794. # if HAVE_RAW_DECL_STRTOD
  795. _GL_WARN_ON_USE (strtod, "strtod is unportable - "
  796. "use gnulib module strtod for portability");
  797. # endif
  798. #endif
  799. #if @GNULIB_STRTOLL@
  800. /* Parse a signed integer whose textual representation starts at STRING.
  801. The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
  802. it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
  803. "0x").
  804. If ENDPTR is not NULL, the address of the first byte after the integer is
  805. stored in *ENDPTR.
  806. Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
  807. to ERANGE. */
  808. # if !@HAVE_STRTOLL@
  809. _GL_FUNCDECL_SYS (strtoll, long long,
  810. (const char *string, char **endptr, int base)
  811. _GL_ARG_NONNULL ((1)));
  812. # endif
  813. _GL_CXXALIAS_SYS (strtoll, long long,
  814. (const char *string, char **endptr, int base));
  815. _GL_CXXALIASWARN (strtoll);
  816. #elif defined GNULIB_POSIXCHECK
  817. # undef strtoll
  818. # if HAVE_RAW_DECL_STRTOLL
  819. _GL_WARN_ON_USE (strtoll, "strtoll is unportable - "
  820. "use gnulib module strtoll for portability");
  821. # endif
  822. #endif
  823. #if @GNULIB_STRTOULL@
  824. /* Parse an unsigned integer whose textual representation starts at STRING.
  825. The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
  826. it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
  827. "0x").
  828. If ENDPTR is not NULL, the address of the first byte after the integer is
  829. stored in *ENDPTR.
  830. Upon overflow, the return value is ULLONG_MAX, and errno is set to
  831. ERANGE. */
  832. # if !@HAVE_STRTOULL@
  833. _GL_FUNCDECL_SYS (strtoull, unsigned long long,
  834. (const char *string, char **endptr, int base)
  835. _GL_ARG_NONNULL ((1)));
  836. # endif
  837. _GL_CXXALIAS_SYS (strtoull, unsigned long long,
  838. (const char *string, char **endptr, int base));
  839. _GL_CXXALIASWARN (strtoull);
  840. #elif defined GNULIB_POSIXCHECK
  841. # undef strtoull
  842. # if HAVE_RAW_DECL_STRTOULL
  843. _GL_WARN_ON_USE (strtoull, "strtoull is unportable - "
  844. "use gnulib module strtoull for portability");
  845. # endif
  846. #endif
  847. #if @GNULIB_UNLOCKPT@
  848. /* Unlock the slave side of the pseudo-terminal whose master side is specified
  849. by FD, so that it can be opened. */
  850. # if !@HAVE_UNLOCKPT@
  851. _GL_FUNCDECL_SYS (unlockpt, int, (int fd));
  852. # endif
  853. _GL_CXXALIAS_SYS (unlockpt, int, (int fd));
  854. _GL_CXXALIASWARN (unlockpt);
  855. #elif defined GNULIB_POSIXCHECK
  856. # undef unlockpt
  857. # if HAVE_RAW_DECL_UNLOCKPT
  858. _GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - "
  859. "use gnulib module unlockpt for portability");
  860. # endif
  861. #endif
  862. #if @GNULIB_UNSETENV@
  863. /* Remove the variable NAME from the environment. */
  864. # if @REPLACE_UNSETENV@
  865. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  866. # undef unsetenv
  867. # define unsetenv rpl_unsetenv
  868. # endif
  869. _GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
  870. _GL_CXXALIAS_RPL (unsetenv, int, (const char *name));
  871. # else
  872. # if !@HAVE_DECL_UNSETENV@
  873. _GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
  874. # endif
  875. _GL_CXXALIAS_SYS (unsetenv, int, (const char *name));
  876. # endif
  877. # if !(@REPLACE_UNSETENV@ && !@HAVE_DECL_UNSETENV@)
  878. _GL_CXXALIASWARN (unsetenv);
  879. # endif
  880. #elif defined GNULIB_POSIXCHECK
  881. # undef unsetenv
  882. # if HAVE_RAW_DECL_UNSETENV
  883. _GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - "
  884. "use gnulib module unsetenv for portability");
  885. # endif
  886. #endif
  887. /* Convert a wide character to a multibyte character. */
  888. #if @GNULIB_WCTOMB@
  889. # if @REPLACE_WCTOMB@
  890. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  891. # undef wctomb
  892. # define wctomb rpl_wctomb
  893. # endif
  894. _GL_FUNCDECL_RPL (wctomb, int, (char *s, wchar_t wc));
  895. _GL_CXXALIAS_RPL (wctomb, int, (char *s, wchar_t wc));
  896. # else
  897. _GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc));
  898. # endif
  899. _GL_CXXALIASWARN (wctomb);
  900. #endif
  901. #endif /* _@GUARD_PREFIX@_STDLIB_H */
  902. #endif /* _@GUARD_PREFIX@_STDLIB_H */
  903. #endif