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