blob: 985ddc567f49402a982bc064435c267fd4da3270 [file] [log] [blame]
Sasha Smundak33d5ddd2020-05-04 13:37:26 -07001//===--------- 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 Nainar7e1f8392021-08-16 17:30:48 -070012// 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 Smundak33d5ddd2020-05-04 13:37:26 -070014#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 Smundak33d5ddd2020-05-04 13:37:26 -070027inline void *operator new(__SIZE_TYPE__ size,
28 const std::nothrow_t &) OPENMP_NOEXCEPT {
29 return ::operator new(size);
30}
31
Sasha Smundak33d5ddd2020-05-04 13:37:26 -070032inline void *operator new[](__SIZE_TYPE__ size, const std::nothrow_t &) {
33 return ::operator new(size);
34}
35
Sasha Smundak33d5ddd2020-05-04 13:37:26 -070036inline void operator delete(void *ptr, const std::nothrow_t &)OPENMP_NOEXCEPT {
37 ::operator delete(ptr);
38}
39
Sasha Smundak33d5ddd2020-05-04 13:37:26 -070040inline void operator delete[](void *ptr,
41 const std::nothrow_t &) OPENMP_NOEXCEPT {
42 ::operator delete(ptr);
43}
44
Sasha Smundak33d5ddd2020-05-04 13:37:26 -070045#pragma pop_macro("OPENMP_NOEXCEPT")
46#endif
47
48#endif // include guard