mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +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
171
third_party/python/PC/config.c
vendored
171
third_party/python/PC/config.c
vendored
|
@ -1,171 +0,0 @@
|
|||
/* clang-format off */
|
||||
/* Module configuration */
|
||||
|
||||
/* This file contains the table of built-in modules.
|
||||
See create_builtin() in import.c. */
|
||||
|
||||
#include "third_party/python/Include/Python.h"
|
||||
|
||||
extern PyObject* PyInit_array(void);
|
||||
#ifndef MS_WINI64
|
||||
extern PyObject* PyInit_audioop(void);
|
||||
#endif
|
||||
extern PyObject* PyInit_binascii(void);
|
||||
extern PyObject* PyInit_cmath(void);
|
||||
extern PyObject* PyInit_errno(void);
|
||||
extern PyObject* PyInit_faulthandler(void);
|
||||
extern PyObject* PyInit__tracemalloc(void);
|
||||
extern PyObject* PyInit_gc(void);
|
||||
extern PyObject* PyInit_math(void);
|
||||
extern PyObject* PyInit__md5(void);
|
||||
extern PyObject* PyInit_nt(void);
|
||||
extern PyObject* PyInit__operator(void);
|
||||
extern PyObject* PyInit__signal(void);
|
||||
extern PyObject* PyInit__sha1(void);
|
||||
extern PyObject* PyInit__sha256(void);
|
||||
extern PyObject* PyInit__sha512(void);
|
||||
extern PyObject* PyInit__sha3(void);
|
||||
extern PyObject* PyInit__blake2(void);
|
||||
extern PyObject* PyInit_time(void);
|
||||
extern PyObject* PyInit__thread(void);
|
||||
#ifdef WIN32
|
||||
extern PyObject* PyInit_msvcrt(void);
|
||||
extern PyObject* PyInit__locale(void);
|
||||
#endif
|
||||
extern PyObject* PyInit__codecs(void);
|
||||
extern PyObject* PyInit__weakref(void);
|
||||
extern PyObject* PyInit_xxsubtype(void);
|
||||
extern PyObject* PyInit_zipimport(void);
|
||||
extern PyObject* PyInit__random(void);
|
||||
extern PyObject* PyInit_itertools(void);
|
||||
extern PyObject* PyInit__collections(void);
|
||||
extern PyObject* PyInit__heapq(void);
|
||||
extern PyObject* PyInit__bisect(void);
|
||||
extern PyObject* PyInit__symtable(void);
|
||||
extern PyObject* PyInit_mmap(void);
|
||||
extern PyObject* PyInit__csv(void);
|
||||
extern PyObject* PyInit__sre(void);
|
||||
extern PyObject* PyInit_parser(void);
|
||||
extern PyObject* PyInit_winreg(void);
|
||||
extern PyObject* PyInit__struct(void);
|
||||
extern PyObject* PyInit__datetime(void);
|
||||
extern PyObject* PyInit__functools(void);
|
||||
extern PyObject* PyInit__json(void);
|
||||
extern PyObject* PyInit_zlib(void);
|
||||
|
||||
extern PyObject* PyInit__multibytecodec(void);
|
||||
extern PyObject* PyInit__codecs_cn(void);
|
||||
extern PyObject* PyInit__codecs_hk(void);
|
||||
extern PyObject* PyInit__codecs_iso2022(void);
|
||||
extern PyObject* PyInit__codecs_jp(void);
|
||||
extern PyObject* PyInit__codecs_kr(void);
|
||||
extern PyObject* PyInit__codecs_tw(void);
|
||||
extern PyObject* PyInit__winapi(void);
|
||||
extern PyObject* PyInit__lsprof(void);
|
||||
extern PyObject* PyInit__ast(void);
|
||||
extern PyObject* PyInit__io(void);
|
||||
extern PyObject* PyInit__pickle(void);
|
||||
extern PyObject* PyInit_atexit(void);
|
||||
extern PyObject* _PyWarnings_Init(void);
|
||||
extern PyObject* PyInit__string(void);
|
||||
extern PyObject* PyInit__stat(void);
|
||||
extern PyObject* PyInit__opcode(void);
|
||||
|
||||
/* tools/freeze/makeconfig.py marker for additional "extern" */
|
||||
/* -- ADDMODULE MARKER 1 -- */
|
||||
|
||||
extern PyObject* PyMarshal_Init(void);
|
||||
extern PyObject* PyInit_imp(void);
|
||||
|
||||
struct _inittab _PyImport_Inittab[] = {
|
||||
|
||||
{"array", PyInit_array},
|
||||
{"_ast", PyInit__ast},
|
||||
#ifdef MS_WINDOWS
|
||||
#ifndef MS_WINI64
|
||||
{"audioop", PyInit_audioop},
|
||||
#endif
|
||||
#endif
|
||||
{"binascii", PyInit_binascii},
|
||||
{"cmath", PyInit_cmath},
|
||||
{"errno", PyInit_errno},
|
||||
{"faulthandler", PyInit_faulthandler},
|
||||
{"gc", PyInit_gc},
|
||||
{"math", PyInit_math},
|
||||
{"nt", PyInit_nt}, /* Use the NT os functions, not posix */
|
||||
{"_operator", PyInit__operator},
|
||||
{"_signal", PyInit__signal},
|
||||
{"_md5", PyInit__md5},
|
||||
{"_sha1", PyInit__sha1},
|
||||
{"_sha256", PyInit__sha256},
|
||||
{"_sha512", PyInit__sha512},
|
||||
{"_sha3", PyInit__sha3},
|
||||
{"_blake2", PyInit__blake2},
|
||||
{"time", PyInit_time},
|
||||
#ifdef WITH_THREAD
|
||||
{"_thread", PyInit__thread},
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
{"msvcrt", PyInit_msvcrt},
|
||||
{"_locale", PyInit__locale},
|
||||
#endif
|
||||
{"_tracemalloc", PyInit__tracemalloc},
|
||||
/* XXX Should _winapi go in a WIN32 block? not WIN64? */
|
||||
{"_winapi", PyInit__winapi},
|
||||
|
||||
{"_codecs", PyInit__codecs},
|
||||
{"_weakref", PyInit__weakref},
|
||||
{"_random", PyInit__random},
|
||||
{"_bisect", PyInit__bisect},
|
||||
{"_heapq", PyInit__heapq},
|
||||
{"_lsprof", PyInit__lsprof},
|
||||
{"itertools", PyInit_itertools},
|
||||
{"_collections", PyInit__collections},
|
||||
{"_symtable", PyInit__symtable},
|
||||
{"mmap", PyInit_mmap},
|
||||
{"_csv", PyInit__csv},
|
||||
{"_sre", PyInit__sre},
|
||||
{"parser", PyInit_parser},
|
||||
{"winreg", PyInit_winreg},
|
||||
{"_struct", PyInit__struct},
|
||||
{"_datetime", PyInit__datetime},
|
||||
{"_functools", PyInit__functools},
|
||||
{"_json", PyInit__json},
|
||||
|
||||
{"xxsubtype", PyInit_xxsubtype},
|
||||
{"zipimport", PyInit_zipimport},
|
||||
{"zlib", PyInit_zlib},
|
||||
|
||||
/* CJK codecs */
|
||||
{"_multibytecodec", PyInit__multibytecodec},
|
||||
{"_codecs_cn", PyInit__codecs_cn},
|
||||
{"_codecs_hk", PyInit__codecs_hk},
|
||||
{"_codecs_iso2022", PyInit__codecs_iso2022},
|
||||
{"_codecs_jp", PyInit__codecs_jp},
|
||||
{"_codecs_kr", PyInit__codecs_kr},
|
||||
{"_codecs_tw", PyInit__codecs_tw},
|
||||
|
||||
/* tools/freeze/makeconfig.py marker for additional "_inittab" entries */
|
||||
/* -- ADDMODULE MARKER 2 -- */
|
||||
|
||||
/* This module "lives in" with marshal.c */
|
||||
{"marshal", PyMarshal_Init},
|
||||
|
||||
/* This lives it with import.c */
|
||||
{"_imp", PyInit_imp},
|
||||
|
||||
/* These entries are here for sys.builtin_module_names */
|
||||
{"builtins", NULL},
|
||||
{"sys", NULL},
|
||||
{"_warnings", _PyWarnings_Init},
|
||||
{"_string", PyInit__string},
|
||||
|
||||
{"_io", PyInit__io},
|
||||
{"_pickle", PyInit__pickle},
|
||||
{"atexit", PyInit_atexit},
|
||||
{"_stat", PyInit__stat},
|
||||
{"_opcode", PyInit__opcode},
|
||||
|
||||
/* Sentinel */
|
||||
{0, 0}
|
||||
};
|
21
third_party/python/PC/getpathp.c
vendored
21
third_party/python/PC/getpathp.c
vendored
|
@ -1,3 +1,4 @@
|
|||
/* clang-format off */
|
||||
#include "windows.h"
|
||||
|
||||
/* Return the initial module search path. */
|
||||
|
@ -79,28 +80,10 @@
|
|||
|
||||
---------------------------------------------------------------- */
|
||||
|
||||
#include <wchar.h>
|
||||
|
||||
#include "Python.h"
|
||||
#include "osdefs.h"
|
||||
|
||||
#ifndef MS_WINDOWS
|
||||
#error getpathp.c should only be built on Windows
|
||||
#endif
|
||||
|
||||
#include <Shlwapi.h>
|
||||
#include <windows.h>
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif /* HAVE_SYS_TYPES_H */
|
||||
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
#endif /* HAVE_SYS_STAT_H */
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/* Search in some common locations for the associated Python libraries.
|
||||
*
|
||||
* Py_GetPath() tries to return a sensible Python module search path.
|
||||
|
@ -375,7 +358,7 @@ static wchar_t *getpythonregpath(HKEY keyBase, int skipcore) {
|
|||
*/
|
||||
ppPaths = PyMem_RawMalloc(sizeof(WCHAR *) * numKeys);
|
||||
if (ppPaths == NULL) goto done;
|
||||
memset(ppPaths, 0, sizeof(WCHAR *) * numKeys);
|
||||
bzero(ppPaths, sizeof(WCHAR *) * numKeys);
|
||||
/* Loop over all subkeys, allocating a temp sub-buffer. */
|
||||
for (index = 0; index < numKeys; index++) {
|
||||
WCHAR keyBuf[MAX_PATH + 1];
|
||||
|
|
2
third_party/python/PC/launcher.c
vendored
2
third_party/python/PC/launcher.c
vendored
|
@ -632,7 +632,7 @@ run_child(wchar_t * cmdline)
|
|||
sizeof(info));
|
||||
if (!ok)
|
||||
error(RC_CREATE_PROCESS, L"Job information setting failed");
|
||||
memset(&si, 0, sizeof(si));
|
||||
bzero(&si, sizeof(si));
|
||||
si.cb = sizeof(si);
|
||||
ok = safe_duplicate_handle(GetStdHandle(STD_INPUT_HANDLE), &si.hStdInput);
|
||||
if (!ok)
|
||||
|
|
1
third_party/python/PC/winreg.c
vendored
1
third_party/python/PC/winreg.c
vendored
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/pyerrors.h"
|
||||
#include "third_party/python/Include/structmember.h"
|
||||
|
||||
static BOOL PyHKEY_AsHKEY(PyObject *ob, HKEY *pRes, BOOL bNoneOK);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue