summaryrefslogtreecommitdiffstats
path: root/Include/object.h
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 /Include/object.h
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 'Include/object.h')
-rw-r--r--Include/object.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/Include/object.h b/Include/object.h
index d22e5c2..48f1ddf 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -239,6 +239,8 @@ PyAPI_FUNC(int) Py_Is(PyObject *x, PyObject *y);
#define Py_Is(x, y) ((x) == (y))
#if defined(Py_GIL_DISABLED) && !defined(Py_LIMITED_API)
+PyAPI_FUNC(uintptr_t) _Py_GetThreadLocal_Addr(void);
+
static inline uintptr_t
_Py_ThreadId(void)
{
@@ -291,7 +293,9 @@ _Py_ThreadId(void)
__asm__ ("mv %0, tp" : "=r" (tid));
#endif
#else
- # error "define _Py_ThreadId for this platform"
+ // Fallback to a portable implementation if we do not have a faster
+ // platform-specific implementation.
+ tid = _Py_GetThreadLocal_Addr();
#endif
return tid;
}