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