@@ -1353,20 +1353,19 @@ allocate_chunk(int size_in_bytes, _PyStackChunk* previous)
13531353 return res ;
13541354}
13551355
1356- static PyThreadState *
1356+ static _PyThreadStateImpl *
13571357alloc_threadstate (void )
13581358{
1359- return PyMem_RawCalloc (1 , sizeof (PyThreadState ));
1359+ return PyMem_RawCalloc (1 , sizeof (_PyThreadStateImpl ));
13601360}
13611361
13621362static void
1363- free_threadstate (PyThreadState * tstate )
1363+ free_threadstate (_PyThreadStateImpl * tstate )
13641364{
13651365 // The initial thread state of the interpreter is allocated
13661366 // as part of the interpreter state so should not be freed.
1367- if (tstate == & tstate -> interp -> _initial_thread ) {
1367+ if (tstate == & tstate -> base . interp -> _initial_thread ) {
13681368 // Restore to _PyThreadState_INIT.
1369- tstate = & tstate -> interp -> _initial_thread ;
13701369 memcpy (tstate ,
13711370 & initial ._main_interpreter ._initial_thread ,
13721371 sizeof (* tstate ));
@@ -1385,9 +1384,10 @@ free_threadstate(PyThreadState *tstate)
13851384 */
13861385
13871386static void
1388- init_threadstate (PyThreadState * tstate ,
1387+ init_threadstate (_PyThreadStateImpl * _tstate ,
13891388 PyInterpreterState * interp , uint64_t id , int whence )
13901389{
1390+ PyThreadState * tstate = (PyThreadState * )_tstate ;
13911391 if (tstate -> _status .initialized ) {
13921392 Py_FatalError ("thread state already initialized" );
13931393 }
@@ -1444,13 +1444,13 @@ add_threadstate(PyInterpreterState *interp, PyThreadState *tstate,
14441444static PyThreadState *
14451445new_threadstate (PyInterpreterState * interp , int whence )
14461446{
1447- PyThreadState * tstate ;
1447+ _PyThreadStateImpl * tstate ;
14481448 _PyRuntimeState * runtime = interp -> runtime ;
14491449 // We don't need to allocate a thread state for the main interpreter
14501450 // (the common case), but doing it later for the other case revealed a
14511451 // reentrancy problem (deadlock). So for now we always allocate before
14521452 // taking the interpreters lock. See GH-96071.
1453- PyThreadState * new_tstate = alloc_threadstate ();
1453+ _PyThreadStateImpl * new_tstate = alloc_threadstate ();
14541454 int used_newtstate ;
14551455 if (new_tstate == NULL ) {
14561456 return NULL ;
@@ -1482,14 +1482,14 @@ new_threadstate(PyInterpreterState *interp, int whence)
14821482 }
14831483
14841484 init_threadstate (tstate , interp , id , whence );
1485- add_threadstate (interp , tstate , old_head );
1485+ add_threadstate (interp , ( PyThreadState * ) tstate , old_head );
14861486
14871487 HEAD_UNLOCK (runtime );
14881488 if (!used_newtstate ) {
14891489 // Must be called with lock unlocked to avoid re-entrancy deadlock.
14901490 PyMem_RawFree (new_tstate );
14911491 }
1492- return tstate ;
1492+ return ( PyThreadState * ) tstate ;
14931493}
14941494
14951495PyThreadState *
@@ -1678,7 +1678,7 @@ zapthreads(PyInterpreterState *interp)
16781678 while ((tstate = interp -> threads .head ) != NULL ) {
16791679 tstate_verify_not_active (tstate );
16801680 tstate_delete_common (tstate );
1681- free_threadstate (tstate );
1681+ free_threadstate (( _PyThreadStateImpl * ) tstate );
16821682 }
16831683}
16841684
@@ -1689,7 +1689,7 @@ PyThreadState_Delete(PyThreadState *tstate)
16891689 _Py_EnsureTstateNotNULL (tstate );
16901690 tstate_verify_not_active (tstate );
16911691 tstate_delete_common (tstate );
1692- free_threadstate (tstate );
1692+ free_threadstate (( _PyThreadStateImpl * ) tstate );
16931693}
16941694
16951695
@@ -1701,7 +1701,7 @@ _PyThreadState_DeleteCurrent(PyThreadState *tstate)
17011701 tstate_delete_common (tstate );
17021702 current_fast_clear (tstate -> interp -> runtime );
17031703 _PyEval_ReleaseLock (tstate -> interp , NULL );
1704- free_threadstate (tstate );
1704+ free_threadstate (( _PyThreadStateImpl * ) tstate );
17051705}
17061706
17071707void
@@ -1751,7 +1751,7 @@ _PyThreadState_DeleteExcept(PyThreadState *tstate)
17511751 for (p = list ; p ; p = next ) {
17521752 next = p -> next ;
17531753 PyThreadState_Clear (p );
1754- free_threadstate (p );
1754+ free_threadstate (( _PyThreadStateImpl * ) p );
17551755 }
17561756}
17571757
0 commit comments