Commit | Line | Data |
---|---|---|
f240aacb LC |
1 | /* A GNU-like <stdlib.h>. |
2 | ||
49114fd4 | 3 | Copyright (C) 1995, 2001-2004, 2006-2011 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 | ||
3d458a81 | 31 | #ifndef _@GUARD_PREFIX@_STDLIB_H |
f240aacb LC |
32 | |
33 | /* The include_next requires a split double-inclusion guard. */ | |
34 | #@INCLUDE_NEXT@ @NEXT_STDLIB_H@ | |
35 | ||
3d458a81 AW |
36 | #ifndef _@GUARD_PREFIX@_STDLIB_H |
37 | #define _@GUARD_PREFIX@_STDLIB_H | |
f240aacb | 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 | ||
49114fd4 LC |
52 | #if @GNULIB_RANDOM_R@ |
53 | ||
f240aacb | 54 | /* OSF/1 5.1 declares 'struct random_data' in <random.h>, which is included |
49114fd4 LC |
55 | from <stdlib.h> if _REENTRANT is defined. Include it whenever we need |
56 | 'struct random_data'. */ | |
57 | # if @HAVE_RANDOM_H@ | |
58 | # include <random.h> | |
59 | # endif | |
f240aacb | 60 | |
49114fd4 LC |
61 | # if !@HAVE_STRUCT_RANDOM_DATA@ || !@HAVE_RANDOM_R@ |
62 | # include <stdint.h> | |
63 | # endif | |
f240aacb | 64 | |
49114fd4 | 65 | # if !@HAVE_STRUCT_RANDOM_DATA@ |
0f00f2c3 LC |
66 | /* Define 'struct random_data'. |
67 | But allow multiple gnulib generated <stdlib.h> replacements to coexist. */ | |
49114fd4 | 68 | # if !GNULIB_defined_struct_random_data |
f240aacb LC |
69 | struct random_data |
70 | { | |
1cd4fffc LC |
71 | int32_t *fptr; /* Front pointer. */ |
72 | int32_t *rptr; /* Rear pointer. */ | |
73 | int32_t *state; /* Array of state values. */ | |
74 | int rand_type; /* Type of random number generator. */ | |
75 | int rand_deg; /* Degree of random number generator. */ | |
76 | int rand_sep; /* Distance between front and rear. */ | |
77 | int32_t *end_ptr; /* Pointer behind state table. */ | |
f240aacb | 78 | }; |
49114fd4 LC |
79 | # define GNULIB_defined_struct_random_data 1 |
80 | # endif | |
0f00f2c3 | 81 | # endif |
f240aacb LC |
82 | #endif |
83 | ||
3d458a81 | 84 | #if (@GNULIB_MKSTEMP@ || @GNULIB_MKSTEMPS@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) |
61cd9dc9 | 85 | /* On MacOS X 10.3, only <unistd.h> declares mkstemp. */ |
3d458a81 | 86 | /* On MacOS X 10.5, only <unistd.h> declares mkstemps. */ |
61cd9dc9 | 87 | /* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */ |
a927b6c1 | 88 | /* But avoid namespace pollution on glibc systems and native Windows. */ |
61cd9dc9 LC |
89 | # include <unistd.h> |
90 | #endif | |
f240aacb | 91 | |
35428fb6 | 92 | /* The definition of _Noreturn is copied here. */ |
9157d901 | 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@ | |
35428fb6 | 119 | _GL_FUNCDECL_SYS (_Exit, _Noreturn void, (int status)); |
9157d901 LC |
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 | ||
dd7d0148 LC |
255 | /* If _GL_USE_STDLIB_ALLOC is nonzero, the including module does not |
256 | rely on GNU or POSIX semantics for malloc and realloc (for example, | |
257 | by never specifying a zero size), so it does not need malloc or | |
258 | realloc to be redefined. */ | |
8912421c | 259 | #if @GNULIB_MALLOC_POSIX@ |
9157d901 | 260 | # if @REPLACE_MALLOC@ |
dd7d0148 LC |
261 | # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ |
262 | || _GL_USE_STDLIB_ALLOC) | |
f4c79b3c LC |
263 | # undef malloc |
264 | # define malloc rpl_malloc | |
265 | # endif | |
266 | _GL_FUNCDECL_RPL (malloc, void *, (size_t size)); | |
267 | _GL_CXXALIAS_RPL (malloc, void *, (size_t size)); | |
268 | # else | |
269 | _GL_CXXALIAS_SYS (malloc, void *, (size_t size)); | |
8912421c | 270 | # endif |
f4c79b3c | 271 | _GL_CXXALIASWARN (malloc); |
dd7d0148 | 272 | #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC |
8912421c | 273 | # undef malloc |
61cd9dc9 LC |
274 | /* Assume malloc is always declared. */ |
275 | _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - " | |
276 | "use gnulib module malloc-posix for portability"); | |
8912421c | 277 | #endif |
f240aacb | 278 | |
dd36ce77 MW |
279 | /* Convert a multibyte character to a wide character. */ |
280 | #if @GNULIB_MBTOWC@ | |
281 | # if @REPLACE_MBTOWC@ | |
282 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
283 | # undef mbtowc | |
284 | # define mbtowc rpl_mbtowc | |
285 | # endif | |
286 | _GL_FUNCDECL_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n)); | |
287 | _GL_CXXALIAS_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n)); | |
288 | # else | |
289 | _GL_CXXALIAS_SYS (mbtowc, int, (wchar_t *pwc, const char *s, size_t n)); | |
290 | # endif | |
291 | _GL_CXXALIASWARN (mbtowc); | |
292 | #endif | |
293 | ||
f240aacb | 294 | #if @GNULIB_MKDTEMP@ |
f240aacb LC |
295 | /* Create a unique temporary directory from TEMPLATE. |
296 | The last six characters of TEMPLATE must be "XXXXXX"; | |
297 | they are replaced with a string that makes the directory name unique. | |
298 | Returns TEMPLATE, or a null pointer if it cannot get a unique name. | |
299 | The directory is created mode 700. */ | |
f4c79b3c LC |
300 | # if !@HAVE_MKDTEMP@ |
301 | _GL_FUNCDECL_SYS (mkdtemp, char *, (char * /*template*/) _GL_ARG_NONNULL ((1))); | |
f240aacb | 302 | # endif |
f4c79b3c LC |
303 | _GL_CXXALIAS_SYS (mkdtemp, char *, (char * /*template*/)); |
304 | _GL_CXXALIASWARN (mkdtemp); | |
f240aacb LC |
305 | #elif defined GNULIB_POSIXCHECK |
306 | # undef mkdtemp | |
61cd9dc9 LC |
307 | # if HAVE_RAW_DECL_MKDTEMP |
308 | _GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - " | |
309 | "use gnulib module mkdtemp for portability"); | |
310 | # endif | |
f240aacb LC |
311 | #endif |
312 | ||
8912421c | 313 | #if @GNULIB_MKOSTEMP@ |
8912421c LC |
314 | /* Create a unique temporary file from TEMPLATE. |
315 | The last six characters of TEMPLATE must be "XXXXXX"; | |
316 | they are replaced with a string that makes the file name unique. | |
317 | The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>) | |
318 | and O_TEXT, O_BINARY (defined in "binary-io.h"). | |
319 | The file is then created, with the specified flags, ensuring it didn't exist | |
320 | before. | |
321 | The file is created read-write (mask at least 0600 & ~umask), but it may be | |
322 | world-readable and world-writable (mask 0666 & ~umask), depending on the | |
323 | implementation. | |
324 | Returns the open file descriptor if successful, otherwise -1 and errno | |
325 | set. */ | |
f4c79b3c LC |
326 | # if !@HAVE_MKOSTEMP@ |
327 | _GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/) | |
328 | _GL_ARG_NONNULL ((1))); | |
8912421c | 329 | # endif |
f4c79b3c LC |
330 | _GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)); |
331 | _GL_CXXALIASWARN (mkostemp); | |
8912421c LC |
332 | #elif defined GNULIB_POSIXCHECK |
333 | # undef mkostemp | |
61cd9dc9 LC |
334 | # if HAVE_RAW_DECL_MKOSTEMP |
335 | _GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - " | |
336 | "use gnulib module mkostemp for portability"); | |
337 | # endif | |
8912421c | 338 | #endif |
f240aacb | 339 | |
f29ded4b | 340 | #if @GNULIB_MKOSTEMPS@ |
f29ded4b LC |
341 | /* Create a unique temporary file from TEMPLATE. |
342 | The last six characters of TEMPLATE before a suffix of length | |
343 | SUFFIXLEN must be "XXXXXX"; | |
344 | they are replaced with a string that makes the file name unique. | |
345 | The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>) | |
346 | and O_TEXT, O_BINARY (defined in "binary-io.h"). | |
347 | The file is then created, with the specified flags, ensuring it didn't exist | |
348 | before. | |
349 | The file is created read-write (mask at least 0600 & ~umask), but it may be | |
350 | world-readable and world-writable (mask 0666 & ~umask), depending on the | |
351 | implementation. | |
352 | Returns the open file descriptor if successful, otherwise -1 and errno | |
353 | set. */ | |
f4c79b3c LC |
354 | # if !@HAVE_MKOSTEMPS@ |
355 | _GL_FUNCDECL_SYS (mkostemps, int, | |
356 | (char * /*template*/, int /*suffixlen*/, int /*flags*/) | |
357 | _GL_ARG_NONNULL ((1))); | |
f29ded4b | 358 | # endif |
f4c79b3c LC |
359 | _GL_CXXALIAS_SYS (mkostemps, int, |
360 | (char * /*template*/, int /*suffixlen*/, int /*flags*/)); | |
361 | _GL_CXXALIASWARN (mkostemps); | |
f29ded4b LC |
362 | #elif defined GNULIB_POSIXCHECK |
363 | # undef mkostemps | |
61cd9dc9 LC |
364 | # if HAVE_RAW_DECL_MKOSTEMPS |
365 | _GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - " | |
366 | "use gnulib module mkostemps for portability"); | |
367 | # endif | |
f29ded4b LC |
368 | #endif |
369 | ||
f240aacb | 370 | #if @GNULIB_MKSTEMP@ |
f240aacb LC |
371 | /* Create a unique temporary file from TEMPLATE. |
372 | The last six characters of TEMPLATE 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 @REPLACE_MKSTEMP@ |
381 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
382 | # define mkstemp rpl_mkstemp | |
383 | # endif | |
384 | _GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1))); | |
385 | _GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/)); | |
386 | # else | |
a927b6c1 LC |
387 | # if ! @HAVE_MKSTEMP@ |
388 | _GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1))); | |
389 | # endif | |
f4c79b3c | 390 | _GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/)); |
f240aacb | 391 | # endif |
f4c79b3c | 392 | _GL_CXXALIASWARN (mkstemp); |
f240aacb LC |
393 | #elif defined GNULIB_POSIXCHECK |
394 | # undef mkstemp | |
61cd9dc9 LC |
395 | # if HAVE_RAW_DECL_MKSTEMP |
396 | _GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - " | |
397 | "use gnulib module mkstemp for portability"); | |
398 | # endif | |
f240aacb LC |
399 | #endif |
400 | ||
f29ded4b | 401 | #if @GNULIB_MKSTEMPS@ |
f29ded4b LC |
402 | /* Create a unique temporary file from TEMPLATE. |
403 | The last six characters of TEMPLATE prior to a suffix of length | |
404 | SUFFIXLEN must be "XXXXXX"; | |
405 | they are replaced with a string that makes the file name unique. | |
406 | The file is then created, ensuring it didn't exist before. | |
407 | The file is created read-write (mask at least 0600 & ~umask), but it may be | |
408 | world-readable and world-writable (mask 0666 & ~umask), depending on the | |
409 | implementation. | |
410 | Returns the open file descriptor if successful, otherwise -1 and errno | |
411 | set. */ | |
f4c79b3c LC |
412 | # if !@HAVE_MKSTEMPS@ |
413 | _GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/) | |
414 | _GL_ARG_NONNULL ((1))); | |
f29ded4b | 415 | # endif |
f4c79b3c LC |
416 | _GL_CXXALIAS_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/)); |
417 | _GL_CXXALIASWARN (mkstemps); | |
f29ded4b LC |
418 | #elif defined GNULIB_POSIXCHECK |
419 | # undef mkstemps | |
61cd9dc9 LC |
420 | # if HAVE_RAW_DECL_MKSTEMPS |
421 | _GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - " | |
422 | "use gnulib module mkstemps for portability"); | |
423 | # endif | |
f29ded4b LC |
424 | #endif |
425 | ||
35428fb6 LC |
426 | #if @GNULIB_POSIX_OPENPT@ |
427 | /* Return an FD open to the master side of a pseudo-terminal. Flags should | |
428 | include O_RDWR, and may also include O_NOCTTY. */ | |
429 | # if !@HAVE_POSIX_OPENPT@ | |
430 | _GL_FUNCDECL_SYS (posix_openpt, int, (int flags)); | |
431 | # endif | |
432 | _GL_CXXALIAS_SYS (posix_openpt, int, (int flags)); | |
433 | _GL_CXXALIASWARN (posix_openpt); | |
434 | #elif defined GNULIB_POSIXCHECK | |
435 | # undef posix_openpt | |
436 | # if HAVE_RAW_DECL_POSIX_OPENPT | |
437 | _GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - " | |
438 | "use gnulib module posix_openpt for portability"); | |
439 | # endif | |
440 | #endif | |
441 | ||
a927b6c1 LC |
442 | #if @GNULIB_PTSNAME@ |
443 | /* Return the pathname of the pseudo-terminal slave associated with | |
444 | the master FD is open on, or NULL on errors. */ | |
445 | # if !@HAVE_PTSNAME@ | |
446 | _GL_FUNCDECL_SYS (ptsname, char *, (int fd)); | |
447 | # endif | |
448 | _GL_CXXALIAS_SYS (ptsname, char *, (int fd)); | |
449 | _GL_CXXALIASWARN (ptsname); | |
450 | #elif defined GNULIB_POSIXCHECK | |
451 | # undef ptsname | |
452 | # if HAVE_RAW_DECL_PTSNAME | |
453 | _GL_WARN_ON_USE (ptsname, "ptsname is not portable - " | |
454 | "use gnulib module ptsname for portability"); | |
455 | # endif | |
456 | #endif | |
457 | ||
f240aacb LC |
458 | #if @GNULIB_PUTENV@ |
459 | # if @REPLACE_PUTENV@ | |
f4c79b3c LC |
460 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
461 | # undef putenv | |
462 | # define putenv rpl_putenv | |
463 | # endif | |
464 | _GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1))); | |
465 | _GL_CXXALIAS_RPL (putenv, int, (char *string)); | |
466 | # else | |
467 | _GL_CXXALIAS_SYS (putenv, int, (char *string)); | |
f240aacb | 468 | # endif |
f4c79b3c | 469 | _GL_CXXALIASWARN (putenv); |
f240aacb LC |
470 | #endif |
471 | ||
f4c79b3c | 472 | |
f240aacb LC |
473 | #if @GNULIB_RANDOM_R@ |
474 | # if !@HAVE_RANDOM_R@ | |
f240aacb LC |
475 | # ifndef RAND_MAX |
476 | # define RAND_MAX 2147483647 | |
477 | # endif | |
f4c79b3c LC |
478 | # endif |
479 | #endif | |
f240aacb | 480 | |
f4c79b3c LC |
481 | #if @GNULIB_RANDOM_R@ |
482 | # if !@HAVE_RANDOM_R@ | |
483 | _GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result) | |
484 | _GL_ARG_NONNULL ((1, 2))); | |
f240aacb | 485 | # endif |
f4c79b3c LC |
486 | _GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result)); |
487 | _GL_CXXALIASWARN (random_r); | |
f240aacb LC |
488 | #elif defined GNULIB_POSIXCHECK |
489 | # undef random_r | |
61cd9dc9 LC |
490 | # if HAVE_RAW_DECL_RANDOM_R |
491 | _GL_WARN_ON_USE (random_r, "random_r is unportable - " | |
492 | "use gnulib module random_r for portability"); | |
493 | # endif | |
f4c79b3c LC |
494 | #endif |
495 | ||
496 | #if @GNULIB_RANDOM_R@ | |
497 | # if !@HAVE_RANDOM_R@ | |
498 | _GL_FUNCDECL_SYS (srandom_r, int, | |
499 | (unsigned int seed, struct random_data *rand_state) | |
500 | _GL_ARG_NONNULL ((2))); | |
61cd9dc9 | 501 | # endif |
f4c79b3c LC |
502 | _GL_CXXALIAS_SYS (srandom_r, int, |
503 | (unsigned int seed, struct random_data *rand_state)); | |
504 | _GL_CXXALIASWARN (srandom_r); | |
505 | #elif defined GNULIB_POSIXCHECK | |
f240aacb | 506 | # undef srandom_r |
61cd9dc9 LC |
507 | # if HAVE_RAW_DECL_SRANDOM_R |
508 | _GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - " | |
509 | "use gnulib module random_r for portability"); | |
510 | # endif | |
f4c79b3c LC |
511 | #endif |
512 | ||
513 | #if @GNULIB_RANDOM_R@ | |
514 | # if !@HAVE_RANDOM_R@ | |
515 | _GL_FUNCDECL_SYS (initstate_r, int, | |
516 | (unsigned int seed, char *buf, size_t buf_size, | |
517 | struct random_data *rand_state) | |
518 | _GL_ARG_NONNULL ((2, 4))); | |
519 | # endif | |
520 | _GL_CXXALIAS_SYS (initstate_r, int, | |
521 | (unsigned int seed, char *buf, size_t buf_size, | |
522 | struct random_data *rand_state)); | |
523 | _GL_CXXALIASWARN (initstate_r); | |
524 | #elif defined GNULIB_POSIXCHECK | |
525 | # undef initstate_r | |
526 | # if HAVE_RAW_DECL_INITSTATE_R | |
527 | _GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - " | |
528 | "use gnulib module random_r for portability"); | |
529 | # endif | |
530 | #endif | |
531 | ||
532 | #if @GNULIB_RANDOM_R@ | |
533 | # if !@HAVE_RANDOM_R@ | |
534 | _GL_FUNCDECL_SYS (setstate_r, int, | |
535 | (char *arg_state, struct random_data *rand_state) | |
536 | _GL_ARG_NONNULL ((1, 2))); | |
537 | # endif | |
538 | _GL_CXXALIAS_SYS (setstate_r, int, | |
539 | (char *arg_state, struct random_data *rand_state)); | |
540 | _GL_CXXALIASWARN (setstate_r); | |
541 | #elif defined GNULIB_POSIXCHECK | |
f240aacb | 542 | # undef setstate_r |
61cd9dc9 LC |
543 | # if HAVE_RAW_DECL_SETSTATE_R |
544 | _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - " | |
545 | "use gnulib module random_r for portability"); | |
546 | # endif | |
f240aacb LC |
547 | #endif |
548 | ||
f4c79b3c | 549 | |
8912421c | 550 | #if @GNULIB_REALLOC_POSIX@ |
9157d901 | 551 | # if @REPLACE_REALLOC@ |
dd7d0148 LC |
552 | # if !((defined __cplusplus && defined GNULIB_NAMESPACE) \ |
553 | || _GL_USE_STDLIB_ALLOC) | |
f4c79b3c LC |
554 | # undef realloc |
555 | # define realloc rpl_realloc | |
556 | # endif | |
557 | _GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size)); | |
558 | _GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size)); | |
559 | # else | |
560 | _GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size)); | |
8912421c | 561 | # endif |
f4c79b3c | 562 | _GL_CXXALIASWARN (realloc); |
dd7d0148 | 563 | #elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC |
8912421c | 564 | # undef realloc |
61cd9dc9 LC |
565 | /* Assume realloc is always declared. */ |
566 | _GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - " | |
567 | "use gnulib module realloc-posix for portability"); | |
8912421c LC |
568 | #endif |
569 | ||
570 | #if @GNULIB_REALPATH@ | |
571 | # if @REPLACE_REALPATH@ | |
f4c79b3c LC |
572 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
573 | # define realpath rpl_realpath | |
574 | # endif | |
575 | _GL_FUNCDECL_RPL (realpath, char *, (const char *name, char *resolved) | |
576 | _GL_ARG_NONNULL ((1))); | |
577 | _GL_CXXALIAS_RPL (realpath, char *, (const char *name, char *resolved)); | |
578 | # else | |
579 | # if !@HAVE_REALPATH@ | |
580 | _GL_FUNCDECL_SYS (realpath, char *, (const char *name, char *resolved) | |
581 | _GL_ARG_NONNULL ((1))); | |
582 | # endif | |
583 | _GL_CXXALIAS_SYS (realpath, char *, (const char *name, char *resolved)); | |
8912421c | 584 | # endif |
f4c79b3c | 585 | _GL_CXXALIASWARN (realpath); |
8912421c LC |
586 | #elif defined GNULIB_POSIXCHECK |
587 | # undef realpath | |
61cd9dc9 LC |
588 | # if HAVE_RAW_DECL_REALPATH |
589 | _GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module " | |
590 | "canonicalize or canonicalize-lgpl for portability"); | |
591 | # endif | |
8912421c | 592 | #endif |
f240aacb LC |
593 | |
594 | #if @GNULIB_RPMATCH@ | |
f240aacb LC |
595 | /* Test a user response to a question. |
596 | Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */ | |
f4c79b3c LC |
597 | # if !@HAVE_RPMATCH@ |
598 | _GL_FUNCDECL_SYS (rpmatch, int, (const char *response) _GL_ARG_NONNULL ((1))); | |
f240aacb | 599 | # endif |
f4c79b3c LC |
600 | _GL_CXXALIAS_SYS (rpmatch, int, (const char *response)); |
601 | _GL_CXXALIASWARN (rpmatch); | |
f240aacb LC |
602 | #elif defined GNULIB_POSIXCHECK |
603 | # undef rpmatch | |
61cd9dc9 LC |
604 | # if HAVE_RAW_DECL_RPMATCH |
605 | _GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - " | |
606 | "use gnulib module rpmatch for portability"); | |
607 | # endif | |
f240aacb LC |
608 | #endif |
609 | ||
f240aacb | 610 | #if @GNULIB_SETENV@ |
f240aacb LC |
611 | /* Set NAME to VALUE in the environment. |
612 | If REPLACE is nonzero, overwrite an existing value. */ | |
f4c79b3c LC |
613 | # if @REPLACE_SETENV@ |
614 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
615 | # undef setenv | |
616 | # define setenv rpl_setenv | |
617 | # endif | |
618 | _GL_FUNCDECL_RPL (setenv, int, | |
619 | (const char *name, const char *value, int replace) | |
620 | _GL_ARG_NONNULL ((1))); | |
621 | _GL_CXXALIAS_RPL (setenv, int, | |
622 | (const char *name, const char *value, int replace)); | |
623 | # else | |
ab4d62ad | 624 | # if !@HAVE_DECL_SETENV@ |
f4c79b3c LC |
625 | _GL_FUNCDECL_SYS (setenv, int, |
626 | (const char *name, const char *value, int replace) | |
627 | _GL_ARG_NONNULL ((1))); | |
628 | # endif | |
629 | _GL_CXXALIAS_SYS (setenv, int, | |
630 | (const char *name, const char *value, int replace)); | |
f240aacb | 631 | # endif |
ab4d62ad | 632 | # if !(@REPLACE_SETENV@ && !@HAVE_DECL_SETENV@) |
f4c79b3c | 633 | _GL_CXXALIASWARN (setenv); |
ab4d62ad | 634 | # endif |
4f02b98d LC |
635 | #elif defined GNULIB_POSIXCHECK |
636 | # undef setenv | |
61cd9dc9 LC |
637 | # if HAVE_RAW_DECL_SETENV |
638 | _GL_WARN_ON_USE (setenv, "setenv is unportable - " | |
639 | "use gnulib module setenv for portability"); | |
640 | # endif | |
f240aacb LC |
641 | #endif |
642 | ||
f240aacb | 643 | #if @GNULIB_STRTOD@ |
f240aacb | 644 | /* Parse a double from STRING, updating ENDP if appropriate. */ |
f4c79b3c LC |
645 | # if @REPLACE_STRTOD@ |
646 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
647 | # define strtod rpl_strtod | |
648 | # endif | |
649 | _GL_FUNCDECL_RPL (strtod, double, (const char *str, char **endp) | |
650 | _GL_ARG_NONNULL ((1))); | |
651 | _GL_CXXALIAS_RPL (strtod, double, (const char *str, char **endp)); | |
652 | # else | |
653 | # if !@HAVE_STRTOD@ | |
654 | _GL_FUNCDECL_SYS (strtod, double, (const char *str, char **endp) | |
655 | _GL_ARG_NONNULL ((1))); | |
656 | # endif | |
657 | _GL_CXXALIAS_SYS (strtod, double, (const char *str, char **endp)); | |
f240aacb | 658 | # endif |
f4c79b3c | 659 | _GL_CXXALIASWARN (strtod); |
f240aacb LC |
660 | #elif defined GNULIB_POSIXCHECK |
661 | # undef strtod | |
61cd9dc9 LC |
662 | # if HAVE_RAW_DECL_STRTOD |
663 | _GL_WARN_ON_USE (strtod, "strtod is unportable - " | |
664 | "use gnulib module strtod for portability"); | |
665 | # endif | |
f240aacb LC |
666 | #endif |
667 | ||
f240aacb | 668 | #if @GNULIB_STRTOLL@ |
f240aacb LC |
669 | /* Parse a signed integer whose textual representation starts at STRING. |
670 | The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0, | |
671 | it may be decimal or octal (with prefix "0") or hexadecimal (with prefix | |
672 | "0x"). | |
673 | If ENDPTR is not NULL, the address of the first byte after the integer is | |
674 | stored in *ENDPTR. | |
675 | Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set | |
676 | to ERANGE. */ | |
f4c79b3c LC |
677 | # if !@HAVE_STRTOLL@ |
678 | _GL_FUNCDECL_SYS (strtoll, long long, | |
679 | (const char *string, char **endptr, int base) | |
680 | _GL_ARG_NONNULL ((1))); | |
f240aacb | 681 | # endif |
f4c79b3c LC |
682 | _GL_CXXALIAS_SYS (strtoll, long long, |
683 | (const char *string, char **endptr, int base)); | |
684 | _GL_CXXALIASWARN (strtoll); | |
f240aacb LC |
685 | #elif defined GNULIB_POSIXCHECK |
686 | # undef strtoll | |
61cd9dc9 LC |
687 | # if HAVE_RAW_DECL_STRTOLL |
688 | _GL_WARN_ON_USE (strtoll, "strtoll is unportable - " | |
689 | "use gnulib module strtoll for portability"); | |
690 | # endif | |
f240aacb LC |
691 | #endif |
692 | ||
f240aacb | 693 | #if @GNULIB_STRTOULL@ |
f240aacb LC |
694 | /* Parse an unsigned integer whose textual representation starts at STRING. |
695 | The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0, | |
696 | it may be decimal or octal (with prefix "0") or hexadecimal (with prefix | |
697 | "0x"). | |
698 | If ENDPTR is not NULL, the address of the first byte after the integer is | |
699 | stored in *ENDPTR. | |
700 | Upon overflow, the return value is ULLONG_MAX, and errno is set to | |
701 | ERANGE. */ | |
f4c79b3c LC |
702 | # if !@HAVE_STRTOULL@ |
703 | _GL_FUNCDECL_SYS (strtoull, unsigned long long, | |
704 | (const char *string, char **endptr, int base) | |
705 | _GL_ARG_NONNULL ((1))); | |
f240aacb | 706 | # endif |
f4c79b3c LC |
707 | _GL_CXXALIAS_SYS (strtoull, unsigned long long, |
708 | (const char *string, char **endptr, int base)); | |
709 | _GL_CXXALIASWARN (strtoull); | |
f240aacb LC |
710 | #elif defined GNULIB_POSIXCHECK |
711 | # undef strtoull | |
61cd9dc9 LC |
712 | # if HAVE_RAW_DECL_STRTOULL |
713 | _GL_WARN_ON_USE (strtoull, "strtoull is unportable - " | |
714 | "use gnulib module strtoull for portability"); | |
715 | # endif | |
f240aacb LC |
716 | #endif |
717 | ||
a927b6c1 LC |
718 | #if @GNULIB_UNLOCKPT@ |
719 | /* Unlock the slave side of the pseudo-terminal whose master side is specified | |
720 | by FD, so that it can be opened. */ | |
721 | # if !@HAVE_UNLOCKPT@ | |
722 | _GL_FUNCDECL_SYS (unlockpt, int, (int fd)); | |
723 | # endif | |
724 | _GL_CXXALIAS_SYS (unlockpt, int, (int fd)); | |
725 | _GL_CXXALIASWARN (unlockpt); | |
726 | #elif defined GNULIB_POSIXCHECK | |
727 | # undef unlockpt | |
728 | # if HAVE_RAW_DECL_UNLOCKPT | |
0f00f2c3 | 729 | _GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - " |
a927b6c1 LC |
730 | "use gnulib module unlockpt for portability"); |
731 | # endif | |
732 | #endif | |
733 | ||
8912421c | 734 | #if @GNULIB_UNSETENV@ |
8912421c | 735 | /* Remove the variable NAME from the environment. */ |
f4c79b3c LC |
736 | # if @REPLACE_UNSETENV@ |
737 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
738 | # undef unsetenv | |
739 | # define unsetenv rpl_unsetenv | |
740 | # endif | |
741 | _GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); | |
742 | _GL_CXXALIAS_RPL (unsetenv, int, (const char *name)); | |
743 | # else | |
ab4d62ad | 744 | # if !@HAVE_DECL_UNSETENV@ |
f4c79b3c LC |
745 | _GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); |
746 | # endif | |
747 | _GL_CXXALIAS_SYS (unsetenv, int, (const char *name)); | |
8912421c | 748 | # endif |
ab4d62ad | 749 | # if !(@REPLACE_UNSETENV@ && !@HAVE_DECL_UNSETENV@) |
f4c79b3c | 750 | _GL_CXXALIASWARN (unsetenv); |
ab4d62ad | 751 | # endif |
4f02b98d LC |
752 | #elif defined GNULIB_POSIXCHECK |
753 | # undef unsetenv | |
61cd9dc9 LC |
754 | # if HAVE_RAW_DECL_UNSETENV |
755 | _GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - " | |
756 | "use gnulib module unsetenv for portability"); | |
757 | # endif | |
8912421c | 758 | #endif |
f240aacb | 759 | |
dd36ce77 MW |
760 | /* Convert a wide character to a multibyte character. */ |
761 | #if @GNULIB_WCTOMB@ | |
762 | # if @REPLACE_WCTOMB@ | |
763 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
764 | # undef wctomb | |
765 | # define wctomb rpl_wctomb | |
766 | # endif | |
767 | _GL_FUNCDECL_RPL (wctomb, int, (char *s, wchar_t wc)); | |
768 | _GL_CXXALIAS_RPL (wctomb, int, (char *s, wchar_t wc)); | |
769 | # else | |
770 | _GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc)); | |
771 | # endif | |
772 | _GL_CXXALIASWARN (wctomb); | |
773 | #endif | |
774 | ||
f240aacb | 775 | |
3d458a81 AW |
776 | #endif /* _@GUARD_PREFIX@_STDLIB_H */ |
777 | #endif /* _@GUARD_PREFIX@_STDLIB_H */ | |
f240aacb | 778 | #endif |