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