From dfb5cadf33437aba9372e0d580022101deaee1d6 Mon Sep 17 00:00:00 2001 From: Daan Date: Sat, 2 Mar 2024 14:06:34 -0800 Subject: [PATCH] don't use the new __builtin_thread_pointer on macOS --- include/mimalloc/prim.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/mimalloc/prim.h b/include/mimalloc/prim.h index c3844d8b..830b36c4 100644 --- a/include/mimalloc/prim.h +++ b/include/mimalloc/prim.h @@ -213,11 +213,12 @@ static inline mi_threadid_t _mi_prim_thread_id(void) mi_attr_noexcept { } #elif defined(__has_builtin) && __has_builtin(__builtin_thread_pointer) && \ + (!defined(__APPLE__)) && /* on apple (M1) the wrong register is read (tpidr_el0 instead of tpidrro_el0) so fall back to TLS slot assembly ()*/ \ (!defined(__clang_major__) || __clang_major__ >= 14) // older clang versions emit bad code; fall back to using the TLS slot () static inline mi_threadid_t _mi_prim_thread_id(void) mi_attr_noexcept { // Works on most Unix based platforms - return (uintptr_t)__builtin_thread_pointer(); + return (uintptr_t)__builtin_thread_pointer(); } #elif defined(MI_HAS_TLS_SLOT)