Add Gnulib maintainer modules.
[bpt/guile.git] / lib / stdlib.in.h
CommitLineData
f240aacb
LC
1/* A GNU-like <stdlib.h>.
2
3 Copyright (C) 1995, 2001-2004, 2006-2009 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18#if __GNUC__ >= 3
19@PRAGMA_SYSTEM_HEADER@
20#endif
21
22#if defined __need_malloc_and_calloc
23/* Special invocation convention inside glibc header files. */
24
25#@INCLUDE_NEXT@ @NEXT_STDLIB_H@
26
27#else
28/* Normal invocation convention. */
29
30#ifndef _GL_STDLIB_H
31
32/* The include_next requires a split double-inclusion guard. */
33#@INCLUDE_NEXT@ @NEXT_STDLIB_H@
34
35#ifndef _GL_STDLIB_H
36#define _GL_STDLIB_H
37
8912421c
LC
38/* NetBSD 5.0 mis-defines NULL. */
39#include <stddef.h>
f240aacb
LC
40
41/* Solaris declares getloadavg() in <sys/loadavg.h>. */
42#if @GNULIB_GETLOADAVG@ && @HAVE_SYS_LOADAVG_H@
43# include <sys/loadavg.h>
44#endif
45
46/* OSF/1 5.1 declares 'struct random_data' in <random.h>, which is included
47 from <stdlib.h> if _REENTRANT is defined. Include it always. */
48#if @HAVE_RANDOM_H@
49# include <random.h>
50#endif
51
52#if @GNULIB_RANDOM_R@ || !@HAVE_STRUCT_RANDOM_DATA@
53# include <stdint.h>
54#endif
55
56#if !@HAVE_STRUCT_RANDOM_DATA@
57struct random_data
58{
59 int32_t *fptr; /* Front pointer. */
60 int32_t *rptr; /* Rear pointer. */
61 int32_t *state; /* Array of state values. */
62 int rand_type; /* Type of random number generator. */
63 int rand_deg; /* Degree of random number generator. */
64 int rand_sep; /* Distance between front and rear. */
65 int32_t *end_ptr; /* Pointer behind state table. */
66};
67#endif
68
69/* The definition of GL_LINK_WARNING is copied here. */
70
71
72/* Some systems do not define EXIT_*, despite otherwise supporting C89. */
73#ifndef EXIT_SUCCESS
74# define EXIT_SUCCESS 0
75#endif
76/* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere
77 with proper operation of xargs. */
78#ifndef EXIT_FAILURE
79# define EXIT_FAILURE 1
80#elif EXIT_FAILURE != 1
81# undef EXIT_FAILURE
82# define EXIT_FAILURE 1
83#endif
84
85
86#ifdef __cplusplus
87extern "C" {
88#endif
89
8912421c
LC
90#if @GNULIB_ATOLL@
91# if !@HAVE_ATOLL@
92/* Parse a signed decimal integer.
93 Returns the value of the integer. Errors are not detected. */
94extern long long atoll (const char *string);
f240aacb
LC
95# endif
96#elif defined GNULIB_POSIXCHECK
8912421c
LC
97# undef atoll
98# define atoll(s) \
99 (GL_LINK_WARNING ("atoll is unportable - " \
100 "use gnulib module atoll for portability"), \
101 atoll (s))
f240aacb
LC
102#endif
103
f240aacb
LC
104#if @GNULIB_CALLOC_POSIX@
105# if !@HAVE_CALLOC_POSIX@
106# undef calloc
107# define calloc rpl_calloc
108extern void * calloc (size_t nmemb, size_t size);
109# endif
110#elif defined GNULIB_POSIXCHECK
111# undef calloc
112# define calloc(n,s) \
113 (GL_LINK_WARNING ("calloc is not POSIX compliant everywhere - " \
114 "use gnulib module calloc-posix for portability"), \
115 calloc (n, s))
116#endif
117
8912421c
LC
118#if @GNULIB_CANONICALIZE_FILE_NAME@
119# if @REPLACE_CANONICALIZE_FILE_NAME@
120# define canonicalize_file_name rpl_canonicalize_file_name
121# endif
122# if !@HAVE_CANONICALIZE_FILE_NAME@ || @REPLACE_CANONICALIZE_FILE_NAME@
123extern char *canonicalize_file_name (const char *name);
f240aacb
LC
124# endif
125#elif defined GNULIB_POSIXCHECK
8912421c
LC
126# undef canonicalize_file_name
127# define canonicalize_file_name(n) \
128 (GL_LINK_WARNING ("canonicalize_file_name is unportable - " \
129 "use gnulib module canonicalize-lgpl for portability"), \
130 canonicalize_file_name (n))
f240aacb
LC
131#endif
132
f240aacb
LC
133#if @GNULIB_GETLOADAVG@
134# if !@HAVE_DECL_GETLOADAVG@
135/* Store max(NELEM,3) load average numbers in LOADAVG[].
136 The three numbers are the load average of the last 1 minute, the last 5
137 minutes, and the last 15 minutes, respectively.
138 LOADAVG is an array of NELEM numbers. */
139extern int getloadavg (double loadavg[], int nelem);
140# endif
141#elif defined GNULIB_POSIXCHECK
142# undef getloadavg
143# define getloadavg(l,n) \
144 (GL_LINK_WARNING ("getloadavg is not portable - " \
145 "use gnulib module getloadavg for portability"), \
146 getloadavg (l, n))
147#endif
148
f240aacb
LC
149#if @GNULIB_GETSUBOPT@
150/* Assuming *OPTIONP is a comma separated list of elements of the form
151 "token" or "token=value", getsubopt parses the first of these elements.
152 If the first element refers to a "token" that is member of the given
153 NULL-terminated array of tokens:
154 - It replaces the comma with a NUL byte, updates *OPTIONP to point past
155 the first option and the comma, sets *VALUEP to the value of the
156 element (or NULL if it doesn't contain an "=" sign),
157 - It returns the index of the "token" in the given array of tokens.
158 Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
159 For more details see the POSIX:2001 specification.
160 http://www.opengroup.org/susv3xsh/getsubopt.html */
161# if !@HAVE_GETSUBOPT@
162extern int getsubopt (char **optionp, char *const *tokens, char **valuep);
163# endif
164#elif defined GNULIB_POSIXCHECK
165# undef getsubopt
166# define getsubopt(o,t,v) \
167 (GL_LINK_WARNING ("getsubopt is unportable - " \
168 "use gnulib module getsubopt for portability"), \
169 getsubopt (o, t, v))
170#endif
171
8912421c
LC
172#if @GNULIB_MALLOC_POSIX@
173# if !@HAVE_MALLOC_POSIX@
174# undef malloc
175# define malloc rpl_malloc
176extern void * malloc (size_t size);
177# endif
178#elif defined GNULIB_POSIXCHECK
179# undef malloc
180# define malloc(s) \
181 (GL_LINK_WARNING ("malloc is not POSIX compliant everywhere - " \
182 "use gnulib module malloc-posix for portability"), \
183 malloc (s))
184#endif
f240aacb
LC
185
186#if @GNULIB_MKDTEMP@
187# if !@HAVE_MKDTEMP@
188/* Create a unique temporary directory from TEMPLATE.
189 The last six characters of TEMPLATE must be "XXXXXX";
190 they are replaced with a string that makes the directory name unique.
191 Returns TEMPLATE, or a null pointer if it cannot get a unique name.
192 The directory is created mode 700. */
193extern char * mkdtemp (char * /*template*/);
194# endif
195#elif defined GNULIB_POSIXCHECK
196# undef mkdtemp
197# define mkdtemp(t) \
198 (GL_LINK_WARNING ("mkdtemp is unportable - " \
199 "use gnulib module mkdtemp for portability"), \
200 mkdtemp (t))
201#endif
202
8912421c
LC
203#if @GNULIB_MKOSTEMP@
204# if !@HAVE_MKOSTEMP@
205/* Create a unique temporary file from TEMPLATE.
206 The last six characters of TEMPLATE must be "XXXXXX";
207 they are replaced with a string that makes the file name unique.
208 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
209 and O_TEXT, O_BINARY (defined in "binary-io.h").
210 The file is then created, with the specified flags, ensuring it didn't exist
211 before.
212 The file is created read-write (mask at least 0600 & ~umask), but it may be
213 world-readable and world-writable (mask 0666 & ~umask), depending on the
214 implementation.
215 Returns the open file descriptor if successful, otherwise -1 and errno
216 set. */
217extern int mkostemp (char * /*template*/, int /*flags*/);
218# endif
219#elif defined GNULIB_POSIXCHECK
220# undef mkostemp
221# define mkostemp(t,f) \
222 (GL_LINK_WARNING ("mkostemp is unportable - " \
223 "use gnulib module mkostemp for portability"), \
224 mkostemp (t, f))
225#endif
f240aacb 226
f29ded4b
LC
227#if @GNULIB_MKOSTEMPS@
228# if !@HAVE_MKOSTEMPS@
229/* Create a unique temporary file from TEMPLATE.
230 The last six characters of TEMPLATE before a suffix of length
231 SUFFIXLEN must be "XXXXXX";
232 they are replaced with a string that makes the file name unique.
233 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
234 and O_TEXT, O_BINARY (defined in "binary-io.h").
235 The file is then created, with the specified flags, ensuring it didn't exist
236 before.
237 The file is created read-write (mask at least 0600 & ~umask), but it may be
238 world-readable and world-writable (mask 0666 & ~umask), depending on the
239 implementation.
240 Returns the open file descriptor if successful, otherwise -1 and errno
241 set. */
242extern int mkostemps (char * /*template*/, int /*suffixlen*/, int /*flags*/);
243# endif
244#elif defined GNULIB_POSIXCHECK
245# undef mkostemps
246# define mkostemps(t,s,f) \
247 (GL_LINK_WARNING ("mkostemps is unportable - " \
248 "use gnulib module mkostemps for portability"), \
249 mkostemps (t, s, f))
250#endif
251
f240aacb
LC
252#if @GNULIB_MKSTEMP@
253# if @REPLACE_MKSTEMP@
254/* Create a unique temporary file from TEMPLATE.
255 The last six characters of TEMPLATE must be "XXXXXX";
256 they are replaced with a string that makes the file name unique.
257 The file is then created, ensuring it didn't exist before.
258 The file is created read-write (mask at least 0600 & ~umask), but it may be
259 world-readable and world-writable (mask 0666 & ~umask), depending on the
260 implementation.
261 Returns the open file descriptor if successful, otherwise -1 and errno
262 set. */
263# define mkstemp rpl_mkstemp
264extern int mkstemp (char * /*template*/);
265# else
266/* On MacOS X 10.3, only <unistd.h> declares mkstemp. */
267# include <unistd.h>
268# endif
269#elif defined GNULIB_POSIXCHECK
270# undef mkstemp
271# define mkstemp(t) \
272 (GL_LINK_WARNING ("mkstemp is unportable - " \
273 "use gnulib module mkstemp for portability"), \
274 mkstemp (t))
275#endif
276
f29ded4b
LC
277#if @GNULIB_MKSTEMPS@
278# if !@HAVE_MKSTEMPS@
279/* Create a unique temporary file from TEMPLATE.
280 The last six characters of TEMPLATE prior to a suffix of length
281 SUFFIXLEN must be "XXXXXX";
282 they are replaced with a string that makes the file name unique.
283 The file is then created, ensuring it didn't exist before.
284 The file is created read-write (mask at least 0600 & ~umask), but it may be
285 world-readable and world-writable (mask 0666 & ~umask), depending on the
286 implementation.
287 Returns the open file descriptor if successful, otherwise -1 and errno
288 set. */
289extern int mkstemps (char * /*template*/, int /*suffixlen*/);
290# endif
291#elif defined GNULIB_POSIXCHECK
292# undef mkstemps
293# define mkstemps(t,s) \
294 (GL_LINK_WARNING ("mkstemps is unportable - " \
295 "use gnulib module mkstemps for portability"), \
296 mkstemps (t, s))
297#endif
298
f240aacb
LC
299#if @GNULIB_PUTENV@
300# if @REPLACE_PUTENV@
301# undef putenv
302# define putenv rpl_putenv
303extern int putenv (char *string);
304# endif
305#endif
306
f240aacb
LC
307#if @GNULIB_RANDOM_R@
308# if !@HAVE_RANDOM_R@
309
310# ifndef RAND_MAX
311# define RAND_MAX 2147483647
312# endif
313
314int srandom_r (unsigned int seed, struct random_data *rand_state);
315int initstate_r (unsigned int seed, char *buf, size_t buf_size,
316 struct random_data *rand_state);
317int setstate_r (char *arg_state, struct random_data *rand_state);
318int random_r (struct random_data *buf, int32_t *result);
319# endif
320#elif defined GNULIB_POSIXCHECK
321# undef random_r
322# define random_r(b,r) \
323 (GL_LINK_WARNING ("random_r is unportable - " \
324 "use gnulib module random_r for portability"), \
325 random_r (b,r))
326# undef initstate_r
327# define initstate_r(s,b,sz,r) \
328 (GL_LINK_WARNING ("initstate_r is unportable - " \
329 "use gnulib module random_r for portability"), \
330 initstate_r (s,b,sz,r))
331# undef srandom_r
332# define srandom_r(s,r) \
333 (GL_LINK_WARNING ("srandom_r is unportable - " \
334 "use gnulib module random_r for portability"), \
335 srandom_r (s,r))
336# undef setstate_r
337# define setstate_r(a,r) \
338 (GL_LINK_WARNING ("setstate_r is unportable - " \
339 "use gnulib module random_r for portability"), \
340 setstate_r (a,r))
341#endif
342
8912421c
LC
343#if @GNULIB_REALLOC_POSIX@
344# if !@HAVE_REALLOC_POSIX@
345# undef realloc
346# define realloc rpl_realloc
347extern void * realloc (void *ptr, size_t size);
348# endif
349#elif defined GNULIB_POSIXCHECK
350# undef realloc
351# define realloc(p,s) \
352 (GL_LINK_WARNING ("realloc is not POSIX compliant everywhere - " \
353 "use gnulib module realloc-posix for portability"), \
354 realloc (p, s))
355#endif
356
357#if @GNULIB_REALPATH@
358# if @REPLACE_REALPATH@
359# define realpath rpl_realpath
360# endif
361# if !@HAVE_REALPATH@ || @REPLACE_REALPATH@
362extern char *realpath (const char *name, char *resolved);
363# endif
364#elif defined GNULIB_POSIXCHECK
365# undef realpath
366# define realpath(n,r) \
367 (GL_LINK_WARNING ("realpath is unportable - use gnulib module " \
368 "canonicalize or canonicalize-lgpl for portability"), \
369 realpath (n, r))
370#endif
f240aacb
LC
371
372#if @GNULIB_RPMATCH@
373# if !@HAVE_RPMATCH@
374/* Test a user response to a question.
375 Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
376extern int rpmatch (const char *response);
377# endif
378#elif defined GNULIB_POSIXCHECK
379# undef rpmatch
380# define rpmatch(r) \
381 (GL_LINK_WARNING ("rpmatch is unportable - " \
382 "use gnulib module rpmatch for portability"), \
383 rpmatch (r))
384#endif
385
f240aacb 386#if @GNULIB_SETENV@
4f02b98d
LC
387# if @REPLACE_SETENV@
388# undef setenv
389# define setenv rpl_setenv
390# endif
391# if !@HAVE_SETENV@ || @REPLACE_SETENV@
f240aacb
LC
392/* Set NAME to VALUE in the environment.
393 If REPLACE is nonzero, overwrite an existing value. */
394extern int setenv (const char *name, const char *value, int replace);
395# endif
4f02b98d
LC
396#elif defined GNULIB_POSIXCHECK
397# undef setenv
398# define setenv(n,v,o) \
399 (GL_LINK_WARNING ("setenv is unportable - " \
400 "use gnulib module setenv for portability"), \
401 setenv (n, v, o))
f240aacb
LC
402#endif
403
f240aacb
LC
404#if @GNULIB_STRTOD@
405# if @REPLACE_STRTOD@
406# define strtod rpl_strtod
407# endif
408# if !@HAVE_STRTOD@ || @REPLACE_STRTOD@
409 /* Parse a double from STRING, updating ENDP if appropriate. */
410extern double strtod (const char *str, char **endp);
411# endif
412#elif defined GNULIB_POSIXCHECK
413# undef strtod
414# define strtod(s, e) \
415 (GL_LINK_WARNING ("strtod is unportable - " \
416 "use gnulib module strtod for portability"), \
417 strtod (s, e))
418#endif
419
f240aacb
LC
420#if @GNULIB_STRTOLL@
421# if !@HAVE_STRTOLL@
422/* Parse a signed integer whose textual representation starts at STRING.
423 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
424 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
425 "0x").
426 If ENDPTR is not NULL, the address of the first byte after the integer is
427 stored in *ENDPTR.
428 Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
429 to ERANGE. */
430extern long long strtoll (const char *string, char **endptr, int base);
431# endif
432#elif defined GNULIB_POSIXCHECK
433# undef strtoll
434# define strtoll(s,e,b) \
435 (GL_LINK_WARNING ("strtoll is unportable - " \
436 "use gnulib module strtoll for portability"), \
437 strtoll (s, e, b))
438#endif
439
f240aacb
LC
440#if @GNULIB_STRTOULL@
441# if !@HAVE_STRTOULL@
442/* Parse an unsigned integer whose textual representation starts at STRING.
443 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
444 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
445 "0x").
446 If ENDPTR is not NULL, the address of the first byte after the integer is
447 stored in *ENDPTR.
448 Upon overflow, the return value is ULLONG_MAX, and errno is set to
449 ERANGE. */
450extern unsigned long long strtoull (const char *string, char **endptr, int base);
451# endif
452#elif defined GNULIB_POSIXCHECK
453# undef strtoull
454# define strtoull(s,e,b) \
455 (GL_LINK_WARNING ("strtoull is unportable - " \
456 "use gnulib module strtoull for portability"), \
457 strtoull (s, e, b))
458#endif
459
8912421c 460#if @GNULIB_UNSETENV@
4f02b98d
LC
461# if @REPLACE_UNSETENV@
462# undef unsetenv
463# define unsetenv rpl_unsetenv
464# endif
465# if !@HAVE_UNSETENV@ || @REPLACE_UNSETENV@
8912421c
LC
466/* Remove the variable NAME from the environment. */
467extern int unsetenv (const char *name);
468# endif
4f02b98d
LC
469#elif defined GNULIB_POSIXCHECK
470# undef unsetenv
471# define unsetenv(n) \
472 (GL_LINK_WARNING ("unsetenv is unportable - " \
473 "use gnulib module unsetenv for portability"), \
474 unsetenv (n))
8912421c 475#endif
f240aacb
LC
476
477#ifdef __cplusplus
478}
479#endif
480
481#endif /* _GL_STDLIB_H */
482#endif /* _GL_STDLIB_H */
483#endif