/* Check if the current thread is the main thread.
Use _Py_IsMainInterpreter() to check if it's the main interpreter. */
-static inline int
-_Py_IsMainThread(void)
-{
- unsigned long thread = PyThread_get_thread_ident();
- return (thread == _PyRuntime.main_thread);
-}
-
+extern int _Py_IsMainThread(void);
-static inline PyInterpreterState *
-_PyInterpreterState_Main(void)
-{
- return _PyRuntime.interpreters.main;
-}
+// Export for '_testinternalcapi' shared extension
+PyAPI_FUNC(PyInterpreterState*) _PyInterpreterState_Main(void);
static inline int
_Py_IsMainInterpreter(PyInterpreterState *interp)
return (interp == _PyInterpreterState_Main());
}
-static inline int
-_Py_IsMainInterpreterFinalizing(PyInterpreterState *interp)
-{
- /* bpo-39877: Access _PyRuntime directly rather than using
- tstate->interp->runtime to support calls from Python daemon threads.
- After Py_Finalize() has been called, tstate can be a dangling pointer:
- point to PyThreadState freed memory. */
- return (_PyRuntimeState_GetFinalizing(&_PyRuntime) != NULL &&
- interp == &_PyRuntime._main_interpreter);
-}
+extern int _Py_IsMainInterpreterFinalizing(PyInterpreterState *interp);
// Export for _interpreters module.
PyAPI_FUNC(PyObject *) _PyInterpreterState_GetIDObject(PyInterpreterState *);
extern int _PyThreadState_IsRunningMain(PyThreadState *);
extern void _PyInterpreterState_ReinitRunningMain(PyThreadState *);
-
-
-static inline const PyConfig *
-_Py_GetMainConfig(void)
-{
- PyInterpreterState *interp = _PyInterpreterState_Main();
- if (interp == NULL) {
- return NULL;
- }
- return _PyInterpreterState_GetConfig(interp);
-}
+extern const PyConfig* _Py_GetMainConfig(void);
/* Only handle signals on the main thread of the main interpreter. */
}
#endif
}
+
+
+int
+_Py_IsMainThread(void)
+{
+ unsigned long thread = PyThread_get_thread_ident();
+ return (thread == _PyRuntime.main_thread);
+}
+
+
+PyInterpreterState *
+_PyInterpreterState_Main(void)
+{
+ return _PyRuntime.interpreters.main;
+}
+
+
+int
+_Py_IsMainInterpreterFinalizing(PyInterpreterState *interp)
+{
+ /* bpo-39877: Access _PyRuntime directly rather than using
+ tstate->interp->runtime to support calls from Python daemon threads.
+ After Py_Finalize() has been called, tstate can be a dangling pointer:
+ point to PyThreadState freed memory. */
+ return (_PyRuntimeState_GetFinalizing(&_PyRuntime) != NULL &&
+ interp == &_PyRuntime._main_interpreter);
+}
+
+
+const PyConfig *
+_Py_GetMainConfig(void)
+{
+ PyInterpreterState *interp = _PyInterpreterState_Main();
+ if (interp == NULL) {
+ return NULL;
+ }
+ return _PyInterpreterState_GetConfig(interp);
+}