* lib/fcntl_.h: Prefer #include_next <foo.h> to #include
[pspp] / lib / stdlib_.h
1 /* A GNU-like <stdlib.h>.
2
3    Copyright (C) 1995, 2001-2002, 2006-2007 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 2, or (at your option)
8    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, write to the Free Software Foundation,
17    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
18
19 #if defined __need_malloc_and_calloc
20 /* Special invocation convention inside glibc header files.  */
21
22 #if @HAVE_INCLUDE_NEXT@
23 # include_next <stdlib.h>
24 #else
25 # include @ABSOLUTE_STDLIB_H@
26 #endif
27
28 #else
29 /* Normal invocation convention.  */
30
31 #if @HAVE_INCLUDE_NEXT@
32 # include_next <stdlib.h>
33 #endif
34
35 #ifndef _GL_STDLIB_H
36 #define _GL_STDLIB_H
37
38 #if ! @HAVE_INCLUDE_NEXT@
39 # include @ABSOLUTE_STDLIB_H@
40 #endif
41
42
43 /* The definition of GL_LINK_WARNING is copied here.  */
44
45
46 /* Some systems do not define EXIT_*, despite otherwise supporting C89.  */
47 #ifndef EXIT_SUCCESS
48 # define EXIT_SUCCESS 0
49 #endif
50 /* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere
51    with proper operation of xargs.  */
52 #ifndef EXIT_FAILURE
53 # define EXIT_FAILURE 1
54 #elif EXIT_FAILURE != 1
55 # undef EXIT_FAILURE
56 # define EXIT_FAILURE 1
57 #endif
58
59
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63
64
65 #if @GNULIB_GETSUBOPT@
66 /* Assuming *OPTIONP is a comma separated list of elements of the form
67    "token" or "token=value", getsubopt parses the first of these elements.
68    If the first element refers to a "token" that is member of the given
69    NULL-terminated array of tokens:
70      - It replaces the comma with a NUL byte, updates *OPTIONP to point past
71        the first option and the comma, sets *VALUEP to the value of the
72        element (or NULL if it doesn't contain an "=" sign),
73      - It returns the index of the "token" in the given array of tokens.
74    Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
75    For more details see the POSIX:2001 specification.
76    http://www.opengroup.org/susv3xsh/getsubopt.html */
77 # if !@HAVE_GETSUBOPT@
78 extern int getsubopt (char **optionp, char *const *tokens, char **valuep);
79 # endif
80 #elif defined GNULIB_POSIXCHECK
81 # undef getsubopt
82 # define getsubopt(o,t,v) \
83     (GL_LINK_WARNING ("getsubopt is unportable - " \
84                       "use gnulib module getsubopt for portability"), \
85      getsubopt (o, t, v))
86 #endif
87
88
89 #if @GNULIB_MKDTEMP@
90 # if !@HAVE_MKDTEMP@
91 /* Create a unique temporary directory from TEMPLATE.
92    The last six characters of TEMPLATE must be "XXXXXX";
93    they are replaced with a string that makes the directory name unique.
94    Returns TEMPLATE, or a null pointer if it cannot get a unique name.
95    The directory is created mode 700.  */
96 extern char * mkdtemp (char * /*template*/);
97 # endif
98 #elif defined GNULIB_POSIXCHECK
99 # undef mkdtemp
100 # define mkdtemp(t) \
101     (GL_LINK_WARNING ("mkdtemp is unportable - " \
102                       "use gnulib module mkdtemp for portability"), \
103      mkdtemp (t))
104 #endif
105
106
107 #if @GNULIB_MKSTEMP@
108 # if @REPLACE_MKSTEMP@
109 /* Create a unique temporary file from TEMPLATE.
110    The last six characters of TEMPLATE must be "XXXXXX";
111    they are replaced with a string that makes the file name unique.
112    The file is then created, ensuring it didn't exist before.
113    The file is created read-write (mask at least 0600 & ~umask), but it may be
114    world-readable and world-writable (mask 0666 & ~umask), depending on the
115    implementation.
116    Returns the open file descriptor if successful, otherwise -1 and errno
117    set.  */
118 #  define mkstemp rpl_mkstemp
119 extern int mkstemp (char * /*template*/);
120 # else
121 /* On MacOS X 10.3, only <unistd.h> declares mkstemp.  */
122 #  include <unistd.h>
123 # endif
124 #elif defined GNULIB_POSIXCHECK
125 # undef mkstemp
126 # define mkstemp(t) \
127     (GL_LINK_WARNING ("mkstemp is unportable - " \
128                       "use gnulib module mkstemp for portability"), \
129      mkstemp (t))
130 #endif
131
132
133 #ifdef __cplusplus
134 }
135 #endif
136
137 #endif /* _GL_STDLIB_H */
138 #endif