libstdc++
|
00001 // -*- C++ -*- forwarding header. 00002 00003 // Copyright (C) 1997-2017 Free Software Foundation, Inc. 00004 // 00005 // This file is part of the GNU ISO C++ Library. This library is free 00006 // software; you can redistribute it and/or modify it under the 00007 // terms of the GNU General Public License as published by the 00008 // Free Software Foundation; either version 3, or (at your option) 00009 // any later version. 00010 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 00016 // Under Section 7 of GPL version 3, you are granted additional 00017 // permissions described in the GCC Runtime Library Exception, version 00018 // 3.1, as published by the Free Software Foundation. 00019 00020 // You should have received a copy of the GNU General Public License and 00021 // a copy of the GCC Runtime Library Exception along with this program; 00022 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 00023 // <http://www.gnu.org/licenses/>. 00024 00025 /** @file include/cstdlib 00026 * This is a Standard C++ Library file. You should @c \#include this file 00027 * in your programs, rather than any of the @a *.h implementation files. 00028 * 00029 * This is the C++ version of the Standard C Library header @c stdlib.h, 00030 * and its contents are (mostly) the same as that header, but are all 00031 * contained in the namespace @c std (except for names which are defined 00032 * as macros in C). 00033 */ 00034 00035 // 00036 // ISO C++ 14882: 20.4.6 C library 00037 // 00038 00039 #pragma GCC system_header 00040 00041 #include <bits/c++config.h> 00042 00043 #ifndef _GLIBCXX_CSTDLIB 00044 #define _GLIBCXX_CSTDLIB 1 00045 00046 #if !_GLIBCXX_HOSTED 00047 // The C standard does not require a freestanding implementation to 00048 // provide <stdlib.h>. However, the C++ standard does still require 00049 // <cstdlib> -- but only the functionality mentioned in 00050 // [lib.support.start.term]. 00051 00052 #define EXIT_SUCCESS 0 00053 #define EXIT_FAILURE 1 00054 00055 namespace std 00056 { 00057 extern "C" void abort(void) throw () _GLIBCXX_NORETURN; 00058 extern "C" int atexit(void (*)(void)) throw (); 00059 extern "C" void exit(int) throw () _GLIBCXX_NORETURN; 00060 #if __cplusplus >= 201103L 00061 # ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT 00062 extern "C" int at_quick_exit(void (*)(void)) throw (); 00063 # endif 00064 # ifdef _GLIBCXX_HAVE_QUICK_EXIT 00065 extern "C" void quick_exit(int) throw() _GLIBCXX_NORETURN; 00066 # endif 00067 #endif 00068 } // namespace std 00069 00070 #else 00071 00072 // Need to ensure this finds the C library's <stdlib.h> not a libstdc++ 00073 // wrapper that might already be installed later in the include search path. 00074 #define _GLIBCXX_INCLUDE_NEXT_C_HEADERS 00075 #include_next <stdlib.h> 00076 #undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS 00077 #include <bits/std_abs.h> 00078 00079 // Get rid of those macros defined in <stdlib.h> in lieu of real functions. 00080 #undef abort 00081 #undef atexit 00082 #if __cplusplus >= 201103L 00083 # ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT 00084 # undef at_quick_exit 00085 # endif 00086 #endif 00087 #undef atof 00088 #undef atoi 00089 #undef atol 00090 #undef bsearch 00091 #undef calloc 00092 #undef div 00093 #undef exit 00094 #undef free 00095 #undef getenv 00096 #undef labs 00097 #undef ldiv 00098 #undef malloc 00099 #undef mblen 00100 #undef mbstowcs 00101 #undef mbtowc 00102 #undef qsort 00103 #if __cplusplus >= 201103L 00104 # ifdef _GLIBCXX_HAVE_QUICK_EXIT 00105 # undef quick_exit 00106 # endif 00107 #endif 00108 #undef rand 00109 #undef realloc 00110 #undef srand 00111 #undef strtod 00112 #undef strtol 00113 #undef strtoul 00114 #undef system 00115 #undef wcstombs 00116 #undef wctomb 00117 00118 extern "C++" 00119 { 00120 namespace std _GLIBCXX_VISIBILITY(default) 00121 { 00122 _GLIBCXX_BEGIN_NAMESPACE_VERSION 00123 00124 using ::div_t; 00125 using ::ldiv_t; 00126 00127 using ::abort; 00128 using ::atexit; 00129 #if __cplusplus >= 201103L 00130 # ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT 00131 using ::at_quick_exit; 00132 # endif 00133 #endif 00134 using ::atof; 00135 using ::atoi; 00136 using ::atol; 00137 using ::bsearch; 00138 using ::calloc; 00139 using ::div; 00140 using ::exit; 00141 using ::free; 00142 using ::getenv; 00143 using ::labs; 00144 using ::ldiv; 00145 using ::malloc; 00146 #ifdef _GLIBCXX_HAVE_MBSTATE_T 00147 using ::mblen; 00148 using ::mbstowcs; 00149 using ::mbtowc; 00150 #endif // _GLIBCXX_HAVE_MBSTATE_T 00151 using ::qsort; 00152 #if __cplusplus >= 201103L 00153 # ifdef _GLIBCXX_HAVE_QUICK_EXIT 00154 using ::quick_exit; 00155 # endif 00156 #endif 00157 using ::rand; 00158 using ::realloc; 00159 using ::srand; 00160 using ::strtod; 00161 using ::strtol; 00162 using ::strtoul; 00163 using ::system; 00164 #ifdef _GLIBCXX_USE_WCHAR_T 00165 using ::wcstombs; 00166 using ::wctomb; 00167 #endif // _GLIBCXX_USE_WCHAR_T 00168 00169 #ifndef __CORRECT_ISO_CPP_STDLIB_H_PROTO 00170 inline ldiv_t 00171 div(long __i, long __j) { return ldiv(__i, __j); } 00172 #endif 00173 00174 00175 _GLIBCXX_END_NAMESPACE_VERSION 00176 } // namespace 00177 00178 #if _GLIBCXX_USE_C99_STDLIB 00179 00180 #undef _Exit 00181 #undef llabs 00182 #undef lldiv 00183 #undef atoll 00184 #undef strtoll 00185 #undef strtoull 00186 #undef strtof 00187 #undef strtold 00188 00189 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) 00190 { 00191 _GLIBCXX_BEGIN_NAMESPACE_VERSION 00192 00193 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC 00194 using ::lldiv_t; 00195 #endif 00196 #if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC 00197 extern "C" void (_Exit)(int) throw () _GLIBCXX_NORETURN; 00198 #endif 00199 #if !_GLIBCXX_USE_C99_DYNAMIC 00200 using ::_Exit; 00201 #endif 00202 00203 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC 00204 using ::llabs; 00205 00206 inline lldiv_t 00207 div(long long __n, long long __d) 00208 { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; } 00209 00210 using ::lldiv; 00211 #endif 00212 00213 #if _GLIBCXX_USE_C99_LONG_LONG_CHECK || _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC 00214 extern "C" long long int (atoll)(const char *) throw (); 00215 extern "C" long long int 00216 (strtoll)(const char * __restrict, char ** __restrict, int) throw (); 00217 extern "C" unsigned long long int 00218 (strtoull)(const char * __restrict, char ** __restrict, int) throw (); 00219 #endif 00220 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC 00221 using ::atoll; 00222 using ::strtoll; 00223 using ::strtoull; 00224 #endif 00225 using ::strtof; 00226 using ::strtold; 00227 00228 _GLIBCXX_END_NAMESPACE_VERSION 00229 } // namespace __gnu_cxx 00230 00231 namespace std 00232 { 00233 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC 00234 using ::__gnu_cxx::lldiv_t; 00235 #endif 00236 using ::__gnu_cxx::_Exit; 00237 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC 00238 using ::__gnu_cxx::llabs; 00239 using ::__gnu_cxx::div; 00240 using ::__gnu_cxx::lldiv; 00241 #endif 00242 using ::__gnu_cxx::atoll; 00243 using ::__gnu_cxx::strtof; 00244 using ::__gnu_cxx::strtoll; 00245 using ::__gnu_cxx::strtoull; 00246 using ::__gnu_cxx::strtold; 00247 } // namespace std 00248 00249 #endif // _GLIBCXX_USE_C99_STDLIB 00250 00251 } // extern "C++" 00252 00253 #endif // !_GLIBCXX_HOSTED 00254 00255 #endif