From 95b61b8c3d9b4e19191507592a18fb9fe31fb53b Mon Sep 17 00:00:00 2001 From: Daan Leijen Date: Mon, 19 Dec 2022 17:45:15 -0800 Subject: [PATCH] forward libc interface used by wasi-libc; originally by @anuraaga in PR #667 but rebased to the dev branch --- src/alloc-override.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/alloc-override.c b/src/alloc-override.c index ca508aa6..84a0d19d 100644 --- a/src/alloc-override.c +++ b/src/alloc-override.c @@ -262,7 +262,15 @@ int reallocarr(void* p, size_t count, size_t size) { return mi_reallocarr(p void* memalign(size_t alignment, size_t size) { return mi_memalign(alignment, size); } void* _aligned_malloc(size_t alignment, size_t size) { return mi_aligned_alloc(alignment, size); } -#if defined(__GLIBC__) && defined(__linux__) +#if defined(__wasi__) + // forward __libc interface (see PR #667) + void* __libc_malloc(size_t size) MI_FORWARD1(mi_malloc, size) + void* __libc_calloc(size_t count, size_t size) MI_FORWARD2(mi_calloc, count, size) + void* __libc_realloc(void* p, size_t size) MI_FORWARD2(mi_realloc, p, size) + void __libc_free(void* p) MI_FORWARD0(mi_free, p) + void* __libc_memalign(size_t alignment, size_t size) { return mi_memalign(alignment, size); } + +#elif defined(__GLIBC__) && defined(__linux__) // forward __libc interface (needed for glibc-based Linux distributions) void* __libc_malloc(size_t size) MI_FORWARD1(mi_malloc,size) void* __libc_calloc(size_t count, size_t size) MI_FORWARD2(mi_calloc,count,size)