diff options
author | Victor Stinner <vstinner@redhat.com> | 2018-11-01 00:51:40 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-01 00:51:40 (GMT) |
commit | 50b48572d9a90c5bb36e2bef6179548ea927a35a (patch) | |
tree | 3b77efe6c7182a3e0b98fcba9854198dbeca3a98 /Python/context.c | |
parent | 27e2d1f21975dfb8c0ddcb192fa0f45a51b7977e (diff) | |
download | cpython-50b48572d9a90c5bb36e2bef6179548ea927a35a.zip cpython-50b48572d9a90c5bb36e2bef6179548ea927a35a.tar.gz cpython-50b48572d9a90c5bb36e2bef6179548ea927a35a.tar.bz2 |
bpo-35081: Add _PyThreadState_GET() internal macro (GH-10266)
If Py_BUILD_CORE is defined, the PyThreadState_GET() macro access
_PyRuntime which comes from the internal pycore_state.h header.
Public headers must not require internal headers.
Move PyThreadState_GET() and _PyInterpreterState_GET_UNSAFE() from
Include/pystate.h to Include/internal/pycore_state.h, and rename
PyThreadState_GET() to _PyThreadState_GET() there.
The PyThreadState_GET() macro of pystate.h is now redefined when
pycore_state.h is included, to use the fast _PyThreadState_GET().
Changes:
* Add _PyThreadState_GET() macro
* Replace "PyThreadState_GET()->interp" with
_PyInterpreterState_GET_UNSAFE()
* Replace PyThreadState_GET() with _PyThreadState_GET() in internal C
files (compiled with Py_BUILD_CORE defined), but keep
PyThreadState_GET() in the public header files.
* _testcapimodule.c: replace PyThreadState_GET() with
PyThreadState_Get(); the module is not compiled with Py_BUILD_CORE
defined.
* pycore_state.h now requires Py_BUILD_CORE to be defined.
Diffstat (limited to 'Python/context.c')
-rw-r--r-- | Python/context.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Python/context.c b/Python/context.c index b1f67b5..1fb2a5d 100644 --- a/Python/context.c +++ b/Python/context.c @@ -112,7 +112,7 @@ PyContext_Enter(PyObject *octx) return -1; } - PyThreadState *ts = PyThreadState_GET(); + PyThreadState *ts = _PyThreadState_GET(); assert(ts != NULL); ctx->ctx_prev = (PyContext *)ts->context; /* borrow */ @@ -138,7 +138,7 @@ PyContext_Exit(PyObject *octx) return -1; } - PyThreadState *ts = PyThreadState_GET(); + PyThreadState *ts = _PyThreadState_GET(); assert(ts != NULL); if (ts->context != (PyObject *)ctx) { @@ -178,7 +178,7 @@ PyContextVar_Get(PyObject *ovar, PyObject *def, PyObject **val) ENSURE_ContextVar(ovar, -1) PyContextVar *var = (PyContextVar *)ovar; - PyThreadState *ts = PyThreadState_GET(); + PyThreadState *ts = _PyThreadState_GET(); assert(ts != NULL); if (ts->context == NULL) { goto not_found; @@ -382,7 +382,7 @@ context_new_from_vars(PyHamtObject *vars) static inline PyContext * context_get(void) { - PyThreadState *ts = PyThreadState_GET(); + PyThreadState *ts = _PyThreadState_GET(); assert(ts != NULL); PyContext *current_ctx = (PyContext *)ts->context; if (current_ctx == NULL) { |