mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 15:03:34 +00:00
This change gets the Python codebase into a state where it conforms to the conventions of this codebase. It's now possible to include headers from Python, without worrying about ordering. Python has traditionally solved that problem by "diamonding" everything in Python.h, but that's problematic since it means any change to any Python header invalidates all the build artifacts. Lastly it makes tooling not work. Since it is hard to explain to Emacs when I press C-c C-h to add an import line it shouldn't add the header that actually defines the symbol, and instead do follow the nonstandard Python convention. Progress has been made on letting Python load source code from the zip executable structure via the standard C library APIs. System calss now recognizes zip!FILENAME alternative URIs as equivalent to zip:FILENAME since Python uses colon as its delimiter. Some progress has been made on embedding the notice license terms into the Python object code. This is easier said than done since Python has an extremely complicated ownership story. - Some termios APIs have been added - Implement rewinddir() dirstream API - GetCpuCount() API added to Cosmopolitan Libc - More bugs in Cosmopolitan Libc have been fixed - zipobj.com now has flags for mangling the path - Fixed bug a priori with sendfile() on certain BSDs - Polyfill F_DUPFD and F_DUPFD_CLOEXEC across platforms - FIOCLEX / FIONCLEX now polyfilled for fast O_CLOEXEC changes - APE now supports a hybrid solution to no-self-modify for builds - Many BSD-only magnums added, e.g. O_SEARCH, O_SHLOCK, SF_NODISKIO
127 lines
3.3 KiB
C
127 lines
3.3 KiB
C
#ifndef Py_PYLIFECYCLE_H
|
|
#define Py_PYLIFECYCLE_H
|
|
#include "third_party/python/Include/object.h"
|
|
#include "third_party/python/Include/pystate.h"
|
|
COSMOPOLITAN_C_START_
|
|
/* clang-format off */
|
|
|
|
void Py_SetProgramName(wchar_t *);
|
|
wchar_t * Py_GetProgramName(void);
|
|
|
|
void Py_SetPythonHome(wchar_t *);
|
|
wchar_t * Py_GetPythonHome(void);
|
|
|
|
#ifndef Py_LIMITED_API
|
|
/* Only used by applications that embed the interpreter and need to
|
|
* override the standard encoding determination mechanism
|
|
*/
|
|
int Py_SetStandardStreamEncoding(const char *encoding,
|
|
const char *errors);
|
|
#endif
|
|
|
|
void Py_Initialize(void);
|
|
void Py_InitializeEx(int);
|
|
#ifndef Py_LIMITED_API
|
|
void _Py_InitializeEx_Private(int, int);
|
|
#endif
|
|
void Py_Finalize(void);
|
|
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060000
|
|
int Py_FinalizeEx(void);
|
|
#endif
|
|
int Py_IsInitialized(void);
|
|
PyThreadState * Py_NewInterpreter(void);
|
|
void Py_EndInterpreter(PyThreadState *);
|
|
|
|
|
|
/* Py_PyAtExit is for the atexit module, Py_AtExit is for low-level
|
|
* exit functions.
|
|
*/
|
|
#ifndef Py_LIMITED_API
|
|
void _Py_PyAtExit(void (*func)(void));
|
|
#endif
|
|
int Py_AtExit(void (*func)(void));
|
|
|
|
void Py_Exit(int);
|
|
|
|
/* Restore signals that the interpreter has called SIG_IGN on to SIG_DFL. */
|
|
#ifndef Py_LIMITED_API
|
|
void _Py_RestoreSignals(void);
|
|
|
|
int Py_FdIsInteractive(FILE *, const char *);
|
|
#endif
|
|
|
|
/* Bootstrap __main__ (defined in Modules/main.c) */
|
|
int Py_Main(int argc, wchar_t **argv);
|
|
|
|
/* In getpath.c */
|
|
wchar_t * Py_GetProgramFullPath(void);
|
|
wchar_t * Py_GetPrefix(void);
|
|
wchar_t * Py_GetExecPrefix(void);
|
|
wchar_t * Py_GetPath(void);
|
|
void Py_SetPath(const wchar_t *);
|
|
#ifdef MS_WINDOWS
|
|
int _Py_CheckPython3();
|
|
#endif
|
|
|
|
/* In their own files */
|
|
const char * Py_GetVersion(void);
|
|
const char * Py_GetPlatform(void);
|
|
const char * Py_GetCopyright(void);
|
|
const char * Py_GetCompiler(void);
|
|
const char * Py_GetBuildInfo(void);
|
|
#ifndef Py_LIMITED_API
|
|
const char * _Py_gitidentifier(void);
|
|
const char * _Py_gitversion(void);
|
|
#endif
|
|
|
|
/* Internal -- various one-time initializations */
|
|
#ifndef Py_LIMITED_API
|
|
PyObject * _PyBuiltin_Init(void);
|
|
PyObject * _PySys_Init(void);
|
|
void _PyImport_Init(void);
|
|
void _PyExc_Init(PyObject * bltinmod);
|
|
void _PyImportHooks_Init(void);
|
|
int _PyFrame_Init(void);
|
|
int _PyFloat_Init(void);
|
|
int PyByteArray_Init(void);
|
|
void _PyRandom_Init(void);
|
|
#endif
|
|
|
|
/* Various internal finalizers */
|
|
#ifndef Py_LIMITED_API
|
|
void _PyExc_Fini(void);
|
|
void _PyImport_Fini(void);
|
|
void PyMethod_Fini(void);
|
|
void PyFrame_Fini(void);
|
|
void PyCFunction_Fini(void);
|
|
void PyDict_Fini(void);
|
|
void PyTuple_Fini(void);
|
|
void PyList_Fini(void);
|
|
void PySet_Fini(void);
|
|
void PyBytes_Fini(void);
|
|
void PyByteArray_Fini(void);
|
|
void PyFloat_Fini(void);
|
|
void PyOS_FiniInterrupts(void);
|
|
void _PyGC_DumpShutdownStats(void);
|
|
void _PyGC_Fini(void);
|
|
void PySlice_Fini(void);
|
|
void _PyType_Fini(void);
|
|
void _PyRandom_Fini(void);
|
|
void PyAsyncGen_Fini(void);
|
|
|
|
extern PyThreadState * _Py_Finalizing;
|
|
#endif
|
|
|
|
/* Signals */
|
|
typedef void (*PyOS_sighandler_t)(int);
|
|
PyOS_sighandler_t PyOS_getsig(int);
|
|
PyOS_sighandler_t PyOS_setsig(int, PyOS_sighandler_t);
|
|
|
|
#ifndef Py_LIMITED_API
|
|
/* Random */
|
|
int _PyOS_URandom(void *buffer, Py_ssize_t size);
|
|
int _PyOS_URandomNonblock(void *buffer, Py_ssize_t size);
|
|
#endif /* !Py_LIMITED_API */
|
|
|
|
COSMOPOLITAN_C_END_
|
|
#endif /* !Py_PYLIFECYCLE_H */
|