stdlib.in.h 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431
  1. /* A GNU-like <stdlib.h>.
  2. Copyright (C) 1995, 2001-2004, 2006-2021 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 <https://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. /* OpenIndiana has a bug: <sys/time.h> must be included before
  37. <sys/loadavg.h>. */
  38. # include <sys/time.h>
  39. # include <sys/loadavg.h>
  40. #endif
  41. /* Native Windows platforms declare _mktemp() in <io.h>. */
  42. #if defined _WIN32 && !defined __CYGWIN__
  43. # include <io.h>
  44. #endif
  45. #if @GNULIB_RANDOM_R@
  46. /* OSF/1 5.1 declares 'struct random_data' in <random.h>, which is included
  47. from <stdlib.h> if _REENTRANT is defined. Include it whenever we need
  48. 'struct random_data'. */
  49. # if @HAVE_RANDOM_H@
  50. # include <random.h>
  51. # endif
  52. # if !@HAVE_STRUCT_RANDOM_DATA@ || @REPLACE_RANDOM_R@ || !@HAVE_RANDOM_R@
  53. # include <stdint.h>
  54. # endif
  55. # if !@HAVE_STRUCT_RANDOM_DATA@
  56. /* Define 'struct random_data'.
  57. But allow multiple gnulib generated <stdlib.h> replacements to coexist. */
  58. # if !GNULIB_defined_struct_random_data
  59. struct random_data
  60. {
  61. int32_t *fptr; /* Front pointer. */
  62. int32_t *rptr; /* Rear pointer. */
  63. int32_t *state; /* Array of state values. */
  64. int rand_type; /* Type of random number generator. */
  65. int rand_deg; /* Degree of random number generator. */
  66. int rand_sep; /* Distance between front and rear. */
  67. int32_t *end_ptr; /* Pointer behind state table. */
  68. };
  69. # define GNULIB_defined_struct_random_data 1
  70. # endif
  71. # endif
  72. #endif
  73. #if (@GNULIB_MKSTEMP@ || @GNULIB_MKSTEMPS@ || @GNULIB_MKOSTEMP@ || @GNULIB_MKOSTEMPS@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !(defined _WIN32 && ! defined __CYGWIN__)
  74. /* On Mac OS X 10.3, only <unistd.h> declares mkstemp. */
  75. /* On Mac OS X 10.5, only <unistd.h> declares mkstemps. */
  76. /* On Mac OS X 10.13, only <unistd.h> declares mkostemp and mkostemps. */
  77. /* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */
  78. /* But avoid namespace pollution on glibc systems and native Windows. */
  79. # include <unistd.h>
  80. #endif
  81. /* The __attribute__ feature is available in gcc versions 2.5 and later.
  82. The attribute __pure__ was added in gcc 2.96. */
  83. #ifndef _GL_ATTRIBUTE_PURE
  84. # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
  85. # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
  86. # else
  87. # define _GL_ATTRIBUTE_PURE /* empty */
  88. # endif
  89. #endif
  90. /* The definition of _Noreturn is copied here. */
  91. /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
  92. /* The definition of _GL_ARG_NONNULL is copied here. */
  93. /* The definition of _GL_WARN_ON_USE is copied here. */
  94. /* Some systems do not define EXIT_*, despite otherwise supporting C89. */
  95. #ifndef EXIT_SUCCESS
  96. # define EXIT_SUCCESS 0
  97. #endif
  98. /* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere
  99. with proper operation of xargs. */
  100. #ifndef EXIT_FAILURE
  101. # define EXIT_FAILURE 1
  102. #elif EXIT_FAILURE != 1
  103. # undef EXIT_FAILURE
  104. # define EXIT_FAILURE 1
  105. #endif
  106. #if @GNULIB__EXIT@
  107. /* Terminate the current process with the given return code, without running
  108. the 'atexit' handlers. */
  109. # if !@HAVE__EXIT@
  110. _GL_FUNCDECL_SYS (_Exit, _Noreturn void, (int status));
  111. # endif
  112. _GL_CXXALIAS_SYS (_Exit, void, (int status));
  113. _GL_CXXALIASWARN (_Exit);
  114. #elif defined GNULIB_POSIXCHECK
  115. # undef _Exit
  116. # if HAVE_RAW_DECL__EXIT
  117. _GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
  118. "use gnulib module _Exit for portability");
  119. # endif
  120. #endif
  121. /* Allocate memory with indefinite extent and specified alignment. */
  122. #if @GNULIB_ALIGNED_ALLOC@
  123. # if @REPLACE_ALIGNED_ALLOC@
  124. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  125. # undef aligned_alloc
  126. # define aligned_alloc rpl_aligned_alloc
  127. # endif
  128. _GL_FUNCDECL_RPL (aligned_alloc, void *, (size_t alignment, size_t size));
  129. _GL_CXXALIAS_RPL (aligned_alloc, void *, (size_t alignment, size_t size));
  130. # else
  131. # if @HAVE_ALIGNED_ALLOC@
  132. _GL_CXXALIAS_SYS (aligned_alloc, void *, (size_t alignment, size_t size));
  133. # endif
  134. # endif
  135. # if @HAVE_ALIGNED_ALLOC@
  136. _GL_CXXALIASWARN (aligned_alloc);
  137. # endif
  138. #elif defined GNULIB_POSIXCHECK
  139. # undef aligned_alloc
  140. # if HAVE_RAW_DECL_ALIGNED_ALLOC
  141. _GL_WARN_ON_USE (aligned_alloc, "aligned_alloc is not portable - "
  142. "use gnulib module aligned_alloc for portability");
  143. # endif
  144. #endif
  145. #if @GNULIB_ATOLL@
  146. /* Parse a signed decimal integer.
  147. Returns the value of the integer. Errors are not detected. */
  148. # if !@HAVE_ATOLL@
  149. _GL_FUNCDECL_SYS (atoll, long long, (const char *string)
  150. _GL_ATTRIBUTE_PURE
  151. _GL_ARG_NONNULL ((1)));
  152. # endif
  153. _GL_CXXALIAS_SYS (atoll, long long, (const char *string));
  154. _GL_CXXALIASWARN (atoll);
  155. #elif defined GNULIB_POSIXCHECK
  156. # undef atoll
  157. # if HAVE_RAW_DECL_ATOLL
  158. _GL_WARN_ON_USE (atoll, "atoll is unportable - "
  159. "use gnulib module atoll for portability");
  160. # endif
  161. #endif
  162. #if @GNULIB_CALLOC_POSIX@
  163. # if @REPLACE_CALLOC@
  164. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  165. # undef calloc
  166. # define calloc rpl_calloc
  167. # endif
  168. _GL_FUNCDECL_RPL (calloc, void *, (size_t nmemb, size_t size));
  169. _GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size));
  170. # else
  171. _GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size));
  172. # endif
  173. # if __GLIBC__ >= 2
  174. _GL_CXXALIASWARN (calloc);
  175. # endif
  176. #elif defined GNULIB_POSIXCHECK
  177. # undef calloc
  178. /* Assume calloc is always declared. */
  179. _GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - "
  180. "use gnulib module calloc-posix for portability");
  181. #endif
  182. #if @GNULIB_CANONICALIZE_FILE_NAME@
  183. # if @REPLACE_CANONICALIZE_FILE_NAME@
  184. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  185. # define canonicalize_file_name rpl_canonicalize_file_name
  186. # endif
  187. _GL_FUNCDECL_RPL (canonicalize_file_name, char *, (const char *name)
  188. _GL_ARG_NONNULL ((1)));
  189. _GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name));
  190. # else
  191. # if !@HAVE_CANONICALIZE_FILE_NAME@
  192. _GL_FUNCDECL_SYS (canonicalize_file_name, char *, (const char *name)
  193. _GL_ARG_NONNULL ((1)));
  194. # endif
  195. _GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name));
  196. # endif
  197. # ifndef GNULIB_defined_canonicalize_file_name
  198. # define GNULIB_defined_canonicalize_file_name \
  199. (!@HAVE_CANONICALIZE_FILE_NAME@ || @REPLACE_CANONICALIZE_FILE_NAME@)
  200. # endif
  201. _GL_CXXALIASWARN (canonicalize_file_name);
  202. #elif defined GNULIB_POSIXCHECK
  203. # undef canonicalize_file_name
  204. # if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
  205. _GL_WARN_ON_USE (canonicalize_file_name,
  206. "canonicalize_file_name is unportable - "
  207. "use gnulib module canonicalize-lgpl for portability");
  208. # endif
  209. #endif
  210. #if @GNULIB_MDA_ECVT@
  211. /* On native Windows, map 'ecvt' to '_ecvt', so that -loldnames is not
  212. required. In C++ with GNULIB_NAMESPACE, avoid differences between
  213. platforms by defining GNULIB_NAMESPACE::ecvt on all platforms that have
  214. it. */
  215. # if defined _WIN32 && !defined __CYGWIN__
  216. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  217. # undef ecvt
  218. # define ecvt _ecvt
  219. # endif
  220. _GL_CXXALIAS_MDA (ecvt, char *,
  221. (double number, int ndigits, int *decptp, int *signp));
  222. # else
  223. # if @HAVE_DECL_ECVT@
  224. _GL_CXXALIAS_SYS (ecvt, char *,
  225. (double number, int ndigits, int *decptp, int *signp));
  226. # endif
  227. # endif
  228. # if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_ECVT@
  229. _GL_CXXALIASWARN (ecvt);
  230. # endif
  231. #endif
  232. #if @GNULIB_MDA_FCVT@
  233. /* On native Windows, map 'fcvt' to '_fcvt', so that -loldnames is not
  234. required. In C++ with GNULIB_NAMESPACE, avoid differences between
  235. platforms by defining GNULIB_NAMESPACE::fcvt on all platforms that have
  236. it. */
  237. # if defined _WIN32 && !defined __CYGWIN__
  238. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  239. # undef fcvt
  240. # define fcvt _fcvt
  241. # endif
  242. _GL_CXXALIAS_MDA (fcvt, char *,
  243. (double number, int ndigits, int *decptp, int *signp));
  244. # else
  245. # if @HAVE_DECL_FCVT@
  246. _GL_CXXALIAS_SYS (fcvt, char *,
  247. (double number, int ndigits, int *decptp, int *signp));
  248. # endif
  249. # endif
  250. # if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_FCVT@
  251. _GL_CXXALIASWARN (fcvt);
  252. # endif
  253. #endif
  254. #if @GNULIB_FREE_POSIX@
  255. # if @REPLACE_FREE@
  256. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  257. # undef free
  258. # define free rpl_free
  259. # endif
  260. _GL_FUNCDECL_RPL (free, void, (void *ptr));
  261. _GL_CXXALIAS_RPL (free, void, (void *ptr));
  262. # else
  263. _GL_CXXALIAS_SYS (free, void, (void *ptr));
  264. # endif
  265. # if __GLIBC__ >= 2
  266. _GL_CXXALIASWARN (free);
  267. # endif
  268. #elif defined GNULIB_POSIXCHECK
  269. # undef free
  270. /* Assume free is always declared. */
  271. _GL_WARN_ON_USE (free, "free is not future POSIX compliant everywhere - "
  272. "use gnulib module free for portability");
  273. #endif
  274. #if @GNULIB_MDA_GCVT@
  275. /* On native Windows, map 'gcvt' to '_gcvt', so that -loldnames is not
  276. required. In C++ with GNULIB_NAMESPACE, avoid differences between
  277. platforms by defining GNULIB_NAMESPACE::gcvt on all platforms that have
  278. it. */
  279. # if defined _WIN32 && !defined __CYGWIN__
  280. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  281. # undef gcvt
  282. # define gcvt _gcvt
  283. # endif
  284. _GL_CXXALIAS_MDA (gcvt, char *, (double number, int ndigits, char *buf));
  285. # else
  286. # if @HAVE_DECL_GCVT@
  287. _GL_CXXALIAS_SYS (gcvt, char *, (double number, int ndigits, char *buf));
  288. # endif
  289. # endif
  290. # if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_GCVT@
  291. _GL_CXXALIASWARN (gcvt);
  292. # endif
  293. #endif
  294. #if @GNULIB_GETLOADAVG@
  295. /* Store max(NELEM,3) load average numbers in LOADAVG[].
  296. The three numbers are the load average of the last 1 minute, the last 5
  297. minutes, and the last 15 minutes, respectively.
  298. LOADAVG is an array of NELEM numbers. */
  299. # if !@HAVE_DECL_GETLOADAVG@
  300. _GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem)
  301. _GL_ARG_NONNULL ((1)));
  302. # endif
  303. _GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem));
  304. _GL_CXXALIASWARN (getloadavg);
  305. #elif defined GNULIB_POSIXCHECK
  306. # undef getloadavg
  307. # if HAVE_RAW_DECL_GETLOADAVG
  308. _GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - "
  309. "use gnulib module getloadavg for portability");
  310. # endif
  311. #endif
  312. #if @GNULIB_GETSUBOPT@
  313. /* Assuming *OPTIONP is a comma separated list of elements of the form
  314. "token" or "token=value", getsubopt parses the first of these elements.
  315. If the first element refers to a "token" that is member of the given
  316. NULL-terminated array of tokens:
  317. - It replaces the comma with a NUL byte, updates *OPTIONP to point past
  318. the first option and the comma, sets *VALUEP to the value of the
  319. element (or NULL if it doesn't contain an "=" sign),
  320. - It returns the index of the "token" in the given array of tokens.
  321. Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
  322. For more details see the POSIX specification.
  323. https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsubopt.html */
  324. # if !@HAVE_GETSUBOPT@
  325. _GL_FUNCDECL_SYS (getsubopt, int,
  326. (char **optionp, char *const *tokens, char **valuep)
  327. _GL_ARG_NONNULL ((1, 2, 3)));
  328. # endif
  329. _GL_CXXALIAS_SYS (getsubopt, int,
  330. (char **optionp, char *const *tokens, char **valuep));
  331. _GL_CXXALIASWARN (getsubopt);
  332. #elif defined GNULIB_POSIXCHECK
  333. # undef getsubopt
  334. # if HAVE_RAW_DECL_GETSUBOPT
  335. _GL_WARN_ON_USE (getsubopt, "getsubopt is unportable - "
  336. "use gnulib module getsubopt for portability");
  337. # endif
  338. #endif
  339. #if @GNULIB_GRANTPT@
  340. /* Change the ownership and access permission of the slave side of the
  341. pseudo-terminal whose master side is specified by FD. */
  342. # if !@HAVE_GRANTPT@
  343. _GL_FUNCDECL_SYS (grantpt, int, (int fd));
  344. # endif
  345. _GL_CXXALIAS_SYS (grantpt, int, (int fd));
  346. _GL_CXXALIASWARN (grantpt);
  347. #elif defined GNULIB_POSIXCHECK
  348. # undef grantpt
  349. # if HAVE_RAW_DECL_GRANTPT
  350. _GL_WARN_ON_USE (grantpt, "grantpt is not portable - "
  351. "use gnulib module grantpt for portability");
  352. # endif
  353. #endif
  354. /* If _GL_USE_STDLIB_ALLOC is nonzero, the including module does not
  355. rely on GNU or POSIX semantics for malloc and realloc (for example,
  356. by never specifying a zero size), so it does not need malloc or
  357. realloc to be redefined. */
  358. #if @GNULIB_MALLOC_POSIX@
  359. # if @REPLACE_MALLOC@
  360. # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
  361. || _GL_USE_STDLIB_ALLOC)
  362. # undef malloc
  363. # define malloc rpl_malloc
  364. # endif
  365. _GL_FUNCDECL_RPL (malloc, void *, (size_t size));
  366. _GL_CXXALIAS_RPL (malloc, void *, (size_t size));
  367. # else
  368. _GL_CXXALIAS_SYS (malloc, void *, (size_t size));
  369. # endif
  370. # if __GLIBC__ >= 2
  371. _GL_CXXALIASWARN (malloc);
  372. # endif
  373. #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
  374. # undef malloc
  375. /* Assume malloc is always declared. */
  376. _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - "
  377. "use gnulib module malloc-posix for portability");
  378. #endif
  379. /* Convert a multibyte character to a wide character. */
  380. #if @GNULIB_MBTOWC@
  381. # if @REPLACE_MBTOWC@
  382. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  383. # undef mbtowc
  384. # define mbtowc rpl_mbtowc
  385. # endif
  386. _GL_FUNCDECL_RPL (mbtowc, int,
  387. (wchar_t *restrict pwc, const char *restrict s, size_t n));
  388. _GL_CXXALIAS_RPL (mbtowc, int,
  389. (wchar_t *restrict pwc, const char *restrict s, size_t n));
  390. # else
  391. # if !@HAVE_MBTOWC@
  392. _GL_FUNCDECL_SYS (mbtowc, int,
  393. (wchar_t *restrict pwc, const char *restrict s, size_t n));
  394. # endif
  395. _GL_CXXALIAS_SYS (mbtowc, int,
  396. (wchar_t *restrict pwc, const char *restrict s, size_t n));
  397. # endif
  398. # if __GLIBC__ >= 2
  399. _GL_CXXALIASWARN (mbtowc);
  400. # endif
  401. #elif defined GNULIB_POSIXCHECK
  402. # undef mbtowc
  403. # if HAVE_RAW_DECL_MBTOWC
  404. _GL_WARN_ON_USE (mbtowc, "mbtowc is not portable - "
  405. "use gnulib module mbtowc for portability");
  406. # endif
  407. #endif
  408. #if @GNULIB_MKDTEMP@
  409. /* Create a unique temporary directory from TEMPLATE.
  410. The last six characters of TEMPLATE must be "XXXXXX";
  411. they are replaced with a string that makes the directory name unique.
  412. Returns TEMPLATE, or a null pointer if it cannot get a unique name.
  413. The directory is created mode 700. */
  414. # if !@HAVE_MKDTEMP@
  415. _GL_FUNCDECL_SYS (mkdtemp, char *, (char * /*template*/) _GL_ARG_NONNULL ((1)));
  416. # endif
  417. _GL_CXXALIAS_SYS (mkdtemp, char *, (char * /*template*/));
  418. _GL_CXXALIASWARN (mkdtemp);
  419. #elif defined GNULIB_POSIXCHECK
  420. # undef mkdtemp
  421. # if HAVE_RAW_DECL_MKDTEMP
  422. _GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - "
  423. "use gnulib module mkdtemp for portability");
  424. # endif
  425. #endif
  426. #if @GNULIB_MKOSTEMP@
  427. /* Create a unique temporary file from TEMPLATE.
  428. The last six characters of TEMPLATE must be "XXXXXX";
  429. they are replaced with a string that makes the file name unique.
  430. The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
  431. and O_TEXT, O_BINARY (defined in "binary-io.h").
  432. The file is then created, with the specified flags, ensuring it didn't exist
  433. before.
  434. The file is created read-write (mask at least 0600 & ~umask), but it may be
  435. world-readable and world-writable (mask 0666 & ~umask), depending on the
  436. implementation.
  437. Returns the open file descriptor if successful, otherwise -1 and errno
  438. set. */
  439. # if !@HAVE_MKOSTEMP@
  440. _GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)
  441. _GL_ARG_NONNULL ((1)));
  442. # endif
  443. _GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/));
  444. _GL_CXXALIASWARN (mkostemp);
  445. #elif defined GNULIB_POSIXCHECK
  446. # undef mkostemp
  447. # if HAVE_RAW_DECL_MKOSTEMP
  448. _GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - "
  449. "use gnulib module mkostemp for portability");
  450. # endif
  451. #endif
  452. #if @GNULIB_MKOSTEMPS@
  453. /* Create a unique temporary file from TEMPLATE.
  454. The last six characters of TEMPLATE before a suffix of length
  455. SUFFIXLEN must be "XXXXXX";
  456. they are replaced with a string that makes the file name unique.
  457. The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
  458. and O_TEXT, O_BINARY (defined in "binary-io.h").
  459. The file is then created, with the specified flags, ensuring it didn't exist
  460. before.
  461. The file is created read-write (mask at least 0600 & ~umask), but it may be
  462. world-readable and world-writable (mask 0666 & ~umask), depending on the
  463. implementation.
  464. Returns the open file descriptor if successful, otherwise -1 and errno
  465. set. */
  466. # if !@HAVE_MKOSTEMPS@
  467. _GL_FUNCDECL_SYS (mkostemps, int,
  468. (char * /*template*/, int /*suffixlen*/, int /*flags*/)
  469. _GL_ARG_NONNULL ((1)));
  470. # endif
  471. _GL_CXXALIAS_SYS (mkostemps, int,
  472. (char * /*template*/, int /*suffixlen*/, int /*flags*/));
  473. _GL_CXXALIASWARN (mkostemps);
  474. #elif defined GNULIB_POSIXCHECK
  475. # undef mkostemps
  476. # if HAVE_RAW_DECL_MKOSTEMPS
  477. _GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - "
  478. "use gnulib module mkostemps for portability");
  479. # endif
  480. #endif
  481. #if @GNULIB_MKSTEMP@
  482. /* Create a unique temporary file from TEMPLATE.
  483. The last six characters of TEMPLATE must be "XXXXXX";
  484. they are replaced with a string that makes the file name unique.
  485. The file is then created, ensuring it didn't exist before.
  486. The file is created read-write (mask at least 0600 & ~umask), but it may be
  487. world-readable and world-writable (mask 0666 & ~umask), depending on the
  488. implementation.
  489. Returns the open file descriptor if successful, otherwise -1 and errno
  490. set. */
  491. # if @REPLACE_MKSTEMP@
  492. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  493. # define mkstemp rpl_mkstemp
  494. # endif
  495. _GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
  496. _GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/));
  497. # else
  498. # if ! @HAVE_MKSTEMP@
  499. _GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
  500. # endif
  501. _GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/));
  502. # endif
  503. _GL_CXXALIASWARN (mkstemp);
  504. #elif defined GNULIB_POSIXCHECK
  505. # undef mkstemp
  506. # if HAVE_RAW_DECL_MKSTEMP
  507. _GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - "
  508. "use gnulib module mkstemp for portability");
  509. # endif
  510. #endif
  511. #if @GNULIB_MKSTEMPS@
  512. /* Create a unique temporary file from TEMPLATE.
  513. The last six characters of TEMPLATE prior to a suffix of length
  514. SUFFIXLEN must be "XXXXXX";
  515. they are replaced with a string that makes the file name unique.
  516. The file is then created, ensuring it didn't exist before.
  517. The file is created read-write (mask at least 0600 & ~umask), but it may be
  518. world-readable and world-writable (mask 0666 & ~umask), depending on the
  519. implementation.
  520. Returns the open file descriptor if successful, otherwise -1 and errno
  521. set. */
  522. # if !@HAVE_MKSTEMPS@
  523. _GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/)
  524. _GL_ARG_NONNULL ((1)));
  525. # endif
  526. _GL_CXXALIAS_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/));
  527. _GL_CXXALIASWARN (mkstemps);
  528. #elif defined GNULIB_POSIXCHECK
  529. # undef mkstemps
  530. # if HAVE_RAW_DECL_MKSTEMPS
  531. _GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - "
  532. "use gnulib module mkstemps for portability");
  533. # endif
  534. #endif
  535. #if @GNULIB_MDA_MKTEMP@
  536. /* On native Windows, map 'mktemp' to '_mktemp', so that -loldnames is not
  537. required. In C++ with GNULIB_NAMESPACE, avoid differences between
  538. platforms by defining GNULIB_NAMESPACE::mktemp always. */
  539. # if defined _WIN32 && !defined __CYGWIN__
  540. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  541. # undef mktemp
  542. # define mktemp _mktemp
  543. # endif
  544. _GL_CXXALIAS_MDA (mktemp, char *, (char * /*template*/));
  545. # else
  546. _GL_CXXALIAS_SYS (mktemp, char *, (char * /*template*/));
  547. # endif
  548. _GL_CXXALIASWARN (mktemp);
  549. #endif
  550. /* Allocate memory with indefinite extent and specified alignment. */
  551. #if @GNULIB_POSIX_MEMALIGN@
  552. # if @REPLACE_POSIX_MEMALIGN@
  553. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  554. # undef posix_memalign
  555. # define posix_memalign rpl_posix_memalign
  556. # endif
  557. _GL_FUNCDECL_RPL (posix_memalign, int,
  558. (void **memptr, size_t alignment, size_t size)
  559. _GL_ARG_NONNULL ((1)));
  560. _GL_CXXALIAS_RPL (posix_memalign, int,
  561. (void **memptr, size_t alignment, size_t size));
  562. # else
  563. # if @HAVE_POSIX_MEMALIGN@
  564. _GL_CXXALIAS_SYS (posix_memalign, int,
  565. (void **memptr, size_t alignment, size_t size));
  566. # endif
  567. # endif
  568. # if @HAVE_POSIX_MEMALIGN@
  569. _GL_CXXALIASWARN (posix_memalign);
  570. # endif
  571. #elif defined GNULIB_POSIXCHECK
  572. # undef posix_memalign
  573. # if HAVE_RAW_DECL_POSIX_MEMALIGN
  574. _GL_WARN_ON_USE (posix_memalign, "posix_memalign is not portable - "
  575. "use gnulib module posix_memalign for portability");
  576. # endif
  577. #endif
  578. #if @GNULIB_POSIX_OPENPT@
  579. /* Return an FD open to the master side of a pseudo-terminal. Flags should
  580. include O_RDWR, and may also include O_NOCTTY. */
  581. # if !@HAVE_POSIX_OPENPT@
  582. _GL_FUNCDECL_SYS (posix_openpt, int, (int flags));
  583. # endif
  584. _GL_CXXALIAS_SYS (posix_openpt, int, (int flags));
  585. _GL_CXXALIASWARN (posix_openpt);
  586. #elif defined GNULIB_POSIXCHECK
  587. # undef posix_openpt
  588. # if HAVE_RAW_DECL_POSIX_OPENPT
  589. _GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - "
  590. "use gnulib module posix_openpt for portability");
  591. # endif
  592. #endif
  593. #if @GNULIB_PTSNAME@
  594. /* Return the pathname of the pseudo-terminal slave associated with
  595. the master FD is open on, or NULL on errors. */
  596. # if @REPLACE_PTSNAME@
  597. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  598. # undef ptsname
  599. # define ptsname rpl_ptsname
  600. # endif
  601. _GL_FUNCDECL_RPL (ptsname, char *, (int fd));
  602. _GL_CXXALIAS_RPL (ptsname, char *, (int fd));
  603. # else
  604. # if !@HAVE_PTSNAME@
  605. _GL_FUNCDECL_SYS (ptsname, char *, (int fd));
  606. # endif
  607. _GL_CXXALIAS_SYS (ptsname, char *, (int fd));
  608. # endif
  609. _GL_CXXALIASWARN (ptsname);
  610. #elif defined GNULIB_POSIXCHECK
  611. # undef ptsname
  612. # if HAVE_RAW_DECL_PTSNAME
  613. _GL_WARN_ON_USE (ptsname, "ptsname is not portable - "
  614. "use gnulib module ptsname for portability");
  615. # endif
  616. #endif
  617. #if @GNULIB_PTSNAME_R@
  618. /* Set the pathname of the pseudo-terminal slave associated with
  619. the master FD is open on and return 0, or set errno and return
  620. non-zero on errors. */
  621. # if @REPLACE_PTSNAME_R@
  622. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  623. # undef ptsname_r
  624. # define ptsname_r rpl_ptsname_r
  625. # endif
  626. _GL_FUNCDECL_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
  627. _GL_CXXALIAS_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
  628. # else
  629. # if !@HAVE_PTSNAME_R@
  630. _GL_FUNCDECL_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
  631. # endif
  632. _GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
  633. # endif
  634. # ifndef GNULIB_defined_ptsname_r
  635. # define GNULIB_defined_ptsname_r (!@HAVE_PTSNAME_R@ || @REPLACE_PTSNAME_R@)
  636. # endif
  637. _GL_CXXALIASWARN (ptsname_r);
  638. #elif defined GNULIB_POSIXCHECK
  639. # undef ptsname_r
  640. # if HAVE_RAW_DECL_PTSNAME_R
  641. _GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - "
  642. "use gnulib module ptsname_r for portability");
  643. # endif
  644. #endif
  645. #if @GNULIB_PUTENV@
  646. # if @REPLACE_PUTENV@
  647. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  648. # undef putenv
  649. # define putenv rpl_putenv
  650. # endif
  651. _GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1)));
  652. _GL_CXXALIAS_RPL (putenv, int, (char *string));
  653. # elif defined _WIN32 && !defined __CYGWIN__
  654. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  655. # undef putenv
  656. # define putenv _putenv
  657. # endif
  658. _GL_CXXALIAS_MDA (putenv, int, (char *string));
  659. # else
  660. _GL_CXXALIAS_SYS (putenv, int, (char *string));
  661. # endif
  662. _GL_CXXALIASWARN (putenv);
  663. #elif @GNULIB_MDA_PUTENV@
  664. /* On native Windows, map 'putenv' to '_putenv', so that -loldnames is not
  665. required. In C++ with GNULIB_NAMESPACE, avoid differences between
  666. platforms by defining GNULIB_NAMESPACE::putenv always. */
  667. # if defined _WIN32 && !defined __CYGWIN__
  668. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  669. # undef putenv
  670. # define putenv _putenv
  671. # endif
  672. /* Need to cast, because on mingw, the parameter is either
  673. 'const char *string' or 'char *string'. */
  674. _GL_CXXALIAS_MDA_CAST (putenv, int, (char *string));
  675. # else
  676. _GL_CXXALIAS_SYS (putenv, int, (char *string));
  677. # endif
  678. _GL_CXXALIASWARN (putenv);
  679. #endif
  680. #if @GNULIB_QSORT_R@
  681. /* Sort an array of NMEMB elements, starting at address BASE, each element
  682. occupying SIZE bytes, in ascending order according to the comparison
  683. function COMPARE. */
  684. # if @REPLACE_QSORT_R@
  685. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  686. # undef qsort_r
  687. # define qsort_r rpl_qsort_r
  688. # endif
  689. _GL_FUNCDECL_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
  690. int (*compare) (void const *, void const *,
  691. void *),
  692. void *arg) _GL_ARG_NONNULL ((1, 4)));
  693. _GL_CXXALIAS_RPL (qsort_r, void, (void *base, size_t nmemb, size_t size,
  694. int (*compare) (void const *, void const *,
  695. void *),
  696. void *arg));
  697. # else
  698. # if !@HAVE_QSORT_R@
  699. _GL_FUNCDECL_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
  700. int (*compare) (void const *, void const *,
  701. void *),
  702. void *arg) _GL_ARG_NONNULL ((1, 4)));
  703. # endif
  704. _GL_CXXALIAS_SYS (qsort_r, void, (void *base, size_t nmemb, size_t size,
  705. int (*compare) (void const *, void const *,
  706. void *),
  707. void *arg));
  708. # endif
  709. _GL_CXXALIASWARN (qsort_r);
  710. #elif defined GNULIB_POSIXCHECK
  711. # undef qsort_r
  712. # if HAVE_RAW_DECL_QSORT_R
  713. _GL_WARN_ON_USE (qsort_r, "qsort_r is not portable - "
  714. "use gnulib module qsort_r for portability");
  715. # endif
  716. #endif
  717. #if @GNULIB_RANDOM_R@
  718. # if !@HAVE_RANDOM_R@
  719. # ifndef RAND_MAX
  720. # define RAND_MAX 2147483647
  721. # endif
  722. # endif
  723. #endif
  724. #if @GNULIB_RANDOM@
  725. # if @REPLACE_RANDOM@
  726. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  727. # undef random
  728. # define random rpl_random
  729. # endif
  730. _GL_FUNCDECL_RPL (random, long, (void));
  731. _GL_CXXALIAS_RPL (random, long, (void));
  732. # else
  733. # if !@HAVE_RANDOM@
  734. _GL_FUNCDECL_SYS (random, long, (void));
  735. # endif
  736. /* Need to cast, because on Haiku, the return type is
  737. int. */
  738. _GL_CXXALIAS_SYS_CAST (random, long, (void));
  739. # endif
  740. _GL_CXXALIASWARN (random);
  741. #elif defined GNULIB_POSIXCHECK
  742. # undef random
  743. # if HAVE_RAW_DECL_RANDOM
  744. _GL_WARN_ON_USE (random, "random is unportable - "
  745. "use gnulib module random for portability");
  746. # endif
  747. #endif
  748. #if @GNULIB_RANDOM@
  749. # if @REPLACE_RANDOM@
  750. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  751. # undef srandom
  752. # define srandom rpl_srandom
  753. # endif
  754. _GL_FUNCDECL_RPL (srandom, void, (unsigned int seed));
  755. _GL_CXXALIAS_RPL (srandom, void, (unsigned int seed));
  756. # else
  757. # if !@HAVE_RANDOM@
  758. _GL_FUNCDECL_SYS (srandom, void, (unsigned int seed));
  759. # endif
  760. /* Need to cast, because on FreeBSD, the first parameter is
  761. unsigned long seed. */
  762. _GL_CXXALIAS_SYS_CAST (srandom, void, (unsigned int seed));
  763. # endif
  764. _GL_CXXALIASWARN (srandom);
  765. #elif defined GNULIB_POSIXCHECK
  766. # undef srandom
  767. # if HAVE_RAW_DECL_SRANDOM
  768. _GL_WARN_ON_USE (srandom, "srandom is unportable - "
  769. "use gnulib module random for portability");
  770. # endif
  771. #endif
  772. #if @GNULIB_RANDOM@
  773. # if @REPLACE_INITSTATE@
  774. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  775. # undef initstate
  776. # define initstate rpl_initstate
  777. # endif
  778. _GL_FUNCDECL_RPL (initstate, char *,
  779. (unsigned int seed, char *buf, size_t buf_size)
  780. _GL_ARG_NONNULL ((2)));
  781. _GL_CXXALIAS_RPL (initstate, char *,
  782. (unsigned int seed, char *buf, size_t buf_size));
  783. # else
  784. # if !@HAVE_INITSTATE@ || !@HAVE_DECL_INITSTATE@
  785. _GL_FUNCDECL_SYS (initstate, char *,
  786. (unsigned int seed, char *buf, size_t buf_size)
  787. _GL_ARG_NONNULL ((2)));
  788. # endif
  789. /* Need to cast, because on FreeBSD, the first parameter is
  790. unsigned long seed. */
  791. _GL_CXXALIAS_SYS_CAST (initstate, char *,
  792. (unsigned int seed, char *buf, size_t buf_size));
  793. # endif
  794. _GL_CXXALIASWARN (initstate);
  795. #elif defined GNULIB_POSIXCHECK
  796. # undef initstate
  797. # if HAVE_RAW_DECL_INITSTATE
  798. _GL_WARN_ON_USE (initstate, "initstate is unportable - "
  799. "use gnulib module random for portability");
  800. # endif
  801. #endif
  802. #if @GNULIB_RANDOM@
  803. # if @REPLACE_SETSTATE@
  804. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  805. # undef setstate
  806. # define setstate rpl_setstate
  807. # endif
  808. _GL_FUNCDECL_RPL (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
  809. _GL_CXXALIAS_RPL (setstate, char *, (char *arg_state));
  810. # else
  811. # if !@HAVE_SETSTATE@ || !@HAVE_DECL_SETSTATE@
  812. _GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
  813. # endif
  814. /* Need to cast, because on Mac OS X 10.13, HP-UX, Solaris the first parameter
  815. is const char *arg_state. */
  816. _GL_CXXALIAS_SYS_CAST (setstate, char *, (char *arg_state));
  817. # endif
  818. _GL_CXXALIASWARN (setstate);
  819. #elif defined GNULIB_POSIXCHECK
  820. # undef setstate
  821. # if HAVE_RAW_DECL_SETSTATE
  822. _GL_WARN_ON_USE (setstate, "setstate is unportable - "
  823. "use gnulib module random for portability");
  824. # endif
  825. #endif
  826. #if @GNULIB_RANDOM_R@
  827. # if @REPLACE_RANDOM_R@
  828. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  829. # undef random_r
  830. # define random_r rpl_random_r
  831. # endif
  832. _GL_FUNCDECL_RPL (random_r, int, (struct random_data *buf, int32_t *result)
  833. _GL_ARG_NONNULL ((1, 2)));
  834. _GL_CXXALIAS_RPL (random_r, int, (struct random_data *buf, int32_t *result));
  835. # else
  836. # if !@HAVE_RANDOM_R@
  837. _GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result)
  838. _GL_ARG_NONNULL ((1, 2)));
  839. # endif
  840. _GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result));
  841. # endif
  842. _GL_CXXALIASWARN (random_r);
  843. #elif defined GNULIB_POSIXCHECK
  844. # undef random_r
  845. # if HAVE_RAW_DECL_RANDOM_R
  846. _GL_WARN_ON_USE (random_r, "random_r is unportable - "
  847. "use gnulib module random_r for portability");
  848. # endif
  849. #endif
  850. #if @GNULIB_RANDOM_R@
  851. # if @REPLACE_RANDOM_R@
  852. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  853. # undef srandom_r
  854. # define srandom_r rpl_srandom_r
  855. # endif
  856. _GL_FUNCDECL_RPL (srandom_r, int,
  857. (unsigned int seed, struct random_data *rand_state)
  858. _GL_ARG_NONNULL ((2)));
  859. _GL_CXXALIAS_RPL (srandom_r, int,
  860. (unsigned int seed, struct random_data *rand_state));
  861. # else
  862. # if !@HAVE_RANDOM_R@
  863. _GL_FUNCDECL_SYS (srandom_r, int,
  864. (unsigned int seed, struct random_data *rand_state)
  865. _GL_ARG_NONNULL ((2)));
  866. # endif
  867. _GL_CXXALIAS_SYS (srandom_r, int,
  868. (unsigned int seed, struct random_data *rand_state));
  869. # endif
  870. _GL_CXXALIASWARN (srandom_r);
  871. #elif defined GNULIB_POSIXCHECK
  872. # undef srandom_r
  873. # if HAVE_RAW_DECL_SRANDOM_R
  874. _GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - "
  875. "use gnulib module random_r for portability");
  876. # endif
  877. #endif
  878. #if @GNULIB_RANDOM_R@
  879. # if @REPLACE_RANDOM_R@
  880. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  881. # undef initstate_r
  882. # define initstate_r rpl_initstate_r
  883. # endif
  884. _GL_FUNCDECL_RPL (initstate_r, int,
  885. (unsigned int seed, char *buf, size_t buf_size,
  886. struct random_data *rand_state)
  887. _GL_ARG_NONNULL ((2, 4)));
  888. _GL_CXXALIAS_RPL (initstate_r, int,
  889. (unsigned int seed, char *buf, size_t buf_size,
  890. struct random_data *rand_state));
  891. # else
  892. # if !@HAVE_RANDOM_R@
  893. _GL_FUNCDECL_SYS (initstate_r, int,
  894. (unsigned int seed, char *buf, size_t buf_size,
  895. struct random_data *rand_state)
  896. _GL_ARG_NONNULL ((2, 4)));
  897. # endif
  898. /* Need to cast, because on Haiku, the third parameter is
  899. unsigned long buf_size. */
  900. _GL_CXXALIAS_SYS_CAST (initstate_r, int,
  901. (unsigned int seed, char *buf, size_t buf_size,
  902. struct random_data *rand_state));
  903. # endif
  904. _GL_CXXALIASWARN (initstate_r);
  905. #elif defined GNULIB_POSIXCHECK
  906. # undef initstate_r
  907. # if HAVE_RAW_DECL_INITSTATE_R
  908. _GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - "
  909. "use gnulib module random_r for portability");
  910. # endif
  911. #endif
  912. #if @GNULIB_RANDOM_R@
  913. # if @REPLACE_RANDOM_R@
  914. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  915. # undef setstate_r
  916. # define setstate_r rpl_setstate_r
  917. # endif
  918. _GL_FUNCDECL_RPL (setstate_r, int,
  919. (char *arg_state, struct random_data *rand_state)
  920. _GL_ARG_NONNULL ((1, 2)));
  921. _GL_CXXALIAS_RPL (setstate_r, int,
  922. (char *arg_state, struct random_data *rand_state));
  923. # else
  924. # if !@HAVE_RANDOM_R@
  925. _GL_FUNCDECL_SYS (setstate_r, int,
  926. (char *arg_state, struct random_data *rand_state)
  927. _GL_ARG_NONNULL ((1, 2)));
  928. # endif
  929. /* Need to cast, because on Haiku, the first parameter is
  930. void *arg_state. */
  931. _GL_CXXALIAS_SYS_CAST (setstate_r, int,
  932. (char *arg_state, struct random_data *rand_state));
  933. # endif
  934. _GL_CXXALIASWARN (setstate_r);
  935. #elif defined GNULIB_POSIXCHECK
  936. # undef setstate_r
  937. # if HAVE_RAW_DECL_SETSTATE_R
  938. _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
  939. "use gnulib module random_r for portability");
  940. # endif
  941. #endif
  942. #if @GNULIB_REALLOC_POSIX@
  943. # if @REPLACE_REALLOC@
  944. # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
  945. || _GL_USE_STDLIB_ALLOC)
  946. # undef realloc
  947. # define realloc rpl_realloc
  948. # endif
  949. _GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size));
  950. _GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size));
  951. # else
  952. _GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size));
  953. # endif
  954. # if __GLIBC__ >= 2
  955. _GL_CXXALIASWARN (realloc);
  956. # endif
  957. #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
  958. # undef realloc
  959. /* Assume realloc is always declared. */
  960. _GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - "
  961. "use gnulib module realloc-posix for portability");
  962. #endif
  963. #if @GNULIB_REALLOCARRAY@
  964. # if ! @HAVE_REALLOCARRAY@
  965. _GL_FUNCDECL_SYS (reallocarray, void *,
  966. (void *ptr, size_t nmemb, size_t size));
  967. # endif
  968. _GL_CXXALIAS_SYS (reallocarray, void *,
  969. (void *ptr, size_t nmemb, size_t size));
  970. _GL_CXXALIASWARN (reallocarray);
  971. #elif defined GNULIB_POSIXCHECK
  972. # undef reallocarray
  973. # if HAVE_RAW_DECL_REALLOCARRAY
  974. _GL_WARN_ON_USE (reallocarray, "reallocarray is not portable - "
  975. "use gnulib module reallocarray for portability");
  976. # endif
  977. #endif
  978. #if @GNULIB_REALPATH@
  979. # if @REPLACE_REALPATH@
  980. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  981. # define realpath rpl_realpath
  982. # endif
  983. _GL_FUNCDECL_RPL (realpath, char *,
  984. (const char *restrict name, char *restrict resolved)
  985. _GL_ARG_NONNULL ((1)));
  986. _GL_CXXALIAS_RPL (realpath, char *,
  987. (const char *restrict name, char *restrict resolved));
  988. # else
  989. # if !@HAVE_REALPATH@
  990. _GL_FUNCDECL_SYS (realpath, char *,
  991. (const char *restrict name, char *restrict resolved)
  992. _GL_ARG_NONNULL ((1)));
  993. # endif
  994. _GL_CXXALIAS_SYS (realpath, char *,
  995. (const char *restrict name, char *restrict resolved));
  996. # endif
  997. _GL_CXXALIASWARN (realpath);
  998. #elif defined GNULIB_POSIXCHECK
  999. # undef realpath
  1000. # if HAVE_RAW_DECL_REALPATH
  1001. _GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module "
  1002. "canonicalize or canonicalize-lgpl for portability");
  1003. # endif
  1004. #endif
  1005. #if @GNULIB_RPMATCH@
  1006. /* Test a user response to a question.
  1007. Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
  1008. # if !@HAVE_RPMATCH@
  1009. _GL_FUNCDECL_SYS (rpmatch, int, (const char *response) _GL_ARG_NONNULL ((1)));
  1010. # endif
  1011. _GL_CXXALIAS_SYS (rpmatch, int, (const char *response));
  1012. _GL_CXXALIASWARN (rpmatch);
  1013. #elif defined GNULIB_POSIXCHECK
  1014. # undef rpmatch
  1015. # if HAVE_RAW_DECL_RPMATCH
  1016. _GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - "
  1017. "use gnulib module rpmatch for portability");
  1018. # endif
  1019. #endif
  1020. #if @GNULIB_SECURE_GETENV@
  1021. /* Look up NAME in the environment, returning 0 in insecure situations. */
  1022. # if !@HAVE_SECURE_GETENV@
  1023. _GL_FUNCDECL_SYS (secure_getenv, char *,
  1024. (char const *name) _GL_ARG_NONNULL ((1)));
  1025. # endif
  1026. _GL_CXXALIAS_SYS (secure_getenv, char *, (char const *name));
  1027. _GL_CXXALIASWARN (secure_getenv);
  1028. #elif defined GNULIB_POSIXCHECK
  1029. # undef secure_getenv
  1030. # if HAVE_RAW_DECL_SECURE_GETENV
  1031. _GL_WARN_ON_USE (secure_getenv, "secure_getenv is unportable - "
  1032. "use gnulib module secure_getenv for portability");
  1033. # endif
  1034. #endif
  1035. #if @GNULIB_SETENV@
  1036. /* Set NAME to VALUE in the environment.
  1037. If REPLACE is nonzero, overwrite an existing value. */
  1038. # if @REPLACE_SETENV@
  1039. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1040. # undef setenv
  1041. # define setenv rpl_setenv
  1042. # endif
  1043. _GL_FUNCDECL_RPL (setenv, int,
  1044. (const char *name, const char *value, int replace)
  1045. _GL_ARG_NONNULL ((1)));
  1046. _GL_CXXALIAS_RPL (setenv, int,
  1047. (const char *name, const char *value, int replace));
  1048. # else
  1049. # if !@HAVE_DECL_SETENV@
  1050. _GL_FUNCDECL_SYS (setenv, int,
  1051. (const char *name, const char *value, int replace)
  1052. _GL_ARG_NONNULL ((1)));
  1053. # endif
  1054. _GL_CXXALIAS_SYS (setenv, int,
  1055. (const char *name, const char *value, int replace));
  1056. # endif
  1057. # if !(@REPLACE_SETENV@ && !@HAVE_DECL_SETENV@)
  1058. _GL_CXXALIASWARN (setenv);
  1059. # endif
  1060. #elif defined GNULIB_POSIXCHECK
  1061. # undef setenv
  1062. # if HAVE_RAW_DECL_SETENV
  1063. _GL_WARN_ON_USE (setenv, "setenv is unportable - "
  1064. "use gnulib module setenv for portability");
  1065. # endif
  1066. #endif
  1067. #if @GNULIB_STRTOD@
  1068. /* Parse a double from STRING, updating ENDP if appropriate. */
  1069. # if @REPLACE_STRTOD@
  1070. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1071. # define strtod rpl_strtod
  1072. # endif
  1073. # define GNULIB_defined_strtod_function 1
  1074. _GL_FUNCDECL_RPL (strtod, double,
  1075. (const char *restrict str, char **restrict endp)
  1076. _GL_ARG_NONNULL ((1)));
  1077. _GL_CXXALIAS_RPL (strtod, double,
  1078. (const char *restrict str, char **restrict endp));
  1079. # else
  1080. # if !@HAVE_STRTOD@
  1081. _GL_FUNCDECL_SYS (strtod, double,
  1082. (const char *restrict str, char **restrict endp)
  1083. _GL_ARG_NONNULL ((1)));
  1084. # endif
  1085. _GL_CXXALIAS_SYS (strtod, double,
  1086. (const char *restrict str, char **restrict endp));
  1087. # endif
  1088. # if __GLIBC__ >= 2
  1089. _GL_CXXALIASWARN (strtod);
  1090. # endif
  1091. #elif defined GNULIB_POSIXCHECK
  1092. # undef strtod
  1093. # if HAVE_RAW_DECL_STRTOD
  1094. _GL_WARN_ON_USE (strtod, "strtod is unportable - "
  1095. "use gnulib module strtod for portability");
  1096. # endif
  1097. #endif
  1098. #if @GNULIB_STRTOLD@
  1099. /* Parse a 'long double' from STRING, updating ENDP if appropriate. */
  1100. # if @REPLACE_STRTOLD@
  1101. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1102. # define strtold rpl_strtold
  1103. # endif
  1104. # define GNULIB_defined_strtold_function 1
  1105. _GL_FUNCDECL_RPL (strtold, long double,
  1106. (const char *restrict str, char **restrict endp)
  1107. _GL_ARG_NONNULL ((1)));
  1108. _GL_CXXALIAS_RPL (strtold, long double,
  1109. (const char *restrict str, char **restrict endp));
  1110. # else
  1111. # if !@HAVE_STRTOLD@
  1112. _GL_FUNCDECL_SYS (strtold, long double,
  1113. (const char *restrict str, char **restrict endp)
  1114. _GL_ARG_NONNULL ((1)));
  1115. # endif
  1116. _GL_CXXALIAS_SYS (strtold, long double,
  1117. (const char *restrict str, char **restrict endp));
  1118. # endif
  1119. _GL_CXXALIASWARN (strtold);
  1120. #elif defined GNULIB_POSIXCHECK
  1121. # undef strtold
  1122. # if HAVE_RAW_DECL_STRTOLD
  1123. _GL_WARN_ON_USE (strtold, "strtold is unportable - "
  1124. "use gnulib module strtold for portability");
  1125. # endif
  1126. #endif
  1127. #if @GNULIB_STRTOL@
  1128. /* Parse a signed integer whose textual representation starts at STRING.
  1129. The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
  1130. it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
  1131. "0x").
  1132. If ENDPTR is not NULL, the address of the first byte after the integer is
  1133. stored in *ENDPTR.
  1134. Upon overflow, the return value is LONG_MAX or LONG_MIN, and errno is set
  1135. to ERANGE. */
  1136. # if @REPLACE_STRTOL@
  1137. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1138. # define strtol rpl_strtol
  1139. # endif
  1140. # define GNULIB_defined_strtol_function 1
  1141. _GL_FUNCDECL_RPL (strtol, long,
  1142. (const char *restrict string, char **restrict endptr,
  1143. int base)
  1144. _GL_ARG_NONNULL ((1)));
  1145. _GL_CXXALIAS_RPL (strtol, long,
  1146. (const char *restrict string, char **restrict endptr,
  1147. int base));
  1148. # else
  1149. # if !@HAVE_STRTOL@
  1150. _GL_FUNCDECL_SYS (strtol, long,
  1151. (const char *restrict string, char **restrict endptr,
  1152. int base)
  1153. _GL_ARG_NONNULL ((1)));
  1154. # endif
  1155. _GL_CXXALIAS_SYS (strtol, long,
  1156. (const char *restrict string, char **restrict endptr,
  1157. int base));
  1158. # endif
  1159. _GL_CXXALIASWARN (strtol);
  1160. #elif defined GNULIB_POSIXCHECK
  1161. # undef strtol
  1162. # if HAVE_RAW_DECL_STRTOL
  1163. _GL_WARN_ON_USE (strtol, "strtol is unportable - "
  1164. "use gnulib module strtol for portability");
  1165. # endif
  1166. #endif
  1167. #if @GNULIB_STRTOLL@
  1168. /* Parse a signed integer whose textual representation starts at STRING.
  1169. The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
  1170. it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
  1171. "0x").
  1172. If ENDPTR is not NULL, the address of the first byte after the integer is
  1173. stored in *ENDPTR.
  1174. Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
  1175. to ERANGE. */
  1176. # if @REPLACE_STRTOLL@
  1177. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1178. # define strtoll rpl_strtoll
  1179. # endif
  1180. # define GNULIB_defined_strtoll_function 1
  1181. _GL_FUNCDECL_RPL (strtoll, long long,
  1182. (const char *restrict string, char **restrict endptr,
  1183. int base)
  1184. _GL_ARG_NONNULL ((1)));
  1185. _GL_CXXALIAS_RPL (strtoll, long long,
  1186. (const char *restrict string, char **restrict endptr,
  1187. int base));
  1188. # else
  1189. # if !@HAVE_STRTOLL@
  1190. _GL_FUNCDECL_SYS (strtoll, long long,
  1191. (const char *restrict string, char **restrict endptr,
  1192. int base)
  1193. _GL_ARG_NONNULL ((1)));
  1194. # endif
  1195. _GL_CXXALIAS_SYS (strtoll, long long,
  1196. (const char *restrict string, char **restrict endptr,
  1197. int base));
  1198. # endif
  1199. _GL_CXXALIASWARN (strtoll);
  1200. #elif defined GNULIB_POSIXCHECK
  1201. # undef strtoll
  1202. # if HAVE_RAW_DECL_STRTOLL
  1203. _GL_WARN_ON_USE (strtoll, "strtoll is unportable - "
  1204. "use gnulib module strtoll for portability");
  1205. # endif
  1206. #endif
  1207. #if @GNULIB_STRTOUL@
  1208. /* Parse an unsigned integer whose textual representation starts at STRING.
  1209. The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
  1210. it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
  1211. "0x").
  1212. If ENDPTR is not NULL, the address of the first byte after the integer is
  1213. stored in *ENDPTR.
  1214. Upon overflow, the return value is ULONG_MAX, and errno is set to ERANGE. */
  1215. # if @REPLACE_STRTOUL@
  1216. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1217. # define strtoul rpl_strtoul
  1218. # endif
  1219. # define GNULIB_defined_strtoul_function 1
  1220. _GL_FUNCDECL_RPL (strtoul, unsigned long,
  1221. (const char *restrict string, char **restrict endptr,
  1222. int base)
  1223. _GL_ARG_NONNULL ((1)));
  1224. _GL_CXXALIAS_RPL (strtoul, unsigned long,
  1225. (const char *restrict string, char **restrict endptr,
  1226. int base));
  1227. # else
  1228. # if !@HAVE_STRTOUL@
  1229. _GL_FUNCDECL_SYS (strtoul, unsigned long,
  1230. (const char *restrict string, char **restrict endptr,
  1231. int base)
  1232. _GL_ARG_NONNULL ((1)));
  1233. # endif
  1234. _GL_CXXALIAS_SYS (strtoul, unsigned long,
  1235. (const char *restrict string, char **restrict endptr,
  1236. int base));
  1237. # endif
  1238. _GL_CXXALIASWARN (strtoul);
  1239. #elif defined GNULIB_POSIXCHECK
  1240. # undef strtoul
  1241. # if HAVE_RAW_DECL_STRTOUL
  1242. _GL_WARN_ON_USE (strtoul, "strtoul is unportable - "
  1243. "use gnulib module strtoul for portability");
  1244. # endif
  1245. #endif
  1246. #if @GNULIB_STRTOULL@
  1247. /* Parse an unsigned integer whose textual representation starts at STRING.
  1248. The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
  1249. it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
  1250. "0x").
  1251. If ENDPTR is not NULL, the address of the first byte after the integer is
  1252. stored in *ENDPTR.
  1253. Upon overflow, the return value is ULLONG_MAX, and errno is set to
  1254. ERANGE. */
  1255. # if @REPLACE_STRTOULL@
  1256. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1257. # define strtoull rpl_strtoull
  1258. # endif
  1259. # define GNULIB_defined_strtoull_function 1
  1260. _GL_FUNCDECL_RPL (strtoull, unsigned long long,
  1261. (const char *restrict string, char **restrict endptr,
  1262. int base)
  1263. _GL_ARG_NONNULL ((1)));
  1264. _GL_CXXALIAS_RPL (strtoull, unsigned long long,
  1265. (const char *restrict string, char **restrict endptr,
  1266. int base));
  1267. # else
  1268. # if !@HAVE_STRTOULL@
  1269. _GL_FUNCDECL_SYS (strtoull, unsigned long long,
  1270. (const char *restrict string, char **restrict endptr,
  1271. int base)
  1272. _GL_ARG_NONNULL ((1)));
  1273. # endif
  1274. _GL_CXXALIAS_SYS (strtoull, unsigned long long,
  1275. (const char *restrict string, char **restrict endptr,
  1276. int base));
  1277. # endif
  1278. _GL_CXXALIASWARN (strtoull);
  1279. #elif defined GNULIB_POSIXCHECK
  1280. # undef strtoull
  1281. # if HAVE_RAW_DECL_STRTOULL
  1282. _GL_WARN_ON_USE (strtoull, "strtoull is unportable - "
  1283. "use gnulib module strtoull for portability");
  1284. # endif
  1285. #endif
  1286. #if @GNULIB_UNLOCKPT@
  1287. /* Unlock the slave side of the pseudo-terminal whose master side is specified
  1288. by FD, so that it can be opened. */
  1289. # if !@HAVE_UNLOCKPT@
  1290. _GL_FUNCDECL_SYS (unlockpt, int, (int fd));
  1291. # endif
  1292. _GL_CXXALIAS_SYS (unlockpt, int, (int fd));
  1293. _GL_CXXALIASWARN (unlockpt);
  1294. #elif defined GNULIB_POSIXCHECK
  1295. # undef unlockpt
  1296. # if HAVE_RAW_DECL_UNLOCKPT
  1297. _GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - "
  1298. "use gnulib module unlockpt for portability");
  1299. # endif
  1300. #endif
  1301. #if @GNULIB_UNSETENV@
  1302. /* Remove the variable NAME from the environment. */
  1303. # if @REPLACE_UNSETENV@
  1304. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1305. # undef unsetenv
  1306. # define unsetenv rpl_unsetenv
  1307. # endif
  1308. _GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
  1309. _GL_CXXALIAS_RPL (unsetenv, int, (const char *name));
  1310. # else
  1311. # if !@HAVE_DECL_UNSETENV@
  1312. _GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
  1313. # endif
  1314. _GL_CXXALIAS_SYS (unsetenv, int, (const char *name));
  1315. # endif
  1316. # if !(@REPLACE_UNSETENV@ && !@HAVE_DECL_UNSETENV@)
  1317. _GL_CXXALIASWARN (unsetenv);
  1318. # endif
  1319. #elif defined GNULIB_POSIXCHECK
  1320. # undef unsetenv
  1321. # if HAVE_RAW_DECL_UNSETENV
  1322. _GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - "
  1323. "use gnulib module unsetenv for portability");
  1324. # endif
  1325. #endif
  1326. /* Convert a wide character to a multibyte character. */
  1327. #if @GNULIB_WCTOMB@
  1328. # if @REPLACE_WCTOMB@
  1329. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1330. # undef wctomb
  1331. # define wctomb rpl_wctomb
  1332. # endif
  1333. _GL_FUNCDECL_RPL (wctomb, int, (char *s, wchar_t wc));
  1334. _GL_CXXALIAS_RPL (wctomb, int, (char *s, wchar_t wc));
  1335. # else
  1336. _GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc));
  1337. # endif
  1338. # if __GLIBC__ >= 2
  1339. _GL_CXXALIASWARN (wctomb);
  1340. # endif
  1341. #endif
  1342. #endif /* _@GUARD_PREFIX@_STDLIB_H */
  1343. #endif /* _@GUARD_PREFIX@_STDLIB_H */
  1344. #endif