-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathjemalloc_cpp.patch
192 lines (166 loc) · 6.77 KB
/
jemalloc_cpp.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
diff --git a/src/jemalloc_cpp.cpp b/src/jemalloc_cpp.cpp
index 08107a8a..01f7ec03 100644
--- a/src/jemalloc_cpp.cpp
+++ b/src/jemalloc_cpp.cpp
@@ -24,33 +24,33 @@ extern "C" {
//
// ... but it needs to work with jemalloc namespaces.
-void *operator new(std::size_t size);
-void *operator new[](std::size_t size);
-void *operator new(std::size_t size, const std::nothrow_t &) noexcept;
-void *operator new[](std::size_t size, const std::nothrow_t &) noexcept;
-void operator delete(void *ptr) noexcept;
-void operator delete[](void *ptr) noexcept;
-void operator delete(void *ptr, const std::nothrow_t &) noexcept;
-void operator delete[](void *ptr, const std::nothrow_t &) noexcept;
+void __attribute__((weak)) *operator new(std::size_t size);
+void __attribute__((weak)) *operator new[](std::size_t size);
+void __attribute__((weak)) *operator new(std::size_t size, const std::nothrow_t &) noexcept;
+void __attribute__((weak)) *operator new[](std::size_t size, const std::nothrow_t &) noexcept;
+void __attribute__((weak)) operator delete(void *ptr) noexcept;
+void __attribute__((weak)) operator delete[](void *ptr) noexcept;
+void __attribute__((weak)) operator delete(void *ptr, const std::nothrow_t &) noexcept;
+void __attribute__((weak)) operator delete[](void *ptr, const std::nothrow_t &) noexcept;
#if __cpp_sized_deallocation >= 201309
/* C++14's sized-delete operators. */
-void operator delete(void *ptr, std::size_t size) noexcept;
-void operator delete[](void *ptr, std::size_t size) noexcept;
+void __attribute__((weak)) operator delete(void *ptr, std::size_t size) noexcept;
+void __attribute__((weak)) operator delete[](void *ptr, std::size_t size) noexcept;
#endif
#if __cpp_aligned_new >= 201606
/* C++17's over-aligned operators. */
-void *operator new(std::size_t size, std::align_val_t);
-void *operator new(std::size_t size, std::align_val_t, const std::nothrow_t &) noexcept;
-void *operator new[](std::size_t size, std::align_val_t);
-void *operator new[](std::size_t size, std::align_val_t, const std::nothrow_t &) noexcept;
-void operator delete(void* ptr, std::align_val_t) noexcept;
-void operator delete(void* ptr, std::align_val_t, const std::nothrow_t &) noexcept;
-void operator delete(void* ptr, std::size_t size, std::align_val_t al) noexcept;
-void operator delete[](void* ptr, std::align_val_t) noexcept;
-void operator delete[](void* ptr, std::align_val_t, const std::nothrow_t &) noexcept;
-void operator delete[](void* ptr, std::size_t size, std::align_val_t al) noexcept;
+void __attribute__((weak)) *operator new(std::size_t size, std::align_val_t);
+void __attribute__((weak)) *operator new(std::size_t size, std::align_val_t, const std::nothrow_t &) noexcept;
+void __attribute__((weak)) *operator new[](std::size_t size, std::align_val_t);
+void __attribute__((weak)) *operator new[](std::size_t size, std::align_val_t, const std::nothrow_t &) noexcept;
+void __attribute__((weak)) operator delete(void* ptr, std::align_val_t) noexcept;
+void __attribute__((weak)) operator delete(void* ptr, std::align_val_t, const std::nothrow_t &) noexcept;
+void __attribute__((weak)) operator delete(void* ptr, std::size_t size, std::align_val_t al) noexcept;
+void __attribute__((weak)) operator delete[](void* ptr, std::align_val_t) noexcept;
+void __attribute__((weak)) operator delete[](void* ptr, std::align_val_t, const std::nothrow_t &) noexcept;
+void __attribute__((weak)) operator delete[](void* ptr, std::size_t size, std::align_val_t al) noexcept;
#endif
JEMALLOC_NOINLINE
@@ -115,22 +115,22 @@ newImpl(std::size_t size) noexcept(IsNoExcept) {
return imalloc_fastpath(size, &fallbackNewImpl<IsNoExcept>);
}
-void *
+void __attribute__((weak))*
operator new(std::size_t size) {
return newImpl<false>(size);
}
-void *
+void __attribute__((weak))*
operator new[](std::size_t size) {
return newImpl<false>(size);
}
-void *
+void __attribute__((weak))*
operator new(std::size_t size, const std::nothrow_t &) noexcept {
return newImpl<true>(size);
}
-void *
+void __attribute__((weak))*
operator new[](std::size_t size, const std::nothrow_t &) noexcept {
return newImpl<true>(size);
}
@@ -149,44 +149,44 @@ alignedNewImpl(std::size_t size, std::align_val_t alignment) noexcept(IsNoExcept
return handleOOM(size, IsNoExcept);
}
-void *
+void __attribute__((weak))*
operator new(std::size_t size, std::align_val_t alignment) {
return alignedNewImpl<false>(size, alignment);
}
-void *
+void __attribute__((weak))*
operator new[](std::size_t size, std::align_val_t alignment) {
return alignedNewImpl<false>(size, alignment);
}
-void *
+void __attribute__((weak))*
operator new(std::size_t size, std::align_val_t alignment, const std::nothrow_t &) noexcept {
return alignedNewImpl<true>(size, alignment);
}
-void *
+void __attribute__((weak))*
operator new[](std::size_t size, std::align_val_t alignment, const std::nothrow_t &) noexcept {
return alignedNewImpl<true>(size, alignment);
}
#endif // __cpp_aligned_new
-void
+void __attribute__((weak))
operator delete(void *ptr) noexcept {
je_free_impl(ptr);
}
-void
+void __attribute__((weak))
operator delete[](void *ptr) noexcept {
je_free_impl(ptr);
}
-void
+void __attribute__((weak))
operator delete(void *ptr, const std::nothrow_t &) noexcept {
je_free_impl(ptr);
}
-void operator delete[](void *ptr, const std::nothrow_t &) noexcept {
+void __attribute__((weak)) operator delete[](void *ptr, const std::nothrow_t &) noexcept {
je_free_impl(ptr);
}
@@ -201,12 +201,12 @@ sizedDeleteImpl(void* ptr, std::size_t size) noexcept {
je_sdallocx_noflags(ptr, size);
}
-void
+void __attribute__((weak))
operator delete(void *ptr, std::size_t size) noexcept {
sizedDeleteImpl(ptr, size);
}
-void
+void __attribute__((weak))
operator delete[](void *ptr, std::size_t size) noexcept {
sizedDeleteImpl(ptr, size);
}
@@ -227,32 +227,32 @@ alignedSizedDeleteImpl(void* ptr, std::size_t size, std::align_val_t alignment)
je_sdallocx_impl(ptr, size, MALLOCX_ALIGN(alignment));
}
-void
+void __attribute__((weak))
operator delete(void* ptr, std::align_val_t) noexcept {
je_free_impl(ptr);
}
-void
+void __attribute__((weak))
operator delete[](void* ptr, std::align_val_t) noexcept {
je_free_impl(ptr);
}
-void
+void __attribute__((weak))
operator delete(void* ptr, std::align_val_t, const std::nothrow_t&) noexcept {
je_free_impl(ptr);
}
-void
+void __attribute__((weak))
operator delete[](void* ptr, std::align_val_t, const std::nothrow_t&) noexcept {
je_free_impl(ptr);
}
-void
+void __attribute__((weak))
operator delete(void* ptr, std::size_t size, std::align_val_t alignment) noexcept {
alignedSizedDeleteImpl(ptr, size, alignment);
}
-void
+void __attribute__((weak))
operator delete[](void* ptr, std::size_t size, std::align_val_t alignment) noexcept {
alignedSizedDeleteImpl(ptr, size, alignment);
}