Skip to content

Commit 12926e2

Browse files
committed
Fix C++ function signatures in mimalloc
The C++ functions that take `std::nothrow_t` all take a reference. Without this change I'm seeing function signature mismatches because the final argument is not pointer-width. I'm guessing this simply went unnoticed because most platforms don't do signature checking in the linker and this just happens to work. e.g. `_ZnwjRKSt9nothrow_t` which demangles to `operator new(unsigned int, std::nothrow_t const&)`
1 parent 0df6362 commit 12926e2

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

system/lib/mimalloc/src/alloc-override.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ typedef struct mi_nothrow_s { int _tag; } mi_nothrow_t;
108108
void _ZdaPvm(void* p, size_t n); // delete[]
109109
void* _Znwm(size_t n); // new
110110
void* _Znam(size_t n); // new[]
111-
void* _ZnwmRKSt9nothrow_t(size_t n, mi_nothrow_t tag); // new nothrow
112-
void* _ZnamRKSt9nothrow_t(size_t n, mi_nothrow_t tag); // new[] nothrow
111+
void* _ZnwmRKSt9nothrow_t(size_t n, mi_nothrow_t* tag); // new nothrow
112+
void* _ZnamRKSt9nothrow_t(size_t n, mi_nothrow_t* tag); // new[] nothrow
113113
#ifdef __cplusplus
114114
}
115115
#endif
@@ -201,21 +201,21 @@ typedef struct mi_nothrow_s { int _tag; } mi_nothrow_t;
201201
#if (MI_INTPTR_SIZE==8)
202202
void* _Znwm(size_t n) MI_FORWARD1(mi_new,n) // new 64-bit
203203
void* _Znam(size_t n) MI_FORWARD1(mi_new,n) // new[] 64-bit
204-
void* _ZnwmRKSt9nothrow_t(size_t n, mi_nothrow_t tag) { MI_UNUSED(tag); return mi_new_nothrow(n); }
205-
void* _ZnamRKSt9nothrow_t(size_t n, mi_nothrow_t tag) { MI_UNUSED(tag); return mi_new_nothrow(n); }
204+
void* _ZnwmRKSt9nothrow_t(size_t n, mi_nothrow_t* tag) { MI_UNUSED(tag); return mi_new_nothrow(n); }
205+
void* _ZnamRKSt9nothrow_t(size_t n, mi_nothrow_t* tag) { MI_UNUSED(tag); return mi_new_nothrow(n); }
206206
void* _ZnwmSt11align_val_t(size_t n, size_t al) MI_FORWARD2(mi_new_aligned, n, al)
207207
void* _ZnamSt11align_val_t(size_t n, size_t al) MI_FORWARD2(mi_new_aligned, n, al)
208-
void* _ZnwmSt11align_val_tRKSt9nothrow_t(size_t n, size_t al, mi_nothrow_t tag) { MI_UNUSED(tag); return mi_new_aligned_nothrow(n,al); }
209-
void* _ZnamSt11align_val_tRKSt9nothrow_t(size_t n, size_t al, mi_nothrow_t tag) { MI_UNUSED(tag); return mi_new_aligned_nothrow(n,al); }
208+
void* _ZnwmSt11align_val_tRKSt9nothrow_t(size_t n, size_t al, mi_nothrow_t* tag) { MI_UNUSED(tag); return mi_new_aligned_nothrow(n,al); }
209+
void* _ZnamSt11align_val_tRKSt9nothrow_t(size_t n, size_t al, mi_nothrow_t* tag) { MI_UNUSED(tag); return mi_new_aligned_nothrow(n,al); }
210210
#elif (MI_INTPTR_SIZE==4)
211211
void* _Znwj(size_t n) MI_FORWARD1(mi_new,n) // new 64-bit
212212
void* _Znaj(size_t n) MI_FORWARD1(mi_new,n) // new[] 64-bit
213-
void* _ZnwjRKSt9nothrow_t(size_t n, mi_nothrow_t tag) { MI_UNUSED(tag); return mi_new_nothrow(n); }
214-
void* _ZnajRKSt9nothrow_t(size_t n, mi_nothrow_t tag) { MI_UNUSED(tag); return mi_new_nothrow(n); }
213+
void* _ZnwjRKSt9nothrow_t(size_t n, mi_nothrow_t* tag) { MI_UNUSED(tag); return mi_new_nothrow(n); }
214+
void* _ZnajRKSt9nothrow_t(size_t n, mi_nothrow_t* tag) { MI_UNUSED(tag); return mi_new_nothrow(n); }
215215
void* _ZnwjSt11align_val_t(size_t n, size_t al) MI_FORWARD2(mi_new_aligned, n, al)
216216
void* _ZnajSt11align_val_t(size_t n, size_t al) MI_FORWARD2(mi_new_aligned, n, al)
217-
void* _ZnwjSt11align_val_tRKSt9nothrow_t(size_t n, size_t al, mi_nothrow_t tag) { MI_UNUSED(tag); return mi_new_aligned_nothrow(n,al); }
218-
void* _ZnajSt11align_val_tRKSt9nothrow_t(size_t n, size_t al, mi_nothrow_t tag) { MI_UNUSED(tag); return mi_new_aligned_nothrow(n,al); }
217+
void* _ZnwjSt11align_val_tRKSt9nothrow_t(size_t n, size_t al, mi_nothrow_t* tag) { MI_UNUSED(tag); return mi_new_aligned_nothrow(n,al); }
218+
void* _ZnajSt11align_val_tRKSt9nothrow_t(size_t n, size_t al, mi_nothrow_t* tag) { MI_UNUSED(tag); return mi_new_aligned_nothrow(n,al); }
219219
#else
220220
#error "define overloads for new/delete for this platform (just for performance, can be skipped)"
221221
#endif

0 commit comments

Comments
 (0)