Avoid some "gcc -pedantic" warnings.
[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 @PRAGMA_SYSTEM_HEADER@
19
20 #if defined __need_malloc_and_calloc
21 /* Special invocation convention inside glibc header files.  */
22
23 #@INCLUDE_NEXT@ @NEXT_STDLIB_H@
24
25 #else
26 /* Normal invocation convention.  */
27
28 #ifndef _GL_STDLIB_H
29
30 /* The include_next requires a split double-inclusion guard.  */
31 #@INCLUDE_NEXT@ @NEXT_STDLIB_H@
32
33 #ifndef _GL_STDLIB_H
34 #define _GL_STDLIB_H
35
36
37 /* The definition of GL_LINK_WARNING is copied here.  */
38
39
40 /* Some systems do not define EXIT_*, despite otherwise supporting C89.  */
41 #ifndef EXIT_SUCCESS
42 # define EXIT_SUCCESS 0
43 #endif
44 /* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere
45    with proper operation of xargs.  */
46 #ifndef EXIT_FAILURE
47 # define EXIT_FAILURE 1
48 #elif EXIT_FAILURE != 1
49 # undef EXIT_FAILURE
50 # define EXIT_FAILURE 1
51 #endif
52
53
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57
58
59 #if @GNULIB_MALLOC_POSIX@
60 # if !@HAVE_MALLOC_POSIX@
61 #  undef malloc
62 #  define malloc rpl_malloc
63 extern void * malloc (size_t size);
64 # endif
65 #elif defined GNULIB_POSIXCHECK
66 # undef malloc
67 # define malloc(s) \
68     (GL_LINK_WARNING ("malloc is not POSIX compliant everywhere - " \
69                       "use gnulib module malloc-posix for portability"), \
70      malloc (s))
71 #endif
72
73
74 #if @GNULIB_REALLOC_POSIX@
75 # if !@HAVE_REALLOC_POSIX@
76 #  undef realloc
77 #  define realloc rpl_realloc
78 extern void * realloc (void *ptr, size_t size);
79 # endif
80 #elif defined GNULIB_POSIXCHECK
81 # undef realloc
82 # define realloc(p,s) \
83     (GL_LINK_WARNING ("realloc is not POSIX compliant everywhere - " \
84                       "use gnulib module realloc-posix for portability"), \
85      realloc (p, s))
86 #endif
87
88
89 #if @GNULIB_CALLOC_POSIX@
90 # if !@HAVE_CALLOC_POSIX@
91 #  undef calloc
92 #  define calloc rpl_calloc
93 extern void * calloc (size_t nmemb, size_t size);
94 # endif
95 #elif defined GNULIB_POSIXCHECK
96 # undef calloc
97 # define calloc(n,s) \
98     (GL_LINK_WARNING ("calloc is not POSIX compliant everywhere - " \
99                       "use gnulib module calloc-posix for portability"), \
100      calloc (n, s))
101 #endif
102
103
104 #if @GNULIB_GETSUBOPT@
105 /* Assuming *OPTIONP is a comma separated list of elements of the form
106    "token" or "token=value", getsubopt parses the first of these elements.
107    If the first element refers to a "token" that is member of the given
108    NULL-terminated array of tokens:
109      - It replaces the comma with a NUL byte, updates *OPTIONP to point past
110        the first option and the comma, sets *VALUEP to the value of the
111        element (or NULL if it doesn't contain an "=" sign),
112      - It returns the index of the "token" in the given array of tokens.
113    Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
114    For more details see the POSIX:2001 specification.
115    http://www.opengroup.org/susv3xsh/getsubopt.html */
116 # if !@HAVE_GETSUBOPT@
117 extern int getsubopt (char **optionp, char *const *tokens, char **valuep);
118 # endif
119 #elif defined GNULIB_POSIXCHECK
120 # undef getsubopt
121 # define getsubopt(o,t,v) \
122     (GL_LINK_WARNING ("getsubopt is unportable - " \
123                       "use gnulib module getsubopt for portability"), \
124      getsubopt (o, t, v))
125 #endif
126
127
128 #if @GNULIB_MKDTEMP@
129 # if !@HAVE_MKDTEMP@
130 /* Create a unique temporary directory from TEMPLATE.
131    The last six characters of TEMPLATE must be "XXXXXX";
132    they are replaced with a string that makes the directory name unique.
133    Returns TEMPLATE, or a null pointer if it cannot get a unique name.
134    The directory is created mode 700.  */
135 extern char * mkdtemp (char * /*template*/);
136 # endif
137 #elif defined GNULIB_POSIXCHECK
138 # undef mkdtemp
139 # define mkdtemp(t) \
140     (GL_LINK_WARNING ("mkdtemp is unportable - " \
141                       "use gnulib module mkdtemp for portability"), \
142      mkdtemp (t))
143 #endif
144
145
146 #if @GNULIB_MKSTEMP@
147 # if @REPLACE_MKSTEMP@
148 /* Create a unique temporary file from TEMPLATE.
149    The last six characters of TEMPLATE must be "XXXXXX";
150    they are replaced with a string that makes the file name unique.
151    The file is then created, ensuring it didn't exist before.
152    The file is created read-write (mask at least 0600 & ~umask), but it may be
153    world-readable and world-writable (mask 0666 & ~umask), depending on the
154    implementation.
155    Returns the open file descriptor if successful, otherwise -1 and errno
156    set.  */
157 #  define mkstemp rpl_mkstemp
158 extern int mkstemp (char * /*template*/);
159 # else
160 /* On MacOS X 10.3, only <unistd.h> declares mkstemp.  */
161 #  include <unistd.h>
162 # endif
163 #elif defined GNULIB_POSIXCHECK
164 # undef mkstemp
165 # define mkstemp(t) \
166     (GL_LINK_WARNING ("mkstemp is unportable - " \
167                       "use gnulib module mkstemp for portability"), \
168      mkstemp (t))
169 #endif
170
171
172 #if @GNULIB_PUTENV@
173 # if @REPLACE_PUTENV@
174 #  undef putenv
175 #  define putenv rpl_putenv
176 extern int putenv (char *string);
177 # endif
178 #endif
179
180
181 #if @GNULIB_RPMATCH@
182 # if !@HAVE_RPMATCH@
183 /* Test a user response to a question.
184    Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear.  */
185 extern int rpmatch (const char *response);
186 # endif
187 #elif defined GNULIB_POSIXCHECK
188 # undef rpmatch
189 # define rpmatch(r) \
190     (GL_LINK_WARNING ("rpmatch is unportable - " \
191                       "use gnulib module rpmatch for portability"), \
192      rpmatch (r))
193 #endif
194
195
196 #if @GNULIB_SETENV@
197 # if !@HAVE_SETENV@
198 /* Set NAME to VALUE in the environment.
199    If REPLACE is nonzero, overwrite an existing value.  */
200 extern int setenv (const char *name, const char *value, int replace);
201 # endif
202 #endif
203
204
205 #if @GNULIB_UNSETENV@
206 # if @HAVE_UNSETENV@
207 #  if @VOID_UNSETENV@
208 /* On some systems, unsetenv() returns void.
209    This is the case for MacOS X 10.3, FreeBSD 4.8, NetBSD 1.6, OpenBSD 3.4.  */
210 #   define unsetenv(name) ((unsetenv)(name), 0)
211 #  endif
212 # else
213 /* Remove the variable NAME from the environment.  */
214 extern int unsetenv (const char *name);
215 # endif
216 #endif
217
218
219 #if @GNULIB_STRTOD@
220 # if @REPLACE_STRTOD@
221 #  define strtod rpl_strtod
222 # endif
223 # if !@HAVE_STRTOD@ || @REPLACE_STRTOD@
224  /* Parse a double from STRING, updating ENDP if appropriate.  */
225 extern double strtod (const char *str, char **endp);
226 # endif
227 #elif defined GNULIB_POSIXCHECK
228 # undef strtod
229 # define strtod(s, e)                           \
230     (GL_LINK_WARNING ("strtod is unportable - " \
231                       "use gnulib module strtod for portability"), \
232      strtod (s, e))
233 #endif
234
235
236 #ifdef __cplusplus
237 }
238 #endif
239
240 #endif /* _GL_STDLIB_H */
241 #endif /* _GL_STDLIB_H */
242 #endif