summaryrefslogtreecommitdiff
path: root/include/mimalloc-internal.h
diff options
context:
space:
mode:
authorDaan <daan@microsoft.com>2021-04-22 10:33:53 -0700
committerGitHub <noreply@github.com>2021-04-22 10:33:53 -0700
commitf941015928c7e4d262a2965b3760bbf8064b7897 (patch)
tree2b4e93c829cd353800d1bfd1c0d88edc4d452849 /include/mimalloc-internal.h
parent00ddc1b8a04f82c7354f34d25860b3083ee7b2d1 (diff)
parentad2fa2bf6f737ba5b8d86716dc96375e8aa56db7 (diff)
Merge pull request #384 from kdrag0n/fix-android-thread-id
Fix thread ID getter on Android ARM/AArch64
Diffstat (limited to 'include/mimalloc-internal.h')
-rw-r--r--include/mimalloc-internal.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/mimalloc-internal.h b/include/mimalloc-internal.h
index 5655cd4..d8e293b 100644
--- a/include/mimalloc-internal.h
+++ b/include/mimalloc-internal.h
@@ -751,6 +751,9 @@ static inline uintptr_t _mi_thread_id(void) mi_attr_noexcept {
#if defined(__aarch64__) && defined(__APPLE__) // M1
// on macOS on the M1, slot 0 does not seem to work, so we fall back to portable C for now. See issue #354
return (uintptr_t)&_mi_heap_default;
+#elif defined(__BIONIC__) && (defined(__arm__) || defined(__aarch64__))
+ // on Android, slot 1 is the thread ID (pointer to pthread internal struct)
+ return (uintptr_t)mi_tls_slot(1);
#else
// in all our other targets, slot 0 is the pointer to the thread control block
return (uintptr_t)mi_tls_slot(0);