00001 /* A GNU-like <stdlib.h>. 00002 00003 Copyright (C) 1995, 2001-2002, 2006-2007 Free Software Foundation, Inc. 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2, or (at your option) 00008 any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software Foundation, 00017 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 00018 00019 #if defined __need_malloc_and_calloc 00020 /* Special invocation convention inside glibc header files. */ 00021 00022 /* This #pragma avoids a warning with "gcc -Wall" on some glibc systems 00023 on which <stdlib.h> has an inappropriate declaration, see 00024 <http://sourceware.org/bugzilla/show_bug.cgi?id=1079>. */ 00025 #ifdef __GNUC__ 00026 # pragma GCC system_header 00027 #endif 00028 00029 #include @ABSOLUTE_STDLIB_H@ 00030 00031 #else 00032 /* Normal invocation convention. */ 00033 00034 #ifdef __DECC 00035 # include_next <stdlib.h> 00036 #endif 00037 00038 #ifndef _GL_STDLIB_H 00039 #define _GL_STDLIB_H 00040 00041 /* This #pragma avoids a warning with "gcc -Wall" on some glibc systems 00042 on which <stdlib.h> has an inappropriate declaration, see 00043 <http://sourceware.org/bugzilla/show_bug.cgi?id=1079>. */ 00044 #ifdef __GNUC__ 00045 # pragma GCC system_header 00046 #endif 00047 00048 #ifndef __DECC 00049 # include @ABSOLUTE_STDLIB_H@ 00050 #endif 00051 00052 00053 /* The definition of GL_LINK_WARNING is copied here. */ 00054 00055 00056 /* Some systems do not define EXIT_*, despite otherwise supporting C89. */ 00057 #ifndef EXIT_SUCCESS 00058 # define EXIT_SUCCESS 0 00059 #endif 00060 /* Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere 00061 with proper operation of xargs. */ 00062 #ifndef EXIT_FAILURE 00063 # define EXIT_FAILURE 1 00064 #elif EXIT_FAILURE != 1 00065 # undef EXIT_FAILURE 00066 # define EXIT_FAILURE 1 00067 #endif 00068 00069 00070 #ifdef __cplusplus 00071 extern "C" { 00072 #endif 00073 00074 00075 #if @GNULIB_GETSUBOPT@ 00076 /* Assuming *OPTIONP is a comma separated list of elements of the form 00077 "token" or "token=value", getsubopt parses the first of these elements. 00078 If the first element refers to a "token" that is member of the given 00079 NULL-terminated array of tokens: 00080 - It replaces the comma with a NUL byte, updates *OPTIONP to point past 00081 the first option and the comma, sets *VALUEP to the value of the 00082 element (or NULL if it doesn't contain an "=" sign), 00083 - It returns the index of the "token" in the given array of tokens. 00084 Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined. 00085 For more details see the POSIX:2001 specification. 00086 http://www.opengroup.org/susv3xsh/getsubopt.html */ 00087 # if !@HAVE_GETSUBOPT@ 00088 extern int getsubopt (char **optionp, char *const *tokens, char **valuep); 00089 # endif 00090 #elif defined GNULIB_POSIXCHECK 00091 # undef getsubopt 00092 # define getsubopt(o,t,v) \ 00093 (GL_LINK_WARNING ("getsubopt is unportable - " \ 00094 "use gnulib module getsubopt for portability"), \ 00095 getsubopt (o, t, v)) 00096 #endif 00097 00098 00099 #if @GNULIB_MKDTEMP@ 00100 # if !@HAVE_MKDTEMP@ 00101 /* Create a unique temporary directory from TEMPLATE. 00102 The last six characters of TEMPLATE must be "XXXXXX"; 00103 they are replaced with a string that makes the directory name unique. 00104 Returns TEMPLATE, or a null pointer if it cannot get a unique name. 00105 The directory is created mode 700. */ 00106 extern char * mkdtemp (char *template); 00107 # endif 00108 #elif defined GNULIB_POSIXCHECK 00109 # undef mkdtemp 00110 # define mkdtemp(t) \ 00111 (GL_LINK_WARNING ("mkdtemp is unportable - " \ 00112 "use gnulib module mkdtemp for portability"), \ 00113 mkdtemp (t)) 00114 #endif 00115 00116 00117 #if @GNULIB_MKSTEMP@ 00118 # if @REPLACE_MKSTEMP@ 00119 /* Create a unique temporary file from TEMPLATE. 00120 The last six characters of TEMPLATE must be "XXXXXX"; 00121 they are replaced with a string that makes the file name unique. 00122 The file is then created, ensuring it didn't exist before. 00123 The file is created read-write (mask at least 0600 & ~umask), but it may be 00124 world-readable and world-writable (mask 0666 & ~umask), depending on the 00125 implementation. 00126 Returns the open file descriptor if successful, otherwise -1 and errno 00127 set. */ 00128 # define mkstemp rpl_mkstemp 00129 extern int mkstemp (char *template); 00130 # else 00131 /* On MacOS X 10.3, only <unistd.h> declares mkstemp. */ 00132 # include <unistd.h> 00133 # endif 00134 #elif defined GNULIB_POSIXCHECK 00135 # undef mkstemp 00136 # define mkstemp(t) \ 00137 (GL_LINK_WARNING ("mkstemp is unportable - " \ 00138 "use gnulib module mkstemp for portability"), \ 00139 mkstemp (t)) 00140 #endif 00141 00142 00143 #ifdef __cplusplus 00144 } 00145 #endif 00146 00147 #endif /* _GL_STDLIB_H */ 00148 #endif