49 lines · plain
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-exception6//7//===-----------------------------------------------------------------------===8 9#ifndef __CLANG_OPENMP_WRAPPERS_NEW10#define __CLANG_OPENMP_WRAPPERS_NEW11 12// We need the system <new> for the std::nothrow_t. The new/delete operators13// which do not use nothrow_t are provided without the <new> header.14#include_next <new>15 16#if (defined(__NVPTX__) || defined(__AMDGPU__)) && defined(_OPENMP)17 18#include <cstdlib>19 20#pragma push_macro("OPENMP_NOEXCEPT")21#if __cplusplus >= 201103L22#define OPENMP_NOEXCEPT noexcept23#else24#define OPENMP_NOEXCEPT25#endif26 27inline void *operator new(__SIZE_TYPE__ size,28 const std::nothrow_t &) OPENMP_NOEXCEPT {29 return ::operator new(size);30}31 32inline void *operator new[](__SIZE_TYPE__ size, const std::nothrow_t &) {33 return ::operator new(size);34}35 36inline void operator delete(void *ptr, const std::nothrow_t &)OPENMP_NOEXCEPT {37 ::operator delete(ptr);38}39 40inline void operator delete[](void *ptr,41 const std::nothrow_t &) OPENMP_NOEXCEPT {42 ::operator delete(ptr);43}44 45#pragma pop_macro("OPENMP_NOEXCEPT")46#endif47 48#endif // include guard49