summaryrefslogtreecommitdiffstats
path: root/Include/internal/pycore_mimalloc.h
diff options
context:
space:
mode:
authorSam Gross <colesbury@gmail.com>2024-02-14 21:41:29 (GMT)
committerGitHub <noreply@github.com>2024-02-14 21:41:29 (GMT)
commit326119d3731f784aa9f5d4afa7b687dd1ab1d916 (patch)
treeccb1bbc22f01f1419fba4e99b30d09bc55445b4b /Include/internal/pycore_mimalloc.h
parenta95b1a56bbba76a382a5c676b71db025915e8695 (diff)
downloadcpython-326119d3731f784aa9f5d4afa7b687dd1ab1d916.zip
cpython-326119d3731f784aa9f5d4afa7b687dd1ab1d916.tar.gz
cpython-326119d3731f784aa9f5d4afa7b687dd1ab1d916.tar.bz2
gh-112529: Use _PyThread_Id() in mimalloc in free-threaded build (#115488)
The free-threaded GC uses mimallocs segment thread IDs to restore the overwritten `ob_tid` thread ids in PyObjects. For that reason, it's important that PyObjects and mimalloc use the same identifiers.
Diffstat (limited to 'Include/internal/pycore_mimalloc.h')
-rw-r--r--Include/internal/pycore_mimalloc.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/Include/internal/pycore_mimalloc.h b/Include/internal/pycore_mimalloc.h
index 1e7ed5a..14c9810 100644
--- a/Include/internal/pycore_mimalloc.h
+++ b/Include/internal/pycore_mimalloc.h
@@ -20,9 +20,12 @@ typedef enum {
#include "pycore_pymem.h"
#ifdef WITH_MIMALLOC
-#define MI_DEBUG_UNINIT PYMEM_CLEANBYTE
-#define MI_DEBUG_FREED PYMEM_DEADBYTE
-#define MI_DEBUG_PADDING PYMEM_FORBIDDENBYTE
+# ifdef Py_GIL_DISABLED
+# define MI_PRIM_THREAD_ID _Py_ThreadId
+# endif
+# define MI_DEBUG_UNINIT PYMEM_CLEANBYTE
+# define MI_DEBUG_FREED PYMEM_DEADBYTE
+# define MI_DEBUG_PADDING PYMEM_FORBIDDENBYTE
#ifdef Py_DEBUG
# define MI_DEBUG 1
#else