Skip to content

Commit d7a2d30

Browse files
Revert "Try a fix"
This reverts commit bde6c5b.
1 parent 743cc6a commit d7a2d30

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

Include/internal/pycore_pystate.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,12 @@ _Py_AssertHoldsTstateFunc(const char *func)
306306
#define _Py_AssertHoldsTstate()
307307
#endif
308308

309+
#if !_Py__has_builtin(__builtin_frame_address) && !defined(__GNUC__) && !defined(_MSC_VER)
310+
static uintptr_t return_pointer_as_int(char* p) {
311+
return (uintptr_t)p;
312+
}
313+
#endif
314+
309315
PyAPI_DATA(uintptr_t) _Py_get_machine_stack_pointer(void);
310316

311317
static inline intptr_t

Python/pystate.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3287,13 +3287,15 @@ _Py_GetMainConfig(void)
32873287
return _PyInterpreterState_GetConfig(interp);
32883288
}
32893289

3290-
static uintptr_t return_pointer_as_int(char* p) {
3291-
return (uintptr_t)p;
3292-
}
3293-
3294-
Py_NO_INLINE uintptr_t
3290+
uintptr_t
32953291
_Py_get_machine_stack_pointer(void) {
3292+
#if _Py__has_builtin(__builtin_frame_address) || defined(__GNUC__)
3293+
return (uintptr_t)__builtin_frame_address(0);
3294+
#elif defined(_MSC_VER)
3295+
return (uintptr_t)_AddressOfReturnAddress();
3296+
#else
32963297
char here;
32973298
/* Avoid compiler warning about returning stack address */
32983299
return return_pointer_as_int(&here);
3300+
#endif
32993301
}

0 commit comments

Comments
 (0)