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 12#include_next <new> 13 14#if defined(__NVPTX__) && defined(_OPENMP) 15 16#include <cstdlib> 17 18#pragma push_macro("OPENMP_NOEXCEPT") 19#if __cplusplus >= 201103L 20#define OPENMP_NOEXCEPT noexcept 21#else 22#define OPENMP_NOEXCEPT 23#endif 24 25// Device overrides for non-placement new and delete. 26inline void *operator new(__SIZE_TYPE__ size) { 27 if (size == 0) 28 size = 1; 29 return ::malloc(size); 30} 31inline void *operator new(__SIZE_TYPE__ size, 32 const std::nothrow_t &) OPENMP_NOEXCEPT { 33 return ::operator new(size); 34} 35 36inline void *operator new[](__SIZE_TYPE__ size) { return ::operator new(size); } 37inline void *operator new[](__SIZE_TYPE__ size, const std::nothrow_t &) { 38 return ::operator new(size); 39} 40 41inline void operator delete(void *ptr)OPENMP_NOEXCEPT { 42 if (ptr) 43 ::free(ptr); 44} 45inline void operator delete(void *ptr, const std::nothrow_t &)OPENMP_NOEXCEPT { 46 ::operator delete(ptr); 47} 48 49inline void operator delete[](void *ptr) OPENMP_NOEXCEPT { 50 ::operator delete(ptr); 51} 52inline void operator delete[](void *ptr, 53 const std::nothrow_t &) OPENMP_NOEXCEPT { 54 ::operator delete(ptr); 55} 56 57// Sized delete, C++14 only. 58#if __cplusplus >= 201402L 59inline void operator delete(void *ptr, __SIZE_TYPE__ size)OPENMP_NOEXCEPT { 60 ::operator delete(ptr); 61} 62inline void operator delete[](void *ptr, __SIZE_TYPE__ size) OPENMP_NOEXCEPT { 63 ::operator delete(ptr); 64} 65#endif 66 67#pragma pop_macro("OPENMP_NOEXCEPT") 68#endif 69 70#endif // include guard 71