summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorDonghee Na <donghee.na@python.org>2023-12-05 09:03:32 (GMT)
committerGitHub <noreply@github.com>2023-12-05 09:03:32 (GMT)
commitd824512059eabbe9d45daeb24d1e2070ad13dd87 (patch)
tree8e6b27c38c144bec0bb41830333d72a9201962fe /Include
parent81ee0260912dc4b55410f3c6ad755b5c4da82f4a (diff)
downloadcpython-d824512059eabbe9d45daeb24d1e2070ad13dd87.zip
cpython-d824512059eabbe9d45daeb24d1e2070ad13dd87.tar.gz
cpython-d824512059eabbe9d45daeb24d1e2070ad13dd87.tar.bz2
gh-112535: Update _Py_ThreadId() to support PowerPC (gh-112624)
Diffstat (limited to 'Include')
-rw-r--r--Include/object.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/Include/object.h b/Include/object.h
index 81f777a..dfeb43b 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -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