@@ -67,7 +67,7 @@ _Py_thread_local PyThreadState *_Py_tss_tstate = NULL;
6767#endif
6868
6969static inline PyThreadState *
70- current_fast_get (_PyRuntimeState * Py_UNUSED ( runtime ) )
70+ current_fast_get (void )
7171{
7272#ifdef HAVE_THREAD_LOCAL
7373 return _Py_tss_tstate ;
@@ -101,14 +101,14 @@ current_fast_clear(_PyRuntimeState *Py_UNUSED(runtime))
101101}
102102
103103#define tstate_verify_not_active (tstate ) \
104- if (tstate == current_fast_get((tstate)->interp->runtime )) { \
104+ if (tstate == current_fast_get()) { \
105105 _Py_FatalErrorFormat(__func__, "tstate %p is still current", tstate); \
106106 }
107107
108108PyThreadState *
109109_PyThreadState_GetCurrent (void )
110110{
111- return current_fast_get (& _PyRuntime );
111+ return current_fast_get ();
112112}
113113
114114
@@ -360,10 +360,9 @@ holds_gil(PyThreadState *tstate)
360360 // XXX Fall back to tstate->interp->runtime->ceval.gil.last_holder
361361 // (and tstate->interp->runtime->ceval.gil.locked).
362362 assert (tstate != NULL );
363- _PyRuntimeState * runtime = tstate -> interp -> runtime ;
364363 /* Must be the tstate for this thread */
365- assert (tstate == gilstate_tss_get (runtime ));
366- return tstate == current_fast_get (runtime );
364+ assert (tstate == gilstate_tss_get (tstate -> interp -> runtime ));
365+ return tstate == current_fast_get ();
367366}
368367
369368
@@ -723,7 +722,7 @@ PyInterpreterState *
723722PyInterpreterState_New (void )
724723{
725724 // tstate can be NULL
726- PyThreadState * tstate = current_fast_get (& _PyRuntime );
725+ PyThreadState * tstate = current_fast_get ();
727726
728727 PyInterpreterState * interp ;
729728 PyStatus status = _PyInterpreterState_New (tstate , & interp );
@@ -882,7 +881,7 @@ PyInterpreterState_Clear(PyInterpreterState *interp)
882881 // Use the current Python thread state to call audit hooks and to collect
883882 // garbage. It can be different than the current Python thread state
884883 // of 'interp'.
885- PyThreadState * current_tstate = current_fast_get (interp -> runtime );
884+ PyThreadState * current_tstate = current_fast_get ();
886885 _PyImport_ClearCore (interp );
887886 interpreter_clear (interp , current_tstate );
888887}
@@ -908,7 +907,7 @@ PyInterpreterState_Delete(PyInterpreterState *interp)
908907
909908 // XXX Clearing the "current" thread state should happen before
910909 // we start finalizing the interpreter (or the current thread state).
911- PyThreadState * tcur = current_fast_get (runtime );
910+ PyThreadState * tcur = current_fast_get ();
912911 if (tcur != NULL && interp == tcur -> interp ) {
913912 /* Unset current thread. After this, many C API calls become crashy. */
914913 _PyThreadState_Detach (tcur );
@@ -1010,7 +1009,7 @@ _PyInterpreterState_SetRunningMain(PyInterpreterState *interp)
10101009 if (_PyInterpreterState_FailIfRunningMain (interp ) < 0 ) {
10111010 return -1 ;
10121011 }
1013- PyThreadState * tstate = current_fast_get (& _PyRuntime );
1012+ PyThreadState * tstate = current_fast_get ();
10141013 _Py_EnsureTstateNotNULL (tstate );
10151014 if (tstate -> interp != interp ) {
10161015 PyErr_SetString (PyExc_RuntimeError ,
@@ -1025,7 +1024,7 @@ void
10251024_PyInterpreterState_SetNotRunningMain (PyInterpreterState * interp )
10261025{
10271026 PyThreadState * tstate = interp -> threads .main ;
1028- assert (tstate == current_fast_get (& _PyRuntime ));
1027+ assert (tstate == current_fast_get ());
10291028
10301029 if (tstate -> on_delete != NULL ) {
10311030 // The threading module was imported for the first time in this
@@ -1178,7 +1177,7 @@ PyInterpreterState_GetDict(PyInterpreterState *interp)
11781177PyInterpreterState *
11791178PyInterpreterState_Get (void )
11801179{
1181- PyThreadState * tstate = current_fast_get (& _PyRuntime );
1180+ PyThreadState * tstate = current_fast_get ();
11821181 _Py_EnsureTstateNotNULL (tstate );
11831182 PyInterpreterState * interp = tstate -> interp ;
11841183 if (interp == NULL ) {
@@ -1474,7 +1473,7 @@ void
14741473PyThreadState_Clear (PyThreadState * tstate )
14751474{
14761475 assert (tstate -> _status .initialized && !tstate -> _status .cleared );
1477- assert (current_fast_get (& _PyRuntime )-> interp == tstate -> interp );
1476+ assert (current_fast_get ()-> interp == tstate -> interp );
14781477 // XXX assert(!tstate->_status.bound || tstate->_status.unbound);
14791478 tstate -> _status .finalizing = 1 ; // just in case
14801479
@@ -1656,7 +1655,7 @@ _PyThreadState_DeleteCurrent(PyThreadState *tstate)
16561655void
16571656PyThreadState_DeleteCurrent (void )
16581657{
1659- PyThreadState * tstate = current_fast_get (& _PyRuntime );
1658+ PyThreadState * tstate = current_fast_get ();
16601659 _PyThreadState_DeleteCurrent (tstate );
16611660}
16621661
@@ -1732,7 +1731,7 @@ _PyThreadState_GetDict(PyThreadState *tstate)
17321731PyObject *
17331732PyThreadState_GetDict (void )
17341733{
1735- PyThreadState * tstate = current_fast_get (& _PyRuntime );
1734+ PyThreadState * tstate = current_fast_get ();
17361735 if (tstate == NULL ) {
17371736 return NULL ;
17381737 }
@@ -1853,7 +1852,7 @@ _PyThreadState_Attach(PyThreadState *tstate)
18531852#endif
18541853
18551854 _Py_EnsureTstateNotNULL (tstate );
1856- if (current_fast_get (& _PyRuntime ) != NULL ) {
1855+ if (current_fast_get () != NULL ) {
18571856 Py_FatalError ("non-NULL old thread state" );
18581857 }
18591858
@@ -1883,7 +1882,7 @@ detach_thread(PyThreadState *tstate, int detached_state)
18831882{
18841883 // XXX assert(tstate_is_alive(tstate) && tstate_is_bound(tstate));
18851884 assert (tstate -> state == _Py_THREAD_ATTACHED );
1886- assert (tstate == current_fast_get (& _PyRuntime ));
1885+ assert (tstate == current_fast_get ());
18871886 if (tstate -> critical_section != 0 ) {
18881887 _PyCriticalSection_SuspendAll (tstate );
18891888 }
@@ -2168,22 +2167,22 @@ PyThreadState_SetAsyncExc(unsigned long id, PyObject *exc)
21682167PyThreadState *
21692168PyThreadState_GetUnchecked (void )
21702169{
2171- return current_fast_get (& _PyRuntime );
2170+ return current_fast_get ();
21722171}
21732172
21742173
21752174PyThreadState *
21762175PyThreadState_Get (void )
21772176{
2178- PyThreadState * tstate = current_fast_get (& _PyRuntime );
2177+ PyThreadState * tstate = current_fast_get ();
21792178 _Py_EnsureTstateNotNULL (tstate );
21802179 return tstate ;
21812180}
21822181
21832182PyThreadState *
21842183_PyThreadState_Swap (_PyRuntimeState * runtime , PyThreadState * newts )
21852184{
2186- PyThreadState * oldts = current_fast_get (runtime );
2185+ PyThreadState * oldts = current_fast_get ();
21872186 if (oldts != NULL ) {
21882187 _PyThreadState_Detach (oldts );
21892188 }
@@ -2278,7 +2277,7 @@ PyObject *
22782277_PyThread_CurrentFrames (void )
22792278{
22802279 _PyRuntimeState * runtime = & _PyRuntime ;
2281- PyThreadState * tstate = current_fast_get (runtime );
2280+ PyThreadState * tstate = current_fast_get ();
22822281 if (_PySys_Audit (tstate , "sys._current_frames" , NULL ) < 0 ) {
22832282 return NULL ;
22842283 }
@@ -2339,7 +2338,7 @@ PyObject *
23392338_PyThread_CurrentExceptions (void )
23402339{
23412340 _PyRuntimeState * runtime = & _PyRuntime ;
2342- PyThreadState * tstate = current_fast_get (runtime );
2341+ PyThreadState * tstate = current_fast_get ();
23432342
23442343 _Py_EnsureTstateNotNULL (tstate );
23452344
@@ -2481,7 +2480,7 @@ PyGILState_Check(void)
24812480 return 1 ;
24822481 }
24832482
2484- PyThreadState * tstate = current_fast_get (runtime );
2483+ PyThreadState * tstate = current_fast_get ();
24852484 if (tstate == NULL ) {
24862485 return 0 ;
24872486 }
@@ -2579,7 +2578,7 @@ PyGILState_Release(PyGILState_STATE oldstate)
25792578 * races; see bugs 225673 and 1061968 (that nasty bug has a
25802579 * habit of coming back).
25812580 */
2582- assert (current_fast_get (runtime ) == tstate );
2581+ assert (current_fast_get () == tstate );
25832582 _PyThreadState_DeleteCurrent (tstate );
25842583 }
25852584 /* Release the lock if necessary */
@@ -2645,9 +2644,8 @@ _PyInterpreterState_GetConfigCopy(PyConfig *config)
26452644const PyConfig *
26462645_Py_GetConfig (void )
26472646{
2648- _PyRuntimeState * runtime = & _PyRuntime ;
26492647 assert (PyGILState_Check ());
2650- PyThreadState * tstate = current_fast_get (runtime );
2648+ PyThreadState * tstate = current_fast_get ();
26512649 _Py_EnsureTstateNotNULL (tstate );
26522650 return _PyInterpreterState_GetConfig (tstate -> interp );
26532651}
0 commit comments