Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-19 09:50:42

0001 #ifndef Py_CPYTHON_PYLIFECYCLE_H
0002 #  error "this header file must not be included directly"
0003 #endif
0004 
0005 /* Py_FrozenMain is kept out of the Limited API until documented and present
0006    in all builds of Python */
0007 PyAPI_FUNC(int) Py_FrozenMain(int argc, char **argv);
0008 
0009 /* PEP 432 Multi-phase initialization API (Private while provisional!) */
0010 
0011 PyAPI_FUNC(PyStatus) Py_PreInitialize(
0012     const PyPreConfig *src_config);
0013 PyAPI_FUNC(PyStatus) Py_PreInitializeFromBytesArgs(
0014     const PyPreConfig *src_config,
0015     Py_ssize_t argc,
0016     char **argv);
0017 PyAPI_FUNC(PyStatus) Py_PreInitializeFromArgs(
0018     const PyPreConfig *src_config,
0019     Py_ssize_t argc,
0020     wchar_t **argv);
0021 
0022 
0023 /* Initialization and finalization */
0024 
0025 PyAPI_FUNC(PyStatus) Py_InitializeFromConfig(
0026     const PyConfig *config);
0027 
0028 // Python 3.8 provisional API (PEP 587)
0029 PyAPI_FUNC(PyStatus) _Py_InitializeMain(void);
0030 
0031 PyAPI_FUNC(int) Py_RunMain(void);
0032 
0033 
0034 PyAPI_FUNC(void) _Py_NO_RETURN Py_ExitStatusException(PyStatus err);
0035 
0036 PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *);
0037 
0038 /* --- PyInterpreterConfig ------------------------------------ */
0039 
0040 #define PyInterpreterConfig_DEFAULT_GIL (0)
0041 #define PyInterpreterConfig_SHARED_GIL (1)
0042 #define PyInterpreterConfig_OWN_GIL (2)
0043 
0044 typedef struct {
0045     // XXX "allow_object_sharing"?  "own_objects"?
0046     int use_main_obmalloc;
0047     int allow_fork;
0048     int allow_exec;
0049     int allow_threads;
0050     int allow_daemon_threads;
0051     int check_multi_interp_extensions;
0052     int gil;
0053 } PyInterpreterConfig;
0054 
0055 #define _PyInterpreterConfig_INIT \
0056     { \
0057         .use_main_obmalloc = 0, \
0058         .allow_fork = 0, \
0059         .allow_exec = 0, \
0060         .allow_threads = 1, \
0061         .allow_daemon_threads = 0, \
0062         .check_multi_interp_extensions = 1, \
0063         .gil = PyInterpreterConfig_OWN_GIL, \
0064     }
0065 
0066 // gh-117649: The free-threaded build does not currently support single-phase
0067 // init extensions in subinterpreters. For now, we ensure that
0068 // `check_multi_interp_extensions` is always `1`, even in the legacy config.
0069 #ifdef Py_GIL_DISABLED
0070 #  define _PyInterpreterConfig_LEGACY_CHECK_MULTI_INTERP_EXTENSIONS 1
0071 #else
0072 #  define _PyInterpreterConfig_LEGACY_CHECK_MULTI_INTERP_EXTENSIONS 0
0073 #endif
0074 
0075 #define _PyInterpreterConfig_LEGACY_INIT \
0076     { \
0077         .use_main_obmalloc = 1, \
0078         .allow_fork = 1, \
0079         .allow_exec = 1, \
0080         .allow_threads = 1, \
0081         .allow_daemon_threads = 1, \
0082         .check_multi_interp_extensions = _PyInterpreterConfig_LEGACY_CHECK_MULTI_INTERP_EXTENSIONS, \
0083         .gil = PyInterpreterConfig_SHARED_GIL, \
0084     }
0085 
0086 PyAPI_FUNC(PyStatus) Py_NewInterpreterFromConfig(
0087     PyThreadState **tstate_p,
0088     const PyInterpreterConfig *config);
0089 
0090 typedef void (*atexit_datacallbackfunc)(void *);
0091 PyAPI_FUNC(int) PyUnstable_AtExit(
0092         PyInterpreterState *, atexit_datacallbackfunc, void *);