@@ -51,36 +51,18 @@ extern "C" {
5151
5252/* Check if the current thread is the main thread.
5353 Use _Py_IsMainInterpreter() to check if it's the main interpreter. */
54- static inline int
55- _Py_IsMainThread (void )
56- {
57- unsigned long thread = PyThread_get_thread_ident ();
58- return (thread == _PyRuntime .main_thread );
59- }
60-
54+ extern int _Py_IsMainThread (void );
6155
62- static inline PyInterpreterState *
63- _PyInterpreterState_Main (void )
64- {
65- return _PyRuntime .interpreters .main ;
66- }
56+ // Export for '_testinternalcapi' shared extension
57+ PyAPI_FUNC (PyInterpreterState * ) _PyInterpreterState_Main (void );
6758
6859static inline int
6960_Py_IsMainInterpreter (PyInterpreterState * interp )
7061{
7162 return (interp == _PyInterpreterState_Main ());
7263}
7364
74- static inline int
75- _Py_IsMainInterpreterFinalizing (PyInterpreterState * interp )
76- {
77- /* bpo-39877: Access _PyRuntime directly rather than using
78- tstate->interp->runtime to support calls from Python daemon threads.
79- After Py_Finalize() has been called, tstate can be a dangling pointer:
80- point to PyThreadState freed memory. */
81- return (_PyRuntimeState_GetFinalizing (& _PyRuntime ) != NULL &&
82- interp == & _PyRuntime ._main_interpreter );
83- }
65+ extern int _Py_IsMainInterpreterFinalizing (PyInterpreterState * interp );
8466
8567// Export for _interpreters module.
8668PyAPI_FUNC (PyObject * ) _PyInterpreterState_GetIDObject (PyInterpreterState * );
@@ -93,17 +75,7 @@ PyAPI_FUNC(void) _PyErr_SetInterpreterAlreadyRunning(void);
9375
9476extern int _PyThreadState_IsRunningMain (PyThreadState * );
9577extern void _PyInterpreterState_ReinitRunningMain (PyThreadState * );
96-
97-
98- static inline const PyConfig *
99- _Py_GetMainConfig (void )
100- {
101- PyInterpreterState * interp = _PyInterpreterState_Main ();
102- if (interp == NULL ) {
103- return NULL ;
104- }
105- return _PyInterpreterState_GetConfig (interp );
106- }
78+ extern const PyConfig * _Py_GetMainConfig (void );
10779
10880
10981/* Only handle signals on the main thread of the main interpreter. */
0 commit comments