Work around an ugly glibc hack.
[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 #include @ABSOLUTE_STDLIB_H@
22 #else
23 /* Normal invocation convention.  */
24 #ifndef _GL_STDLIB_H
25 #define _GL_STDLIB_H
26
27 #include @ABSOLUTE_STDLIB_H@
28
29
30 /* The definition of GL_LINK_WARNING is copied here.  */
31
32
33 /* Some systems do not define EXIT_*, despite otherwise supporting C89.  */
34 #ifndef EXIT_SUCCESS
35 # define EXIT_SUCCESS 0
36 #endif
37 #ifndef EXIT_FAILURE
38 # define EXIT_FAILURE 1
39 #endif
40
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46
47 #if @GNULIB_MKDTEMP@
48 # if !@HAVE_MKDTEMP@
49 /* Create a unique temporary directory from TEMPLATE.
50    The last six characters of TEMPLATE must be "XXXXXX";
51    they are replaced with a string that makes the directory name unique.
52    Returns TEMPLATE, or a null pointer if it cannot get a unique name.
53    The directory is created mode 700.  */
54 extern char * mkdtemp (char *template);
55 # endif
56 #elif defined GNULIB_POSIXCHECK
57 # undef mkdtemp
58 # define mkdtemp(t) \
59     (GL_LINK_WARNING ("mkdtemp is unportable - "\
60                       "use gnulib module mkdtemp for portability"), \
61      mkdtemp (t))
62 #endif
63
64 #if @GNULIB_MKSTEMP@
65 # if @REPLACE_MKSTEMP@
66 /* Create a unique temporary file from TEMPLATE.
67    The last six characters of TEMPLATE must be "XXXXXX";
68    they are replaced with a string that makes the file name unique.
69    The file is then created, ensuring it didn't exist before.
70    The file is created read-write (mask at least 0600 & ~umask), but it may be
71    world-readable and world-writable (mask 0666 & ~umask), depending on the
72    implementation.
73    Returns the open file descriptor if successful, otherwise -1 and errno
74    set.  */
75 #  define mkstemp rpl_mkstemp
76 extern int mkstemp (char *template);
77 # endif
78 #elif defined GNULIB_POSIXCHECK
79 # undef mkstemp
80 # define mkstemp(t) \
81     (GL_LINK_WARNING ("mkstemp is unportable - "\
82                       "use gnulib module mkstemp for portability"), \
83      mkstemp (t))
84 #endif
85
86
87 #ifdef __cplusplus
88 }
89 #endif
90
91 #endif /* _GL_STDLIB_H */
92 #endif