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 | ||
a927b6c1 | 70 | #if (@GNULIB_MKSTEMP@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) |
61cd9dc9 LC |
71 | /* On MacOS X 10.3, only <unistd.h> declares mkstemp. */ |
72 | /* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */ | |
a927b6c1 | 73 | /* But avoid namespace pollution on glibc systems and native Windows. */ |
61cd9dc9 LC |
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 | ||
a927b6c1 LC |
204 | #if @GNULIB_GRANTPT@ |
205 | /* Change the ownership and access permission of the slave side of the | |
206 | pseudo-terminal whose master side is specified by FD. */ | |
207 | # if !@HAVE_GRANTPT@ | |
208 | _GL_FUNCDECL_SYS (grantpt, int, (int fd)); | |
209 | # endif | |
210 | _GL_CXXALIAS_SYS (grantpt, int, (int fd)); | |
211 | _GL_CXXALIASWARN (grantpt); | |
212 | #elif defined GNULIB_POSIXCHECK | |
213 | # undef grantpt | |
214 | # if HAVE_RAW_DECL_GRANTPT | |
215 | _GL_WARN_ON_USE (ptsname, "grantpt is not portable - " | |
216 | "use gnulib module grantpt for portability"); | |
217 | # endif | |
218 | #endif | |
219 | ||
8912421c LC |
220 | #if @GNULIB_MALLOC_POSIX@ |
221 | # if !@HAVE_MALLOC_POSIX@ | |
f4c79b3c LC |
222 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
223 | # undef malloc | |
224 | # define malloc rpl_malloc | |
225 | # endif | |
226 | _GL_FUNCDECL_RPL (malloc, void *, (size_t size)); | |
227 | _GL_CXXALIAS_RPL (malloc, void *, (size_t size)); | |
228 | # else | |
229 | _GL_CXXALIAS_SYS (malloc, void *, (size_t size)); | |
8912421c | 230 | # endif |
f4c79b3c | 231 | _GL_CXXALIASWARN (malloc); |
8912421c LC |
232 | #elif defined GNULIB_POSIXCHECK |
233 | # undef malloc | |
61cd9dc9 LC |
234 | /* Assume malloc is always declared. */ |
235 | _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - " | |
236 | "use gnulib module malloc-posix for portability"); | |
8912421c | 237 | #endif |
f240aacb LC |
238 | |
239 | #if @GNULIB_MKDTEMP@ | |
f240aacb LC |
240 | /* Create a unique temporary directory from TEMPLATE. |
241 | The last six characters of TEMPLATE must be "XXXXXX"; | |
242 | they are replaced with a string that makes the directory name unique. | |
243 | Returns TEMPLATE, or a null pointer if it cannot get a unique name. | |
244 | The directory is created mode 700. */ | |
f4c79b3c LC |
245 | # if !@HAVE_MKDTEMP@ |
246 | _GL_FUNCDECL_SYS (mkdtemp, char *, (char * /*template*/) _GL_ARG_NONNULL ((1))); | |
f240aacb | 247 | # endif |
f4c79b3c LC |
248 | _GL_CXXALIAS_SYS (mkdtemp, char *, (char * /*template*/)); |
249 | _GL_CXXALIASWARN (mkdtemp); | |
f240aacb LC |
250 | #elif defined GNULIB_POSIXCHECK |
251 | # undef mkdtemp | |
61cd9dc9 LC |
252 | # if HAVE_RAW_DECL_MKDTEMP |
253 | _GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - " | |
254 | "use gnulib module mkdtemp for portability"); | |
255 | # endif | |
f240aacb LC |
256 | #endif |
257 | ||
8912421c | 258 | #if @GNULIB_MKOSTEMP@ |
8912421c LC |
259 | /* Create a unique temporary file from TEMPLATE. |
260 | The last six characters of TEMPLATE must be "XXXXXX"; | |
261 | they are replaced with a string that makes the file name unique. | |
262 | The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>) | |
263 | and O_TEXT, O_BINARY (defined in "binary-io.h"). | |
264 | The file is then created, with the specified flags, ensuring it didn't exist | |
265 | before. | |
266 | The file is created read-write (mask at least 0600 & ~umask), but it may be | |
267 | world-readable and world-writable (mask 0666 & ~umask), depending on the | |
268 | implementation. | |
269 | Returns the open file descriptor if successful, otherwise -1 and errno | |
270 | set. */ | |
f4c79b3c LC |
271 | # if !@HAVE_MKOSTEMP@ |
272 | _GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/) | |
273 | _GL_ARG_NONNULL ((1))); | |
8912421c | 274 | # endif |
f4c79b3c LC |
275 | _GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)); |
276 | _GL_CXXALIASWARN (mkostemp); | |
8912421c LC |
277 | #elif defined GNULIB_POSIXCHECK |
278 | # undef mkostemp | |
61cd9dc9 LC |
279 | # if HAVE_RAW_DECL_MKOSTEMP |
280 | _GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - " | |
281 | "use gnulib module mkostemp for portability"); | |
282 | # endif | |
8912421c | 283 | #endif |
f240aacb | 284 | |
f29ded4b | 285 | #if @GNULIB_MKOSTEMPS@ |
f29ded4b LC |
286 | /* Create a unique temporary file from TEMPLATE. |
287 | The last six characters of TEMPLATE before a suffix of length | |
288 | SUFFIXLEN must be "XXXXXX"; | |
289 | they are replaced with a string that makes the file name unique. | |
290 | The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>) | |
291 | and O_TEXT, O_BINARY (defined in "binary-io.h"). | |
292 | The file is then created, with the specified flags, ensuring it didn't exist | |
293 | before. | |
294 | The file is created read-write (mask at least 0600 & ~umask), but it may be | |
295 | world-readable and world-writable (mask 0666 & ~umask), depending on the | |
296 | implementation. | |
297 | Returns the open file descriptor if successful, otherwise -1 and errno | |
298 | set. */ | |
f4c79b3c LC |
299 | # if !@HAVE_MKOSTEMPS@ |
300 | _GL_FUNCDECL_SYS (mkostemps, int, | |
301 | (char * /*template*/, int /*suffixlen*/, int /*flags*/) | |
302 | _GL_ARG_NONNULL ((1))); | |
f29ded4b | 303 | # endif |
f4c79b3c LC |
304 | _GL_CXXALIAS_SYS (mkostemps, int, |
305 | (char * /*template*/, int /*suffixlen*/, int /*flags*/)); | |
306 | _GL_CXXALIASWARN (mkostemps); | |
f29ded4b LC |
307 | #elif defined GNULIB_POSIXCHECK |
308 | # undef mkostemps | |
61cd9dc9 LC |
309 | # if HAVE_RAW_DECL_MKOSTEMPS |
310 | _GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - " | |
311 | "use gnulib module mkostemps for portability"); | |
312 | # endif | |
f29ded4b LC |
313 | #endif |
314 | ||
f240aacb | 315 | #if @GNULIB_MKSTEMP@ |
f240aacb LC |
316 | /* Create a unique temporary file from TEMPLATE. |
317 | The last six characters of TEMPLATE must be "XXXXXX"; | |
318 | they are replaced with a string that makes the file name unique. | |
319 | The file is then created, ensuring it didn't exist before. | |
320 | The file is created read-write (mask at least 0600 & ~umask), but it may be | |
321 | world-readable and world-writable (mask 0666 & ~umask), depending on the | |
322 | implementation. | |
323 | Returns the open file descriptor if successful, otherwise -1 and errno | |
324 | set. */ | |
f4c79b3c LC |
325 | # if @REPLACE_MKSTEMP@ |
326 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
327 | # define mkstemp rpl_mkstemp | |
328 | # endif | |
329 | _GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1))); | |
330 | _GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/)); | |
331 | # else | |
a927b6c1 LC |
332 | # if ! @HAVE_MKSTEMP@ |
333 | _GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1))); | |
334 | # endif | |
f4c79b3c | 335 | _GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/)); |
f240aacb | 336 | # endif |
f4c79b3c | 337 | _GL_CXXALIASWARN (mkstemp); |
f240aacb LC |
338 | #elif defined GNULIB_POSIXCHECK |
339 | # undef mkstemp | |
61cd9dc9 LC |
340 | # if HAVE_RAW_DECL_MKSTEMP |
341 | _GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - " | |
342 | "use gnulib module mkstemp for portability"); | |
343 | # endif | |
f240aacb LC |
344 | #endif |
345 | ||
f29ded4b | 346 | #if @GNULIB_MKSTEMPS@ |
f29ded4b LC |
347 | /* Create a unique temporary file from TEMPLATE. |
348 | The last six characters of TEMPLATE prior to a suffix of length | |
349 | SUFFIXLEN must be "XXXXXX"; | |
350 | they are replaced with a string that makes the file name unique. | |
351 | The file is then created, ensuring it didn't exist before. | |
352 | The file is created read-write (mask at least 0600 & ~umask), but it may be | |
353 | world-readable and world-writable (mask 0666 & ~umask), depending on the | |
354 | implementation. | |
355 | Returns the open file descriptor if successful, otherwise -1 and errno | |
356 | set. */ | |
f4c79b3c LC |
357 | # if !@HAVE_MKSTEMPS@ |
358 | _GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/) | |
359 | _GL_ARG_NONNULL ((1))); | |
f29ded4b | 360 | # endif |
f4c79b3c LC |
361 | _GL_CXXALIAS_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/)); |
362 | _GL_CXXALIASWARN (mkstemps); | |
f29ded4b LC |
363 | #elif defined GNULIB_POSIXCHECK |
364 | # undef mkstemps | |
61cd9dc9 LC |
365 | # if HAVE_RAW_DECL_MKSTEMPS |
366 | _GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - " | |
367 | "use gnulib module mkstemps for portability"); | |
368 | # endif | |
f29ded4b LC |
369 | #endif |
370 | ||
a927b6c1 LC |
371 | #if @GNULIB_PTSNAME@ |
372 | /* Return the pathname of the pseudo-terminal slave associated with | |
373 | the master FD is open on, or NULL on errors. */ | |
374 | # if !@HAVE_PTSNAME@ | |
375 | _GL_FUNCDECL_SYS (ptsname, char *, (int fd)); | |
376 | # endif | |
377 | _GL_CXXALIAS_SYS (ptsname, char *, (int fd)); | |
378 | _GL_CXXALIASWARN (ptsname); | |
379 | #elif defined GNULIB_POSIXCHECK | |
380 | # undef ptsname | |
381 | # if HAVE_RAW_DECL_PTSNAME | |
382 | _GL_WARN_ON_USE (ptsname, "ptsname is not portable - " | |
383 | "use gnulib module ptsname for portability"); | |
384 | # endif | |
385 | #endif | |
386 | ||
f240aacb LC |
387 | #if @GNULIB_PUTENV@ |
388 | # if @REPLACE_PUTENV@ | |
f4c79b3c LC |
389 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
390 | # undef putenv | |
391 | # define putenv rpl_putenv | |
392 | # endif | |
393 | _GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1))); | |
394 | _GL_CXXALIAS_RPL (putenv, int, (char *string)); | |
395 | # else | |
396 | _GL_CXXALIAS_SYS (putenv, int, (char *string)); | |
f240aacb | 397 | # endif |
f4c79b3c | 398 | _GL_CXXALIASWARN (putenv); |
f240aacb LC |
399 | #endif |
400 | ||
f4c79b3c | 401 | |
f240aacb LC |
402 | #if @GNULIB_RANDOM_R@ |
403 | # if !@HAVE_RANDOM_R@ | |
f240aacb LC |
404 | # ifndef RAND_MAX |
405 | # define RAND_MAX 2147483647 | |
406 | # endif | |
f4c79b3c LC |
407 | # endif |
408 | #endif | |
f240aacb | 409 | |
f4c79b3c LC |
410 | #if @GNULIB_RANDOM_R@ |
411 | # if !@HAVE_RANDOM_R@ | |
412 | _GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result) | |
413 | _GL_ARG_NONNULL ((1, 2))); | |
f240aacb | 414 | # endif |
f4c79b3c LC |
415 | _GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result)); |
416 | _GL_CXXALIASWARN (random_r); | |
f240aacb LC |
417 | #elif defined GNULIB_POSIXCHECK |
418 | # undef random_r | |
61cd9dc9 LC |
419 | # if HAVE_RAW_DECL_RANDOM_R |
420 | _GL_WARN_ON_USE (random_r, "random_r is unportable - " | |
421 | "use gnulib module random_r for portability"); | |
422 | # endif | |
f4c79b3c LC |
423 | #endif |
424 | ||
425 | #if @GNULIB_RANDOM_R@ | |
426 | # if !@HAVE_RANDOM_R@ | |
427 | _GL_FUNCDECL_SYS (srandom_r, int, | |
428 | (unsigned int seed, struct random_data *rand_state) | |
429 | _GL_ARG_NONNULL ((2))); | |
61cd9dc9 | 430 | # endif |
f4c79b3c LC |
431 | _GL_CXXALIAS_SYS (srandom_r, int, |
432 | (unsigned int seed, struct random_data *rand_state)); | |
433 | _GL_CXXALIASWARN (srandom_r); | |
434 | #elif defined GNULIB_POSIXCHECK | |
f240aacb | 435 | # undef srandom_r |
61cd9dc9 LC |
436 | # if HAVE_RAW_DECL_SRANDOM_R |
437 | _GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - " | |
438 | "use gnulib module random_r for portability"); | |
439 | # endif | |
f4c79b3c LC |
440 | #endif |
441 | ||
442 | #if @GNULIB_RANDOM_R@ | |
443 | # if !@HAVE_RANDOM_R@ | |
444 | _GL_FUNCDECL_SYS (initstate_r, int, | |
445 | (unsigned int seed, char *buf, size_t buf_size, | |
446 | struct random_data *rand_state) | |
447 | _GL_ARG_NONNULL ((2, 4))); | |
448 | # endif | |
449 | _GL_CXXALIAS_SYS (initstate_r, int, | |
450 | (unsigned int seed, char *buf, size_t buf_size, | |
451 | struct random_data *rand_state)); | |
452 | _GL_CXXALIASWARN (initstate_r); | |
453 | #elif defined GNULIB_POSIXCHECK | |
454 | # undef initstate_r | |
455 | # if HAVE_RAW_DECL_INITSTATE_R | |
456 | _GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - " | |
457 | "use gnulib module random_r for portability"); | |
458 | # endif | |
459 | #endif | |
460 | ||
461 | #if @GNULIB_RANDOM_R@ | |
462 | # if !@HAVE_RANDOM_R@ | |
463 | _GL_FUNCDECL_SYS (setstate_r, int, | |
464 | (char *arg_state, struct random_data *rand_state) | |
465 | _GL_ARG_NONNULL ((1, 2))); | |
466 | # endif | |
467 | _GL_CXXALIAS_SYS (setstate_r, int, | |
468 | (char *arg_state, struct random_data *rand_state)); | |
469 | _GL_CXXALIASWARN (setstate_r); | |
470 | #elif defined GNULIB_POSIXCHECK | |
f240aacb | 471 | # undef setstate_r |
61cd9dc9 LC |
472 | # if HAVE_RAW_DECL_SETSTATE_R |
473 | _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - " | |
474 | "use gnulib module random_r for portability"); | |
475 | # endif | |
f240aacb LC |
476 | #endif |
477 | ||
f4c79b3c | 478 | |
8912421c LC |
479 | #if @GNULIB_REALLOC_POSIX@ |
480 | # if !@HAVE_REALLOC_POSIX@ | |
f4c79b3c LC |
481 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
482 | # undef realloc | |
483 | # define realloc rpl_realloc | |
484 | # endif | |
485 | _GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size)); | |
486 | _GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size)); | |
487 | # else | |
488 | _GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size)); | |
8912421c | 489 | # endif |
f4c79b3c | 490 | _GL_CXXALIASWARN (realloc); |
8912421c LC |
491 | #elif defined GNULIB_POSIXCHECK |
492 | # undef realloc | |
61cd9dc9 LC |
493 | /* Assume realloc is always declared. */ |
494 | _GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - " | |
495 | "use gnulib module realloc-posix for portability"); | |
8912421c LC |
496 | #endif |
497 | ||
498 | #if @GNULIB_REALPATH@ | |
499 | # if @REPLACE_REALPATH@ | |
f4c79b3c LC |
500 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
501 | # define realpath rpl_realpath | |
502 | # endif | |
503 | _GL_FUNCDECL_RPL (realpath, char *, (const char *name, char *resolved) | |
504 | _GL_ARG_NONNULL ((1))); | |
505 | _GL_CXXALIAS_RPL (realpath, char *, (const char *name, char *resolved)); | |
506 | # else | |
507 | # if !@HAVE_REALPATH@ | |
508 | _GL_FUNCDECL_SYS (realpath, char *, (const char *name, char *resolved) | |
509 | _GL_ARG_NONNULL ((1))); | |
510 | # endif | |
511 | _GL_CXXALIAS_SYS (realpath, char *, (const char *name, char *resolved)); | |
8912421c | 512 | # endif |
f4c79b3c | 513 | _GL_CXXALIASWARN (realpath); |
8912421c LC |
514 | #elif defined GNULIB_POSIXCHECK |
515 | # undef realpath | |
61cd9dc9 LC |
516 | # if HAVE_RAW_DECL_REALPATH |
517 | _GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module " | |
518 | "canonicalize or canonicalize-lgpl for portability"); | |
519 | # endif | |
8912421c | 520 | #endif |
f240aacb LC |
521 | |
522 | #if @GNULIB_RPMATCH@ | |
f240aacb LC |
523 | /* Test a user response to a question. |
524 | Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */ | |
f4c79b3c LC |
525 | # if !@HAVE_RPMATCH@ |
526 | _GL_FUNCDECL_SYS (rpmatch, int, (const char *response) _GL_ARG_NONNULL ((1))); | |
f240aacb | 527 | # endif |
f4c79b3c LC |
528 | _GL_CXXALIAS_SYS (rpmatch, int, (const char *response)); |
529 | _GL_CXXALIASWARN (rpmatch); | |
f240aacb LC |
530 | #elif defined GNULIB_POSIXCHECK |
531 | # undef rpmatch | |
61cd9dc9 LC |
532 | # if HAVE_RAW_DECL_RPMATCH |
533 | _GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - " | |
534 | "use gnulib module rpmatch for portability"); | |
535 | # endif | |
f240aacb LC |
536 | #endif |
537 | ||
f240aacb | 538 | #if @GNULIB_SETENV@ |
f240aacb LC |
539 | /* Set NAME to VALUE in the environment. |
540 | If REPLACE is nonzero, overwrite an existing value. */ | |
f4c79b3c LC |
541 | # if @REPLACE_SETENV@ |
542 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
543 | # undef setenv | |
544 | # define setenv rpl_setenv | |
545 | # endif | |
546 | _GL_FUNCDECL_RPL (setenv, int, | |
547 | (const char *name, const char *value, int replace) | |
548 | _GL_ARG_NONNULL ((1))); | |
549 | _GL_CXXALIAS_RPL (setenv, int, | |
550 | (const char *name, const char *value, int replace)); | |
551 | # else | |
552 | # if !@HAVE_SETENV@ | |
553 | _GL_FUNCDECL_SYS (setenv, int, | |
554 | (const char *name, const char *value, int replace) | |
555 | _GL_ARG_NONNULL ((1))); | |
556 | # endif | |
557 | _GL_CXXALIAS_SYS (setenv, int, | |
558 | (const char *name, const char *value, int replace)); | |
f240aacb | 559 | # endif |
f4c79b3c | 560 | _GL_CXXALIASWARN (setenv); |
4f02b98d LC |
561 | #elif defined GNULIB_POSIXCHECK |
562 | # undef setenv | |
61cd9dc9 LC |
563 | # if HAVE_RAW_DECL_SETENV |
564 | _GL_WARN_ON_USE (setenv, "setenv is unportable - " | |
565 | "use gnulib module setenv for portability"); | |
566 | # endif | |
f240aacb LC |
567 | #endif |
568 | ||
f240aacb | 569 | #if @GNULIB_STRTOD@ |
f240aacb | 570 | /* Parse a double from STRING, updating ENDP if appropriate. */ |
f4c79b3c LC |
571 | # if @REPLACE_STRTOD@ |
572 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
573 | # define strtod rpl_strtod | |
574 | # endif | |
575 | _GL_FUNCDECL_RPL (strtod, double, (const char *str, char **endp) | |
576 | _GL_ARG_NONNULL ((1))); | |
577 | _GL_CXXALIAS_RPL (strtod, double, (const char *str, char **endp)); | |
578 | # else | |
579 | # if !@HAVE_STRTOD@ | |
580 | _GL_FUNCDECL_SYS (strtod, double, (const char *str, char **endp) | |
581 | _GL_ARG_NONNULL ((1))); | |
582 | # endif | |
583 | _GL_CXXALIAS_SYS (strtod, double, (const char *str, char **endp)); | |
f240aacb | 584 | # endif |
f4c79b3c | 585 | _GL_CXXALIASWARN (strtod); |
f240aacb LC |
586 | #elif defined GNULIB_POSIXCHECK |
587 | # undef strtod | |
61cd9dc9 LC |
588 | # if HAVE_RAW_DECL_STRTOD |
589 | _GL_WARN_ON_USE (strtod, "strtod is unportable - " | |
590 | "use gnulib module strtod for portability"); | |
591 | # endif | |
f240aacb LC |
592 | #endif |
593 | ||
f240aacb | 594 | #if @GNULIB_STRTOLL@ |
f240aacb LC |
595 | /* Parse a signed integer whose textual representation starts at STRING. |
596 | The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0, | |
597 | it may be decimal or octal (with prefix "0") or hexadecimal (with prefix | |
598 | "0x"). | |
599 | If ENDPTR is not NULL, the address of the first byte after the integer is | |
600 | stored in *ENDPTR. | |
601 | Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set | |
602 | to ERANGE. */ | |
f4c79b3c LC |
603 | # if !@HAVE_STRTOLL@ |
604 | _GL_FUNCDECL_SYS (strtoll, long long, | |
605 | (const char *string, char **endptr, int base) | |
606 | _GL_ARG_NONNULL ((1))); | |
f240aacb | 607 | # endif |
f4c79b3c LC |
608 | _GL_CXXALIAS_SYS (strtoll, long long, |
609 | (const char *string, char **endptr, int base)); | |
610 | _GL_CXXALIASWARN (strtoll); | |
f240aacb LC |
611 | #elif defined GNULIB_POSIXCHECK |
612 | # undef strtoll | |
61cd9dc9 LC |
613 | # if HAVE_RAW_DECL_STRTOLL |
614 | _GL_WARN_ON_USE (strtoll, "strtoll is unportable - " | |
615 | "use gnulib module strtoll for portability"); | |
616 | # endif | |
f240aacb LC |
617 | #endif |
618 | ||
f240aacb | 619 | #if @GNULIB_STRTOULL@ |
f240aacb LC |
620 | /* Parse an unsigned integer whose textual representation starts at STRING. |
621 | The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0, | |
622 | it may be decimal or octal (with prefix "0") or hexadecimal (with prefix | |
623 | "0x"). | |
624 | If ENDPTR is not NULL, the address of the first byte after the integer is | |
625 | stored in *ENDPTR. | |
626 | Upon overflow, the return value is ULLONG_MAX, and errno is set to | |
627 | ERANGE. */ | |
f4c79b3c LC |
628 | # if !@HAVE_STRTOULL@ |
629 | _GL_FUNCDECL_SYS (strtoull, unsigned long long, | |
630 | (const char *string, char **endptr, int base) | |
631 | _GL_ARG_NONNULL ((1))); | |
f240aacb | 632 | # endif |
f4c79b3c LC |
633 | _GL_CXXALIAS_SYS (strtoull, unsigned long long, |
634 | (const char *string, char **endptr, int base)); | |
635 | _GL_CXXALIASWARN (strtoull); | |
f240aacb LC |
636 | #elif defined GNULIB_POSIXCHECK |
637 | # undef strtoull | |
61cd9dc9 LC |
638 | # if HAVE_RAW_DECL_STRTOULL |
639 | _GL_WARN_ON_USE (strtoull, "strtoull is unportable - " | |
640 | "use gnulib module strtoull for portability"); | |
641 | # endif | |
f240aacb LC |
642 | #endif |
643 | ||
a927b6c1 LC |
644 | #if @GNULIB_UNLOCKPT@ |
645 | /* Unlock the slave side of the pseudo-terminal whose master side is specified | |
646 | by FD, so that it can be opened. */ | |
647 | # if !@HAVE_UNLOCKPT@ | |
648 | _GL_FUNCDECL_SYS (unlockpt, int, (int fd)); | |
649 | # endif | |
650 | _GL_CXXALIAS_SYS (unlockpt, int, (int fd)); | |
651 | _GL_CXXALIASWARN (unlockpt); | |
652 | #elif defined GNULIB_POSIXCHECK | |
653 | # undef unlockpt | |
654 | # if HAVE_RAW_DECL_UNLOCKPT | |
655 | _GL_WARN_ON_USE (ptsname, "unlockpt is not portable - " | |
656 | "use gnulib module unlockpt for portability"); | |
657 | # endif | |
658 | #endif | |
659 | ||
8912421c | 660 | #if @GNULIB_UNSETENV@ |
8912421c | 661 | /* Remove the variable NAME from the environment. */ |
f4c79b3c LC |
662 | # if @REPLACE_UNSETENV@ |
663 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
664 | # undef unsetenv | |
665 | # define unsetenv rpl_unsetenv | |
666 | # endif | |
667 | _GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); | |
668 | _GL_CXXALIAS_RPL (unsetenv, int, (const char *name)); | |
669 | # else | |
670 | # if !@HAVE_UNSETENV@ | |
671 | _GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); | |
672 | # endif | |
673 | _GL_CXXALIAS_SYS (unsetenv, int, (const char *name)); | |
8912421c | 674 | # endif |
f4c79b3c | 675 | _GL_CXXALIASWARN (unsetenv); |
4f02b98d LC |
676 | #elif defined GNULIB_POSIXCHECK |
677 | # undef unsetenv | |
61cd9dc9 LC |
678 | # if HAVE_RAW_DECL_UNSETENV |
679 | _GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - " | |
680 | "use gnulib module unsetenv for portability"); | |
681 | # endif | |
8912421c | 682 | #endif |
f240aacb | 683 | |
f240aacb LC |
684 | |
685 | #endif /* _GL_STDLIB_H */ | |
686 | #endif /* _GL_STDLIB_H */ | |
687 | #endif |