}
+static inline PyInterpreterState *
+_PyInterpreterState_Main(void)
+{
+ return _PyRuntime.interpreters.main;
+}
+
static inline int
_Py_IsMainInterpreter(PyInterpreterState *interp)
{
- /* Use directly _PyRuntime rather than tstate->interp->runtime, since
- this function is used in performance critical code path (ceval) */
- return (interp == _PyRuntime.interpreters.main);
+ return (interp == _PyInterpreterState_Main());
}
static inline const PyConfig *
_Py_GetMainConfig(void)
{
- PyInterpreterState *interp = _PyRuntime.interpreters.main;
+ PyInterpreterState *interp = _PyInterpreterState_Main();
if (interp == NULL) {
return NULL;
}
static inline int
_Py_ThreadCanHandleSignals(PyInterpreterState *interp)
{
- return (_Py_IsMainThread() && interp == _PyRuntime.interpreters.main);
+ return (_Py_IsMainThread() && _Py_IsMainInterpreter(interp));
}
{
pid_t pid;
- if (_PyInterpreterState_GET() != PyInterpreterState_Main()) {
+ if (!_Py_IsMainInterpreter(_PyInterpreterState_GET())) {
PyErr_SetString(PyExc_RuntimeError, "fork not supported for subinterpreters");
return NULL;
}
int master_fd = -1;
pid_t pid;
- if (_PyInterpreterState_GET() != PyInterpreterState_Main()) {
+ if (!_Py_IsMainInterpreter(_PyInterpreterState_GET())) {
PyErr_SetString(PyExc_RuntimeError, "fork not supported for subinterpreters");
return NULL;
}
#endif
{
/* No current thread state, copy from the main interpreter */
- PyInterpreterState *main_interp = PyInterpreterState_Main();
+ PyInterpreterState *main_interp = _PyInterpreterState_Main();
config = _PyInterpreterState_GetConfig(main_interp);
}
PyInterpreterState *
PyInterpreterState_Main(void)
{
- return _PyRuntime.interpreters.main;
+ return _PyInterpreterState_Main();
}
PyInterpreterState *