Skip to content

Commit

Permalink
pythongh-112535: Update _Py_ThreadId() to support PowerPC (pythongh-1…
Browse files Browse the repository at this point in the history
  • Loading branch information
corona10 authored Dec 5, 2023
1 parent 81ee026 commit d824512
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Include/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d824512

Please sign in to comment.