Add strtoull() declaration to <stdlib.h>.
[gnulib.git] / lib / stdlib.in.h
1 /* A GNU-like <stdlib.h>.
2
3    Copyright (C) 1995, 2001-2004, 2006-2008 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 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 General Public License for more details.
14
15    You should have received a copy of the GNU 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
38
39 /* Solaris declares getloadavg() in <sys/loadavg.h>.  */
40 #if @GNULIB_GETLOADAVG@ && @HAVE_SYS_LOADAVG_H@
41 # include <sys/loadavg.h>
42 #endif
43
44 /* The definition of GL_LINK_WARNING is copied here.  */
45
46
47 /* Some systems do not define EXIT_*, despite otherwise supporting C89.  */
48 #ifndef EXIT_SUCCESS
49 # define EXIT_SUCCESS 0
50 #endif
51 /* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere
52    with proper operation of xargs.  */
53 #ifndef EXIT_FAILURE
54 # define EXIT_FAILURE 1
55 #elif EXIT_FAILURE != 1
56 # undef EXIT_FAILURE
57 # define EXIT_FAILURE 1
58 #endif
59
60
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64
65
66 #if @GNULIB_MALLOC_POSIX@
67 # if !@HAVE_MALLOC_POSIX@
68 #  undef malloc
69 #  define malloc rpl_malloc
70 extern void * malloc (size_t size);
71 # endif
72 #elif defined GNULIB_POSIXCHECK
73 # undef malloc
74 # define malloc(s) \
75     (GL_LINK_WARNING ("malloc is not POSIX compliant everywhere - " \
76                       "use gnulib module malloc-posix for portability"), \
77      malloc (s))
78 #endif
79
80
81 #if @GNULIB_REALLOC_POSIX@
82 # if !@HAVE_REALLOC_POSIX@
83 #  undef realloc
84 #  define realloc rpl_realloc
85 extern void * realloc (void *ptr, size_t size);
86 # endif
87 #elif defined GNULIB_POSIXCHECK
88 # undef realloc
89 # define realloc(p,s) \
90     (GL_LINK_WARNING ("realloc is not POSIX compliant everywhere - " \
91                       "use gnulib module realloc-posix for portability"), \
92      realloc (p, s))
93 #endif
94
95
96 #if @GNULIB_CALLOC_POSIX@
97 # if !@HAVE_CALLOC_POSIX@
98 #  undef calloc
99 #  define calloc rpl_calloc
100 extern void * calloc (size_t nmemb, size_t size);
101 # endif
102 #elif defined GNULIB_POSIXCHECK
103 # undef calloc
104 # define calloc(n,s) \
105     (GL_LINK_WARNING ("calloc is not POSIX compliant everywhere - " \
106                       "use gnulib module calloc-posix for portability"), \
107      calloc (n, s))
108 #endif
109
110
111 #if @GNULIB_GETLOADAVG@
112 # if !@HAVE_DECL_GETLOADAVG@
113 /* Store max(NELEM,3) load average numbers in LOADAVG[].
114    The three numbers are the load average of the last 1 minute, the last 5
115    minutes, and the last 15 minutes, respectively.
116    LOADAVG is an array of NELEM numbers.  */
117 extern int getloadavg (double loadavg[], int nelem);
118 # endif
119 #elif defined GNULIB_POSIXCHECK
120 # undef getloadavg
121 # define getloadavg(l,n) \
122     (GL_LINK_WARNING ("getloadavg is not portable - " \
123                       "use gnulib module getloadavg for portability"), \
124      getloadavg (l, n))
125 #endif
126
127
128 #if @GNULIB_GETSUBOPT@
129 /* Assuming *OPTIONP is a comma separated list of elements of the form
130    "token" or "token=value", getsubopt parses the first of these elements.
131    If the first element refers to a "token" that is member of the given
132    NULL-terminated array of tokens:
133      - It replaces the comma with a NUL byte, updates *OPTIONP to point past
134        the first option and the comma, sets *VALUEP to the value of the
135        element (or NULL if it doesn't contain an "=" sign),
136      - It returns the index of the "token" in the given array of tokens.
137    Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
138    For more details see the POSIX:2001 specification.
139    http://www.opengroup.org/susv3xsh/getsubopt.html */
140 # if !@HAVE_GETSUBOPT@
141 extern int getsubopt (char **optionp, char *const *tokens, char **valuep);
142 # endif
143 #elif defined GNULIB_POSIXCHECK
144 # undef getsubopt
145 # define getsubopt(o,t,v) \
146     (GL_LINK_WARNING ("getsubopt is unportable - " \
147                       "use gnulib module getsubopt for portability"), \
148      getsubopt (o, t, v))
149 #endif
150
151
152 #if @GNULIB_MKDTEMP@
153 # if !@HAVE_MKDTEMP@
154 /* Create a unique temporary directory from TEMPLATE.
155    The last six characters of TEMPLATE must be "XXXXXX";
156    they are replaced with a string that makes the directory name unique.
157    Returns TEMPLATE, or a null pointer if it cannot get a unique name.
158    The directory is created mode 700.  */
159 extern char * mkdtemp (char * /*template*/);
160 # endif
161 #elif defined GNULIB_POSIXCHECK
162 # undef mkdtemp
163 # define mkdtemp(t) \
164     (GL_LINK_WARNING ("mkdtemp is unportable - " \
165                       "use gnulib module mkdtemp for portability"), \
166      mkdtemp (t))
167 #endif
168
169
170 #if @GNULIB_MKSTEMP@
171 # if @REPLACE_MKSTEMP@
172 /* Create a unique temporary file from TEMPLATE.
173    The last six characters of TEMPLATE must be "XXXXXX";
174    they are replaced with a string that makes the file name unique.
175    The file is then created, ensuring it didn't exist before.
176    The file is created read-write (mask at least 0600 & ~umask), but it may be
177    world-readable and world-writable (mask 0666 & ~umask), depending on the
178    implementation.
179    Returns the open file descriptor if successful, otherwise -1 and errno
180    set.  */
181 #  define mkstemp rpl_mkstemp
182 extern int mkstemp (char * /*template*/);
183 # else
184 /* On MacOS X 10.3, only <unistd.h> declares mkstemp.  */
185 #  include <unistd.h>
186 # endif
187 #elif defined GNULIB_POSIXCHECK
188 # undef mkstemp
189 # define mkstemp(t) \
190     (GL_LINK_WARNING ("mkstemp is unportable - " \
191                       "use gnulib module mkstemp for portability"), \
192      mkstemp (t))
193 #endif
194
195
196 #if @GNULIB_PUTENV@
197 # if @REPLACE_PUTENV@
198 #  undef putenv
199 #  define putenv rpl_putenv
200 extern int putenv (char *string);
201 # endif
202 #endif
203
204
205 #if @GNULIB_RPMATCH@
206 # if !@HAVE_RPMATCH@
207 /* Test a user response to a question.
208    Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear.  */
209 extern int rpmatch (const char *response);
210 # endif
211 #elif defined GNULIB_POSIXCHECK
212 # undef rpmatch
213 # define rpmatch(r) \
214     (GL_LINK_WARNING ("rpmatch is unportable - " \
215                       "use gnulib module rpmatch for portability"), \
216      rpmatch (r))
217 #endif
218
219
220 #if @GNULIB_SETENV@
221 # if !@HAVE_SETENV@
222 /* Set NAME to VALUE in the environment.
223    If REPLACE is nonzero, overwrite an existing value.  */
224 extern int setenv (const char *name, const char *value, int replace);
225 # endif
226 #endif
227
228
229 #if @GNULIB_UNSETENV@
230 # if @HAVE_UNSETENV@
231 #  if @VOID_UNSETENV@
232 /* On some systems, unsetenv() returns void.
233    This is the case for MacOS X 10.3, FreeBSD 4.8, NetBSD 1.6, OpenBSD 3.4.  */
234 #   define unsetenv(name) ((unsetenv)(name), 0)
235 #  endif
236 # else
237 /* Remove the variable NAME from the environment.  */
238 extern int unsetenv (const char *name);
239 # endif
240 #endif
241
242
243 #if @GNULIB_STRTOD@
244 # if @REPLACE_STRTOD@
245 #  define strtod rpl_strtod
246 # endif
247 # if !@HAVE_STRTOD@ || @REPLACE_STRTOD@
248  /* Parse a double from STRING, updating ENDP if appropriate.  */
249 extern double strtod (const char *str, char **endp);
250 # endif
251 #elif defined GNULIB_POSIXCHECK
252 # undef strtod
253 # define strtod(s, e)                           \
254     (GL_LINK_WARNING ("strtod is unportable - " \
255                       "use gnulib module strtod for portability"), \
256      strtod (s, e))
257 #endif
258
259
260 #if @GNULIB_STRTOLL@
261 # if !@HAVE_STRTOLL@
262 /* Parse a signed integer whose textual representation starts at STRING.
263    The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
264    it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
265    "0x").
266    If ENDPTR is not NULL, the address of the first byte after the integer is
267    stored in *ENDPTR.
268    Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
269    to ERANGE.  */
270 extern long long strtoll (const char *string, char **endptr, int base);
271 # endif
272 #elif defined GNULIB_POSIXCHECK
273 # undef strtoll
274 # define strtoll(s,e,b) \
275     (GL_LINK_WARNING ("strtoll is unportable - " \
276                       "use gnulib module strtoll for portability"), \
277      strtoll (s, e, b))
278 #endif
279
280
281 #if @GNULIB_STRTOULL@
282 # if !@HAVE_STRTOULL@
283 /* Parse an unsigned integer whose textual representation starts at STRING.
284    The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
285    it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
286    "0x").
287    If ENDPTR is not NULL, the address of the first byte after the integer is
288    stored in *ENDPTR.
289    Upon overflow, the return value is ULLONG_MAX, and errno is set to
290    ERANGE.  */
291 extern unsigned long long strtoull (const char *string, char **endptr, int base);
292 # endif
293 #elif defined GNULIB_POSIXCHECK
294 # undef strtoull
295 # define strtoull(s,e,b) \
296     (GL_LINK_WARNING ("strtoull is unportable - " \
297                       "use gnulib module strtoull for portability"), \
298      strtoull (s, e, b))
299 #endif
300
301
302 #ifdef __cplusplus
303 }
304 #endif
305
306 #endif /* _GL_STDLIB_H */
307 #endif /* _GL_STDLIB_H */
308 #endif