• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef Py_INTERNAL_LIFECYCLE_H
2 #define Py_INTERNAL_LIFECYCLE_H
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
6 
7 #ifndef Py_BUILD_CORE
8 #  error "this header requires Py_BUILD_CORE define"
9 #endif
10 
11 #ifdef HAVE_SIGNAL_H
12 #include <signal.h>
13 #endif
14 
15 #include "pycore_runtime.h"       // _PyRuntimeState
16 
17 #ifndef NSIG
18 # if defined(_NSIG)
19 #  define NSIG _NSIG            /* For BSD/SysV */
20 # elif defined(_SIGMAX)
21 #  define NSIG (_SIGMAX + 1)    /* For QNX */
22 # elif defined(SIGMAX)
23 #  define NSIG (SIGMAX + 1)     /* For djgpp */
24 # else
25 #  define NSIG 64               /* Use a reasonable default value */
26 # endif
27 #endif
28 
29 /* Forward declarations */
30 struct _PyArgv;
31 struct pyruntimestate;
32 
33 /* True if the main interpreter thread exited due to an unhandled
34  * KeyboardInterrupt exception, suggesting the user pressed ^C. */
35 PyAPI_DATA(int) _Py_UnhandledKeyboardInterrupt;
36 
37 extern int _Py_SetFileSystemEncoding(
38     const char *encoding,
39     const char *errors);
40 extern void _Py_ClearFileSystemEncoding(void);
41 extern PyStatus _PyUnicode_InitEncodings(PyThreadState *tstate);
42 #ifdef MS_WINDOWS
43 extern int _PyUnicode_EnableLegacyWindowsFSEncoding(void);
44 #endif
45 
46 PyAPI_FUNC(void) _Py_ClearStandardStreamEncoding(void);
47 
48 PyAPI_FUNC(int) _Py_IsLocaleCoercionTarget(const char *ctype_loc);
49 
50 /* Various one-time initializers */
51 
52 extern PyStatus _PyUnicode_Init(PyInterpreterState *interp);
53 extern PyStatus _PyUnicode_InitTypes(void);
54 extern PyStatus _PyBytes_Init(PyInterpreterState *interp);
55 extern int _PyStructSequence_Init(void);
56 extern int _PyLong_Init(PyInterpreterState *interp);
57 extern int _PyLong_InitTypes(void);
58 extern PyStatus _PyTuple_Init(PyInterpreterState *interp);
59 extern PyStatus _PyFaulthandler_Init(int enable);
60 extern int _PyTraceMalloc_Init(int enable);
61 extern PyObject * _PyBuiltin_Init(PyInterpreterState *interp);
62 extern PyStatus _PySys_Create(
63     PyThreadState *tstate,
64     PyObject **sysmod_p);
65 extern PyStatus _PySys_ReadPreinitWarnOptions(PyWideStringList *options);
66 extern PyStatus _PySys_ReadPreinitXOptions(PyConfig *config);
67 extern int _PySys_UpdateConfig(PyThreadState *tstate);
68 extern PyStatus _PyExc_Init(PyInterpreterState *interp);
69 extern PyStatus _PyErr_InitTypes(void);
70 extern PyStatus _PyBuiltins_AddExceptions(PyObject * bltinmod);
71 extern void _PyFloat_Init(void);
72 extern int _PyFloat_InitTypes(void);
73 extern PyStatus _Py_HashRandomization_Init(const PyConfig *);
74 
75 extern PyStatus _PyTypes_Init(void);
76 extern PyStatus _PyTypes_InitSlotDefs(void);
77 extern PyStatus _PyImportZip_Init(PyThreadState *tstate);
78 extern PyStatus _PyGC_Init(PyInterpreterState *interp);
79 extern PyStatus _PyAtExit_Init(PyInterpreterState *interp);
80 
81 
82 /* Various internal finalizers */
83 
84 extern void _PyFrame_Fini(PyInterpreterState *interp);
85 extern void _PyDict_Fini(PyInterpreterState *interp);
86 extern void _PyTuple_Fini(PyInterpreterState *interp);
87 extern void _PyList_Fini(PyInterpreterState *interp);
88 extern void _PyBytes_Fini(PyInterpreterState *interp);
89 extern void _PyFloat_Fini(PyInterpreterState *interp);
90 extern void _PySlice_Fini(PyInterpreterState *interp);
91 extern void _PyAsyncGen_Fini(PyInterpreterState *interp);
92 
93 extern int _PySignal_Init(int install_signal_handlers);
94 extern void _PySignal_Fini(void);
95 
96 extern void _PyExc_Fini(PyInterpreterState *interp);
97 extern void _PyImport_Fini(void);
98 extern void _PyImport_Fini2(void);
99 extern void _PyGC_Fini(PyInterpreterState *interp);
100 extern void _PyType_Fini(PyInterpreterState *interp);
101 extern void _Py_HashRandomization_Fini(void);
102 extern void _PyUnicode_Fini(PyInterpreterState *interp);
103 extern void _PyUnicode_ClearInterned(PyInterpreterState *interp);
104 extern void _PyLong_Fini(PyInterpreterState *interp);
105 extern void _PyFaulthandler_Fini(void);
106 extern void _PyHash_Fini(void);
107 extern void _PyTraceMalloc_Fini(void);
108 extern void _PyWarnings_Fini(PyInterpreterState *interp);
109 extern void _PyAST_Fini(PyInterpreterState *interp);
110 extern void _PyAtExit_Fini(PyInterpreterState *interp);
111 
112 extern PyStatus _PyGILState_Init(_PyRuntimeState *runtime);
113 extern PyStatus _PyGILState_SetTstate(PyThreadState *tstate);
114 extern void _PyGILState_Fini(PyInterpreterState *interp);
115 
116 PyAPI_FUNC(void) _PyGC_DumpShutdownStats(PyInterpreterState *interp);
117 
118 PyAPI_FUNC(PyStatus) _Py_PreInitializeFromPyArgv(
119     const PyPreConfig *src_config,
120     const struct _PyArgv *args);
121 PyAPI_FUNC(PyStatus) _Py_PreInitializeFromConfig(
122     const PyConfig *config,
123     const struct _PyArgv *args);
124 
125 
126 PyAPI_FUNC(int) _Py_HandleSystemExit(int *exitcode_p);
127 
128 PyAPI_FUNC(PyObject*) _PyErr_WriteUnraisableDefaultHook(PyObject *unraisable);
129 
130 PyAPI_FUNC(void) _PyErr_Print(PyThreadState *tstate);
131 PyAPI_FUNC(void) _PyErr_Display(PyObject *file, PyObject *exception,
132                                 PyObject *value, PyObject *tb);
133 
134 PyAPI_FUNC(void) _PyThreadState_DeleteCurrent(PyThreadState *tstate);
135 
136 extern void _PyAtExit_Call(PyInterpreterState *interp);
137 
138 #ifdef __cplusplus
139 }
140 #endif
141 #endif /* !Py_INTERNAL_LIFECYCLE_H */
142