@@ -37,11 +37,8 @@ to avoid the expense of doing their own locking).
3737extern "C" {
3838#endif
3939
40- #define _PyRuntimeGILState_GetThreadState (gilstate ) \
41- ((PyThreadState*)_Py_atomic_load_relaxed(&(gilstate)->tstate_current))
42- #define _PyRuntimeGILState_SetThreadState (gilstate , value ) \
43- _Py_atomic_store_relaxed(&(gilstate)->tstate_current, \
44- (uintptr_t)(value))
40+ #define _PyRuntimeGILState_GetThreadState (gilstate ) _PyThreadState_GET()
41+ #define _PyRuntimeGILState_SetThreadState (gilstate , value ) _PyThreadState_SET(value)
4542
4643/* Forward declarations */
4744static PyThreadState * _PyGILState_GetThisThreadState (struct _gilstate_runtime_state * gilstate );
@@ -58,6 +55,9 @@ _Py_COMP_DIAG_IGNORE_DEPR_DECLS
5855static const _PyRuntimeState initial = _PyRuntimeState_INIT (_PyRuntime );
5956_Py_COMP_DIAG_POP
6057
58+ Py_DECL_THREAD PyThreadState * _Py_current_tstate ;
59+
60+
6161static int
6262alloc_for_runtime (PyThread_type_lock * plock1 , PyThread_type_lock * plock2 ,
6363 PyThread_type_lock * plock3 , PyThread_type_lock * plock4 )
@@ -1164,8 +1164,7 @@ _PyThreadState_DeleteCurrent(PyThreadState *tstate)
11641164void
11651165PyThreadState_DeleteCurrent (void )
11661166{
1167- struct _gilstate_runtime_state * gilstate = & _PyRuntime .gilstate ;
1168- PyThreadState * tstate = _PyRuntimeGILState_GetThreadState (gilstate );
1167+ PyThreadState * tstate = _PyThreadState_GET ();
11691168 _PyThreadState_DeleteCurrent (tstate );
11701169}
11711170
@@ -1531,9 +1530,8 @@ static int
15311530PyThreadState_IsCurrent (PyThreadState * tstate )
15321531{
15331532 /* Must be the tstate for this thread */
1534- struct _gilstate_runtime_state * gilstate = & _PyRuntime .gilstate ;
1535- assert (_PyGILState_GetThisThreadState (gilstate ) == tstate );
1536- return tstate == _PyRuntimeGILState_GetThreadState (gilstate );
1533+ assert (_PyGILState_GetThisThreadState (& _PyRuntime .gilstate ) == tstate );
1534+ return tstate == _PyThreadState_GET ();
15371535}
15381536
15391537/* Internal initialization/finalization functions called by
0 commit comments