From c2f6a86939c3bd4895bc6d7606c171343ccd34cb Mon Sep 17 00:00:00 2001 From: Koen Schmeets Date: Mon, 1 Feb 2021 23:08:45 +0100 Subject: [PATCH] Fix _mi_thread_id issue on apple arm64 --- include/mimalloc-internal.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/mimalloc-internal.h b/include/mimalloc-internal.h index 6a239f1a..40f0a045 100644 --- a/include/mimalloc-internal.h +++ b/include/mimalloc-internal.h @@ -744,8 +744,12 @@ static inline void mi_tls_slot_set(size_t slot, void* value) mi_attr_noexcept { } static inline uintptr_t _mi_thread_id(void) mi_attr_noexcept { - // in all our targets, slot 0 is the pointer to the thread control block +#if defined(__aarch64__) && defined(__APPLE__) + return (uintptr_t)&_mi_heap_default; +#else + // in all our other targets, slot 0 is the pointer to the thread control block return (uintptr_t)mi_tls_slot(0); +#endif } #else // otherwise use standard C