@@ -37,11 +37,8 @@ to avoid the expense of doing their own locking).
37
37
extern "C" {
38
38
#endif
39
39
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)
45
42
46
43
/* Forward declarations */
47
44
static PyThreadState * _PyGILState_GetThisThreadState (struct _gilstate_runtime_state * gilstate );
@@ -58,6 +55,9 @@ _Py_COMP_DIAG_IGNORE_DEPR_DECLS
58
55
static const _PyRuntimeState initial = _PyRuntimeState_INIT (_PyRuntime );
59
56
_Py_COMP_DIAG_POP
60
57
58
+ Py_DECL_THREAD PyThreadState * _Py_current_tstate ;
59
+
60
+
61
61
static int
62
62
alloc_for_runtime (PyThread_type_lock * plock1 , PyThread_type_lock * plock2 ,
63
63
PyThread_type_lock * plock3 , PyThread_type_lock * plock4 )
@@ -1164,8 +1164,7 @@ _PyThreadState_DeleteCurrent(PyThreadState *tstate)
1164
1164
void
1165
1165
PyThreadState_DeleteCurrent (void )
1166
1166
{
1167
- struct _gilstate_runtime_state * gilstate = & _PyRuntime .gilstate ;
1168
- PyThreadState * tstate = _PyRuntimeGILState_GetThreadState (gilstate );
1167
+ PyThreadState * tstate = _PyThreadState_GET ();
1169
1168
_PyThreadState_DeleteCurrent (tstate );
1170
1169
}
1171
1170
@@ -1531,9 +1530,8 @@ static int
1531
1530
PyThreadState_IsCurrent (PyThreadState * tstate )
1532
1531
{
1533
1532
/* 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 ();
1537
1535
}
1538
1536
1539
1537
/* Internal initialization/finalization functions called by
0 commit comments