cstdlib

Go to the documentation of this file.
00001 // -*- C++ -*- forwarding header.
00002 
00003 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
00004 // 2006, 2007
00005 // Free Software Foundation, Inc.
00006 //
00007 // This file is part of the GNU ISO C++ Library.  This library is free
00008 // software; you can redistribute it and/or modify it under the
00009 // terms of the GNU General Public License as published by the
00010 // Free Software Foundation; either version 2, or (at your option)
00011 // any later version.
00012 
00013 // This library is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 
00018 // You should have received a copy of the GNU General Public License
00019 // along with this library; see the file COPYING.  If not, write to
00020 // the Free Software Foundation, 51 Franklin Street, Fifth Floor,
00021 // Boston, MA 02110-1301, USA.
00022 
00023 // As a special exception, you may use this file as part of a free software
00024 // library without restriction.  Specifically, if other files instantiate
00025 // templates or use macros or inline functions from this file, or you compile
00026 // this file and link it with other files to produce an executable, this
00027 // file does not by itself cause the resulting executable to be covered by
00028 // the GNU General Public License.  This exception does not however
00029 // invalidate any other reasons why the executable file might be covered by
00030 // the GNU General Public License.
00031 
00032 /** @file include/cstdlib
00033  *  This is a Standard C++ Library file.  You should @c #include this file
00034  *  in your programs, rather than any of the "*.h" implementation files.
00035  *
00036  *  This is the C++ version of the Standard C Library header @c stdlib.h,
00037  *  and its contents are (mostly) the same as that header, but are all
00038  *  contained in the namespace @c std (except for names which are defined
00039  *  as macros in C).
00040  */
00041 
00042 //
00043 // ISO C++ 14882: 20.4.6  C library
00044 //
00045 
00046 #pragma GCC system_header
00047 
00048 #include <bits/c++config.h>
00049 #include <cstddef>
00050 
00051 #ifndef _GLIBCXX_CSTDLIB
00052 #define _GLIBCXX_CSTDLIB 1
00053 
00054 #if !_GLIBCXX_HOSTED
00055 // The C standard does not require a freestanding implementation to
00056 // provide <stdlib.h>.  However, the C++ standard does still require
00057 // <cstdlib> -- but only the functionality mentioned in
00058 // [lib.support.start.term].
00059 
00060 #define EXIT_SUCCESS 0
00061 #define EXIT_FAILURE 1
00062 
00063 _GLIBCXX_BEGIN_NAMESPACE(std)
00064 
00065   extern "C" void abort(void);
00066   extern "C" int atexit(void (*)());
00067   extern "C" void exit(int);
00068 
00069 _GLIBCXX_END_NAMESPACE
00070 
00071 #else
00072 
00073 #include_next <stdlib.h>
00074 
00075 // Get rid of those macros defined in <stdlib.h> in lieu of real functions.
00076 #undef abort
00077 #undef abs
00078 #undef atexit
00079 #undef atof
00080 #undef atoi
00081 #undef atol
00082 #undef bsearch
00083 #undef calloc
00084 #undef div
00085 #undef exit
00086 #undef free
00087 #undef getenv
00088 #undef labs
00089 #undef ldiv
00090 #undef malloc
00091 #undef mblen
00092 #undef mbstowcs
00093 #undef mbtowc
00094 #undef qsort
00095 #undef rand
00096 #undef realloc
00097 #undef srand
00098 #undef strtod
00099 #undef strtol
00100 #undef strtoul
00101 #undef system
00102 #undef wcstombs
00103 #undef wctomb
00104 
00105 _GLIBCXX_BEGIN_NAMESPACE(std)
00106 
00107   using ::div_t;
00108   using ::ldiv_t;
00109 
00110   using ::abort;
00111   using ::abs;
00112   using ::atexit;
00113   using ::atof;
00114   using ::atoi;
00115   using ::atol;
00116   using ::bsearch;
00117   using ::calloc;
00118   using ::div;
00119   using ::exit;
00120   using ::free;
00121   using ::getenv;
00122   using ::labs;
00123   using ::ldiv;
00124   using ::malloc;
00125 #ifdef _GLIBCXX_HAVE_MBSTATE_T
00126   using ::mblen;
00127   using ::mbstowcs;
00128   using ::mbtowc;
00129 #endif // _GLIBCXX_HAVE_MBSTATE_T
00130   using ::qsort;
00131   using ::rand;
00132   using ::realloc;
00133   using ::srand;
00134   using ::strtod;
00135   using ::strtol;
00136   using ::strtoul;
00137   using ::system;
00138 #ifdef _GLIBCXX_USE_WCHAR_T
00139   using ::wcstombs;
00140   using ::wctomb;
00141 #endif // _GLIBCXX_USE_WCHAR_T
00142 
00143   inline long
00144   abs(long __i) { return labs(__i); }
00145 
00146   inline ldiv_t
00147   div(long __i, long __j) { return ldiv(__i, __j); }
00148 
00149 _GLIBCXX_END_NAMESPACE
00150 
00151 #if _GLIBCXX_USE_C99
00152 
00153 #undef _Exit
00154 #undef llabs
00155 #undef lldiv
00156 #undef atoll
00157 #undef strtoll
00158 #undef strtoull
00159 #undef strtof
00160 #undef strtold
00161 
00162 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
00163 
00164 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
00165   using ::lldiv_t;
00166 #endif
00167 #if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC
00168   extern "C" void (_Exit)(int);
00169 #endif
00170 #if !_GLIBCXX_USE_C99_DYNAMIC
00171   using ::_Exit;
00172 #endif
00173 
00174   inline long long
00175   abs(long long __x) { return __x >= 0 ? __x : -__x; }
00176 
00177 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
00178   using ::llabs;
00179 
00180   inline lldiv_t
00181   div(long long __n, long long __d)
00182   { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
00183 
00184   using ::lldiv;
00185 #endif
00186 
00187 #if _GLIBCXX_USE_C99_LONG_LONG_CHECK || _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
00188   extern "C" long long int (atoll)(const char *);
00189   extern "C" long long int
00190     (strtoll)(const char * restrict, char ** restrict, int);
00191   extern "C" unsigned long long int
00192     (strtoull)(const char * restrict, char ** restrict, int);
00193 #endif
00194 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
00195   using ::atoll;
00196   using ::strtoll;
00197   using ::strtoull;
00198 #endif
00199   using ::strtof;
00200   using ::strtold;
00201 
00202 _GLIBCXX_END_NAMESPACE
00203 
00204 _GLIBCXX_BEGIN_NAMESPACE(std)
00205 
00206 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
00207   using ::__gnu_cxx::lldiv_t;
00208 #endif
00209   using ::__gnu_cxx::_Exit;
00210   using ::__gnu_cxx::abs;
00211 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
00212   using ::__gnu_cxx::llabs;
00213   using ::__gnu_cxx::div;
00214   using ::__gnu_cxx::lldiv;
00215 #endif
00216   using ::__gnu_cxx::atoll;
00217   using ::__gnu_cxx::strtof;
00218   using ::__gnu_cxx::strtoll;
00219   using ::__gnu_cxx::strtoull;
00220   using ::__gnu_cxx::strtold;
00221 
00222 _GLIBCXX_END_NAMESPACE
00223 
00224 #endif // _GLIBCXX_USE_C99
00225 
00226 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00227 #  if defined(_GLIBCXX_INCLUDE_AS_TR1)
00228 #    error C++0x header cannot be included from TR1 header
00229 #  endif
00230 #  if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
00231 #    include <tr1_impl/cstdlib>
00232 #  else
00233 #    define _GLIBCXX_INCLUDE_AS_CXX0X
00234 #    define _GLIBCXX_BEGIN_NAMESPACE_TR1
00235 #    define _GLIBCXX_END_NAMESPACE_TR1
00236 #    define _GLIBCXX_TR1
00237 #    include <tr1_impl/cstdlib>
00238 #    undef _GLIBCXX_TR1
00239 #    undef _GLIBCXX_END_NAMESPACE_TR1
00240 #    undef _GLIBCXX_BEGIN_NAMESPACE_TR1
00241 #    undef _GLIBCXX_INCLUDE_AS_CXX0X
00242 #  endif
00243 #endif
00244 
00245 #endif // !_GLIBCXX_HOSTED
00246 
00247 #endif

Generated on Wed Mar 26 00:42:56 2008 for libstdc++ by  doxygen 1.5.1