mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-112535: Update _Py_ThreadId() to support RISC-V (gh-113084)
Update _Py_ThreadId() to support RISC-V
This commit is contained in:
parent
5f7d7353b4
commit
f34e22c647
1 changed files with 7 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue