1 | use crate::{PyConfig, PyPreConfig, PyStatus, Py_ssize_t}; |
2 | use libc::wchar_t; |
3 | use std::os::raw::{c_char, c_int}; |
4 | |
5 | // "private" functions in cpython/pylifecycle.h accepted in PEP 587 |
6 | extern "C" { |
7 | // skipped _Py_SetStandardStreamEncoding; |
8 | pub fn Py_PreInitialize(src_config: *const PyPreConfig) -> PyStatus; |
9 | pub fn Py_PreInitializeFromBytesArgs( |
10 | src_config: *const PyPreConfig, |
11 | argc: Py_ssize_t, |
12 | argv: *mut *mut c_char, |
13 | ) -> PyStatus; |
14 | pub fn Py_PreInitializeFromArgs( |
15 | src_config: *const PyPreConfig, |
16 | argc: Py_ssize_t, |
17 | argv: *mut *mut wchar_t, |
18 | ) -> PyStatus; |
19 | pub fn _Py_IsCoreInitialized() -> c_int; |
20 | |
21 | pub fn Py_InitializeFromConfig(config: *const PyConfig) -> PyStatus; |
22 | pub fn _Py_InitializeMain() -> PyStatus; |
23 | |
24 | pub fn Py_RunMain() -> c_int; |
25 | |
26 | pub fn Py_ExitStatusException(status: PyStatus) -> !; |
27 | |
28 | // skipped _Py_RestoreSignals |
29 | |
30 | // skipped Py_FdIsInteractive |
31 | // skipped _Py_FdIsInteractive |
32 | |
33 | // skipped _Py_SetProgramFullPath |
34 | |
35 | // skipped _Py_gitidentifier |
36 | // skipped _Py_getversion |
37 | |
38 | // skipped _Py_IsFinalizing |
39 | |
40 | // skipped _PyOS_URandom |
41 | // skipped _PyOS_URandomNonblock |
42 | |
43 | // skipped _Py_CoerceLegacyLocale |
44 | // skipped _Py_LegacyLocaleDetected |
45 | // skipped _Py_SetLocaleFromEnv |
46 | |
47 | } |
48 | |
49 | #[cfg (Py_3_12)] |
50 | pub const PyInterpreterConfig_DEFAULT_GIL: c_int = 0; |
51 | #[cfg (Py_3_12)] |
52 | pub const PyInterpreterConfig_SHARED_GIL: c_int = 1; |
53 | #[cfg (Py_3_12)] |
54 | pub const PyInterpreterConfig_OWN_GIL: c_int = 2; |
55 | |
56 | #[cfg (Py_3_12)] |
57 | #[repr (C)] |
58 | pub struct PyInterpreterConfig { |
59 | pub use_main_obmalloc: c_int, |
60 | pub allow_fork: c_int, |
61 | pub allow_exec: c_int, |
62 | pub allow_threads: c_int, |
63 | pub allow_daemon_threads: c_int, |
64 | pub check_multi_interp_extensions: c_int, |
65 | pub gil: c_int, |
66 | } |
67 | |
68 | #[cfg (Py_3_12)] |
69 | pub const _PyInterpreterConfig_INIT: PyInterpreterConfig = PyInterpreterConfig { |
70 | use_main_obmalloc: 0, |
71 | allow_fork: 0, |
72 | allow_exec: 0, |
73 | allow_threads: 1, |
74 | allow_daemon_threads: 0, |
75 | check_multi_interp_extensions: 1, |
76 | gil: PyInterpreterConfig_OWN_GIL, |
77 | }; |
78 | |
79 | #[cfg (Py_3_12)] |
80 | pub const _PyInterpreterConfig_LEGACY_INIT: PyInterpreterConfig = PyInterpreterConfig { |
81 | use_main_obmalloc: 1, |
82 | allow_fork: 1, |
83 | allow_exec: 1, |
84 | allow_threads: 1, |
85 | allow_daemon_threads: 1, |
86 | check_multi_interp_extensions: 0, |
87 | gil: PyInterpreterConfig_SHARED_GIL, |
88 | }; |
89 | |
90 | extern "C" { |
91 | #[cfg (Py_3_12)] |
92 | pub fn Py_NewInterpreterFromConfig( |
93 | tstate_p: *mut *mut crate::PyThreadState, |
94 | config: *const PyInterpreterConfig, |
95 | ) -> PyStatus; |
96 | } |
97 | |
98 | // skipped atexit_datacallbackfunc |
99 | // skipped _Py_AtExit |
100 | |