Revert.
[gnulib.git] / 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 /* This #pragma avoids a warning with "gcc -Wall" on some glibc systems
23    on which <stdlib.h> has an inappropriate declaration, see
24    <http://sourceware.org/bugzilla/show_bug.cgi?id=1079>.  */
25 #ifdef __GNUC__
26 # pragma GCC system_header
27 #endif
28
29 #include @ABSOLUTE_STDLIB_H@
30
31 #else
32 /* Normal invocation convention.  */
33 #ifndef _GL_STDLIB_H
34 #define _GL_STDLIB_H
35
36 /* This #pragma avoids a warning with "gcc -Wall" on some glibc systems
37    on which <stdlib.h> has an inappropriate declaration, see
38    <http://sourceware.org/bugzilla/show_bug.cgi?id=1079>.  */
39 #ifdef __GNUC__
40 # pragma GCC system_header
41 #endif
42
43 #include @ABSOLUTE_STDLIB_H@
44
45
46 /* The definition of GL_LINK_WARNING is copied here.  */
47
48
49 /* Some systems do not define EXIT_*, despite otherwise supporting C89.  */
50 #ifndef EXIT_SUCCESS
51 # define EXIT_SUCCESS 0
52 #endif
53 #ifndef EXIT_FAILURE
54 # define EXIT_FAILURE 1
55 #endif
56
57
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61
62
63 #if @GNULIB_GETSUBOPT@
64 /* Assuming *OPTIONP is a comma separated list of elements of the form
65    "token" or "token=value", getsubopt parses the first of these elements.
66    If the first element refers to a "token" that is member of the given
67    NULL-terminated array of tokens:
68      - It replaces the comma with a NUL byte, updates *OPTIONP to point past
69        the first option and the comma, sets *VALUEP to the value of the
70        element (or NULL if it doesn't contain an "=" sign),
71      - It returns the index of the "token" in the given array of tokens.
72    Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
73    For more details see the POSIX:2001 specification.
74    http://www.opengroup.org/susv3xsh/getsubopt.html */
75 # if !@HAVE_GETSUBOPT@
76 extern int getsubopt (char **optionp, char *const *tokens, char **valuep);
77 # endif
78 #elif defined GNULIB_POSIXCHECK
79 # undef getsubopt
80 # define getsubopt(o,t,v) \
81     (GL_LINK_WARNING ("getsubopt is unportable - " \
82                       "use gnulib module getsubopt for portability"), \
83      getsubopt (o, t, v))
84 #endif
85
86
87 #if @GNULIB_MKDTEMP@
88 # if !@HAVE_MKDTEMP@
89 /* Create a unique temporary directory from TEMPLATE.
90    The last six characters of TEMPLATE must be "XXXXXX";
91    they are replaced with a string that makes the directory name unique.
92    Returns TEMPLATE, or a null pointer if it cannot get a unique name.
93    The directory is created mode 700.  */
94 extern char * mkdtemp (char *template);
95 # endif
96 #elif defined GNULIB_POSIXCHECK
97 # undef mkdtemp
98 # define mkdtemp(t) \
99     (GL_LINK_WARNING ("mkdtemp is unportable - " \
100                       "use gnulib module mkdtemp for portability"), \
101      mkdtemp (t))
102 #endif
103
104
105 #if @GNULIB_MKSTEMP@
106 # if @REPLACE_MKSTEMP@
107 /* Create a unique temporary file from TEMPLATE.
108    The last six characters of TEMPLATE must be "XXXXXX";
109    they are replaced with a string that makes the file name unique.
110    The file is then created, ensuring it didn't exist before.
111    The file is created read-write (mask at least 0600 & ~umask), but it may be
112    world-readable and world-writable (mask 0666 & ~umask), depending on the
113    implementation.
114    Returns the open file descriptor if successful, otherwise -1 and errno
115    set.  */
116 #  define mkstemp rpl_mkstemp
117 extern int mkstemp (char *template);
118 # endif
119 #elif defined GNULIB_POSIXCHECK
120 # undef mkstemp
121 # define mkstemp(t) \
122     (GL_LINK_WARNING ("mkstemp is unportable - " \
123                       "use gnulib module mkstemp for portability"), \
124      mkstemp (t))
125 #endif
126
127
128 #ifdef __cplusplus
129 }
130 #endif
131
132 #endif /* _GL_STDLIB_H */
133 #endif