@@ -51,36 +51,18 @@ extern "C" {
51
51
52
52
/* Check if the current thread is the main thread.
53
53
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 );
61
55
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 );
67
58
68
59
static inline int
69
60
_Py_IsMainInterpreter (PyInterpreterState * interp )
70
61
{
71
62
return (interp == _PyInterpreterState_Main ());
72
63
}
73
64
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 );
84
66
85
67
// Export for _interpreters module.
86
68
PyAPI_FUNC (PyObject * ) _PyInterpreterState_GetIDObject (PyInterpreterState * );
@@ -93,17 +75,7 @@ PyAPI_FUNC(void) _PyErr_SetInterpreterAlreadyRunning(void);
93
75
94
76
extern int _PyThreadState_IsRunningMain (PyThreadState * );
95
77
extern 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 );
107
79
108
80
109
81
/* Only handle signals on the main thread of the main interpreter. */
0 commit comments