From df43792729f253d4e14b345fae7f7cd916910197 Mon Sep 17 00:00:00 2001 From: Joshua Kriegshauser Date: Wed, 14 Feb 2024 19:42:33 +0000 Subject: [PATCH] Fix for #851 --- include/mimalloc/prim.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/mimalloc/prim.h b/include/mimalloc/prim.h index 9e560696..1ecbcc19 100644 --- a/include/mimalloc/prim.h +++ b/include/mimalloc/prim.h @@ -206,7 +206,9 @@ static inline void mi_prim_tls_slot_set(size_t slot, void* value) mi_attr_noexce } static inline mi_threadid_t _mi_prim_thread_id(void) mi_attr_noexcept { - #if defined(__BIONIC__) + #if defined(__aarch64__) || defined(__arm__) + return (uintptr_t)__builtin_thread_pointer(); + #elif defined(__BIONIC__) // issue #384, #495: on the Bionic libc (Android), slot 1 is the thread id // see: https://github.com/aosp-mirror/platform_bionic/blob/c44b1d0676ded732df4b3b21c5f798eacae93228/libc/platform/bionic/tls_defines.h#L86 return (uintptr_t)mi_prim_tls_slot(1);