summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorDonghee Na <donghee.na@python.org>2023-12-18 16:54:49 (GMT)
committerGitHub <noreply@github.com>2023-12-18 16:54:49 (GMT)
commitd00dbf541525fcb36c9c6ebb7b41a5637c5aa6c0 (patch)
tree6f8d19d85f3cca55f6e913ddde727b83cd66fbfa /Python
parent59f0766ae5aef8bd393a53ab9234371b7d165ec3 (diff)
downloadcpython-d00dbf541525fcb36c9c6ebb7b41a5637c5aa6c0.zip
cpython-d00dbf541525fcb36c9c6ebb7b41a5637c5aa6c0.tar.gz
cpython-d00dbf541525fcb36c9c6ebb7b41a5637c5aa6c0.tar.bz2
gh-112535: Implement fallback implementation of _Py_ThreadId() (gh-113185)
--------- Co-authored-by: Sam Gross <colesbury@gmail.com>
Diffstat (limited to 'Python')
-rw-r--r--Python/pystate.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/Python/pystate.c b/Python/pystate.c
index e18eb01..632a119 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -1951,6 +1951,20 @@ _PyThreadState_Bind(PyThreadState *tstate)
}
}
+#if defined(Py_GIL_DISABLED) && !defined(Py_LIMITED_API)
+uintptr_t
+_Py_GetThreadLocal_Addr(void)
+{
+#ifdef HAVE_THREAD_LOCAL
+ // gh-112535: Use the address of the thread-local PyThreadState variable as
+ // a unique identifier for the current thread. Each thread has a unique
+ // _Py_tss_tstate variable with a unique address.
+ return (uintptr_t)&_Py_tss_tstate;
+#else
+# error "no supported thread-local variable storage classifier"
+#endif
+}
+#endif
/***********************************/
/* routines for advanced debuggers */