summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorFurkan Onder <furkanonder@protonmail.com>2023-12-14 23:42:33 (GMT)
committerGitHub <noreply@github.com>2023-12-14 23:42:33 (GMT)
commitf34e22c6470d1c5d0e2a3ffb2272d375c22654b9 (patch)
tree90a727aeac526d218c3c0d8da4d7564a4d0fe5e8 /Include
parent5f7d7353b47ccf634b9b65f933d3fdeeb395301f (diff)
downloadcpython-f34e22c6470d1c5d0e2a3ffb2272d375c22654b9.zip
cpython-f34e22c6470d1c5d0e2a3ffb2272d375c22654b9.tar.gz
cpython-f34e22c6470d1c5d0e2a3ffb2272d375c22654b9.tar.bz2
gh-112535: Update _Py_ThreadId() to support RISC-V (gh-113084)
Update _Py_ThreadId() to support RISC-V
Diffstat (limited to 'Include')
-rw-r--r--Include/object.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/Include/object.h b/Include/object.h
index bd576b0..d22e5c2 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -283,6 +283,13 @@ _Py_ThreadId(void)
// Both GCC and Clang have supported __builtin_thread_pointer
// for s390 from long time ago.
tid = (uintptr_t)__builtin_thread_pointer();
+#elif defined(__riscv)
+ #if defined(__clang__) && _Py__has_builtin(__builtin_thread_pointer)
+ tid = (uintptr_t)__builtin_thread_pointer();
+ #else
+ // tp is Thread Pointer provided by the RISC-V ABI.
+ __asm__ ("mv %0, tp" : "=r" (tid));
+ #endif
#else
# error "define _Py_ThreadId for this platform"
#endif