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