From f34e22c6470d1c5d0e2a3ffb2272d375c22654b9 Mon Sep 17 00:00:00 2001 From: Furkan Onder Date: Fri, 15 Dec 2023 02:42:33 +0300 Subject: gh-112535: Update _Py_ThreadId() to support RISC-V (gh-113084) Update _Py_ThreadId() to support RISC-V --- Include/object.h | 7 +++++++ 1 file changed, 7 insertions(+) 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 -- cgit v0.12