bpo-40268: Add pycore_runtime.h header file (GH-19493)

Move PyRuntimeState from pycore_pystate.h to pycore_runtime.h.

Remove _PyGILState_check_enabled macro: access directly
_PyRuntime.gilstate.check_enabled.
This commit is contained in:
Victor Stinner 2020-04-13 11:45:21 +02:00 committed by GitHub
parent 0135598d72
commit 1c4cbdf94d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 152 additions and 125 deletions

View file

@ -1553,7 +1553,7 @@ new_interpreter(PyThreadState **tstate_p)
/* Issue #10915, #15751: The GIL API doesn't work with multiple
interpreters: disable PyGILState_Check(). */
_PyGILState_check_enabled = 0;
runtime->gilstate.check_enabled = 0;
PyInterpreterState *interp = PyInterpreterState_New();
if (interp == NULL) {

View file

@ -1329,12 +1329,11 @@ PyGILState_GetThisThreadState(void)
int
PyGILState_Check(void)
{
if (!_PyGILState_check_enabled) {
struct _gilstate_runtime_state *gilstate = &_PyRuntime.gilstate;
if (!gilstate->check_enabled) {
return 1;
}
struct _gilstate_runtime_state *gilstate = &_PyRuntime.gilstate;
if (!PyThread_tss_is_created(&gilstate->autoTSSkey)) {
return 1;
}