@@ -67,7 +67,7 @@ _Py_thread_local PyThreadState *_Py_tss_tstate = NULL;
67
67
#endif
68
68
69
69
static inline PyThreadState *
70
- current_fast_get (_PyRuntimeState * Py_UNUSED ( runtime ) )
70
+ current_fast_get (void )
71
71
{
72
72
#ifdef HAVE_THREAD_LOCAL
73
73
return _Py_tss_tstate ;
@@ -101,14 +101,14 @@ current_fast_clear(_PyRuntimeState *Py_UNUSED(runtime))
101
101
}
102
102
103
103
#define tstate_verify_not_active (tstate ) \
104
- if (tstate == current_fast_get((tstate)->interp->runtime )) { \
104
+ if (tstate == current_fast_get()) { \
105
105
_Py_FatalErrorFormat(__func__, "tstate %p is still current", tstate); \
106
106
}
107
107
108
108
PyThreadState *
109
109
_PyThreadState_GetCurrent (void )
110
110
{
111
- return current_fast_get (& _PyRuntime );
111
+ return current_fast_get ();
112
112
}
113
113
114
114
@@ -360,10 +360,9 @@ holds_gil(PyThreadState *tstate)
360
360
// XXX Fall back to tstate->interp->runtime->ceval.gil.last_holder
361
361
// (and tstate->interp->runtime->ceval.gil.locked).
362
362
assert (tstate != NULL );
363
- _PyRuntimeState * runtime = tstate -> interp -> runtime ;
364
363
/* 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 ();
367
366
}
368
367
369
368
@@ -723,7 +722,7 @@ PyInterpreterState *
723
722
PyInterpreterState_New (void )
724
723
{
725
724
// tstate can be NULL
726
- PyThreadState * tstate = current_fast_get (& _PyRuntime );
725
+ PyThreadState * tstate = current_fast_get ();
727
726
728
727
PyInterpreterState * interp ;
729
728
PyStatus status = _PyInterpreterState_New (tstate , & interp );
@@ -882,7 +881,7 @@ PyInterpreterState_Clear(PyInterpreterState *interp)
882
881
// Use the current Python thread state to call audit hooks and to collect
883
882
// garbage. It can be different than the current Python thread state
884
883
// of 'interp'.
885
- PyThreadState * current_tstate = current_fast_get (interp -> runtime );
884
+ PyThreadState * current_tstate = current_fast_get ();
886
885
_PyImport_ClearCore (interp );
887
886
interpreter_clear (interp , current_tstate );
888
887
}
@@ -908,7 +907,7 @@ PyInterpreterState_Delete(PyInterpreterState *interp)
908
907
909
908
// XXX Clearing the "current" thread state should happen before
910
909
// we start finalizing the interpreter (or the current thread state).
911
- PyThreadState * tcur = current_fast_get (runtime );
910
+ PyThreadState * tcur = current_fast_get ();
912
911
if (tcur != NULL && interp == tcur -> interp ) {
913
912
/* Unset current thread. After this, many C API calls become crashy. */
914
913
_PyThreadState_Detach (tcur );
@@ -1010,7 +1009,7 @@ _PyInterpreterState_SetRunningMain(PyInterpreterState *interp)
1010
1009
if (_PyInterpreterState_FailIfRunningMain (interp ) < 0 ) {
1011
1010
return -1 ;
1012
1011
}
1013
- PyThreadState * tstate = current_fast_get (& _PyRuntime );
1012
+ PyThreadState * tstate = current_fast_get ();
1014
1013
_Py_EnsureTstateNotNULL (tstate );
1015
1014
if (tstate -> interp != interp ) {
1016
1015
PyErr_SetString (PyExc_RuntimeError ,
@@ -1025,7 +1024,7 @@ void
1025
1024
_PyInterpreterState_SetNotRunningMain (PyInterpreterState * interp )
1026
1025
{
1027
1026
PyThreadState * tstate = interp -> threads .main ;
1028
- assert (tstate == current_fast_get (& _PyRuntime ));
1027
+ assert (tstate == current_fast_get ());
1029
1028
1030
1029
if (tstate -> on_delete != NULL ) {
1031
1030
// The threading module was imported for the first time in this
@@ -1178,7 +1177,7 @@ PyInterpreterState_GetDict(PyInterpreterState *interp)
1178
1177
PyInterpreterState *
1179
1178
PyInterpreterState_Get (void )
1180
1179
{
1181
- PyThreadState * tstate = current_fast_get (& _PyRuntime );
1180
+ PyThreadState * tstate = current_fast_get ();
1182
1181
_Py_EnsureTstateNotNULL (tstate );
1183
1182
PyInterpreterState * interp = tstate -> interp ;
1184
1183
if (interp == NULL ) {
@@ -1474,7 +1473,7 @@ void
1474
1473
PyThreadState_Clear (PyThreadState * tstate )
1475
1474
{
1476
1475
assert (tstate -> _status .initialized && !tstate -> _status .cleared );
1477
- assert (current_fast_get (& _PyRuntime )-> interp == tstate -> interp );
1476
+ assert (current_fast_get ()-> interp == tstate -> interp );
1478
1477
// XXX assert(!tstate->_status.bound || tstate->_status.unbound);
1479
1478
tstate -> _status .finalizing = 1 ; // just in case
1480
1479
@@ -1656,7 +1655,7 @@ _PyThreadState_DeleteCurrent(PyThreadState *tstate)
1656
1655
void
1657
1656
PyThreadState_DeleteCurrent (void )
1658
1657
{
1659
- PyThreadState * tstate = current_fast_get (& _PyRuntime );
1658
+ PyThreadState * tstate = current_fast_get ();
1660
1659
_PyThreadState_DeleteCurrent (tstate );
1661
1660
}
1662
1661
@@ -1732,7 +1731,7 @@ _PyThreadState_GetDict(PyThreadState *tstate)
1732
1731
PyObject *
1733
1732
PyThreadState_GetDict (void )
1734
1733
{
1735
- PyThreadState * tstate = current_fast_get (& _PyRuntime );
1734
+ PyThreadState * tstate = current_fast_get ();
1736
1735
if (tstate == NULL ) {
1737
1736
return NULL ;
1738
1737
}
@@ -1853,7 +1852,7 @@ _PyThreadState_Attach(PyThreadState *tstate)
1853
1852
#endif
1854
1853
1855
1854
_Py_EnsureTstateNotNULL (tstate );
1856
- if (current_fast_get (& _PyRuntime ) != NULL ) {
1855
+ if (current_fast_get () != NULL ) {
1857
1856
Py_FatalError ("non-NULL old thread state" );
1858
1857
}
1859
1858
@@ -1883,7 +1882,7 @@ detach_thread(PyThreadState *tstate, int detached_state)
1883
1882
{
1884
1883
// XXX assert(tstate_is_alive(tstate) && tstate_is_bound(tstate));
1885
1884
assert (tstate -> state == _Py_THREAD_ATTACHED );
1886
- assert (tstate == current_fast_get (& _PyRuntime ));
1885
+ assert (tstate == current_fast_get ());
1887
1886
if (tstate -> critical_section != 0 ) {
1888
1887
_PyCriticalSection_SuspendAll (tstate );
1889
1888
}
@@ -2168,22 +2167,22 @@ PyThreadState_SetAsyncExc(unsigned long id, PyObject *exc)
2168
2167
PyThreadState *
2169
2168
PyThreadState_GetUnchecked (void )
2170
2169
{
2171
- return current_fast_get (& _PyRuntime );
2170
+ return current_fast_get ();
2172
2171
}
2173
2172
2174
2173
2175
2174
PyThreadState *
2176
2175
PyThreadState_Get (void )
2177
2176
{
2178
- PyThreadState * tstate = current_fast_get (& _PyRuntime );
2177
+ PyThreadState * tstate = current_fast_get ();
2179
2178
_Py_EnsureTstateNotNULL (tstate );
2180
2179
return tstate ;
2181
2180
}
2182
2181
2183
2182
PyThreadState *
2184
2183
_PyThreadState_Swap (_PyRuntimeState * runtime , PyThreadState * newts )
2185
2184
{
2186
- PyThreadState * oldts = current_fast_get (runtime );
2185
+ PyThreadState * oldts = current_fast_get ();
2187
2186
if (oldts != NULL ) {
2188
2187
_PyThreadState_Detach (oldts );
2189
2188
}
@@ -2278,7 +2277,7 @@ PyObject *
2278
2277
_PyThread_CurrentFrames (void )
2279
2278
{
2280
2279
_PyRuntimeState * runtime = & _PyRuntime ;
2281
- PyThreadState * tstate = current_fast_get (runtime );
2280
+ PyThreadState * tstate = current_fast_get ();
2282
2281
if (_PySys_Audit (tstate , "sys._current_frames" , NULL ) < 0 ) {
2283
2282
return NULL ;
2284
2283
}
@@ -2339,7 +2338,7 @@ PyObject *
2339
2338
_PyThread_CurrentExceptions (void )
2340
2339
{
2341
2340
_PyRuntimeState * runtime = & _PyRuntime ;
2342
- PyThreadState * tstate = current_fast_get (runtime );
2341
+ PyThreadState * tstate = current_fast_get ();
2343
2342
2344
2343
_Py_EnsureTstateNotNULL (tstate );
2345
2344
@@ -2481,7 +2480,7 @@ PyGILState_Check(void)
2481
2480
return 1 ;
2482
2481
}
2483
2482
2484
- PyThreadState * tstate = current_fast_get (runtime );
2483
+ PyThreadState * tstate = current_fast_get ();
2485
2484
if (tstate == NULL ) {
2486
2485
return 0 ;
2487
2486
}
@@ -2579,7 +2578,7 @@ PyGILState_Release(PyGILState_STATE oldstate)
2579
2578
* races; see bugs 225673 and 1061968 (that nasty bug has a
2580
2579
* habit of coming back).
2581
2580
*/
2582
- assert (current_fast_get (runtime ) == tstate );
2581
+ assert (current_fast_get () == tstate );
2583
2582
_PyThreadState_DeleteCurrent (tstate );
2584
2583
}
2585
2584
/* Release the lock if necessary */
@@ -2645,9 +2644,8 @@ _PyInterpreterState_GetConfigCopy(PyConfig *config)
2645
2644
const PyConfig *
2646
2645
_Py_GetConfig (void )
2647
2646
{
2648
- _PyRuntimeState * runtime = & _PyRuntime ;
2649
2647
assert (PyGILState_Check ());
2650
- PyThreadState * tstate = current_fast_get (runtime );
2648
+ PyThreadState * tstate = current_fast_get ();
2651
2649
_Py_EnsureTstateNotNULL (tstate );
2652
2650
return _PyInterpreterState_GetConfig (tstate -> interp );
2653
2651
}
0 commit comments