Import Gnulib modules: link, fsync, readlink, rename, mkdir, rmdir, unistd.
[bpt/guile.git] / lib / stdlib.in.h
CommitLineData
f240aacb
LC
1/* A GNU-like <stdlib.h>.
2
5e69ceb7 3 Copyright (C) 1995, 2001-2004, 2006-2014 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 22
af07e104
AW
23#if defined __need_system_stdlib_h || defined __need_malloc_and_calloc
24/* Special invocation conventions inside some gnulib header files,
25 and inside some glibc header files, respectively. */
f240aacb
LC
26
27#@INCLUDE_NEXT@ @NEXT_STDLIB_H@
28
29#else
30/* Normal invocation convention. */
31
3d458a81 32#ifndef _@GUARD_PREFIX@_STDLIB_H
f240aacb
LC
33
34/* The include_next requires a split double-inclusion guard. */
35#@INCLUDE_NEXT@ @NEXT_STDLIB_H@
36
3d458a81
AW
37#ifndef _@GUARD_PREFIX@_STDLIB_H
38#define _@GUARD_PREFIX@_STDLIB_H
f240aacb 39
8912421c
LC
40/* NetBSD 5.0 mis-defines NULL. */
41#include <stddef.h>
f240aacb 42
0f00f2c3
LC
43/* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>. */
44#if @GNULIB_SYSTEM_POSIX@ && !defined WEXITSTATUS
45# include <sys/wait.h>
46#endif
47
f240aacb 48/* Solaris declares getloadavg() in <sys/loadavg.h>. */
61cd9dc9 49#if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@
f240aacb
LC
50# include <sys/loadavg.h>
51#endif
52
f0007cad
LC
53/* Native Windows platforms declare mktemp() in <io.h>. */
54#if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
55# include <io.h>
56#endif
57
49114fd4
LC
58#if @GNULIB_RANDOM_R@
59
f240aacb 60/* OSF/1 5.1 declares 'struct random_data' in <random.h>, which is included
49114fd4
LC
61 from <stdlib.h> if _REENTRANT is defined. Include it whenever we need
62 'struct random_data'. */
63# if @HAVE_RANDOM_H@
64# include <random.h>
65# endif
f240aacb 66
f0007cad 67# if !@HAVE_STRUCT_RANDOM_DATA@ || @REPLACE_RANDOM_R@ || !@HAVE_RANDOM_R@
49114fd4
LC
68# include <stdint.h>
69# endif
f240aacb 70
49114fd4 71# if !@HAVE_STRUCT_RANDOM_DATA@
0f00f2c3
LC
72/* Define 'struct random_data'.
73 But allow multiple gnulib generated <stdlib.h> replacements to coexist. */
49114fd4 74# if !GNULIB_defined_struct_random_data
f240aacb
LC
75struct random_data
76{
1cd4fffc
LC
77 int32_t *fptr; /* Front pointer. */
78 int32_t *rptr; /* Rear pointer. */
79 int32_t *state; /* Array of state values. */
80 int rand_type; /* Type of random number generator. */
81 int rand_deg; /* Degree of random number generator. */
82 int rand_sep; /* Distance between front and rear. */
83 int32_t *end_ptr; /* Pointer behind state table. */
f240aacb 84};
49114fd4
LC
85# define GNULIB_defined_struct_random_data 1
86# endif
0f00f2c3 87# endif
f240aacb
LC
88#endif
89
3d458a81 90#if (@GNULIB_MKSTEMP@ || @GNULIB_MKSTEMPS@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
005de2e8
LC
91/* On Mac OS X 10.3, only <unistd.h> declares mkstemp. */
92/* On Mac OS X 10.5, only <unistd.h> declares mkstemps. */
61cd9dc9 93/* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */
a927b6c1 94/* But avoid namespace pollution on glibc systems and native Windows. */
61cd9dc9
LC
95# include <unistd.h>
96#endif
f240aacb 97
005de2e8
LC
98/* The __attribute__ feature is available in gcc versions 2.5 and later.
99 The attribute __pure__ was added in gcc 2.96. */
100#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
101# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
102#else
103# define _GL_ATTRIBUTE_PURE /* empty */
104#endif
105
35428fb6 106/* The definition of _Noreturn is copied here. */
9157d901 107
f4c79b3c
LC
108/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
109
1cd4fffc
LC
110/* The definition of _GL_ARG_NONNULL is copied here. */
111
61cd9dc9
LC
112/* The definition of _GL_WARN_ON_USE is copied here. */
113
f240aacb
LC
114
115/* Some systems do not define EXIT_*, despite otherwise supporting C89. */
116#ifndef EXIT_SUCCESS
117# define EXIT_SUCCESS 0
118#endif
119/* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere
120 with proper operation of xargs. */
121#ifndef EXIT_FAILURE
122# define EXIT_FAILURE 1
123#elif EXIT_FAILURE != 1
124# undef EXIT_FAILURE
125# define EXIT_FAILURE 1
126#endif
127
128
9157d901
LC
129#if @GNULIB__EXIT@
130/* Terminate the current process with the given return code, without running
131 the 'atexit' handlers. */
132# if !@HAVE__EXIT@
35428fb6 133_GL_FUNCDECL_SYS (_Exit, _Noreturn void, (int status));
9157d901
LC
134# endif
135_GL_CXXALIAS_SYS (_Exit, void, (int status));
136_GL_CXXALIASWARN (_Exit);
137#elif defined GNULIB_POSIXCHECK
138# undef _Exit
139# if HAVE_RAW_DECL__EXIT
140_GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
141 "use gnulib module _Exit for portability");
142# endif
143#endif
144
145
8912421c 146#if @GNULIB_ATOLL@
8912421c
LC
147/* Parse a signed decimal integer.
148 Returns the value of the integer. Errors are not detected. */
f4c79b3c 149# if !@HAVE_ATOLL@
005de2e8
LC
150_GL_FUNCDECL_SYS (atoll, long long, (const char *string)
151 _GL_ATTRIBUTE_PURE
152 _GL_ARG_NONNULL ((1)));
f240aacb 153# endif
f4c79b3c
LC
154_GL_CXXALIAS_SYS (atoll, long long, (const char *string));
155_GL_CXXALIASWARN (atoll);
f240aacb 156#elif defined GNULIB_POSIXCHECK
8912421c 157# undef atoll
61cd9dc9
LC
158# if HAVE_RAW_DECL_ATOLL
159_GL_WARN_ON_USE (atoll, "atoll is unportable - "
160 "use gnulib module atoll for portability");
161# endif
f240aacb
LC
162#endif
163
f240aacb 164#if @GNULIB_CALLOC_POSIX@
9157d901 165# if @REPLACE_CALLOC@
f4c79b3c
LC
166# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
167# undef calloc
168# define calloc rpl_calloc
169# endif
170_GL_FUNCDECL_RPL (calloc, void *, (size_t nmemb, size_t size));
171_GL_CXXALIAS_RPL (calloc, void *, (size_t nmemb, size_t size));
172# else
173_GL_CXXALIAS_SYS (calloc, void *, (size_t nmemb, size_t size));
f240aacb 174# endif
f4c79b3c 175_GL_CXXALIASWARN (calloc);
f240aacb
LC
176#elif defined GNULIB_POSIXCHECK
177# undef calloc
61cd9dc9
LC
178/* Assume calloc is always declared. */
179_GL_WARN_ON_USE (calloc, "calloc is not POSIX compliant everywhere - "
180 "use gnulib module calloc-posix for portability");
f240aacb
LC
181#endif
182
8912421c
LC
183#if @GNULIB_CANONICALIZE_FILE_NAME@
184# if @REPLACE_CANONICALIZE_FILE_NAME@
f4c79b3c
LC
185# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
186# define canonicalize_file_name rpl_canonicalize_file_name
187# endif
188_GL_FUNCDECL_RPL (canonicalize_file_name, char *, (const char *name)
189 _GL_ARG_NONNULL ((1)));
190_GL_CXXALIAS_RPL (canonicalize_file_name, char *, (const char *name));
191# else
192# if !@HAVE_CANONICALIZE_FILE_NAME@
193_GL_FUNCDECL_SYS (canonicalize_file_name, char *, (const char *name)
194 _GL_ARG_NONNULL ((1)));
195# endif
196_GL_CXXALIAS_SYS (canonicalize_file_name, char *, (const char *name));
f240aacb 197# endif
f4c79b3c 198_GL_CXXALIASWARN (canonicalize_file_name);
f240aacb 199#elif defined GNULIB_POSIXCHECK
8912421c 200# undef canonicalize_file_name
61cd9dc9 201# if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
0f00f2c3
LC
202_GL_WARN_ON_USE (canonicalize_file_name,
203 "canonicalize_file_name is unportable - "
61cd9dc9
LC
204 "use gnulib module canonicalize-lgpl for portability");
205# endif
f240aacb
LC
206#endif
207
f240aacb 208#if @GNULIB_GETLOADAVG@
f240aacb
LC
209/* Store max(NELEM,3) load average numbers in LOADAVG[].
210 The three numbers are the load average of the last 1 minute, the last 5
211 minutes, and the last 15 minutes, respectively.
212 LOADAVG is an array of NELEM numbers. */
f4c79b3c
LC
213# if !@HAVE_DECL_GETLOADAVG@
214_GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem)
215 _GL_ARG_NONNULL ((1)));
f240aacb 216# endif
f4c79b3c
LC
217_GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem));
218_GL_CXXALIASWARN (getloadavg);
f240aacb
LC
219#elif defined GNULIB_POSIXCHECK
220# undef getloadavg
61cd9dc9
LC
221# if HAVE_RAW_DECL_GETLOADAVG
222_GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - "
223 "use gnulib module getloadavg for portability");
224# endif
f240aacb
LC
225#endif
226
f240aacb
LC
227#if @GNULIB_GETSUBOPT@
228/* Assuming *OPTIONP is a comma separated list of elements of the form
229 "token" or "token=value", getsubopt parses the first of these elements.
230 If the first element refers to a "token" that is member of the given
231 NULL-terminated array of tokens:
232 - It replaces the comma with a NUL byte, updates *OPTIONP to point past
233 the first option and the comma, sets *VALUEP to the value of the
234 element (or NULL if it doesn't contain an "=" sign),
235 - It returns the index of the "token" in the given array of tokens.
236 Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
237 For more details see the POSIX:2001 specification.
238 http://www.opengroup.org/susv3xsh/getsubopt.html */
239# if !@HAVE_GETSUBOPT@
f4c79b3c
LC
240_GL_FUNCDECL_SYS (getsubopt, int,
241 (char **optionp, char *const *tokens, char **valuep)
242 _GL_ARG_NONNULL ((1, 2, 3)));
f240aacb 243# endif
f4c79b3c
LC
244_GL_CXXALIAS_SYS (getsubopt, int,
245 (char **optionp, char *const *tokens, char **valuep));
246_GL_CXXALIASWARN (getsubopt);
f240aacb
LC
247#elif defined GNULIB_POSIXCHECK
248# undef getsubopt
61cd9dc9
LC
249# if HAVE_RAW_DECL_GETSUBOPT
250_GL_WARN_ON_USE (getsubopt, "getsubopt is unportable - "
251 "use gnulib module getsubopt for portability");
252# endif
f240aacb
LC
253#endif
254
a927b6c1
LC
255#if @GNULIB_GRANTPT@
256/* Change the ownership and access permission of the slave side of the
257 pseudo-terminal whose master side is specified by FD. */
258# if !@HAVE_GRANTPT@
259_GL_FUNCDECL_SYS (grantpt, int, (int fd));
260# endif
261_GL_CXXALIAS_SYS (grantpt, int, (int fd));
262_GL_CXXALIASWARN (grantpt);
263#elif defined GNULIB_POSIXCHECK
264# undef grantpt
265# if HAVE_RAW_DECL_GRANTPT
7f1ea859 266_GL_WARN_ON_USE (grantpt, "grantpt is not portable - "
a927b6c1
LC
267 "use gnulib module grantpt for portability");
268# endif
269#endif
270
dd7d0148
LC
271/* If _GL_USE_STDLIB_ALLOC is nonzero, the including module does not
272 rely on GNU or POSIX semantics for malloc and realloc (for example,
273 by never specifying a zero size), so it does not need malloc or
274 realloc to be redefined. */
8912421c 275#if @GNULIB_MALLOC_POSIX@
9157d901 276# if @REPLACE_MALLOC@
dd7d0148
LC
277# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
278 || _GL_USE_STDLIB_ALLOC)
f4c79b3c
LC
279# undef malloc
280# define malloc rpl_malloc
281# endif
282_GL_FUNCDECL_RPL (malloc, void *, (size_t size));
283_GL_CXXALIAS_RPL (malloc, void *, (size_t size));
284# else
285_GL_CXXALIAS_SYS (malloc, void *, (size_t size));
8912421c 286# endif
f4c79b3c 287_GL_CXXALIASWARN (malloc);
dd7d0148 288#elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
8912421c 289# undef malloc
61cd9dc9
LC
290/* Assume malloc is always declared. */
291_GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - "
292 "use gnulib module malloc-posix for portability");
8912421c 293#endif
f240aacb 294
dd36ce77
MW
295/* Convert a multibyte character to a wide character. */
296#if @GNULIB_MBTOWC@
297# if @REPLACE_MBTOWC@
298# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
299# undef mbtowc
300# define mbtowc rpl_mbtowc
301# endif
302_GL_FUNCDECL_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
303_GL_CXXALIAS_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
304# else
305_GL_CXXALIAS_SYS (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
306# endif
307_GL_CXXALIASWARN (mbtowc);
308#endif
309
f240aacb 310#if @GNULIB_MKDTEMP@
f240aacb
LC
311/* Create a unique temporary directory from TEMPLATE.
312 The last six characters of TEMPLATE must be "XXXXXX";
313 they are replaced with a string that makes the directory name unique.
314 Returns TEMPLATE, or a null pointer if it cannot get a unique name.
315 The directory is created mode 700. */
f4c79b3c
LC
316# if !@HAVE_MKDTEMP@
317_GL_FUNCDECL_SYS (mkdtemp, char *, (char * /*template*/) _GL_ARG_NONNULL ((1)));
f240aacb 318# endif
f4c79b3c
LC
319_GL_CXXALIAS_SYS (mkdtemp, char *, (char * /*template*/));
320_GL_CXXALIASWARN (mkdtemp);
f240aacb
LC
321#elif defined GNULIB_POSIXCHECK
322# undef mkdtemp
61cd9dc9
LC
323# if HAVE_RAW_DECL_MKDTEMP
324_GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - "
325 "use gnulib module mkdtemp for portability");
326# endif
f240aacb
LC
327#endif
328
8912421c 329#if @GNULIB_MKOSTEMP@
8912421c
LC
330/* Create a unique temporary file from TEMPLATE.
331 The last six characters of TEMPLATE must be "XXXXXX";
332 they are replaced with a string that makes the file name unique.
333 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
334 and O_TEXT, O_BINARY (defined in "binary-io.h").
335 The file is then created, with the specified flags, ensuring it didn't exist
336 before.
337 The file is created read-write (mask at least 0600 & ~umask), but it may be
338 world-readable and world-writable (mask 0666 & ~umask), depending on the
339 implementation.
340 Returns the open file descriptor if successful, otherwise -1 and errno
341 set. */
f4c79b3c
LC
342# if !@HAVE_MKOSTEMP@
343_GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)
344 _GL_ARG_NONNULL ((1)));
8912421c 345# endif
f4c79b3c
LC
346_GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/));
347_GL_CXXALIASWARN (mkostemp);
8912421c
LC
348#elif defined GNULIB_POSIXCHECK
349# undef mkostemp
61cd9dc9
LC
350# if HAVE_RAW_DECL_MKOSTEMP
351_GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - "
352 "use gnulib module mkostemp for portability");
353# endif
8912421c 354#endif
f240aacb 355
f29ded4b 356#if @GNULIB_MKOSTEMPS@
f29ded4b
LC
357/* Create a unique temporary file from TEMPLATE.
358 The last six characters of TEMPLATE before a suffix of length
359 SUFFIXLEN must be "XXXXXX";
360 they are replaced with a string that makes the file name unique.
361 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
362 and O_TEXT, O_BINARY (defined in "binary-io.h").
363 The file is then created, with the specified flags, ensuring it didn't exist
364 before.
365 The file is created read-write (mask at least 0600 & ~umask), but it may be
366 world-readable and world-writable (mask 0666 & ~umask), depending on the
367 implementation.
368 Returns the open file descriptor if successful, otherwise -1 and errno
369 set. */
f4c79b3c
LC
370# if !@HAVE_MKOSTEMPS@
371_GL_FUNCDECL_SYS (mkostemps, int,
372 (char * /*template*/, int /*suffixlen*/, int /*flags*/)
373 _GL_ARG_NONNULL ((1)));
f29ded4b 374# endif
f4c79b3c
LC
375_GL_CXXALIAS_SYS (mkostemps, int,
376 (char * /*template*/, int /*suffixlen*/, int /*flags*/));
377_GL_CXXALIASWARN (mkostemps);
f29ded4b
LC
378#elif defined GNULIB_POSIXCHECK
379# undef mkostemps
61cd9dc9
LC
380# if HAVE_RAW_DECL_MKOSTEMPS
381_GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - "
382 "use gnulib module mkostemps for portability");
383# endif
f29ded4b
LC
384#endif
385
f240aacb 386#if @GNULIB_MKSTEMP@
f240aacb
LC
387/* Create a unique temporary file from TEMPLATE.
388 The last six characters of TEMPLATE must be "XXXXXX";
389 they are replaced with a string that makes the file name unique.
390 The file is then created, ensuring it didn't exist before.
391 The file is created read-write (mask at least 0600 & ~umask), but it may be
392 world-readable and world-writable (mask 0666 & ~umask), depending on the
393 implementation.
394 Returns the open file descriptor if successful, otherwise -1 and errno
395 set. */
f4c79b3c
LC
396# if @REPLACE_MKSTEMP@
397# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
398# define mkstemp rpl_mkstemp
399# endif
400_GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
401_GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/));
402# else
a927b6c1
LC
403# if ! @HAVE_MKSTEMP@
404_GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
405# endif
f4c79b3c 406_GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/));
f240aacb 407# endif
f4c79b3c 408_GL_CXXALIASWARN (mkstemp);
f240aacb
LC
409#elif defined GNULIB_POSIXCHECK
410# undef mkstemp
61cd9dc9
LC
411# if HAVE_RAW_DECL_MKSTEMP
412_GL_WARN_ON_USE (mkstemp, "mkstemp is unportable - "
413 "use gnulib module mkstemp for portability");
414# endif
f240aacb
LC
415#endif
416
f29ded4b 417#if @GNULIB_MKSTEMPS@
f29ded4b
LC
418/* Create a unique temporary file from TEMPLATE.
419 The last six characters of TEMPLATE prior to a suffix of length
420 SUFFIXLEN must be "XXXXXX";
421 they are replaced with a string that makes the file name unique.
422 The file is then created, ensuring it didn't exist before.
423 The file is created read-write (mask at least 0600 & ~umask), but it may be
424 world-readable and world-writable (mask 0666 & ~umask), depending on the
425 implementation.
426 Returns the open file descriptor if successful, otherwise -1 and errno
427 set. */
f4c79b3c
LC
428# if !@HAVE_MKSTEMPS@
429_GL_FUNCDECL_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/)
430 _GL_ARG_NONNULL ((1)));
f29ded4b 431# endif
f4c79b3c
LC
432_GL_CXXALIAS_SYS (mkstemps, int, (char * /*template*/, int /*suffixlen*/));
433_GL_CXXALIASWARN (mkstemps);
f29ded4b
LC
434#elif defined GNULIB_POSIXCHECK
435# undef mkstemps
61cd9dc9
LC
436# if HAVE_RAW_DECL_MKSTEMPS
437_GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - "
438 "use gnulib module mkstemps for portability");
439# endif
f29ded4b
LC
440#endif
441
35428fb6
LC
442#if @GNULIB_POSIX_OPENPT@
443/* Return an FD open to the master side of a pseudo-terminal. Flags should
444 include O_RDWR, and may also include O_NOCTTY. */
445# if !@HAVE_POSIX_OPENPT@
446_GL_FUNCDECL_SYS (posix_openpt, int, (int flags));
447# endif
448_GL_CXXALIAS_SYS (posix_openpt, int, (int flags));
449_GL_CXXALIASWARN (posix_openpt);
450#elif defined GNULIB_POSIXCHECK
451# undef posix_openpt
452# if HAVE_RAW_DECL_POSIX_OPENPT
453_GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - "
454 "use gnulib module posix_openpt for portability");
455# endif
456#endif
457
a927b6c1
LC
458#if @GNULIB_PTSNAME@
459/* Return the pathname of the pseudo-terminal slave associated with
460 the master FD is open on, or NULL on errors. */
7ae4e75a
LC
461# if @REPLACE_PTSNAME@
462# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
463# undef ptsname
464# define ptsname rpl_ptsname
465# endif
466_GL_FUNCDECL_RPL (ptsname, char *, (int fd));
467_GL_CXXALIAS_RPL (ptsname, char *, (int fd));
468# else
469# if !@HAVE_PTSNAME@
a927b6c1 470_GL_FUNCDECL_SYS (ptsname, char *, (int fd));
7ae4e75a 471# endif
a927b6c1 472_GL_CXXALIAS_SYS (ptsname, char *, (int fd));
7ae4e75a 473# endif
a927b6c1
LC
474_GL_CXXALIASWARN (ptsname);
475#elif defined GNULIB_POSIXCHECK
476# undef ptsname
477# if HAVE_RAW_DECL_PTSNAME
478_GL_WARN_ON_USE (ptsname, "ptsname is not portable - "
479 "use gnulib module ptsname for portability");
480# endif
481#endif
482
7f1ea859
LC
483#if @GNULIB_PTSNAME_R@
484/* Set the pathname of the pseudo-terminal slave associated with
485 the master FD is open on and return 0, or set errno and return
486 non-zero on errors. */
487# if @REPLACE_PTSNAME_R@
488# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
489# undef ptsname_r
490# define ptsname_r rpl_ptsname_r
491# endif
492_GL_FUNCDECL_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
493_GL_CXXALIAS_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
494# else
495# if !@HAVE_PTSNAME_R@
496_GL_FUNCDECL_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
497# endif
498_GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
499# endif
500_GL_CXXALIASWARN (ptsname_r);
501#elif defined GNULIB_POSIXCHECK
502# undef ptsname_r
503# if HAVE_RAW_DECL_PTSNAME_R
504_GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - "
505 "use gnulib module ptsname_r for portability");
506# endif
507#endif
508
f240aacb
LC
509#if @GNULIB_PUTENV@
510# if @REPLACE_PUTENV@
f4c79b3c
LC
511# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
512# undef putenv
513# define putenv rpl_putenv
514# endif
515_GL_FUNCDECL_RPL (putenv, int, (char *string) _GL_ARG_NONNULL ((1)));
516_GL_CXXALIAS_RPL (putenv, int, (char *string));
517# else
518_GL_CXXALIAS_SYS (putenv, int, (char *string));
f240aacb 519# endif
f4c79b3c 520_GL_CXXALIASWARN (putenv);
f240aacb
LC
521#endif
522
f4c79b3c 523
f240aacb
LC
524#if @GNULIB_RANDOM_R@
525# if !@HAVE_RANDOM_R@
f240aacb
LC
526# ifndef RAND_MAX
527# define RAND_MAX 2147483647
528# endif
f4c79b3c
LC
529# endif
530#endif
f240aacb 531
f0007cad
LC
532
533#if @GNULIB_RANDOM@
534# if !@HAVE_RANDOM@
535_GL_FUNCDECL_SYS (random, long, (void));
536# endif
537_GL_CXXALIAS_SYS (random, long, (void));
538_GL_CXXALIASWARN (random);
539#elif defined GNULIB_POSIXCHECK
540# undef random
541# if HAVE_RAW_DECL_RANDOM
542_GL_WARN_ON_USE (random, "random is unportable - "
543 "use gnulib module random for portability");
544# endif
545#endif
546
547#if @GNULIB_RANDOM@
548# if !@HAVE_RANDOM@
549_GL_FUNCDECL_SYS (srandom, void, (unsigned int seed));
550# endif
551_GL_CXXALIAS_SYS (srandom, void, (unsigned int seed));
552_GL_CXXALIASWARN (srandom);
553#elif defined GNULIB_POSIXCHECK
554# undef srandom
555# if HAVE_RAW_DECL_SRANDOM
556_GL_WARN_ON_USE (srandom, "srandom is unportable - "
557 "use gnulib module random for portability");
558# endif
559#endif
560
561#if @GNULIB_RANDOM@
562# if !@HAVE_RANDOM@
563_GL_FUNCDECL_SYS (initstate, char *,
564 (unsigned int seed, char *buf, size_t buf_size)
565 _GL_ARG_NONNULL ((2)));
566# endif
567_GL_CXXALIAS_SYS (initstate, char *,
568 (unsigned int seed, char *buf, size_t buf_size));
569_GL_CXXALIASWARN (initstate);
570#elif defined GNULIB_POSIXCHECK
571# undef initstate
572# if HAVE_RAW_DECL_INITSTATE_R
573_GL_WARN_ON_USE (initstate, "initstate is unportable - "
574 "use gnulib module random for portability");
575# endif
576#endif
577
578#if @GNULIB_RANDOM@
579# if !@HAVE_RANDOM@
580_GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
581# endif
582_GL_CXXALIAS_SYS (setstate, char *, (char *arg_state));
583_GL_CXXALIASWARN (setstate);
584#elif defined GNULIB_POSIXCHECK
585# undef setstate
586# if HAVE_RAW_DECL_SETSTATE_R
587_GL_WARN_ON_USE (setstate, "setstate is unportable - "
588 "use gnulib module random for portability");
589# endif
590#endif
591
592
f4c79b3c 593#if @GNULIB_RANDOM_R@
f0007cad
LC
594# if @REPLACE_RANDOM_R@
595# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
596# undef random_r
597# define random_r rpl_random_r
598# endif
599_GL_FUNCDECL_RPL (random_r, int, (struct random_data *buf, int32_t *result)
600 _GL_ARG_NONNULL ((1, 2)));
601_GL_CXXALIAS_RPL (random_r, int, (struct random_data *buf, int32_t *result));
602# else
603# if !@HAVE_RANDOM_R@
f4c79b3c
LC
604_GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result)
605 _GL_ARG_NONNULL ((1, 2)));
f0007cad 606# endif
f4c79b3c 607_GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result));
f0007cad 608# endif
f4c79b3c 609_GL_CXXALIASWARN (random_r);
f240aacb
LC
610#elif defined GNULIB_POSIXCHECK
611# undef random_r
61cd9dc9
LC
612# if HAVE_RAW_DECL_RANDOM_R
613_GL_WARN_ON_USE (random_r, "random_r is unportable - "
614 "use gnulib module random_r for portability");
615# endif
f4c79b3c
LC
616#endif
617
618#if @GNULIB_RANDOM_R@
f0007cad
LC
619# if @REPLACE_RANDOM_R@
620# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
621# undef srandom_r
622# define srandom_r rpl_srandom_r
623# endif
624_GL_FUNCDECL_RPL (srandom_r, int,
625 (unsigned int seed, struct random_data *rand_state)
626 _GL_ARG_NONNULL ((2)));
627_GL_CXXALIAS_RPL (srandom_r, int,
628 (unsigned int seed, struct random_data *rand_state));
629# else
630# if !@HAVE_RANDOM_R@
f4c79b3c
LC
631_GL_FUNCDECL_SYS (srandom_r, int,
632 (unsigned int seed, struct random_data *rand_state)
633 _GL_ARG_NONNULL ((2)));
f0007cad 634# endif
f4c79b3c
LC
635_GL_CXXALIAS_SYS (srandom_r, int,
636 (unsigned int seed, struct random_data *rand_state));
f0007cad 637# endif
f4c79b3c
LC
638_GL_CXXALIASWARN (srandom_r);
639#elif defined GNULIB_POSIXCHECK
f240aacb 640# undef srandom_r
61cd9dc9
LC
641# if HAVE_RAW_DECL_SRANDOM_R
642_GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - "
643 "use gnulib module random_r for portability");
644# endif
f4c79b3c
LC
645#endif
646
647#if @GNULIB_RANDOM_R@
f0007cad
LC
648# if @REPLACE_RANDOM_R@
649# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
650# undef initstate_r
651# define initstate_r rpl_initstate_r
652# endif
653_GL_FUNCDECL_RPL (initstate_r, int,
654 (unsigned int seed, char *buf, size_t buf_size,
655 struct random_data *rand_state)
656 _GL_ARG_NONNULL ((2, 4)));
657_GL_CXXALIAS_RPL (initstate_r, int,
658 (unsigned int seed, char *buf, size_t buf_size,
659 struct random_data *rand_state));
660# else
661# if !@HAVE_RANDOM_R@
f4c79b3c
LC
662_GL_FUNCDECL_SYS (initstate_r, int,
663 (unsigned int seed, char *buf, size_t buf_size,
664 struct random_data *rand_state)
665 _GL_ARG_NONNULL ((2, 4)));
f0007cad 666# endif
f4c79b3c
LC
667_GL_CXXALIAS_SYS (initstate_r, int,
668 (unsigned int seed, char *buf, size_t buf_size,
669 struct random_data *rand_state));
f0007cad 670# endif
f4c79b3c
LC
671_GL_CXXALIASWARN (initstate_r);
672#elif defined GNULIB_POSIXCHECK
673# undef initstate_r
674# if HAVE_RAW_DECL_INITSTATE_R
675_GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - "
676 "use gnulib module random_r for portability");
677# endif
678#endif
679
680#if @GNULIB_RANDOM_R@
f0007cad
LC
681# if @REPLACE_RANDOM_R@
682# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
683# undef setstate_r
684# define setstate_r rpl_setstate_r
685# endif
686_GL_FUNCDECL_RPL (setstate_r, int,
687 (char *arg_state, struct random_data *rand_state)
688 _GL_ARG_NONNULL ((1, 2)));
689_GL_CXXALIAS_RPL (setstate_r, int,
690 (char *arg_state, struct random_data *rand_state));
691# else
692# if !@HAVE_RANDOM_R@
f4c79b3c
LC
693_GL_FUNCDECL_SYS (setstate_r, int,
694 (char *arg_state, struct random_data *rand_state)
695 _GL_ARG_NONNULL ((1, 2)));
f0007cad 696# endif
f4c79b3c
LC
697_GL_CXXALIAS_SYS (setstate_r, int,
698 (char *arg_state, struct random_data *rand_state));
f0007cad 699# endif
f4c79b3c
LC
700_GL_CXXALIASWARN (setstate_r);
701#elif defined GNULIB_POSIXCHECK
f240aacb 702# undef setstate_r
61cd9dc9
LC
703# if HAVE_RAW_DECL_SETSTATE_R
704_GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
705 "use gnulib module random_r for portability");
706# endif
f240aacb
LC
707#endif
708
f4c79b3c 709
8912421c 710#if @GNULIB_REALLOC_POSIX@
9157d901 711# if @REPLACE_REALLOC@
dd7d0148
LC
712# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
713 || _GL_USE_STDLIB_ALLOC)
f4c79b3c
LC
714# undef realloc
715# define realloc rpl_realloc
716# endif
717_GL_FUNCDECL_RPL (realloc, void *, (void *ptr, size_t size));
718_GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size));
719# else
720_GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size));
8912421c 721# endif
f4c79b3c 722_GL_CXXALIASWARN (realloc);
dd7d0148 723#elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
8912421c 724# undef realloc
61cd9dc9
LC
725/* Assume realloc is always declared. */
726_GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - "
727 "use gnulib module realloc-posix for portability");
8912421c
LC
728#endif
729
730#if @GNULIB_REALPATH@
731# if @REPLACE_REALPATH@
f4c79b3c
LC
732# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
733# define realpath rpl_realpath
734# endif
735_GL_FUNCDECL_RPL (realpath, char *, (const char *name, char *resolved)
736 _GL_ARG_NONNULL ((1)));
737_GL_CXXALIAS_RPL (realpath, char *, (const char *name, char *resolved));
738# else
739# if !@HAVE_REALPATH@
740_GL_FUNCDECL_SYS (realpath, char *, (const char *name, char *resolved)
741 _GL_ARG_NONNULL ((1)));
742# endif
743_GL_CXXALIAS_SYS (realpath, char *, (const char *name, char *resolved));
8912421c 744# endif
f4c79b3c 745_GL_CXXALIASWARN (realpath);
8912421c
LC
746#elif defined GNULIB_POSIXCHECK
747# undef realpath
61cd9dc9
LC
748# if HAVE_RAW_DECL_REALPATH
749_GL_WARN_ON_USE (realpath, "realpath is unportable - use gnulib module "
750 "canonicalize or canonicalize-lgpl for portability");
751# endif
8912421c 752#endif
f240aacb
LC
753
754#if @GNULIB_RPMATCH@
f240aacb
LC
755/* Test a user response to a question.
756 Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
f4c79b3c
LC
757# if !@HAVE_RPMATCH@
758_GL_FUNCDECL_SYS (rpmatch, int, (const char *response) _GL_ARG_NONNULL ((1)));
f240aacb 759# endif
f4c79b3c
LC
760_GL_CXXALIAS_SYS (rpmatch, int, (const char *response));
761_GL_CXXALIASWARN (rpmatch);
f240aacb
LC
762#elif defined GNULIB_POSIXCHECK
763# undef rpmatch
61cd9dc9
LC
764# if HAVE_RAW_DECL_RPMATCH
765_GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - "
766 "use gnulib module rpmatch for portability");
767# endif
f240aacb
LC
768#endif
769
af07e104
AW
770#if @GNULIB_SECURE_GETENV@
771/* Look up NAME in the environment, returning 0 in insecure situations. */
772# if !@HAVE_SECURE_GETENV@
773_GL_FUNCDECL_SYS (secure_getenv, char *,
774 (char const *name) _GL_ARG_NONNULL ((1)));
775# endif
776_GL_CXXALIAS_SYS (secure_getenv, char *, (char const *name));
777_GL_CXXALIASWARN (secure_getenv);
778#elif defined GNULIB_POSIXCHECK
779# undef secure_getenv
780# if HAVE_RAW_DECL_SECURE_GETENV
781_GL_WARN_ON_USE (secure_getenv, "secure_getenv is unportable - "
782 "use gnulib module secure_getenv for portability");
783# endif
784#endif
785
f240aacb 786#if @GNULIB_SETENV@
f240aacb
LC
787/* Set NAME to VALUE in the environment.
788 If REPLACE is nonzero, overwrite an existing value. */
f4c79b3c
LC
789# if @REPLACE_SETENV@
790# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
791# undef setenv
792# define setenv rpl_setenv
793# endif
794_GL_FUNCDECL_RPL (setenv, int,
795 (const char *name, const char *value, int replace)
796 _GL_ARG_NONNULL ((1)));
797_GL_CXXALIAS_RPL (setenv, int,
798 (const char *name, const char *value, int replace));
799# else
ab4d62ad 800# if !@HAVE_DECL_SETENV@
f4c79b3c
LC
801_GL_FUNCDECL_SYS (setenv, int,
802 (const char *name, const char *value, int replace)
803 _GL_ARG_NONNULL ((1)));
804# endif
805_GL_CXXALIAS_SYS (setenv, int,
806 (const char *name, const char *value, int replace));
f240aacb 807# endif
ab4d62ad 808# if !(@REPLACE_SETENV@ && !@HAVE_DECL_SETENV@)
f4c79b3c 809_GL_CXXALIASWARN (setenv);
ab4d62ad 810# endif
4f02b98d
LC
811#elif defined GNULIB_POSIXCHECK
812# undef setenv
61cd9dc9
LC
813# if HAVE_RAW_DECL_SETENV
814_GL_WARN_ON_USE (setenv, "setenv is unportable - "
815 "use gnulib module setenv for portability");
816# endif
f240aacb
LC
817#endif
818
f240aacb 819#if @GNULIB_STRTOD@
f240aacb 820 /* Parse a double from STRING, updating ENDP if appropriate. */
f4c79b3c
LC
821# if @REPLACE_STRTOD@
822# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
823# define strtod rpl_strtod
824# endif
825_GL_FUNCDECL_RPL (strtod, double, (const char *str, char **endp)
826 _GL_ARG_NONNULL ((1)));
827_GL_CXXALIAS_RPL (strtod, double, (const char *str, char **endp));
828# else
829# if !@HAVE_STRTOD@
830_GL_FUNCDECL_SYS (strtod, double, (const char *str, char **endp)
831 _GL_ARG_NONNULL ((1)));
832# endif
833_GL_CXXALIAS_SYS (strtod, double, (const char *str, char **endp));
f240aacb 834# endif
f4c79b3c 835_GL_CXXALIASWARN (strtod);
f240aacb
LC
836#elif defined GNULIB_POSIXCHECK
837# undef strtod
61cd9dc9
LC
838# if HAVE_RAW_DECL_STRTOD
839_GL_WARN_ON_USE (strtod, "strtod is unportable - "
840 "use gnulib module strtod for portability");
841# endif
f240aacb
LC
842#endif
843
f240aacb 844#if @GNULIB_STRTOLL@
f240aacb
LC
845/* Parse a signed integer whose textual representation starts at STRING.
846 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
847 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
848 "0x").
849 If ENDPTR is not NULL, the address of the first byte after the integer is
850 stored in *ENDPTR.
851 Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
852 to ERANGE. */
f4c79b3c
LC
853# if !@HAVE_STRTOLL@
854_GL_FUNCDECL_SYS (strtoll, long long,
855 (const char *string, char **endptr, int base)
856 _GL_ARG_NONNULL ((1)));
f240aacb 857# endif
f4c79b3c
LC
858_GL_CXXALIAS_SYS (strtoll, long long,
859 (const char *string, char **endptr, int base));
860_GL_CXXALIASWARN (strtoll);
f240aacb
LC
861#elif defined GNULIB_POSIXCHECK
862# undef strtoll
61cd9dc9
LC
863# if HAVE_RAW_DECL_STRTOLL
864_GL_WARN_ON_USE (strtoll, "strtoll is unportable - "
865 "use gnulib module strtoll for portability");
866# endif
f240aacb
LC
867#endif
868
f240aacb 869#if @GNULIB_STRTOULL@
f240aacb
LC
870/* Parse an unsigned integer whose textual representation starts at STRING.
871 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
872 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
873 "0x").
874 If ENDPTR is not NULL, the address of the first byte after the integer is
875 stored in *ENDPTR.
876 Upon overflow, the return value is ULLONG_MAX, and errno is set to
877 ERANGE. */
f4c79b3c
LC
878# if !@HAVE_STRTOULL@
879_GL_FUNCDECL_SYS (strtoull, unsigned long long,
880 (const char *string, char **endptr, int base)
881 _GL_ARG_NONNULL ((1)));
f240aacb 882# endif
f4c79b3c
LC
883_GL_CXXALIAS_SYS (strtoull, unsigned long long,
884 (const char *string, char **endptr, int base));
885_GL_CXXALIASWARN (strtoull);
f240aacb
LC
886#elif defined GNULIB_POSIXCHECK
887# undef strtoull
61cd9dc9
LC
888# if HAVE_RAW_DECL_STRTOULL
889_GL_WARN_ON_USE (strtoull, "strtoull is unportable - "
890 "use gnulib module strtoull for portability");
891# endif
f240aacb
LC
892#endif
893
a927b6c1
LC
894#if @GNULIB_UNLOCKPT@
895/* Unlock the slave side of the pseudo-terminal whose master side is specified
896 by FD, so that it can be opened. */
897# if !@HAVE_UNLOCKPT@
898_GL_FUNCDECL_SYS (unlockpt, int, (int fd));
899# endif
900_GL_CXXALIAS_SYS (unlockpt, int, (int fd));
901_GL_CXXALIASWARN (unlockpt);
902#elif defined GNULIB_POSIXCHECK
903# undef unlockpt
904# if HAVE_RAW_DECL_UNLOCKPT
0f00f2c3 905_GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - "
a927b6c1
LC
906 "use gnulib module unlockpt for portability");
907# endif
908#endif
909
8912421c 910#if @GNULIB_UNSETENV@
8912421c 911/* Remove the variable NAME from the environment. */
f4c79b3c
LC
912# if @REPLACE_UNSETENV@
913# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
914# undef unsetenv
915# define unsetenv rpl_unsetenv
916# endif
917_GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
918_GL_CXXALIAS_RPL (unsetenv, int, (const char *name));
919# else
ab4d62ad 920# if !@HAVE_DECL_UNSETENV@
f4c79b3c
LC
921_GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
922# endif
923_GL_CXXALIAS_SYS (unsetenv, int, (const char *name));
8912421c 924# endif
ab4d62ad 925# if !(@REPLACE_UNSETENV@ && !@HAVE_DECL_UNSETENV@)
f4c79b3c 926_GL_CXXALIASWARN (unsetenv);
ab4d62ad 927# endif
4f02b98d
LC
928#elif defined GNULIB_POSIXCHECK
929# undef unsetenv
61cd9dc9
LC
930# if HAVE_RAW_DECL_UNSETENV
931_GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - "
932 "use gnulib module unsetenv for portability");
933# endif
8912421c 934#endif
f240aacb 935
dd36ce77
MW
936/* Convert a wide character to a multibyte character. */
937#if @GNULIB_WCTOMB@
938# if @REPLACE_WCTOMB@
939# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
940# undef wctomb
941# define wctomb rpl_wctomb
942# endif
943_GL_FUNCDECL_RPL (wctomb, int, (char *s, wchar_t wc));
944_GL_CXXALIAS_RPL (wctomb, int, (char *s, wchar_t wc));
945# else
946_GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc));
947# endif
948_GL_CXXALIASWARN (wctomb);
949#endif
950
f240aacb 951
3d458a81
AW
952#endif /* _@GUARD_PREFIX@_STDLIB_H */
953#endif /* _@GUARD_PREFIX@_STDLIB_H */
f240aacb 954#endif