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