8000 Factor out "current_tss" helpers. · python/cpython@bb86c59 · GitHub
[go: up one dir, main page]

Skip to content

Commit bb86c59

Browse files
Factor out "current_tss" helpers.
1 parent c35aee5 commit bb86c59

File tree

3 files changed

+143
-88
lines changed

3 files changed

+143
-88
lines changed

Include/internal/pycore_pystate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ _PyThreadState_UpdateTracingState(PyThreadState *tstate)
142142
/* Other */
143143

144144
PyAPI_FUNC(PyThreadState *) _PyThreadState_Swap(
145-
struct _gilstate_runtime_state *gilstate,
145+
_PyRuntimeState *runtime,
146146
PyThreadState *newts);
10000
147147

148148
PyAPI_FUNC(PyStatus) _PyInterpreterState_Enable(_PyRuntimeState *runtime);

Python/ceval_gil.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,7 @@ PyEval_AcquireThread(PyThreadState *tstate)
581581

582582
take_gil(tstate);
583583

584-
struct _gilstate_runtime_state *gilstate = &tstate->interp->runtime->gilstate;
585-
if (_PyThreadState_Swap(gilstate, tstate) != NULL) {
584+
if (_PyThreadState_Swap(tstate->interp->runtime, tstate) != NULL) {
586585
Py_FatalError("non-NULL old thread state");
587586
}
588587
}
@@ -593,7 +592,7 @@ PyEval_ReleaseThread(PyThreadState *tstate)
593592
assert(is_tstate_valid(tstate));
594593

595594
_PyRuntimeState *runtime = tstate->interp->runtime;
596-
PyThreadState *new_tstate = _PyThreadState_Swap(&runtime->gilstate, NULL);
595+
PyThreadState *new_tstate = _PyThreadState_Swap(runtime, NULL);
597596
if (new_tstate != tstate) {
598597
Py_FatalError("wrong thread state");
599598
}
@@ -643,7 +642,7 @@ PyThreadState *
643642
PyEval_SaveThread(void)
644643
{
645644
_PyRuntimeState *runtime = &_PyRuntime;
646-
PyThreadState *tstate = _PyThreadState_Swap(&runtime->gilstate, NULL);
645+
PyThreadState *tstate = _PyThreadState_Swap(runtime, NULL);
647646
_Py_EnsureTstateNotNULL(tstate);
648647

649648
struct _ceval_runtime_state *ceval = &runtime->ceval;
@@ -660,8 +659,7 @@ PyEval_RestoreThread(PyThreadState *tstate)
660659

661660
take_gil(tstate);
662661

663-
struct _gilstate_runtime_state *gilstate = &tstate->interp->runtime->gilstate;
664-
_PyThreadState_Swap(gilstate, tstate);
662+
_PyThreadState_Swap(tstate->interp->runtime, tstate);
665663
}
666664

667665

@@ -965,7 +963,7 @@ _Py_HandlePending(PyThreadState *tstate)
965963
/* GIL drop request */
966964
if (_Py_atomic_load_relaxed_int32(&interp_ceval_state->gil_drop_request)) {
967965
/* Give another thread a chance */
968-
if (_PyThreadState_Swap(&runtime->gilstate, NULL) != tstate) {
966+
if (_PyThreadState_Swap(runtime, NULL) != tstate) {
969967
Py_FatalError("tstate mix-up");
970968
}
971969
drop_gil(ceval, interp_ceval_state, tstate);
@@ -974,7 +972,7 @@ _Py_HandlePending(PyThreadState *tstate)
974972

975973
take_gil(tstate);
976974

977-
if (_PyThreadState_Swap(&runtime->gilstate, tstate) != NULL) {
975+
if (_PyThreadState_Swap(runtime, tstate) != NULL) {
978976
Py_FatalError("orphan tstate");
979977
}
980978
}

0 commit comments

Comments
 (0)
0