Sasha Smundak | 33d5ddd | 2020-05-04 13:37:26 -0700 | [diff] [blame] | 1 | //===--------- new - OPENMP wrapper for <new> ------------------------------=== |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===-----------------------------------------------------------------------=== |
| 8 | |
| 9 | #ifndef __CLANG_OPENMP_WRAPPERS_NEW |
| 10 | #define __CLANG_OPENMP_WRAPPERS_NEW |
| 11 | |
Pirama Arumuga Nainar | 7e1f839 | 2021-08-16 17:30:48 -0700 | [diff] [blame] | 12 | // We need the system <new> for the std::nothrow_t. The new/delete operators |
| 13 | // which do not use nothrow_t are provided without the <new> header. |
Sasha Smundak | 33d5ddd | 2020-05-04 13:37:26 -0700 | [diff] [blame] | 14 | #include_next <new> |
| 15 | |
| 16 | #if defined(__NVPTX__) && defined(_OPENMP) |
| 17 | |
| 18 | #include <cstdlib> |
| 19 | |
| 20 | #pragma push_macro("OPENMP_NOEXCEPT") |
| 21 | #if __cplusplus >= 201103L |
| 22 | #define OPENMP_NOEXCEPT noexcept |
| 23 | #else |
| 24 | #define OPENMP_NOEXCEPT |
| 25 | #endif |
| 26 | |
Sasha Smundak | 33d5ddd | 2020-05-04 13:37:26 -0700 | [diff] [blame] | 27 | inline void *operator new(__SIZE_TYPE__ size, |
| 28 | const std::nothrow_t &) OPENMP_NOEXCEPT { |
| 29 | return ::operator new(size); |
| 30 | } |
| 31 | |
Sasha Smundak | 33d5ddd | 2020-05-04 13:37:26 -0700 | [diff] [blame] | 32 | inline void *operator new[](__SIZE_TYPE__ size, const std::nothrow_t &) { |
| 33 | return ::operator new(size); |
| 34 | } |
| 35 | |
Sasha Smundak | 33d5ddd | 2020-05-04 13:37:26 -0700 | [diff] [blame] | 36 | inline void operator delete(void *ptr, const std::nothrow_t &)OPENMP_NOEXCEPT { |
| 37 | ::operator delete(ptr); |
| 38 | } |
| 39 | |
Sasha Smundak | 33d5ddd | 2020-05-04 13:37:26 -0700 | [diff] [blame] | 40 | inline void operator delete[](void *ptr, |
| 41 | const std::nothrow_t &) OPENMP_NOEXCEPT { |
| 42 | ::operator delete(ptr); |
| 43 | } |
| 44 | |
Sasha Smundak | 33d5ddd | 2020-05-04 13:37:26 -0700 | [diff] [blame] | 45 | #pragma pop_macro("OPENMP_NOEXCEPT") |
| 46 | #endif |
| 47 | |
| 48 | #endif // include guard |