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:
Justine Tunney 2021-08-12 00:42:14 -07:00
parent 20bb8db9f8
commit b420ed8248
762 changed files with 18410 additions and 53772 deletions

View file

@ -1,5 +1,6 @@
#ifndef Py_TRACEBACK_H
#define Py_TRACEBACK_H
#include "third_party/python/Include/object.h"
#include "third_party/python/Include/pystate.h"
COSMOPOLITAN_C_START_
/* clang-format off */
@ -17,15 +18,15 @@ typedef struct _traceback {
} PyTracebackObject;
#endif
PyAPI_FUNC(int) PyTraceBack_Here(struct _frame *);
PyAPI_FUNC(int) PyTraceBack_Print(PyObject *, PyObject *);
int PyTraceBack_Here(struct _frame *);
int PyTraceBack_Print(PyObject *, PyObject *);
#ifndef Py_LIMITED_API
PyAPI_FUNC(int) _Py_DisplaySourceLine(PyObject *, PyObject *, int, int);
PyAPI_FUNC(void) _PyTraceback_Add(const char *, const char *, int);
int _Py_DisplaySourceLine(PyObject *, PyObject *, int, int);
void _PyTraceback_Add(const char *, const char *, int);
#endif
/* Reveal traceback type so we can typecheck traceback objects */
PyAPI_DATA(PyTypeObject) PyTraceBack_Type;
extern PyTypeObject PyTraceBack_Type;
#define PyTraceBack_Check(v) (Py_TYPE(v) == &PyTraceBack_Type)
#ifndef Py_LIMITED_API
@ -46,7 +47,7 @@ PyAPI_DATA(PyTypeObject) PyTraceBack_Type;
This function is signal safe. */
PyAPI_FUNC(void) _Py_DumpTraceback(
void _Py_DumpTraceback(
int fd,
PyThreadState *tstate);
@ -73,7 +74,7 @@ PyAPI_FUNC(void) _Py_DumpTraceback(
This function is signal safe. */
PyAPI_FUNC(const char*) _Py_DumpTracebackThreads(
const char* _Py_DumpTracebackThreads(
int fd,
PyInterpreterState *interp,
PyThreadState *current_tstate);
@ -88,12 +89,12 @@ PyAPI_FUNC(const char*) _Py_DumpTracebackThreads(
string which is not ready (PyUnicode_WCHAR_KIND).
This function is signal safe. */
PyAPI_FUNC(void) _Py_DumpASCII(int fd, PyObject *text);
void _Py_DumpASCII(int fd, PyObject *text);
/* Format an integer as decimal into the file descriptor fd.
This function is signal safe. */
PyAPI_FUNC(void) _Py_DumpDecimal(
void _Py_DumpDecimal(
int fd,
unsigned long value);
@ -103,7 +104,7 @@ PyAPI_FUNC(void) _Py_DumpDecimal(
The maximum width is sizeof(unsigned long)*2 digits.
This function is signal safe. */
PyAPI_FUNC(void) _Py_DumpHexadecimal(
void _Py_DumpHexadecimal(
int fd,
unsigned long value,
Py_ssize_t width);