gh-112535: Update _Py_ThreadId() to support PowerPC (gh-112624)

This commit is contained in:
Donghee Na 2023-12-05 09:03:32 +00:00 committed by GitHub
parent 81ee026091
commit d824512059
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 0 deletions

View File

@ -261,6 +261,22 @@ _Py_ThreadId(void)
__asm__ ("mrs %0, tpidrro_el0" : "=r" (tid));
#elif defined(__aarch64__)
__asm__ ("mrs %0, tpidr_el0" : "=r" (tid));
#elif defined(__powerpc64__)
#if defined(__clang__) && _Py__has_builtin(__builtin_thread_pointer)
tid = (uintptr_t)__builtin_thread_pointer();
#else
register uintptr_t tp __asm__ ("r13");
__asm__("" : "=r" (tp));
tid = tp;
#endif
#elif defined(__powerpc__)
#if defined(__clang__) && _Py__has_builtin(__builtin_thread_pointer)
tid = (uintptr_t)__builtin_thread_pointer();
#else
register uintptr_t tp __asm__ ("r2");
__asm__ ("" : "=r" (tp));
tid = tp;
#endif
#else
# error "define _Py_ThreadId for this platform"
#endif