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