Skip to content

Commit 8f0d65f

Browse files
committed
use _AddressOfReturnAddress
1 parent f89d3bc commit 8f0d65f

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

Include/internal/pycore_ceval.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,29 +193,24 @@ extern void _PyEval_DeactivateOpCache(void);
193193

194194
/* --- _Py_EnterRecursiveCall() ----------------------------------------- */
195195

196-
#if !_Py__has_builtin(__builtin_frame_address)
196+
#if !_Py__has_builtin(__builtin_frame_address) && !defined(_MSC_VER)
197197
static uintptr_t return_pointer_as_int(char* p) {
198198
return (uintptr_t)p;
199199
}
200200
#endif
201201

202-
#ifdef _MSC_VER
203-
#pragma warning(push)
204-
#pragma warning(disable:4172)
205-
#endif
206202
static inline uintptr_t
207203
_Py_get_machine_stack_pointer(void) {
208204
#if _Py__has_builtin(__builtin_frame_address)
209205
return (uintptr_t)__builtin_frame_address(0);
206+
#elif defined(_MSC_VER)
207+
return (uintptr_t)_AddressOfReturnAddress();
210208
#else
211209
char here;
212210
/* Avoid compiler warning about returning stack address */
213211
return return_pointer_as_int(&here);
214212
#endif
215213
}
216-
#ifdef _MSC_VER
217-
#pragma warning(pop)
218-
#endif
219214

220215
static inline int _Py_MakeRecCheck(PyThreadState *tstate) {
221216
uintptr_t here_addr = _Py_get_machine_stack_pointer();

0 commit comments

Comments
 (0)