mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 22:02:27 +00:00
Undiamond Python headers
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
This commit is contained in:
parent
20bb8db9f8
commit
b420ed8248
762 changed files with 18410 additions and 53772 deletions
71
third_party/python/Include/pystate.h
vendored
71
third_party/python/Include/pystate.h
vendored
|
@ -1,5 +1,8 @@
|
|||
#ifndef Py_PYSTATE_H
|
||||
#define Py_PYSTATE_H
|
||||
#include "third_party/python/Include/moduleobject.h"
|
||||
#include "third_party/python/Include/object.h"
|
||||
#include "third_party/python/Include/pyatomic.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -161,53 +164,53 @@ typedef struct _ts {
|
|||
#endif
|
||||
|
||||
|
||||
PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_New(void);
|
||||
PyAPI_FUNC(void) PyInterpreterState_Clear(PyInterpreterState *);
|
||||
PyAPI_FUNC(void) PyInterpreterState_Delete(PyInterpreterState *);
|
||||
PyInterpreterState * PyInterpreterState_New(void);
|
||||
void PyInterpreterState_Clear(PyInterpreterState *);
|
||||
void PyInterpreterState_Delete(PyInterpreterState *);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(int) _PyState_AddModule(PyObject*, struct PyModuleDef*);
|
||||
int _PyState_AddModule(PyObject*, struct PyModuleDef*);
|
||||
#endif /* !Py_LIMITED_API */
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
/* New in 3.3 */
|
||||
PyAPI_FUNC(int) PyState_AddModule(PyObject*, struct PyModuleDef*);
|
||||
PyAPI_FUNC(int) PyState_RemoveModule(struct PyModuleDef*);
|
||||
int PyState_AddModule(PyObject*, struct PyModuleDef*);
|
||||
int PyState_RemoveModule(struct PyModuleDef*);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject*) PyState_FindModule(struct PyModuleDef*);
|
||||
PyObject* PyState_FindModule(struct PyModuleDef*);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void) _PyState_ClearModules(void);
|
||||
void _PyState_ClearModules(void);
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(PyThreadState *) PyThreadState_New(PyInterpreterState *);
|
||||
PyThreadState * PyThreadState_New(PyInterpreterState *);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyThreadState *) _PyThreadState_Prealloc(PyInterpreterState *);
|
||||
PyAPI_FUNC(void) _PyThreadState_Init(PyThreadState *);
|
||||
PyThreadState * _PyThreadState_Prealloc(PyInterpreterState *);
|
||||
void _PyThreadState_Init(PyThreadState *);
|
||||
#endif /* !Py_LIMITED_API */
|
||||
PyAPI_FUNC(void) PyThreadState_Clear(PyThreadState *);
|
||||
PyAPI_FUNC(void) PyThreadState_Delete(PyThreadState *);
|
||||
void PyThreadState_Clear(PyThreadState *);
|
||||
void PyThreadState_Delete(PyThreadState *);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void) _PyThreadState_DeleteExcept(PyThreadState *tstate);
|
||||
void _PyThreadState_DeleteExcept(PyThreadState *tstate);
|
||||
#endif /* !Py_LIMITED_API */
|
||||
#ifdef WITH_THREAD
|
||||
PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void);
|
||||
void PyThreadState_DeleteCurrent(void);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void) _PyGILState_Reinit(void);
|
||||
void _PyGILState_Reinit(void);
|
||||
#endif /* !Py_LIMITED_API */
|
||||
#endif
|
||||
|
||||
/* Return the current thread state. The global interpreter lock must be held.
|
||||
* When the current thread state is NULL, this issues a fatal error (so that
|
||||
* the caller needn't check for NULL). */
|
||||
PyAPI_FUNC(PyThreadState *) PyThreadState_Get(void);
|
||||
PyThreadState * PyThreadState_Get(void);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
/* Similar to PyThreadState_Get(), but don't issue a fatal error
|
||||
* if it is NULL. */
|
||||
PyAPI_FUNC(PyThreadState *) _PyThreadState_UncheckedGet(void);
|
||||
PyThreadState * _PyThreadState_UncheckedGet(void);
|
||||
#endif /* !Py_LIMITED_API */
|
||||
|
||||
PyAPI_FUNC(PyThreadState *) PyThreadState_Swap(PyThreadState *);
|
||||
PyAPI_FUNC(PyObject *) PyThreadState_GetDict(void);
|
||||
PyAPI_FUNC(int) PyThreadState_SetAsyncExc(long, PyObject *);
|
||||
PyThreadState * PyThreadState_Swap(PyThreadState *);
|
||||
PyObject * PyThreadState_GetDict(void);
|
||||
int PyThreadState_SetAsyncExc(long, PyObject *);
|
||||
|
||||
|
||||
/* Variable and macro for in-line access to current thread state */
|
||||
|
@ -215,7 +218,7 @@ PyAPI_FUNC(int) PyThreadState_SetAsyncExc(long, PyObject *);
|
|||
/* Assuming the current thread holds the GIL, this is the
|
||||
PyThreadState for the current thread. */
|
||||
#ifdef Py_BUILD_CORE
|
||||
PyAPI_DATA(_Py_atomic_address) _PyThreadState_Current;
|
||||
extern _Py_atomic_address _PyThreadState_Current;
|
||||
# define PyThreadState_GET() \
|
||||
((PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current))
|
||||
#else
|
||||
|
@ -249,7 +252,7 @@ typedef
|
|||
|
||||
Failure is a fatal error.
|
||||
*/
|
||||
PyAPI_FUNC(PyGILState_STATE) PyGILState_Ensure(void);
|
||||
PyGILState_STATE PyGILState_Ensure(void);
|
||||
|
||||
/* Release any resources previously acquired. After this call, Python's
|
||||
state will be the same as it was prior to the corresponding
|
||||
|
@ -259,7 +262,7 @@ PyAPI_FUNC(PyGILState_STATE) PyGILState_Ensure(void);
|
|||
Every call to PyGILState_Ensure must be matched by a call to
|
||||
PyGILState_Release on the same thread.
|
||||
*/
|
||||
PyAPI_FUNC(void) PyGILState_Release(PyGILState_STATE);
|
||||
void PyGILState_Release(PyGILState_STATE);
|
||||
|
||||
/* Helper/diagnostic function - get the current thread state for
|
||||
this thread. May return NULL if no GILState API has been used
|
||||
|
@ -267,25 +270,25 @@ PyAPI_FUNC(void) PyGILState_Release(PyGILState_STATE);
|
|||
thread-state, even if no auto-thread-state call has been made
|
||||
on the main thread.
|
||||
*/
|
||||
PyAPI_FUNC(PyThreadState *) PyGILState_GetThisThreadState(void);
|
||||
PyThreadState * PyGILState_GetThisThreadState(void);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
/* Issue #26558: Flag to disable PyGILState_Check().
|
||||
If set to non-zero, PyGILState_Check() always return 1. */
|
||||
PyAPI_DATA(int) _PyGILState_check_enabled;
|
||||
extern int _PyGILState_check_enabled;
|
||||
|
||||
/* Helper/diagnostic function - return 1 if the current thread
|
||||
currently holds the GIL, 0 otherwise.
|
||||
|
||||
The function returns 1 if _PyGILState_check_enabled is non-zero. */
|
||||
PyAPI_FUNC(int) PyGILState_Check(void);
|
||||
int PyGILState_Check(void);
|
||||
|
||||
/* Unsafe function to get the single PyInterpreterState used by this process'
|
||||
GILState implementation.
|
||||
|
||||
Return NULL before _PyGILState_Init() is called and after _PyGILState_Fini()
|
||||
is called. */
|
||||
PyAPI_FUNC(PyInterpreterState *) _PyGILState_GetInterpreterStateUnsafe(void);
|
||||
PyInterpreterState * _PyGILState_GetInterpreterStateUnsafe(void);
|
||||
#endif
|
||||
|
||||
#endif /* #ifdef WITH_THREAD */
|
||||
|
@ -294,23 +297,23 @@ PyAPI_FUNC(PyInterpreterState *) _PyGILState_GetInterpreterStateUnsafe(void);
|
|||
thread id to that thread's current frame.
|
||||
*/
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) _PyThread_CurrentFrames(void);
|
||||
PyObject * _PyThread_CurrentFrames(void);
|
||||
#endif
|
||||
|
||||
/* Routines for advanced debuggers, requested by David Beazley.
|
||||
Don't use unless you know what you are doing! */
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Head(void);
|
||||
PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *);
|
||||
PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *);
|
||||
PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *);
|
||||
PyInterpreterState * PyInterpreterState_Head(void);
|
||||
PyInterpreterState * PyInterpreterState_Next(PyInterpreterState *);
|
||||
PyThreadState * PyInterpreterState_ThreadHead(PyInterpreterState *);
|
||||
PyThreadState * PyThreadState_Next(PyThreadState *);
|
||||
|
||||
typedef struct _frame *(*PyThreadFrameGetter)(PyThreadState *self_);
|
||||
#endif
|
||||
|
||||
/* hook for PyEval_GetFrame(), requested for Psyco */
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_DATA(PyThreadFrameGetter) _PyThreadState_GetFrame;
|
||||
extern PyThreadFrameGetter _PyThreadState_GetFrame;
|
||||
#endif
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue