}
-/* Variable and macro for in-line access to current thread
+/* Variable and static inline functions for in-line access to current thread
and interpreter state */
#if defined(HAVE_THREAD_LOCAL) && !defined(Py_BUILD_CORE_MODULE)
#endif
}
-static inline PyThreadState*
-_PyRuntimeState_GetThreadState(_PyRuntimeState *Py_UNUSED(runtime))
-{
- return _PyThreadState_GET();
-}
-
static inline void
_Py_EnsureFuncTstateNotNULL(const char *func, PyThreadState *tstate)
/* Get the current interpreter state.
- The macro is unsafe: it does not check for error and it can return NULL.
+ The function is unsafe: it does not check for error and it can return NULL.
The caller must hold the GIL.
void
PyEval_AcquireLock(void)
{
- _PyRuntimeState *runtime = &_PyRuntime;
- PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
+ PyThreadState *tstate = _PyThreadState_GET();
_Py_EnsureTstateNotNULL(tstate);
take_gil(tstate);
PyEval_ReleaseLock(void)
{
_PyRuntimeState *runtime = &_PyRuntime;
- PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
+ PyThreadState *tstate = _PyThreadState_GET();
/* This function must succeed when the current thread state is NULL.
We therefore avoid PyThreadState_Get() which dumps a fatal error
in debug mode. */
if (_PyStatus_EXCEPTION(status)) {
return status;
}
- _PyRuntimeState *runtime = &_PyRuntime;
- PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
+ PyThreadState *tstate = _PyThreadState_GET();
return pyinit_main(tstate);
}
}
/* Get current thread state and interpreter pointer */
- PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
+ PyThreadState *tstate = _PyThreadState_GET();
// XXX assert(_Py_IsMainInterpreter(tstate->interp));
// XXX assert(_Py_IsMainThread());
tss_tstate != tstate if the current Python thread does not hold the GIL.
*/
- PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
+ PyThreadState *tstate = _PyThreadState_GET();
PyInterpreterState *interp = NULL;
PyThreadState *tss_tstate = PyGILState_GetThisThreadState();
if (tstate != NULL) {
PyThreadState_SetAsyncExc(unsigned long id, PyObject *exc)
{
_PyRuntimeState *runtime = &_PyRuntime;
- PyInterpreterState *interp = _PyRuntimeState_GetThreadState(runtime)->interp;
+ PyInterpreterState *interp = _PyInterpreterState_GET();
/* Although the GIL is held, a few C API functions can be called
* without the GIL held, and in particular some that create and
_PyRuntimeState *runtime = &_PyRuntime;
PyThreadState *tstate;
if (runtime->initialized) {
- tstate = _PyRuntimeState_GetThreadState(runtime);
+ tstate = _PyThreadState_GET();
}
else {
tstate = NULL;