Commit | Line | Data |
---|---|---|
f240aacb LC |
1 | /* A GNU-like <stdlib.h>. |
2 | ||
61cd9dc9 | 3 | Copyright (C) 1995, 2001-2004, 2006-2010 Free Software Foundation, Inc. |
f240aacb LC |
4 | |
5 | This program is free software: you can redistribute it and/or modify | |
6 | it under the terms of the GNU Lesser General Public License as published by | |
7 | the Free Software Foundation; either version 3 of the License, or | |
8 | (at your option) any later version. | |
9 | ||
10 | This program is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU Lesser General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public License | |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
17 | ||
18 | #if __GNUC__ >= 3 | |
19 | @PRAGMA_SYSTEM_HEADER@ | |
20 | #endif | |
21 | ||
22 | #if defined __need_malloc_and_calloc | |
23 | /* Special invocation convention inside glibc header files. */ | |
24 | ||
25 | #@INCLUDE_NEXT@ @NEXT_STDLIB_H@ | |
26 | ||
27 | #else | |
28 | /* Normal invocation convention. */ | |
29 | ||
30 | #ifndef _GL_STDLIB_H | |
31 | ||
32 | /* The include_next requires a split double-inclusion guard. */ | |
33 | #@INCLUDE_NEXT@ @NEXT_STDLIB_H@ | |
34 | ||
35 | #ifndef _GL_STDLIB_H | |
36 | #define _GL_STDLIB_H | |
37 | ||
8912421c LC |
38 | /* NetBSD 5.0 mis-defines NULL. */ |
39 | #include <stddef.h> | |
f240aacb LC |
40 | |
41 | /* Solaris declares getloadavg() in <sys/loadavg.h>. */ | |
61cd9dc9 | 42 | #if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@ |
f240aacb LC |
43 | # include <sys/loadavg.h> |
44 | #endif | |
45 | ||
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 always. */ | |
48 | #if @HAVE_RANDOM_H@ | |
49 | # include <random.h> | |
50 | #endif | |
51 | ||
61cd9dc9 LC |
52 | #if !@HAVE_STRUCT_RANDOM_DATA@ || (@GNULIB_RANDOM_R@ && !@HAVE_RANDOM_R@) \ |
53 | || defined GNULIB_POSIXCHECK | |
f240aacb LC |
54 | # include <stdint.h> |
55 | #endif | |
56 | ||
57 | #if !@HAVE_STRUCT_RANDOM_DATA@ | |
58 | struct random_data | |
59 | { | |
1cd4fffc LC |
60 | int32_t *fptr; /* Front pointer. */ |
61 | int32_t *rptr; /* Rear pointer. */ | |
62 | int32_t *state; /* Array of state values. */ | |
63 | int rand_type; /* Type of random number generator. */ | |
64 | int rand_deg; /* Degree of random number generator. */ | |
65 | int rand_sep; /* Distance between front and rear. */ | |
66 | int32_t *end_ptr; /* Pointer behind state table. */ | |
f240aacb LC |
67 | }; |
68 | #endif | |
69 | ||
61cd9dc9 LC |
70 | #if (@GNULIB_MKSTEMP@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ |
71 | /* On MacOS X 10.3, only <unistd.h> declares mkstemp. */ | |
72 | /* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */ | |
73 | /* But avoid namespace pollution on glibc systems. */ | |
74 | # include <unistd.h> | |
75 | #endif | |
f240aacb | 76 | |
f4c79b3c LC |
77 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ |
78 | ||
1cd4fffc LC |
79 | /* The definition of _GL_ARG_NONNULL is copied here. */ |
80 | ||
61cd9dc9 LC |
81 | /* The definition of _GL_WARN_ON_USE is copied here. */ |
82 | ||
f240aacb LC |
83 | |
84 | /* Some systems do not define EXIT_*, despite otherwise supporting C89. */ | |
85 | #ifndef EXIT_SUCCESS | |
86 | # define EXIT_SUCCESS 0 | |
87 | #endif | |
88 | /* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere | |
89 | with proper operation of xargs. */ | |
90 | #ifndef EXIT_FAILURE | |
91 | # define EXIT_FAILURE 1 | |
92 | #elif EXIT_FAILURE != 1 | |
93 | # undef EXIT_FAILURE | |
94 | # define EXIT_FAILURE 1 | |
95 | #endif | |
96 | ||
97 | ||
8912421c | 98 | #if @GNULIB_ATOLL@ |
8912421c LC |
99 | /* Parse a signed decimal integer. |
100 | Returns the value of the integer. Errors are not detected. */ | |
f4c79b3c LC |
101 | # if !@HAVE_ATOLL@ |
102 | _GL_FUNCDECL_SYS (atoll, long long, (const char *string) _GL_ARG_NONNULL ((1))); | |
f240aacb | 103 | # endif |
f4c79b3c LC |
104 | _GL_CXXALIAS_SYS (atoll, long long, (const char *string)); |
105 | _GL_CXXALIASWARN (atoll); | |
f240aacb | 106 | #elif defined GNULIB_POSIXCHECK |
8912421c | 107 | # undef atoll |
61cd9dc9 LC |
108 | # if HAVE_RAW_DECL_ATOLL |
109 | _GL_WARN_ON_USE (atoll, "atoll is unportable - " | |
110 | "use gnulib module atoll for portability"); | |
111 | # endif | |
f240aacb LC |
112 | #endif |
113 | ||
f240aacb LC |
114 | #if @GNULIB_CALLOC_POSIX@ |
115 | # if !@HAVE_CALLOC_POSIX@ | |
f4c79b3c LC |
116 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
117 | # undef calloc | |
118 | # define calloc rpl_calloc | |
119 | # endif | |
120 | _GL_FUNCDECL_RPL (calloc, void *, (size_t nmemb, size_t size)); | |
121 | _GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size)); | |
122 | # else | |
123 | _GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size)); | |
f240aacb | 124 | # endif |
f4c79b3c | 125 | _GL_CXXALIASWARN (calloc); |
f240aacb LC |
126 | #elif defined GNULIB_POSIXCHECK |
127 | # undef calloc | |
61cd9dc9 LC |
128 | /* Assume calloc is always declared. */ |
129 | _GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - " | |
130 | "use gnulib module calloc-posix for portability"); | |
f240aacb LC |
131 | #endif |
132 | ||
8912421c LC |
133 | #if @GNULIB_CANONICALIZE_FILE_NAME@ |
134 | # if @REPLACE_CANONICALIZE_FILE_NAME@ | |
f4c79b3c LC |
135 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
136 | # define canonicalize_file_name rpl_canonicalize_file_name | |
137 | # endif | |
138 | _GL_FUNCDECL_RPL (canonicalize_file_name, char *, (const char *name) | |
139 | _GL_ARG_NONNULL ((1))); | |
140 | _GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name)); | |
141 | # else | |
142 | # if !@HAVE_CANONICALIZE_FILE_NAME@ | |
143 | _GL_FUNCDECL_SYS (canonicalize_file_name, char *, (const char *name) | |
144 | _GL_ARG_NONNULL ((1))); | |
145 | # endif | |
146 | _GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name)); | |
f240aacb | 147 | # endif |
f4c79b3c | 148 | _GL_CXXALIASWARN (canonicalize_file_name); |
f240aacb | 149 | #elif defined GNULIB_POSIXCHECK |
8912421c | 150 | # undef canonicalize_file_name |
61cd9dc9 LC |
151 | # if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME |
152 | _GL_WARN_ON_USE (canonicalize_file_name, "canonicalize_file_name is unportable - " | |
153 | "use gnulib module canonicalize-lgpl for portability"); | |
154 | # endif | |
f240aacb LC |
155 | #endif |
156 | ||
f240aacb | 157 | #if @GNULIB_GETLOADAVG@ |
f240aacb LC |
158 | /* Store max(NELEM,3) load average numbers in LOADAVG[]. |
159 | The three numbers are the load average of the last 1 minute, the last 5 | |
160 | minutes, and the last 15 minutes, respectively. | |
161 | LOADAVG is an array of NELEM numbers. */ | |
f4c79b3c LC |
162 | # if !@HAVE_DECL_GETLOADAVG@ |
163 | _GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem) | |
164 | _GL_ARG_NONNULL ((1))); | |
f240aacb | 165 | # endif |
f4c79b3c LC |
166 | _GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem)); |
167 | _GL_CXXALIASWARN (getloadavg); | |
f240aacb LC |
168 | #elif defined GNULIB_POSIXCHECK |
169 | # undef getloadavg | |
61cd9dc9 LC |
170 | # if HAVE_RAW_DECL_GETLOADAVG |
171 | _GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - " | |
172 | "use gnulib module getloadavg for portability"); | |
173 | # endif | |
f240aacb LC |
174 | #endif |
175 | ||
f240aacb LC |
176 | #if @GNULIB_GETSUBOPT@ |
177 | /* Assuming *OPTIONP is a comma separated list of elements of the form | |
178 | "token" or "token=value", getsubopt parses the first of these elements. | |
179 | If the first element refers to a "token" that is member of the given | |
180 | NULL-terminated array of tokens: | |
181 | - It replaces the comma with a NUL byte, updates *OPTIONP to point past | |
182 | the first option and the comma, sets *VALUEP to the value of the | |
183 | element (or NULL if it doesn't contain an "=" sign), | |
184 | - It returns the index of the "token" in the given array of tokens. | |
185 | Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined. | |
186 | For more details see the POSIX:2001 specification. | |
187 | http://www.opengroup.org/susv3xsh/getsubopt.html */ | |
188 | # if !@HAVE_GETSUBOPT@ | |
f4c79b3c LC |
189 | _GL_FUNCDECL_SYS (getsubopt, int, |
190 | (char **optionp, char *const *tokens, char **valuep) | |
191 | _GL_ARG_NONNULL ((1, 2, 3))); | |
f240aacb | 192 | # endif |
f4c79b3c LC |
193 | _GL_CXXALIAS_SYS (getsubopt, int, |
194 | (char **optionp, char *const *tokens, char **valuep)); | |
195 | _GL_CXXALIASWARN (getsubopt); | |
f240aacb LC |
196 | #elif defined GNULIB_POSIXCHECK |
197 | # undef getsubopt | |
61cd9dc9 LC |
198 | # if HAVE_RAW_DECL_GETSUBOPT |
199 | _GL_WARN_ON_USE (getsubopt, "getsubopt is unportable - " | |
200 | "use gnulib module getsubopt for portability"); | |
201 | # endif | |
f240aacb LC |
202 | #endif |
203 | ||
8912421c LC |
204 | #if @GNULIB_MALLOC_POSIX@ |
205 | # if !@HAVE_MALLOC_POSIX@ | |
f4c79b3c LC |
206 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
207 | # undef malloc | |
208 | # define malloc rpl_malloc | |
209 | # endif | |
210 | _GL_FUNCDECL_RPL (malloc, void *, (size_t size)); | |
211 | _GL_CXXALIAS_RPL (malloc, void *, (size_t size)); | |
212 | # else | |
213 | _GL_CXXALIAS_SYS (malloc, void *, (size_t size)); | |
8912421c | 214 | # endif |
f4c79b3c | 215 | _GL_CXXALIASWARN (malloc); |
8912421c LC |
216 | #elif defined GNULIB_POSIXCHECK |
217 | # undef malloc | |
61cd9dc9 LC |
218 | /* Assume malloc is always declared. */ |
219 | _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - " | |
220 | "use gnulib module malloc-posix for portability"); | |
8912421c | 221 | #endif |
f240aacb LC |
222 | |
223 | #if @GNULIB_MKDTEMP@ | |
f240aacb LC |
224 | /* Create a unique temporary directory from TEMPLATE. |
225 | The last six characters of TEMPLATE must be "XXXXXX"; | |
226 | they are replaced with a string that makes the directory name unique. | |
227 | Returns TEMPLATE, or a null pointer if it cannot get a unique name. | |
228 | The directory is created mode 700. */ | |
f4c79b3c LC |
229 | # if !@HAVE_MKDTEMP@ |
230 | _GL_FUNCDECL_SYS (mkdtemp, char *, (char * /*template*/) _GL_ARG_NONNULL ((1))); | |
f240aacb | 231 | # endif |
f4c79b3c LC |
232 | _GL_CXXALIAS_SYS (mkdtemp, char *, (char * /*template*/)); |
233 | _GL_CXXALIASWARN (mkdtemp); | |
f240aacb LC |
234 | #elif defined GNULIB_POSIXCHECK |
235 | # undef mkdtemp | |
61cd9dc9 LC |
236 | # if HAVE_RAW_DECL_MKDTEMP |
237 | _GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - " | |
238 | "use gnulib module mkdtemp for portability"); | |
239 | # endif | |
f240aacb LC |
240 | #endif |
241 | ||
8912421c | 242 | #if @GNULIB_MKOSTEMP@ |
8912421c LC |
243 | /* Create a unique temporary file from TEMPLATE. |
244 | The last six characters of TEMPLATE must be "XXXXXX"; | |
245 | they are replaced with a string that makes the file name unique. | |
246 | The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>) | |
247 | and O_TEXT, O_BINARY (defined in "binary-io.h"). | |
248 | The file is then created, with the specified flags, ensuring it didn't exist | |
249 | before. | |
250 | The file is created read-write (mask at least 0600 & ~umask), but it may be | |
251 | world-readable and world-writable (mask 0666 & ~umask), depending on the | |
252 | implementation. | |
253 | Returns the open file descriptor if successful, otherwise -1 and errno | |
254 | set. */ | |
f4c79b3c LC |
255 | # if !@HAVE_MKOSTEMP@ |
256 | _GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/) | |
257 | _GL_ARG_NONNULL ((1))); | |
8912421c | 258 | # endif |
f4c79b3c LC |
259 | _GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)); |
260 | _GL_CXXALIASWARN (mkostemp); | |
8912421c LC |
261 | #elif defined GNULIB_POSIXCHECK |
262 | # undef mkostemp | |
61cd9dc9 LC |
263 | # if HAVE_RAW_DECL_MKOSTEMP |
264 | _GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - " | |
265 | "use gnulib module mkostemp for portability"); | |
266 | # endif | |
8912421c | 267 | #endif |
f240aacb | 268 | |
f29ded4b | 269 | #if @GNULIB_MKOSTEMPS@ |
f29ded4b LC |
270 | /* Create a unique temporary file from TEMPLATE. |
271 | The last six characters of TEMPLATE before a suffix of length | |
272 | SUFFIXLEN must be "XXXXXX"; | |
273 | they are replaced with a string that makes the file name unique. | |
274 | The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>) | |
275 | and O_TEXT, O_BINARY (defined in "binary-io.h"). | |
276 | The file is then created, with the specified flags, ensuring it didn't exist | |
277 | before. | |
278 | The file is created read-write (mask at least 0600 & ~umask), but it may be | |
279 | world-readable and world-writable (mask 0666 & ~umask), depending on the | |
280 | implementation. | |
281 | Returns the open file descriptor if successful, otherwise -1 and errno | |
282 | set. */ | |
f4c79b3c LC |
283 | # if !@HAVE_MKOSTEMPS@ |
284 | _GL_FUNCDECL_SYS (mkostemps, int, | |
285 | (char * /*template*/, int /*suffixlen*/, int /*flags*/) | |
286 | _GL_ARG_NONNULL ((1))); | |
f29ded4b | 287 | # endif |
f4c79b3c LC |
288 | _GL_CXXALIAS_SYS (mkostemps, int, |
289 | (char * /*template*/, int /*suffixlen*/, int /*flags*/)); | |
290 | _GL_CXXALIASWARN (mkostemps); | |
f29ded4b LC |
291 | #elif defined GNULIB_POSIXCHECK |
292 | # undef mkostemps | |
61cd9dc9 LC |
293 | # if HAVE_RAW_DECL_MKOSTEMPS |
294 | _GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - " | |
295 | "use gnulib module mkostemps for portability"); | |
296 | # endif | |
f29ded4b LC |
297 | #endif |
298 | ||
f240aacb | 299 | #if @GNULIB_MKSTEMP@ |
f240aacb LC |
300 | /* Create a unique temporary file from TEMPLATE. |
301 | The last six characters of TEMPLATE must be "XXXXXX"; | |
302 | they are replaced with a string that makes the file name unique. | |
303 | The file is then created, ensuring it didn't exist before. | |
304 | The file is created read-write (mask at least 0600 & ~umask), but it may be | |
305 | world-readable and world-writable (mask 0666 & ~umask), depending on the | |
306 | implementation. | |
307 | Returns the open file descriptor if successful, otherwise -1 and errno | |
308 | set. */ | |
f4c79b3c LC |
309 | # if @REPLACE_MKSTEMP@ |
310 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
311 | # define mkstemp rpl_mkstemp | |
312 | # endif | |
313 | _GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1))); | |
314 | _GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/)); | |
315 | # else | |
316 | _GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/)); | |
f240aacb | 317 | # endif |
f4c79b3c | 318 | _GL_CXXALIASWARN (mkstemp); |
f240aacb LC |
319 | #elif defined GNULIB_POSIXCHECK |
320 | # undef mkstemp | |
61cd9dc9 LC |
321 | # if HAVE_RAW_DECL_MKSTEMP |
322 | _GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - " | |
323 | "use gnulib module mkstemp for portability"); | |
324 | # endif | |
f240aacb LC |
325 | #endif |
326 | ||
f29ded4b | 327 | #if @GNULIB_MKSTEMPS@ |
f29ded4b LC |
328 | /* Create a unique temporary file from TEMPLATE. |
329 | The last six characters of TEMPLATE prior to a suffix of length | |
330 | SUFFIXLEN must be "XXXXXX"; | |
331 | they are replaced with a string that makes the file name unique. | |
332 | The file is then created, ensuring it didn't exist before. | |
333 | The file is created read-write (mask at least 0600 & ~umask), but it may be | |
334 | world-readable and world-writable (mask 0666 & ~umask), depending on the | |
335 | implementation. | |
336 | Returns the open file descriptor if successful, otherwise -1 and errno | |
337 | set. */ | |
f4c79b3c LC |
338 | # if !@HAVE_MKSTEMPS@ |
339 | _GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/) | |
340 | _GL_ARG_NONNULL ((1))); | |
f29ded4b | 341 | # endif |
f4c79b3c LC |
342 | _GL_CXXALIAS_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/)); |
343 | _GL_CXXALIASWARN (mkstemps); | |
f29ded4b LC |
344 | #elif defined GNULIB_POSIXCHECK |
345 | # undef mkstemps | |
61cd9dc9 LC |
346 | # if HAVE_RAW_DECL_MKSTEMPS |
347 | _GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - " | |
348 | "use gnulib module mkstemps for portability"); | |
349 | # endif | |
f29ded4b LC |
350 | #endif |
351 | ||
f240aacb LC |
352 | #if @GNULIB_PUTENV@ |
353 | # if @REPLACE_PUTENV@ | |
f4c79b3c LC |
354 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
355 | # undef putenv | |
356 | # define putenv rpl_putenv | |
357 | # endif | |
358 | _GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1))); | |
359 | _GL_CXXALIAS_RPL (putenv, int, (char *string)); | |
360 | # else | |
361 | _GL_CXXALIAS_SYS (putenv, int, (char *string)); | |
f240aacb | 362 | # endif |
f4c79b3c | 363 | _GL_CXXALIASWARN (putenv); |
f240aacb LC |
364 | #endif |
365 | ||
f4c79b3c | 366 | |
f240aacb LC |
367 | #if @GNULIB_RANDOM_R@ |
368 | # if !@HAVE_RANDOM_R@ | |
f240aacb LC |
369 | # ifndef RAND_MAX |
370 | # define RAND_MAX 2147483647 | |
371 | # endif | |
f4c79b3c LC |
372 | # endif |
373 | #endif | |
f240aacb | 374 | |
f4c79b3c LC |
375 | #if @GNULIB_RANDOM_R@ |
376 | # if !@HAVE_RANDOM_R@ | |
377 | _GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result) | |
378 | _GL_ARG_NONNULL ((1, 2))); | |
f240aacb | 379 | # endif |
f4c79b3c LC |
380 | _GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result)); |
381 | _GL_CXXALIASWARN (random_r); | |
f240aacb LC |
382 | #elif defined GNULIB_POSIXCHECK |
383 | # undef random_r | |
61cd9dc9 LC |
384 | # if HAVE_RAW_DECL_RANDOM_R |
385 | _GL_WARN_ON_USE (random_r, "random_r is unportable - " | |
386 | "use gnulib module random_r for portability"); | |
387 | # endif | |
f4c79b3c LC |
388 | #endif |
389 | ||
390 | #if @GNULIB_RANDOM_R@ | |
391 | # if !@HAVE_RANDOM_R@ | |
392 | _GL_FUNCDECL_SYS (srandom_r, int, | |
393 | (unsigned int seed, struct random_data *rand_state) | |
394 | _GL_ARG_NONNULL ((2))); | |
61cd9dc9 | 395 | # endif |
f4c79b3c LC |
396 | _GL_CXXALIAS_SYS (srandom_r, int, |
397 | (unsigned int seed, struct random_data *rand_state)); | |
398 | _GL_CXXALIASWARN (srandom_r); | |
399 | #elif defined GNULIB_POSIXCHECK | |
f240aacb | 400 | # undef srandom_r |
61cd9dc9 LC |
401 | # if HAVE_RAW_DECL_SRANDOM_R |
402 | _GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - " | |
403 | "use gnulib module random_r for portability"); | |
404 | # endif | |
f4c79b3c LC |
405 | #endif |
406 | ||
407 | #if @GNULIB_RANDOM_R@ | |
408 | # if !@HAVE_RANDOM_R@ | |
409 | _GL_FUNCDECL_SYS (initstate_r, int, | |
410 | (unsigned int seed, char *buf, size_t buf_size, | |
411 | struct random_data *rand_state) | |
412 | _GL_ARG_NONNULL ((2, 4))); | |
413 | # endif | |
414 | _GL_CXXALIAS_SYS (initstate_r, int, | |
415 | (unsigned int seed, char *buf, size_t buf_size, | |
416 | struct random_data *rand_state)); | |
417 | _GL_CXXALIASWARN (initstate_r); | |
418 | #elif defined GNULIB_POSIXCHECK | |
419 | # undef initstate_r | |
420 | # if HAVE_RAW_DECL_INITSTATE_R | |
421 | _GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - " | |
422 | "use gnulib module random_r for portability"); | |
423 | # endif | |
424 | #endif | |
425 | ||
426 | #if @GNULIB_RANDOM_R@ | |
427 | # if !@HAVE_RANDOM_R@ | |
428 | _GL_FUNCDECL_SYS (setstate_r, int, | |
429 | (char *arg_state, struct random_data *rand_state) | |
430 | _GL_ARG_NONNULL ((1, 2))); | |
431 | # endif | |
432 | _GL_CXXALIAS_SYS (setstate_r, int, | |
433 | (char *arg_state, struct random_data *rand_state)); | |
434 | _GL_CXXALIASWARN (setstate_r); | |
435 | #elif defined GNULIB_POSIXCHECK | |
f240aacb | 436 | # undef setstate_r |
61cd9dc9 LC |
437 | # if HAVE_RAW_DECL_SETSTATE_R |
438 | _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - " | |
439 | "use gnulib module random_r for portability"); | |
440 | # endif | |
f240aacb LC |
441 | #endif |
442 | ||
f4c79b3c | 443 | |
8912421c LC |
444 | #if @GNULIB_REALLOC_POSIX@ |
445 | # if !@HAVE_REALLOC_POSIX@ | |
f4c79b3c LC |
446 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
447 | # undef realloc | |
448 | # define realloc rpl_realloc | |
449 | # endif | |
450 | _GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size)); | |
451 | _GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size)); | |
452 | # else | |
453 | _GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size)); | |
8912421c | 454 | # endif |
f4c79b3c | 455 | _GL_CXXALIASWARN (realloc); |
8912421c LC |
456 | #elif defined GNULIB_POSIXCHECK |
457 | # undef realloc | |
61cd9dc9 LC |
458 | /* Assume realloc is always declared. */ |
459 | _GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - " | |
460 | "use gnulib module realloc-posix for portability"); | |
8912421c LC |
461 | #endif |
462 | ||
463 | #if @GNULIB_REALPATH@ | |
464 | # if @REPLACE_REALPATH@ | |
f4c79b3c LC |
465 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
466 | # define realpath rpl_realpath | |
467 | # endif | |
468 | _GL_FUNCDECL_RPL (realpath, char *, (const char *name, char *resolved) | |
469 | _GL_ARG_NONNULL ((1))); | |
470 | _GL_CXXALIAS_RPL (realpath, char *, (const char *name, char *resolved)); | |
471 | # else | |
472 | # if !@HAVE_REALPATH@ | |
473 | _GL_FUNCDECL_SYS (realpath, char *, (const char *name, char *resolved) | |
474 | _GL_ARG_NONNULL ((1))); | |
475 | # endif | |
476 | _GL_CXXALIAS_SYS (realpath, char *, (const char *name, char *resolved)); | |
8912421c | 477 | # endif |
f4c79b3c | 478 | _GL_CXXALIASWARN (realpath); |
8912421c LC |
479 | #elif defined GNULIB_POSIXCHECK |
480 | # undef realpath | |
61cd9dc9 LC |
481 | # if HAVE_RAW_DECL_REALPATH |
482 | _GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module " | |
483 | "canonicalize or canonicalize-lgpl for portability"); | |
484 | # endif | |
8912421c | 485 | #endif |
f240aacb LC |
486 | |
487 | #if @GNULIB_RPMATCH@ | |
f240aacb LC |
488 | /* Test a user response to a question. |
489 | Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */ | |
f4c79b3c LC |
490 | # if !@HAVE_RPMATCH@ |
491 | _GL_FUNCDECL_SYS (rpmatch, int, (const char *response) _GL_ARG_NONNULL ((1))); | |
f240aacb | 492 | # endif |
f4c79b3c LC |
493 | _GL_CXXALIAS_SYS (rpmatch, int, (const char *response)); |
494 | _GL_CXXALIASWARN (rpmatch); | |
f240aacb LC |
495 | #elif defined GNULIB_POSIXCHECK |
496 | # undef rpmatch | |
61cd9dc9 LC |
497 | # if HAVE_RAW_DECL_RPMATCH |
498 | _GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - " | |
499 | "use gnulib module rpmatch for portability"); | |
500 | # endif | |
f240aacb LC |
501 | #endif |
502 | ||
f240aacb | 503 | #if @GNULIB_SETENV@ |
f240aacb LC |
504 | /* Set NAME to VALUE in the environment. |
505 | If REPLACE is nonzero, overwrite an existing value. */ | |
f4c79b3c LC |
506 | # if @REPLACE_SETENV@ |
507 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
508 | # undef setenv | |
509 | # define setenv rpl_setenv | |
510 | # endif | |
511 | _GL_FUNCDECL_RPL (setenv, int, | |
512 | (const char *name, const char *value, int replace) | |
513 | _GL_ARG_NONNULL ((1))); | |
514 | _GL_CXXALIAS_RPL (setenv, int, | |
515 | (const char *name, const char *value, int replace)); | |
516 | # else | |
517 | # if !@HAVE_SETENV@ | |
518 | _GL_FUNCDECL_SYS (setenv, int, | |
519 | (const char *name, const char *value, int replace) | |
520 | _GL_ARG_NONNULL ((1))); | |
521 | # endif | |
522 | _GL_CXXALIAS_SYS (setenv, int, | |
523 | (const char *name, const char *value, int replace)); | |
f240aacb | 524 | # endif |
f4c79b3c | 525 | _GL_CXXALIASWARN (setenv); |
4f02b98d LC |
526 | #elif defined GNULIB_POSIXCHECK |
527 | # undef setenv | |
61cd9dc9 LC |
528 | # if HAVE_RAW_DECL_SETENV |
529 | _GL_WARN_ON_USE (setenv, "setenv is unportable - " | |
530 | "use gnulib module setenv for portability"); | |
531 | # endif | |
f240aacb LC |
532 | #endif |
533 | ||
f240aacb | 534 | #if @GNULIB_STRTOD@ |
f240aacb | 535 | /* Parse a double from STRING, updating ENDP if appropriate. */ |
f4c79b3c LC |
536 | # if @REPLACE_STRTOD@ |
537 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
538 | # define strtod rpl_strtod | |
539 | # endif | |
540 | _GL_FUNCDECL_RPL (strtod, double, (const char *str, char **endp) | |
541 | _GL_ARG_NONNULL ((1))); | |
542 | _GL_CXXALIAS_RPL (strtod, double, (const char *str, char **endp)); | |
543 | # else | |
544 | # if !@HAVE_STRTOD@ | |
545 | _GL_FUNCDECL_SYS (strtod, double, (const char *str, char **endp) | |
546 | _GL_ARG_NONNULL ((1))); | |
547 | # endif | |
548 | _GL_CXXALIAS_SYS (strtod, double, (const char *str, char **endp)); | |
f240aacb | 549 | # endif |
f4c79b3c | 550 | _GL_CXXALIASWARN (strtod); |
f240aacb LC |
551 | #elif defined GNULIB_POSIXCHECK |
552 | # undef strtod | |
61cd9dc9 LC |
553 | # if HAVE_RAW_DECL_STRTOD |
554 | _GL_WARN_ON_USE (strtod, "strtod is unportable - " | |
555 | "use gnulib module strtod for portability"); | |
556 | # endif | |
f240aacb LC |
557 | #endif |
558 | ||
f240aacb | 559 | #if @GNULIB_STRTOLL@ |
f240aacb LC |
560 | /* Parse a signed integer whose textual representation starts at STRING. |
561 | The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0, | |
562 | it may be decimal or octal (with prefix "0") or hexadecimal (with prefix | |
563 | "0x"). | |
564 | If ENDPTR is not NULL, the address of the first byte after the integer is | |
565 | stored in *ENDPTR. | |
566 | Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set | |
567 | to ERANGE. */ | |
f4c79b3c LC |
568 | # if !@HAVE_STRTOLL@ |
569 | _GL_FUNCDECL_SYS (strtoll, long long, | |
570 | (const char *string, char **endptr, int base) | |
571 | _GL_ARG_NONNULL ((1))); | |
f240aacb | 572 | # endif |
f4c79b3c LC |
573 | _GL_CXXALIAS_SYS (strtoll, long long, |
574 | (const char *string, char **endptr, int base)); | |
575 | _GL_CXXALIASWARN (strtoll); | |
f240aacb LC |
576 | #elif defined GNULIB_POSIXCHECK |
577 | # undef strtoll | |
61cd9dc9 LC |
578 | # if HAVE_RAW_DECL_STRTOLL |
579 | _GL_WARN_ON_USE (strtoll, "strtoll is unportable - " | |
580 | "use gnulib module strtoll for portability"); | |
581 | # endif | |
f240aacb LC |
582 | #endif |
583 | ||
f240aacb | 584 | #if @GNULIB_STRTOULL@ |
f240aacb LC |
585 | /* Parse an unsigned integer whose textual representation starts at STRING. |
586 | The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0, | |
587 | it may be decimal or octal (with prefix "0") or hexadecimal (with prefix | |
588 | "0x"). | |
589 | If ENDPTR is not NULL, the address of the first byte after the integer is | |
590 | stored in *ENDPTR. | |
591 | Upon overflow, the return value is ULLONG_MAX, and errno is set to | |
592 | ERANGE. */ | |
f4c79b3c LC |
593 | # if !@HAVE_STRTOULL@ |
594 | _GL_FUNCDECL_SYS (strtoull, unsigned long long, | |
595 | (const char *string, char **endptr, int base) | |
596 | _GL_ARG_NONNULL ((1))); | |
f240aacb | 597 | # endif |
f4c79b3c LC |
598 | _GL_CXXALIAS_SYS (strtoull, unsigned long long, |
599 | (const char *string, char **endptr, int base)); | |
600 | _GL_CXXALIASWARN (strtoull); | |
f240aacb LC |
601 | #elif defined GNULIB_POSIXCHECK |
602 | # undef strtoull | |
61cd9dc9 LC |
603 | # if HAVE_RAW_DECL_STRTOULL |
604 | _GL_WARN_ON_USE (strtoull, "strtoull is unportable - " | |
605 | "use gnulib module strtoull for portability"); | |
606 | # endif | |
f240aacb LC |
607 | #endif |
608 | ||
8912421c | 609 | #if @GNULIB_UNSETENV@ |
8912421c | 610 | /* Remove the variable NAME from the environment. */ |
f4c79b3c LC |
611 | # if @REPLACE_UNSETENV@ |
612 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
613 | # undef unsetenv | |
614 | # define unsetenv rpl_unsetenv | |
615 | # endif | |
616 | _GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); | |
617 | _GL_CXXALIAS_RPL (unsetenv, int, (const char *name)); | |
618 | # else | |
619 | # if !@HAVE_UNSETENV@ | |
620 | _GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); | |
621 | # endif | |
622 | _GL_CXXALIAS_SYS (unsetenv, int, (const char *name)); | |
8912421c | 623 | # endif |
f4c79b3c | 624 | _GL_CXXALIASWARN (unsetenv); |
4f02b98d LC |
625 | #elif defined GNULIB_POSIXCHECK |
626 | # undef unsetenv | |
61cd9dc9 LC |
627 | # if HAVE_RAW_DECL_UNSETENV |
628 | _GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - " | |
629 | "use gnulib module unsetenv for portability"); | |
630 | # endif | |
8912421c | 631 | #endif |
f240aacb | 632 | |
f240aacb LC |
633 | |
634 | #endif /* _GL_STDLIB_H */ | |
635 | #endif /* _GL_STDLIB_H */ | |
636 | #endif |