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