std_cstdlib.h revision 97403
1// -*- C++ -*- forwarding header. 2 3// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 4// Free Software Foundation, Inc. 5// 6// This file is part of the GNU ISO C++ Library. This library is free 7// software; you can redistribute it and/or modify it under the 8// terms of the GNU General Public License as published by the 9// Free Software Foundation; either version 2, or (at your option) 10// any later version. 11 12// This library is distributed in the hope that it will be useful, 13// but WITHOUT ANY WARRANTY; without even the implied warranty of 14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15// GNU General Public License for more details. 16 17// You should have received a copy of the GNU General Public License along 18// with this library; see the file COPYING. If not, write to the Free 19// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 20// USA. 21 22// As a special exception, you may use this file as part of a free software 23// library without restriction. Specifically, if other files instantiate 24// templates or use macros or inline functions from this file, or you compile 25// this file and link it with other files to produce an executable, this 26// file does not by itself cause the resulting executable to be covered by 27// the GNU General Public License. This exception does not however 28// invalidate any other reasons why the executable file might be covered by 29// the GNU General Public License. 30 31// 32// ISO C++ 14882: 20.4.6 C library 33// 34 35/** @file cstdlib 36 * This is a Standard C++ Library file. You should @c #include this file 37 * in your programs, rather than any of the "*.h" implementation files. 38 * 39 * This is the C++ version of the Standard C Library header @c stdlib.h, 40 * and its contents are (mostly) the same as that header, but are all 41 * contained in the namespace @c std. 42 */ 43 44#ifndef _CPP_CSTDLIB 45#define _CPP_CSTDLIB 1 46 47#pragma GCC system_header 48 49#include <bits/c++config.h> 50#include <cstddef> 51 52#include <stdlib.h> 53 54// Get rid of those macros defined in <stdlib.h> in lieu of real functions. 55#undef abort 56#undef abs 57#undef atexit 58#undef atof 59#undef atoi 60#undef atol 61#undef bsearch 62#undef calloc 63#undef div 64#undef exit 65#undef free 66#undef getenv 67#undef labs 68#undef ldiv 69#undef malloc 70#undef mblen 71#undef mbstowcs 72#undef mbtowc 73#undef qsort 74#undef rand 75#undef realloc 76#undef srand 77#undef strtod 78#undef strtol 79#undef strtoul 80#undef system 81#undef wcstombs 82#undef wctomb 83 84namespace std 85{ 86 using ::div_t; 87 using ::ldiv_t; 88 89 using ::abort; 90 using ::abs; 91 using ::atexit; 92 using ::atof; 93 using ::atoi; 94 using ::atol; 95 using ::bsearch; 96 using ::calloc; 97 using ::div; 98 using ::exit; 99 using ::free; 100 using ::getenv; 101 using ::labs; 102 using ::ldiv; 103 using ::malloc; 104 using ::mblen; 105 using ::mbstowcs; 106 using ::mbtowc; 107 using ::qsort; 108 using ::rand; 109 using ::realloc; 110 using ::srand; 111 using ::strtod; 112 using ::strtol; 113 using ::strtoul; 114 using ::system; 115 using ::wcstombs; 116 using ::wctomb; 117 118 inline long 119 abs(long __i) { return labs(__i); } 120 121 inline ldiv_t 122 div(long __i, long __j) { return ldiv(__i, __j); } 123} 124 125#if _GLIBCPP_USE_C99 126 127#undef _Exit 128#undef llabs 129#undef lldiv 130#undef atoll 131#undef strtoll 132#undef strtoull 133#undef strtof 134#undef strtold 135 136namespace __gnu_cxx 137{ 138 using ::lldiv_t; 139 using ::_Exit; 140 141 inline long long 142 abs(long long __x) { return __x >= 0 ? __x : -__x; } 143 144 inline long long 145 llabs(long long __x) { return __x >= 0 ? __x : -__x; } 146 147 inline lldiv_t 148 div(long long __n, long long __d) 149 { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; } 150 151 inline lldiv_t 152 lldiv(long long __n, long long __d) 153 { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; } 154 155 using ::atoll; 156 using ::strtof; 157 using ::strtoll; 158 using ::strtoull; 159 using ::strtold; 160} 161 162namespace std 163{ 164 using __gnu_cxx::lldiv_t; 165 using __gnu_cxx::_Exit; 166 using __gnu_cxx::abs; 167 using __gnu_cxx::llabs; 168 using __gnu_cxx::div; 169 using __gnu_cxx::lldiv; 170 using __gnu_cxx::atoll; 171 using __gnu_cxx::strtof; 172 using __gnu_cxx::strtoll; 173 using __gnu_cxx::strtoull; 174 using __gnu_cxx::strtold; 175} 176#endif 177 178#endif 179