Skip to content

Commit

Permalink
Fix undefined symbol errors when building for wasi #758, by @anuraaga
Browse files Browse the repository at this point in the history
  • Loading branch information
daanx committed Mar 3, 2024
1 parent 16c3f12 commit e1f6516
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 6 additions & 0 deletions include/mimalloc/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,12 @@ static inline uintptr_t _mi_align_up(uintptr_t sz, size_t alignment) {
}
}

// Align a pointer upwards
static inline void* mi_align_up_ptr(void* p, size_t alignment) {
return (void*)_mi_align_up((uintptr_t)p, alignment);
}


// Divide upwards: `s <= _mi_divide_up(s,d)*d < s+d`.
static inline uintptr_t _mi_divide_up(uintptr_t size, size_t divider) {
mi_assert_internal(divider != 0);
Expand Down
4 changes: 0 additions & 4 deletions src/os.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ void _mi_os_init(void) {
bool _mi_os_decommit(void* addr, size_t size, mi_stats_t* stats);
bool _mi_os_commit(void* addr, size_t size, bool* is_zero, mi_stats_t* tld_stats);

static void* mi_align_up_ptr(void* p, size_t alignment) {
return (void*)_mi_align_up((uintptr_t)p, alignment);
}

static inline uintptr_t _mi_align_down(uintptr_t sz, size_t alignment) {
mi_assert_internal(alignment != 0);
uintptr_t mask = alignment - 1;
Expand Down
5 changes: 5 additions & 0 deletions src/prim/wasi/prim.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ terms of the MIT license. A copy of the license can be found in the file
#include "mimalloc/atomic.h"
#include "mimalloc/prim.h"

#include <stdio.h> // fputs
#include <stdlib.h> // getenv

//---------------------------------------------
// Initialize
//---------------------------------------------
Expand Down Expand Up @@ -40,6 +43,8 @@ int _mi_prim_free(void* addr, size_t size ) {
//---------------------------------------------

#if defined(MI_USE_SBRK)
#include <unistd.h> // for sbrk

static void* mi_memory_grow( size_t size ) {
void* p = sbrk(size);
if (p == (void*)(-1)) return NULL;
Expand Down

0 comments on commit e1f6516

Please sign in to comment.