libstdc++
|
00001 // -*- C++ -*- forwarding header. 00002 00003 // Copyright (C) 1997-2019 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 #if __cplusplus >= 201703L && defined(_GLIBCXX_HAVE_ALIGNED_ALLOC) 00082 # undef aligned_alloc 00083 #endif 00084 #undef atexit 00085 #if __cplusplus >= 201103L 00086 # ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT 00087 # undef at_quick_exit 00088 # endif 00089 #endif 00090 #undef atof 00091 #undef atoi 00092 #undef atol 00093 #undef bsearch 00094 #undef calloc 00095 #undef div 00096 #undef exit 00097 #undef free 00098 #undef getenv 00099 #undef labs 00100 #undef ldiv 00101 #undef malloc 00102 #undef mblen 00103 #undef mbstowcs 00104 #undef mbtowc 00105 #undef qsort 00106 #if __cplusplus >= 201103L 00107 # ifdef _GLIBCXX_HAVE_QUICK_EXIT 00108 # undef quick_exit 00109 # endif 00110 #endif 00111 #undef rand 00112 #undef realloc 00113 #undef srand 00114 #undef strtod 00115 #undef strtol 00116 #undef strtoul 00117 #undef system 00118 #undef wcstombs 00119 #undef wctomb 00120 00121 extern "C++" 00122 { 00123 namespace std _GLIBCXX_VISIBILITY(default) 00124 { 00125 _GLIBCXX_BEGIN_NAMESPACE_VERSION 00126 00127 using ::div_t; 00128 using ::ldiv_t; 00129 00130 using ::abort; 00131 #if __cplusplus >= 201703L && defined(_GLIBCXX_HAVE_ALIGNED_ALLOC) 00132 using ::aligned_alloc; 00133 #endif 00134 using ::atexit; 00135 #if __cplusplus >= 201103L 00136 # ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT 00137 using ::at_quick_exit; 00138 # endif 00139 #endif 00140 using ::atof; 00141 using ::atoi; 00142 using ::atol; 00143 using ::bsearch; 00144 using ::calloc; 00145 using ::div; 00146 using ::exit; 00147 using ::free; 00148 using ::getenv; 00149 using ::labs; 00150 using ::ldiv; 00151 using ::malloc; 00152 #ifdef _GLIBCXX_HAVE_MBSTATE_T 00153 using ::mblen; 00154 using ::mbstowcs; 00155 using ::mbtowc; 00156 #endif // _GLIBCXX_HAVE_MBSTATE_T 00157 using ::qsort; 00158 #if __cplusplus >= 201103L 00159 # ifdef _GLIBCXX_HAVE_QUICK_EXIT 00160 using ::quick_exit; 00161 # endif 00162 #endif 00163 using ::rand; 00164 using ::realloc; 00165 using ::srand; 00166 using ::strtod; 00167 using ::strtol; 00168 using ::strtoul; 00169 using ::system; 00170 #ifdef _GLIBCXX_USE_WCHAR_T 00171 using ::wcstombs; 00172 using ::wctomb; 00173 #endif // _GLIBCXX_USE_WCHAR_T 00174 00175 #ifndef __CORRECT_ISO_CPP_STDLIB_H_PROTO 00176 inline ldiv_t 00177 div(long __i, long __j) { return ldiv(__i, __j); } 00178 #endif 00179 00180 00181 _GLIBCXX_END_NAMESPACE_VERSION 00182 } // namespace 00183 00184 #if _GLIBCXX_USE_C99_STDLIB 00185 00186 #undef _Exit 00187 #undef llabs 00188 #undef lldiv 00189 #undef atoll 00190 #undef strtoll 00191 #undef strtoull 00192 #undef strtof 00193 #undef strtold 00194 00195 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) 00196 { 00197 _GLIBCXX_BEGIN_NAMESPACE_VERSION 00198 00199 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC 00200 using ::lldiv_t; 00201 #endif 00202 #if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC 00203 extern "C" void (_Exit)(int) throw () _GLIBCXX_NORETURN; 00204 #endif 00205 #if !_GLIBCXX_USE_C99_DYNAMIC 00206 using ::_Exit; 00207 #endif 00208 00209 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC 00210 using ::llabs; 00211 00212 inline lldiv_t 00213 div(long long __n, long long __d) 00214 { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; } 00215 00216 using ::lldiv; 00217 #endif 00218 00219 #if _GLIBCXX_USE_C99_LONG_LONG_CHECK || _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC 00220 extern "C" long long int (atoll)(const char *) throw (); 00221 extern "C" long long int 00222 (strtoll)(const char * __restrict, char ** __restrict, int) throw (); 00223 extern "C" unsigned long long int 00224 (strtoull)(const char * __restrict, char ** __restrict, int) throw (); 00225 #endif 00226 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC 00227 using ::atoll; 00228 using ::strtoll; 00229 using ::strtoull; 00230 #endif 00231 using ::strtof; 00232 using ::strtold; 00233 00234 _GLIBCXX_END_NAMESPACE_VERSION 00235 } // namespace __gnu_cxx 00236 00237 namespace std 00238 { 00239 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC 00240 using ::__gnu_cxx::lldiv_t; 00241 #endif 00242 using ::__gnu_cxx::_Exit; 00243 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC 00244 using ::__gnu_cxx::llabs; 00245 using ::__gnu_cxx::div; 00246 using ::__gnu_cxx::lldiv; 00247 #endif 00248 using ::__gnu_cxx::atoll; 00249 using ::__gnu_cxx::strtof; 00250 using ::__gnu_cxx::strtoll; 00251 using ::__gnu_cxx::strtoull; 00252 using ::__gnu_cxx::strtold; 00253 } // namespace std 00254 00255 #endif // _GLIBCXX_USE_C99_STDLIB 00256 00257 } // extern "C++" 00258 00259 #endif // !_GLIBCXX_HOSTED 00260 00261 #endif