mirror of
https://github.com/python/cpython.git
synced 2026-04-15 08:11:10 +00:00
GH-126910: avoid reading the FP for getting the SP (GH-146521)
This commit is contained in:
parent
6763d26b2b
commit
b60b9261b5
2 changed files with 14 additions and 12 deletions
|
|
@ -3286,3 +3286,16 @@ _Py_GetMainConfig(void)
|
|||
}
|
||||
return _PyInterpreterState_GetConfig(interp);
|
||||
}
|
||||
|
||||
uintptr_t
|
||||
_Py_get_machine_stack_pointer(void) {
|
||||
#if _Py__has_builtin(__builtin_frame_address) || defined(__GNUC__)
|
||||
return (uintptr_t)__builtin_frame_address(0);
|
||||
#elif defined(_MSC_VER)
|
||||
return (uintptr_t)_AddressOfReturnAddress();
|
||||
#else
|
||||
char here;
|
||||
/* Avoid compiler warning about returning stack address */
|
||||
return return_pointer_as_int(&here);
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue