From 66052f135fa3454d3474b217ab191d6395d873da Mon Sep 17 00:00:00 2001 From: Daan Date: Sat, 18 May 2024 17:05:13 -0700 Subject: [PATCH] allow custom thread id, upstream of python/cpython#115488) --- include/mimalloc/prim.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/mimalloc/prim.h b/include/mimalloc/prim.h index 9561335a..126ea7cd 100644 --- a/include/mimalloc/prim.h +++ b/include/mimalloc/prim.h @@ -222,7 +222,13 @@ extern bool _mi_process_is_initialized; // has mi_process_init been static inline mi_threadid_t _mi_prim_thread_id(void) mi_attr_noexcept; // Get a unique id for the current thread. -#if defined(_WIN32) +#if defined(MI_PRIM_THREAD_ID) + +static inline mi_threadid_t _mi_prim_thread_id(void) mi_attr_noexcept { + return MI_PRIM_THREAD_ID(); // used for example by CPython for a free threaded build (see python/cpython#115488) +} + +#elif defined(_WIN32) #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN