summaryrefslogtreecommitdiff
path: root/Include
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2023-05-05 15:59:20 -0600
committerGitHub <noreply@github.com>2023-05-05 15:59:20 -0600
commitf3e7eb48f86057919c347f56dabf417acfd55845 (patch)
tree1b4c1a4a939f6609ddf17e842abf8490c582a037 /Include
parent66558d2a16ee42afc0e2c02e6a90bfd62dcb67f6 (diff)
downloadcpython-git-f3e7eb48f86057919c347f56dabf417acfd55845.tar.gz
gh-99113: Add PyInterpreterConfig.own_gil (gh-104204)
We also add PyInterpreterState.ceval.own_gil to record if the interpreter actually has its own GIL. Note that for now we don't actually respect own_gil; all interpreters still share the one GIL. However, PyInterpreterState.ceval.own_gil does reflect PyInterpreterConfig.own_gil. That lie is a temporary one that we will fix when the GIL really becomes per-interpreter.
Diffstat (limited to 'Include')
-rw-r--r--Include/cpython/initconfig.h3
-rw-r--r--Include/internal/pycore_ceval.h2
-rw-r--r--Include/internal/pycore_ceval_state.h1
3 files changed, 5 insertions, 1 deletions
diff --git a/Include/cpython/initconfig.h b/Include/cpython/initconfig.h
index 9c1783d272..efae2409b5 100644
--- a/Include/cpython/initconfig.h
+++ b/Include/cpython/initconfig.h
@@ -252,6 +252,7 @@ typedef struct {
int allow_threads;
int allow_daemon_threads;
int check_multi_interp_extensions;
+ int own_gil;
} PyInterpreterConfig;
#define _PyInterpreterConfig_INIT \
@@ -262,6 +263,7 @@ typedef struct {
.allow_threads = 1, \
.allow_daemon_threads = 0, \
.check_multi_interp_extensions = 1, \
+ .own_gil = 1, \
}
#define _PyInterpreterConfig_LEGACY_INIT \
@@ -272,6 +274,7 @@ typedef struct {
.allow_threads = 1, \
.allow_daemon_threads = 1, \
.check_multi_interp_extensions = 0, \
+ .own_gil = 0, \
}
/* --- Helper functions --------------------------------------- */
diff --git a/Include/internal/pycore_ceval.h b/Include/internal/pycore_ceval.h
index 0bbc9efdda..b7a9bf4042 100644
--- a/Include/internal/pycore_ceval.h
+++ b/Include/internal/pycore_ceval.h
@@ -97,7 +97,7 @@ _PyEval_Vector(PyThreadState *tstate,
PyObject *kwnames);
extern int _PyEval_ThreadsInitialized(void);
-extern PyStatus _PyEval_InitGIL(PyThreadState *tstate);
+extern PyStatus _PyEval_InitGIL(PyThreadState *tstate, int own_gil);
extern void _PyEval_FiniGIL(PyInterpreterState *interp);
extern void _PyEval_ReleaseLock(PyThreadState *tstate);
diff --git a/Include/internal/pycore_ceval_state.h b/Include/internal/pycore_ceval_state.h
index 1a00ec8027..4781dd5735 100644
--- a/Include/internal/pycore_ceval_state.h
+++ b/Include/internal/pycore_ceval_state.h
@@ -86,6 +86,7 @@ struct _pending_calls {
struct _ceval_state {
int recursion_limit;
struct _gil_runtime_state *gil;
+ int own_gil;
/* This single variable consolidates all requests to break out of
the fast path in the eval loop. */
_Py_atomic_int eval_breaker;