]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/compiler-rt/lib/scudo/standalone/wrappers_cpp.cc
Unbreak DRM KMS build by adding the needed compatibility field in the LinuxKPI.
[FreeBSD/FreeBSD.git] / contrib / llvm-project / compiler-rt / lib / scudo / standalone / wrappers_cpp.cc
1 //===-- wrappers_cpp.cc -----------------------------------------*- C++ -*-===//
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 #include "platform.h"
10
11 // Skip this compilation unit if compiled as part of Bionic.
12 #if !SCUDO_ANDROID || !_BIONIC
13
14 #include "allocator_config.h"
15
16 #include <stdint.h>
17
18 extern scudo::Allocator<scudo::Config> *AllocatorPtr;
19
20 namespace std {
21 struct nothrow_t {};
22 enum class align_val_t : size_t {};
23 } // namespace std
24
25 INTERFACE WEAK void *operator new(size_t size) {
26   return AllocatorPtr->allocate(size, scudo::Chunk::Origin::New);
27 }
28 INTERFACE WEAK void *operator new[](size_t size) {
29   return AllocatorPtr->allocate(size, scudo::Chunk::Origin::NewArray);
30 }
31 INTERFACE WEAK void *operator new(size_t size,
32                                   std::nothrow_t const &) NOEXCEPT {
33   return AllocatorPtr->allocate(size, scudo::Chunk::Origin::New);
34 }
35 INTERFACE WEAK void *operator new[](size_t size,
36                                     std::nothrow_t const &) NOEXCEPT {
37   return AllocatorPtr->allocate(size, scudo::Chunk::Origin::NewArray);
38 }
39 INTERFACE WEAK void *operator new(size_t size, std::align_val_t align) {
40   return AllocatorPtr->allocate(size, scudo::Chunk::Origin::New,
41                                 static_cast<scudo::uptr>(align));
42 }
43 INTERFACE WEAK void *operator new[](size_t size, std::align_val_t align) {
44   return AllocatorPtr->allocate(size, scudo::Chunk::Origin::NewArray,
45                                 static_cast<scudo::uptr>(align));
46 }
47 INTERFACE WEAK void *operator new(size_t size, std::align_val_t align,
48                                   std::nothrow_t const &) NOEXCEPT {
49   return AllocatorPtr->allocate(size, scudo::Chunk::Origin::New,
50                                 static_cast<scudo::uptr>(align));
51 }
52 INTERFACE WEAK void *operator new[](size_t size, std::align_val_t align,
53                                     std::nothrow_t const &) NOEXCEPT {
54   return AllocatorPtr->allocate(size, scudo::Chunk::Origin::NewArray,
55                                 static_cast<scudo::uptr>(align));
56 }
57
58 INTERFACE WEAK void operator delete(void *ptr)NOEXCEPT {
59   AllocatorPtr->deallocate(ptr, scudo::Chunk::Origin::New);
60 }
61 INTERFACE WEAK void operator delete[](void *ptr) NOEXCEPT {
62   AllocatorPtr->deallocate(ptr, scudo::Chunk::Origin::NewArray);
63 }
64 INTERFACE WEAK void operator delete(void *ptr, std::nothrow_t const &)NOEXCEPT {
65   AllocatorPtr->deallocate(ptr, scudo::Chunk::Origin::New);
66 }
67 INTERFACE WEAK void operator delete[](void *ptr,
68                                       std::nothrow_t const &) NOEXCEPT {
69   AllocatorPtr->deallocate(ptr, scudo::Chunk::Origin::NewArray);
70 }
71 INTERFACE WEAK void operator delete(void *ptr, size_t size)NOEXCEPT {
72   AllocatorPtr->deallocate(ptr, scudo::Chunk::Origin::New, size);
73 }
74 INTERFACE WEAK void operator delete[](void *ptr, size_t size) NOEXCEPT {
75   AllocatorPtr->deallocate(ptr, scudo::Chunk::Origin::NewArray, size);
76 }
77 INTERFACE WEAK void operator delete(void *ptr, std::align_val_t align)NOEXCEPT {
78   AllocatorPtr->deallocate(ptr, scudo::Chunk::Origin::New, 0,
79                            static_cast<scudo::uptr>(align));
80 }
81 INTERFACE WEAK void operator delete[](void *ptr,
82                                       std::align_val_t align) NOEXCEPT {
83   AllocatorPtr->deallocate(ptr, scudo::Chunk::Origin::NewArray, 0,
84                            static_cast<scudo::uptr>(align));
85 }
86 INTERFACE WEAK void operator delete(void *ptr, std::align_val_t align,
87                                     std::nothrow_t const &)NOEXCEPT {
88   AllocatorPtr->deallocate(ptr, scudo::Chunk::Origin::New, 0,
89                            static_cast<scudo::uptr>(align));
90 }
91 INTERFACE WEAK void operator delete[](void *ptr, std::align_val_t align,
92                                       std::nothrow_t const &) NOEXCEPT {
93   AllocatorPtr->deallocate(ptr, scudo::Chunk::Origin::NewArray, 0,
94                            static_cast<scudo::uptr>(align));
95 }
96 INTERFACE WEAK void operator delete(void *ptr, size_t size,
97                                     std::align_val_t align)NOEXCEPT {
98   AllocatorPtr->deallocate(ptr, scudo::Chunk::Origin::New, size,
99                            static_cast<scudo::uptr>(align));
100 }
101 INTERFACE WEAK void operator delete[](void *ptr, size_t size,
102                                       std::align_val_t align) NOEXCEPT {
103   AllocatorPtr->deallocate(ptr, scudo::Chunk::Origin::NewArray, size,
104                            static_cast<scudo::uptr>(align));
105 }
106
107 #endif // !SCUDO_ANDROID || !_BIONIC