From: Victor Stinner Date: Thu, 1 May 2025 17:13:03 +0000 (+0200) Subject: gh-133261: Use __builtin_frame_address() on GCC 9 and older (#133269) X-Git-Tag: v3.14.0b1~135 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d10bd81b45b9fd066edc6f82675ed4305603c4f4;p=thirdparty%2FPython%2Fcpython.git gh-133261: Use __builtin_frame_address() on GCC 9 and older (#133269) GCC 9 and older don't have __has_builtin(), but have __builtin_frame_address() function. --- diff --git a/Include/internal/pycore_pystate.h b/Include/internal/pycore_pystate.h index e8b630f5441b..633e5cf77db9 100644 --- a/Include/internal/pycore_pystate.h +++ b/Include/internal/pycore_pystate.h @@ -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();