From b5b52b8879a0574bdd5b8c2b416a26c48080ef41 Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Wed, 20 Oct 2021 18:33:12 +0000 Subject: [PATCH 1/3] Haiku build update, since the beta3 few more posix functions are available e.g. madvise --- src/os.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/os.c b/src/os.c index bf1d4716..3066dad5 100644 --- a/src/os.c +++ b/src/os.c @@ -51,10 +51,6 @@ terms of the MIT license. A copy of the license can be found in the file #include #endif #endif -#if defined(__HAIKU__) -#define madvise posix_madvise -#define MADV_DONTNEED POSIX_MADV_DONTNEED -#endif #endif /* ----------------------------------------------------------- From 45321237b53435e75b1d8545b6b37c40cddef898 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Thu, 21 Oct 2021 21:15:08 +0800 Subject: [PATCH 2/3] Fix ARM64 MSVC linker problem Close https://github.com/microsoft/mimalloc/issues/426 --- src/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/init.c b/src/init.c index c088cada..a712f9f1 100644 --- a/src/init.c +++ b/src/init.c @@ -571,7 +571,7 @@ static void mi_process_done(void) { return 0; } typedef int(*_crt_cb)(void); - #ifdef _M_X64 + #if defined(_M_X64) || defined(_M_ARM64) __pragma(comment(linker, "/include:" "_mi_msvc_initu")) #pragma section(".CRT$XIU", long, read) #else From 13de1920ae7bf39021d6c131222b6b71330ed0c2 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Thu, 21 Oct 2021 21:39:28 +0200 Subject: [PATCH 3/3] Rename _os_random_weak to _mi_os_random_weak The ``_os_random_weak`` function is the only non-static function besides ``_ZSt15get_new_handlerv`` that is not prefixed with ``mi`` or ``_mi``. The discrepancy was discovered by CPython's smelly script. The checker looks for exported symbols that don't have well-defined prefixes. Signed-off-by: Christian Heimes --- include/mimalloc-internal.h | 2 +- src/init.c | 2 +- src/random.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/mimalloc-internal.h b/include/mimalloc-internal.h index 5a29c54d..0563d3de 100644 --- a/include/mimalloc-internal.h +++ b/include/mimalloc-internal.h @@ -50,7 +50,7 @@ void _mi_random_init(mi_random_ctx_t* ctx); void _mi_random_split(mi_random_ctx_t* ctx, mi_random_ctx_t* new_ctx); uintptr_t _mi_random_next(mi_random_ctx_t* ctx); uintptr_t _mi_heap_random_next(mi_heap_t* heap); -uintptr_t _os_random_weak(uintptr_t extra_seed); +uintptr_t _mi_os_random_weak(uintptr_t extra_seed); static inline uintptr_t _mi_random_shuffle(uintptr_t x); // init.c diff --git a/src/init.c b/src/init.c index c088cada..a41bcdd1 100644 --- a/src/init.c +++ b/src/init.c @@ -141,7 +141,7 @@ mi_stats_t _mi_stats_main = { MI_STATS_NULL }; static void mi_heap_main_init(void) { if (_mi_heap_main.cookie == 0) { _mi_heap_main.thread_id = _mi_thread_id(); - _mi_heap_main.cookie = _os_random_weak((uintptr_t)&mi_heap_main_init); + _mi_heap_main.cookie = _mi_os_random_weak((uintptr_t)&mi_heap_main_init); _mi_random_init(&_mi_heap_main.random); _mi_heap_main.keys[0] = _mi_heap_random_next(&_mi_heap_main); _mi_heap_main.keys[1] = _mi_heap_random_next(&_mi_heap_main); diff --git a/src/random.c b/src/random.c index ce6db7c6..05c5c99c 100644 --- a/src/random.c +++ b/src/random.c @@ -257,8 +257,8 @@ static bool os_random_buf(void* buf, size_t buf_len) { #include #endif -uintptr_t _os_random_weak(uintptr_t extra_seed) { - uintptr_t x = (uintptr_t)&_os_random_weak ^ extra_seed; // ASLR makes the address random +uintptr_t _mi_os_random_weak(uintptr_t extra_seed) { + uintptr_t x = (uintptr_t)&_mi_os_random_weak ^ extra_seed; // ASLR makes the address random #if defined(_WIN32) LARGE_INTEGER pcount; @@ -289,7 +289,7 @@ void _mi_random_init(mi_random_ctx_t* ctx) { #if !defined(__wasi__) _mi_warning_message("unable to use secure randomness\n"); #endif - uintptr_t x = _os_random_weak(0); + uintptr_t x = _mi_os_random_weak(0); for (size_t i = 0; i < 8; i++) { // key is eight 32-bit words. x = _mi_random_shuffle(x); ((uint32_t*)key)[i] = (uint32_t)x;