std_cstdlib.h revision 117397
11590Srgrimes// -*- C++ -*- forwarding header. 21590Srgrimes 31590Srgrimes// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 41590Srgrimes// Free Software Foundation, Inc. 51590Srgrimes// 61590Srgrimes// This file is part of the GNU ISO C++ Library. This library is free 71590Srgrimes// software; you can redistribute it and/or modify it under the 81590Srgrimes// terms of the GNU General Public License as published by the 91590Srgrimes// Free Software Foundation; either version 2, or (at your option) 101590Srgrimes// any later version. 111590Srgrimes 121590Srgrimes// This library is distributed in the hope that it will be useful, 131590Srgrimes// but WITHOUT ANY WARRANTY; without even the implied warranty of 141590Srgrimes// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 151590Srgrimes// GNU General Public License for more details. 161590Srgrimes 171590Srgrimes// You should have received a copy of the GNU General Public License along 181590Srgrimes// with this library; see the file COPYING. If not, write to the Free 191590Srgrimes// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 201590Srgrimes// USA. 211590Srgrimes 221590Srgrimes// As a special exception, you may use this file as part of a free software 231590Srgrimes// library without restriction. Specifically, if other files instantiate 241590Srgrimes// templates or use macros or inline functions from this file, or you compile 251590Srgrimes// this file and link it with other files to produce an executable, this 261590Srgrimes// file does not by itself cause the resulting executable to be covered by 271590Srgrimes// the GNU General Public License. This exception does not however 281590Srgrimes// invalidate any other reasons why the executable file might be covered by 291590Srgrimes// the GNU General Public License. 301590Srgrimes 311590Srgrimes// 321590Srgrimes// ISO C++ 14882: 20.4.6 C library 331590Srgrimes// 341590Srgrimes 351590Srgrimes/** @file cstdlib 361590Srgrimes * This is a Standard C++ Library file. You should @c #include this file 371590Srgrimes * in your programs, rather than any of the "*.h" implementation files. 381590Srgrimes * 391590Srgrimes * This is the C++ version of the Standard C Library header @c stdlib.h, 401590Srgrimes * and its contents are (mostly) the same as that header, but are all 411590Srgrimes * contained in the namespace @c std. 421590Srgrimes */ 431590Srgrimes 441590Srgrimes#ifndef _CPP_CSTDLIB 451590Srgrimes#define _CPP_CSTDLIB 1 461590Srgrimes 471590Srgrimes#pragma GCC system_header 481590Srgrimes 491590Srgrimes#include <bits/c++config.h> 501590Srgrimes#include <cstddef> 511590Srgrimes 521590Srgrimes#include <stdlib.h> 531590Srgrimes 541590Srgrimes// Get rid of those macros defined in <stdlib.h> in lieu of real functions. 551590Srgrimes#undef abort 561590Srgrimes#undef abs 571590Srgrimes#undef atexit 581590Srgrimes#undef atof 591590Srgrimes#undef atoi 601590Srgrimes#undef atol 611590Srgrimes#undef bsearch 621590Srgrimes#undef calloc 631590Srgrimes#undef div 641590Srgrimes#undef exit 651590Srgrimes#undef free 661590Srgrimes#undef getenv 671590Srgrimes#undef labs 681590Srgrimes#undef ldiv 691590Srgrimes#undef malloc 701590Srgrimes#undef mblen 711590Srgrimes#undef mbstowcs 721590Srgrimes#undef mbtowc 731590Srgrimes#undef qsort 741590Srgrimes#undef rand 751590Srgrimes#undef realloc 761590Srgrimes#undef srand 771590Srgrimes#undef strtod 781590Srgrimes#undef strtol 791590Srgrimes#undef strtoul 801590Srgrimes#undef system 811590Srgrimes#undef wcstombs 821590Srgrimes#undef wctomb 831590Srgrimes 841590Srgrimesnamespace std 851590Srgrimes{ 861590Srgrimes using ::div_t; 871590Srgrimes using ::ldiv_t; 881590Srgrimes 891590Srgrimes using ::abort; 901590Srgrimes using ::abs; 911590Srgrimes using ::atexit; 921590Srgrimes using ::atof; 931590Srgrimes using ::atoi; 941590Srgrimes using ::atol; 951590Srgrimes using ::bsearch; 961590Srgrimes using ::calloc; 971590Srgrimes using ::div; 981590Srgrimes using ::exit; 991590Srgrimes using ::free; 1001590Srgrimes using ::getenv; 1011590Srgrimes using ::labs; 1021590Srgrimes using ::ldiv; 1031590Srgrimes using ::malloc; 1041590Srgrimes using ::mblen; 1051590Srgrimes using ::mbstowcs; 1061590Srgrimes using ::mbtowc; 1071590Srgrimes using ::qsort; 1081590Srgrimes using ::rand; 1091590Srgrimes using ::realloc; 1101590Srgrimes using ::srand; 1111590Srgrimes using ::strtod; 1121590Srgrimes using ::strtol; 1131590Srgrimes using ::strtoul; 1141590Srgrimes using ::system; 1151590Srgrimes using ::wcstombs; 1161590Srgrimes using ::wctomb; 1171590Srgrimes 1181590Srgrimes inline long 1191590Srgrimes abs(long __i) { return labs(__i); } 1201590Srgrimes 1211590Srgrimes inline ldiv_t 1221590Srgrimes div(long __i, long __j) { return ldiv(__i, __j); } 1231590Srgrimes} 1241590Srgrimes 1251590Srgrimes#if _GLIBCPP_USE_C99 1261590Srgrimes 1271590Srgrimes#undef _Exit 1281590Srgrimes#undef llabs 1291590Srgrimes#undef lldiv 1301590Srgrimes#undef atoll 1311590Srgrimes#undef strtoll 1321590Srgrimes#undef strtoull 1331590Srgrimes#undef strtof 1341590Srgrimes#undef strtold 1351590Srgrimes 1361590Srgrimesnamespace __gnu_cxx 1371590Srgrimes{ 1381590Srgrimes#if !_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC 1391590Srgrimes using ::lldiv_t; 1401590Srgrimes#endif 1411590Srgrimes#if _GLIBCPP_USE_C99_CHECK || _GLIBCPP_USE_C99_DYNAMIC 1421590Srgrimes extern "C" void (_Exit)(int); 1431590Srgrimes#endif 1441590Srgrimes#if !_GLIBCPP_USE_C99_DYNAMIC 1451590Srgrimes using ::_Exit; 1461590Srgrimes#endif 1471590Srgrimes 1481590Srgrimes inline long long 1491590Srgrimes abs(long long __x) { return __x >= 0 ? __x : -__x; } 1501590Srgrimes 1511590Srgrimes inline long long 1521590Srgrimes llabs(long long __x) { return __x >= 0 ? __x : -__x; } 1531590Srgrimes 1541590Srgrimes#if !_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC 1551590Srgrimes inline lldiv_t 1561590Srgrimes div(long long __n, long long __d) 1571590Srgrimes { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; } 1581590Srgrimes 1591590Srgrimes inline lldiv_t 1601590Srgrimes lldiv(long long __n, long long __d) 1611590Srgrimes { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; } 1621590Srgrimes#endif 1631590Srgrimes 1641590Srgrimes#if _GLIBCPP_USE_C99_LONG_LONG_CHECK || _GLIBCPP_USE_C99_LONG_LONG_DYNAMIC 1651590Srgrimes extern "C" long long int (atoll)(const char *); 1661590Srgrimes extern "C" long long int 1671590Srgrimes (strtoll)(const char * restrict, char ** restrict, int); 1681590Srgrimes extern "C" unsigned long long int 1691590Srgrimes (strtoull)(const char * restrict, char ** restrict, int); 1701590Srgrimes#endif 1711590Srgrimes#if !_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC 1721590Srgrimes using ::atoll; 1731590Srgrimes using ::strtoll; 1741590Srgrimes using ::strtoull; 1751590Srgrimes#endif 1761590Srgrimes using ::strtof; 1771590Srgrimes using ::strtold; 1781590Srgrimes} 1791590Srgrimes 1801590Srgrimesnamespace std 1811590Srgrimes{ 1821590Srgrimes#if !_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC 1831590Srgrimes using __gnu_cxx::lldiv_t; 1841590Srgrimes#endif 1851590Srgrimes using __gnu_cxx::_Exit; 1861590Srgrimes using __gnu_cxx::abs; 1871590Srgrimes using __gnu_cxx::llabs; 1881590Srgrimes#if !_GLIBCPP_USE_C99_LONG_LONG_DYNAMIC 1891590Srgrimes using __gnu_cxx::div; 1901590Srgrimes using __gnu_cxx::lldiv; 1911590Srgrimes#endif 1921590Srgrimes using __gnu_cxx::atoll; 193 using __gnu_cxx::strtof; 194 using __gnu_cxx::strtoll; 195 using __gnu_cxx::strtoull; 196 using __gnu_cxx::strtold; 197} 198#endif 199 200#endif 201