]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-133261: Use __builtin_frame_address() on GCC 9 and older (#133269)
authorVictor Stinner <vstinner@python.org>
Thu, 1 May 2025 17:13:03 +0000 (19:13 +0200)
committerGitHub <noreply@github.com>
Thu, 1 May 2025 17:13:03 +0000 (19:13 +0200)
GCC 9 and older don't have __has_builtin(), but have
__builtin_frame_address() function.

Include/internal/pycore_pystate.h

index e8b630f5441b3a6b22f6a0b8dd26df9356e6f072..633e5cf77db918c9fe9444554ec414b62a522764 100644 (file)
@@ -300,7 +300,7 @@ _Py_AssertHoldsTstateFunc(const char *func)
 #define _Py_AssertHoldsTstate()
 #endif
 
-#if !_Py__has_builtin(__builtin_frame_address) && !defined(_MSC_VER)
+#if !_Py__has_builtin(__builtin_frame_address) && !defined(__GNUC__) && !defined(_MSC_VER)
 static uintptr_t return_pointer_as_int(char* p) {
     return (uintptr_t)p;
 }
@@ -308,7 +308,7 @@ static uintptr_t return_pointer_as_int(char* p) {
 
 static inline uintptr_t
 _Py_get_machine_stack_pointer(void) {
-#if _Py__has_builtin(__builtin_frame_address)
+#if _Py__has_builtin(__builtin_frame_address) || defined(__GNUC__)
     return (uintptr_t)__builtin_frame_address(0);
 #elif defined(_MSC_VER)
     return (uintptr_t)_AddressOfReturnAddress();