pylifecycle.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #ifndef Py_CPYTHON_PYLIFECYCLE_H
  2. # error "this header file must not be included directly"
  3. #endif
  4. /* Py_FrozenMain is kept out of the Limited API until documented and present
  5. in all builds of Python */
  6. PyAPI_FUNC(int) Py_FrozenMain(int argc, char **argv);
  7. /* Only used by applications that embed the interpreter and need to
  8. * override the standard encoding determination mechanism
  9. */
  10. Py_DEPRECATED(3.11) PyAPI_FUNC(int) Py_SetStandardStreamEncoding(
  11. const char *encoding,
  12. const char *errors);
  13. /* PEP 432 Multi-phase initialization API (Private while provisional!) */
  14. PyAPI_FUNC(PyStatus) Py_PreInitialize(
  15. const PyPreConfig *src_config);
  16. PyAPI_FUNC(PyStatus) Py_PreInitializeFromBytesArgs(
  17. const PyPreConfig *src_config,
  18. Py_ssize_t argc,
  19. char **argv);
  20. PyAPI_FUNC(PyStatus) Py_PreInitializeFromArgs(
  21. const PyPreConfig *src_config,
  22. Py_ssize_t argc,
  23. wchar_t **argv);
  24. PyAPI_FUNC(int) _Py_IsCoreInitialized(void);
  25. /* Initialization and finalization */
  26. PyAPI_FUNC(PyStatus) Py_InitializeFromConfig(
  27. const PyConfig *config);
  28. PyAPI_FUNC(PyStatus) _Py_InitializeMain(void);
  29. PyAPI_FUNC(int) Py_RunMain(void);
  30. PyAPI_FUNC(void) _Py_NO_RETURN Py_ExitStatusException(PyStatus err);
  31. /* Restore signals that the interpreter has called SIG_IGN on to SIG_DFL. */
  32. PyAPI_FUNC(void) _Py_RestoreSignals(void);
  33. PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *);
  34. PyAPI_FUNC(int) _Py_FdIsInteractive(FILE *fp, PyObject *filename);
  35. Py_DEPRECATED(3.11) PyAPI_FUNC(void) _Py_SetProgramFullPath(const wchar_t *);
  36. PyAPI_FUNC(const char *) _Py_gitidentifier(void);
  37. PyAPI_FUNC(const char *) _Py_gitversion(void);
  38. PyAPI_FUNC(int) _Py_IsFinalizing(void);
  39. PyAPI_FUNC(int) _Py_IsInterpreterFinalizing(PyInterpreterState *interp);
  40. /* Random */
  41. PyAPI_FUNC(int) _PyOS_URandom(void *buffer, Py_ssize_t size);
  42. PyAPI_FUNC(int) _PyOS_URandomNonblock(void *buffer, Py_ssize_t size);
  43. /* Legacy locale support */
  44. PyAPI_FUNC(int) _Py_CoerceLegacyLocale(int warn);
  45. PyAPI_FUNC(int) _Py_LegacyLocaleDetected(int warn);
  46. PyAPI_FUNC(char *) _Py_SetLocaleFromEnv(int category);
  47. /* --- PyInterpreterConfig ------------------------------------ */
  48. #define PyInterpreterConfig_DEFAULT_GIL (0)
  49. #define PyInterpreterConfig_SHARED_GIL (1)
  50. #define PyInterpreterConfig_OWN_GIL (2)
  51. typedef struct {
  52. // XXX "allow_object_sharing"? "own_objects"?
  53. int use_main_obmalloc;
  54. int allow_fork;
  55. int allow_exec;
  56. int allow_threads;
  57. int allow_daemon_threads;
  58. int check_multi_interp_extensions;
  59. int gil;
  60. } PyInterpreterConfig;
  61. #define _PyInterpreterConfig_INIT \
  62. { \
  63. .use_main_obmalloc = 0, \
  64. .allow_fork = 0, \
  65. .allow_exec = 0, \
  66. .allow_threads = 1, \
  67. .allow_daemon_threads = 0, \
  68. .check_multi_interp_extensions = 1, \
  69. .gil = PyInterpreterConfig_OWN_GIL, \
  70. }
  71. #define _PyInterpreterConfig_LEGACY_INIT \
  72. { \
  73. .use_main_obmalloc = 1, \
  74. .allow_fork = 1, \
  75. .allow_exec = 1, \
  76. .allow_threads = 1, \
  77. .allow_daemon_threads = 1, \
  78. .check_multi_interp_extensions = 0, \
  79. .gil = PyInterpreterConfig_SHARED_GIL, \
  80. }
  81. PyAPI_FUNC(PyStatus) Py_NewInterpreterFromConfig(
  82. PyThreadState **tstate_p,
  83. const PyInterpreterConfig *config);
  84. typedef void (*atexit_datacallbackfunc)(void *);
  85. PyAPI_FUNC(int) _Py_AtExit(
  86. PyInterpreterState *, atexit_datacallbackfunc, void *);