1// -*- C++ -*- 2//===----------------------------- new ------------------------------------===// 3// 4// The LLVM Compiler Infrastructure 5// 6// This file is dual licensed under the MIT and the University of Illinois Open 7// Source Licenses. See LICENSE.TXT for details. 8// 9//===----------------------------------------------------------------------===// 10 11#ifndef _LIBCPP_NEW 12#define _LIBCPP_NEW 13 14/* 15 new synopsis 16 17namespace std 18{ 19 20class bad_alloc 21 : public exception 22{ 23public: 24 bad_alloc() throw(); 25 bad_alloc(const bad_alloc&) throw(); 26 bad_alloc& operator=(const bad_alloc&) throw(); 27 virtual ~bad_alloc() throw(); 28 virtual const char* what() const throw(); 29}; 30 31struct nothrow_t {}; 32extern const nothrow_t nothrow; 33typedef void (*new_handler)(); 34new_handler set_new_handler(new_handler new_p) throw(); 35new_handler get_new_handler() throw(); 36 37} // std 38 39void* operator new(std::size_t size) throw(std::bad_alloc); // replaceable 40void* operator new(std::size_t size, const std::nothrow_t&) throw(); // replaceable 41void operator delete(void* ptr) throw(); // replaceable 42void operator delete(void* ptr, const std::nothrow_t&) throw(); // replaceable 43 44void* operator new[](std::size_t size) throw(std::bad_alloc); // replaceable 45void* operator new[](std::size_t size, const std::nothrow_t&) throw(); // replaceable 46void operator delete[](void* ptr) throw(); // replaceable 47void operator delete[](void* ptr, const std::nothrow_t&) throw(); // replaceable 48 49void* operator new (std::size_t size, void* ptr) throw(); 50void* operator new[](std::size_t size, void* ptr) throw(); 51void operator delete (void* ptr, void*) throw(); 52void operator delete[](void* ptr, void*) throw(); 53 54*/ 55 56#include <__config> 57#include <exception> 58#include <cstddef> 59 60#pragma GCC system_header 61 62namespace std // purposefully not using versioning namespace 63{ 64 65class _LIBCPP_EXCEPTION_ABI bad_alloc 66 : public exception 67{ 68public: 69 bad_alloc() throw(); 70 virtual ~bad_alloc() throw(); 71 virtual const char* what() const throw(); 72}; 73 74class _LIBCPP_EXCEPTION_ABI bad_array_new_length 75 : public bad_alloc 76{ 77public: 78 bad_array_new_length() throw(); 79 virtual ~bad_array_new_length() throw(); 80 virtual const char* what() const throw(); 81}; 82 83void __throw_bad_alloc(); // not in C++ spec 84 85struct _LIBCPP_VISIBLE nothrow_t {}; 86extern _LIBCPP_VISIBLE const nothrow_t nothrow; 87typedef void (*new_handler)(); 88_LIBCPP_VISIBLE new_handler set_new_handler(new_handler) throw(); 89_LIBCPP_VISIBLE new_handler get_new_handler() throw(); 90 91} // std 92 93_LIBCPP_VISIBLE void* operator new(std::size_t) throw(std::bad_alloc); 94_LIBCPP_VISIBLE void* operator new(std::size_t, const std::nothrow_t&) throw(); 95_LIBCPP_VISIBLE void operator delete(void*) throw(); 96_LIBCPP_VISIBLE void operator delete(void*, const std::nothrow_t&) throw(); 97 98_LIBCPP_VISIBLE void* operator new[](std::size_t) throw(std::bad_alloc); 99_LIBCPP_VISIBLE void* operator new[](std::size_t, const std::nothrow_t&) throw(); 100_LIBCPP_VISIBLE void operator delete[](void*) throw(); 101_LIBCPP_VISIBLE void operator delete[](void*, const std::nothrow_t&) throw(); 102 103_LIBCPP_INLINE_VISIBILITY inline void* operator new (std::size_t, void* __p) throw() {return __p;} 104_LIBCPP_INLINE_VISIBILITY inline void* operator new[](std::size_t, void* __p) throw() {return __p;} 105_LIBCPP_INLINE_VISIBILITY inline void operator delete (void*, void*) throw() {} 106_LIBCPP_INLINE_VISIBILITY inline void operator delete[](void*, void*) throw() {} 107 108#endif // _LIBCPP_NEW 109