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