@@ -309,21 +309,23 @@ _Py_ReachedRecursionLimitWithMargin(PyThreadState *tstate, int margin_count)
309309{
310310 char here ;
311311 uintptr_t here_addr = (uintptr_t )& here ;
312- if (here_addr > tstate -> c_stack_soft_limit + margin_count * PYOS_STACK_MARGIN_BYTES ) {
312+ _PyThreadStateImpl * _tstate = (_PyThreadStateImpl * )tstate ;
313+ if (here_addr > _tstate -> c_stack_soft_limit + margin_count * PYOS_STACK_MARGIN_BYTES ) {
313314 return 0 ;
314315 }
315- if (tstate -> c_stack_hard_limit == 0 ) {
316+ if (_tstate -> c_stack_hard_limit == 0 ) {
316317 _Py_InitializeRecursionLimits (tstate );
317318 }
318- return here_addr <= tstate -> c_stack_soft_limit + margin_count * PYOS_STACK_MARGIN_BYTES ;
319+ return here_addr <= _tstate -> c_stack_soft_limit + margin_count * PYOS_STACK_MARGIN_BYTES ;
319320}
320321
321322void
322323_Py_EnterRecursiveCallUnchecked (PyThreadState * tstate )
323324{
324325 char here ;
325326 uintptr_t here_addr = (uintptr_t )& here ;
326- if (here_addr < tstate -> c_stack_hard_limit ) {
327+ _PyThreadStateImpl * _tstate = (_PyThreadStateImpl * )tstate ;
328+ if (here_addr < _tstate -> c_stack_hard_limit ) {
327329 Py_FatalError ("Unchecked stack overflow." );
328330 }
329331}
@@ -350,20 +352,21 @@ _Py_EnterRecursiveCallUnchecked(PyThreadState *tstate)
350352void
351353_Py_InitializeRecursionLimits (PyThreadState * tstate )
352354{
355+ _PyThreadStateImpl * _tstate = (_PyThreadStateImpl * )tstate ;
353356#ifdef WIN32
354357 ULONG_PTR low , high ;
355358 GetCurrentThreadStackLimits (& low , & high );
356- tstate -> c_stack_top = (uintptr_t )high ;
359+ _tstate -> c_stack_top = (uintptr_t )high ;
357360 ULONG guarantee = 0 ;
358361 SetThreadStackGuarantee (& guarantee );
359- tstate -> c_stack_hard_limit = ((uintptr_t )low ) + guarantee + PYOS_STACK_MARGIN_BYTES ;
360- tstate -> c_stack_soft_limit = tstate -> c_stack_hard_limit + PYOS_STACK_MARGIN_BYTES ;
362+ _tstate -> c_stack_hard_limit = ((uintptr_t )low ) + guarantee + PYOS_STACK_MARGIN_BYTES ;
363+ _tstate -> c_stack_soft_limit = tstate -> c_stack_hard_limit + PYOS_STACK_MARGIN_BYTES ;
361364#else
362365 char here ;
363366 uintptr_t here_addr = (uintptr_t )& here ;
364- tstate -> c_stack_top = _Py_SIZE_ROUND_UP (here_addr , 4096 );
365- tstate -> c_stack_soft_limit = tstate -> c_stack_top - Py_C_STACK_SIZE ;
366- tstate -> c_stack_hard_limit = tstate -> c_stack_top - (Py_C_STACK_SIZE + PYOS_STACK_MARGIN_BYTES );
367+ _tstate -> c_stack_top = _Py_SIZE_ROUND_UP (here_addr , 4096 );
368+ _tstate -> c_stack_soft_limit = _tstate -> c_stack_top - Py_C_STACK_SIZE ;
369+ _tstate -> c_stack_hard_limit = _tstate -> c_stack_top - (Py_C_STACK_SIZE + PYOS_STACK_MARGIN_BYTES );
367370#endif
368371}
369372
@@ -372,19 +375,20 @@ _Py_InitializeRecursionLimits(PyThreadState *tstate)
372375int
373376_Py_CheckRecursiveCall (PyThreadState * tstate , const char * where )
374377{
378+ _PyThreadStateImpl * _tstate = (_PyThreadStateImpl * )tstate ;
375379 char here ;
376380 uintptr_t here_addr = (uintptr_t )& here ;
377- assert (tstate -> c_stack_soft_limit != 0 );
378- if (tstate -> c_stack_hard_limit == 0 ) {
381+ assert (_tstate -> c_stack_soft_limit != 0 );
382+ if (_tstate -> c_stack_hard_limit == 0 ) {
379383 _Py_InitializeRecursionLimits (tstate );
380384 }
381- if (here_addr >= tstate -> c_stack_soft_limit ) {
385+ if (here_addr >= _tstate -> c_stack_soft_limit ) {
382386 return 0 ;
383387 }
384- assert (tstate -> c_stack_hard_limit != 0 );
385- if (here_addr < tstate -> c_stack_hard_limit ) {
388+ assert (_tstate -> c_stack_hard_limit != 0 );
389+ if (here_addr < _tstate -> c_stack_hard_limit ) {
386390 /* Overflowing while handling an overflow. Give up. */
387- int kbytes_used = (int )(tstate -> c_stack_top - here_addr )/1024 ;
391+ int kbytes_used = (int )(_tstate -> c_stack_top - here_addr )/1024 ;
388392 char buffer [80 ];
389393 snprintf (buffer , 80 , "Unrecoverable stack overflow (used %d kB)%s" , kbytes_used , where );
390394 Py_FatalError (buffer );
@@ -393,7 +397,7 @@ _Py_CheckRecursiveCall(PyThreadState *tstate, const char *where)
393397 return 0 ;
394398 }
395399 else {
396- int kbytes_used = (int )(tstate -> c_stack_top - here_addr )/1024 ;
400+ int kbytes_used = (int )(_tstate -> c_stack_top - here_addr )/1024 ;
397401 tstate -> recursion_headroom ++ ;
398402 _PyErr_Format (tstate , PyExc_RecursionError ,
399403 "Stack overflow (used %d kB)%s" ,
0 commit comments