@@ -35,7 +35,8 @@ typedef struct mi_nothrow_s { int _tag; } mi_nothrow_t;
35
35
#pragma GCC diagnostic ignored "-Wattributes" // or we get warnings that nodiscard is ignored on a forward
36
36
#define MI_FORWARD (fun ) __attribute__((alias(#fun), used, visibility("default"), copy(fun)));
37
37
#else
38
- #define MI_FORWARD (fun ) __attribute__((alias(#fun), used, visibility("default")));
38
+ // XXX EMSCRIPTEN: Add "weak"
39
+ #define MI_FORWARD (fun ) __attribute__((alias(#fun), used, visibility("default"), weak));
39
40
#endif
40
41
#define MI_FORWARD1 (fun ,x ) MI_FORWARD(fun)
41
42
#define MI_FORWARD2 (fun ,x ,y ) MI_FORWARD(fun)
@@ -239,9 +240,11 @@ extern "C" {
239
240
#endif
240
241
241
242
// No forwarding here due to aliasing/name mangling issues
243
+ __attribute__((weak )) // XXX EMSCRIPTEN
242
244
void * valloc (size_t size ) { return mi_valloc (size ); }
243
245
void vfree (void * p ) { mi_free (p ); }
244
246
size_t malloc_good_size (size_t size ) { return mi_malloc_good_size (size ); }
247
+ __attribute__((weak )) // XXX EMSCRIPTEN
245
248
int posix_memalign (void * * p , size_t alignment , size_t size ) { return mi_posix_memalign (p , alignment , size ); }
246
249
247
250
// `aligned_alloc` is only available when __USE_ISOC11 is defined.
@@ -252,15 +255,18 @@ extern "C" {
252
255
// Fortunately, in the case where `aligned_alloc` is declared as `static inline` it
253
256
// uses internally `memalign`, `posix_memalign`, or `_aligned_malloc` so we can avoid overriding it ourselves.
254
257
#if !defined(__GLIBC__ ) || __USE_ISOC11
258
+ __attribute__((weak )) // XXX EMSCRIPTEN
255
259
void * aligned_alloc (size_t alignment , size_t size ) { return mi_aligned_alloc (alignment , size ); }
256
260
#endif
257
261
#endif
258
262
259
263
// no forwarding here due to aliasing/name mangling issues
260
264
void cfree (void * p ) { mi_free (p ); }
261
265
void * pvalloc (size_t size ) { return mi_pvalloc (size ); }
266
+ __attribute__((weak )) // XXX EMSCRIPTEN
262
267
void * reallocarray (void * p , size_t count , size_t size ) { return mi_reallocarray (p , count , size ); }
263
268
int reallocarr (void * p , size_t count , size_t size ) { return mi_reallocarr (p , count , size ); }
269
+ __attribute__((weak )) // XXX EMSCRIPTEN
264
270
void * memalign (size_t alignment , size_t size ) { return mi_memalign (alignment , size ); }
265
271
void * _aligned_malloc (size_t alignment , size_t size ) { return mi_aligned_alloc (alignment , size ); }
266
272
@@ -270,6 +276,7 @@ void* _aligned_malloc(size_t alignment, size_t size) { return mi_aligned_allo
270
276
void * __libc_calloc (size_t count , size_t size ) MI_FORWARD2 (mi_calloc , count , size )
271
277
void * __libc_realloc (void * p , size_t size ) MI_FORWARD2 (mi_realloc , p , size )
272
278
void __libc_free (void * p ) MI_FORWARD0 (mi_free , p )
279
+ __attribute__((weak )) // XXX EMSCRIPTEN
273
280
void * __libc_memalign (size_t alignment , size_t size ) { return mi_memalign (alignment , size ); }
274
281
275
282
#ifdef __EMSCRIPTEN__ // emscripten adds some more on top of WASI
0 commit comments