Decentralize Python native module linkage

We can now link even smaller Python binaries. For example, the hello.com
program in the Python build directory is a compiled linked executable of
hello.py which just prints hello world. Using decentralized sections, we
can make that binary 1.9mb in size (noting that python.com is 6.3 megs!)

This works for nontrivial programs too. For example, say we want an APE
binary that's equivalent to python.com -m http.server. Our makefile now
builds such a binary using the new launcher and it's only 3.2mb in size
since Python sources get turned into ELF objects, which tell our linker
that we need things like native hashing algorithm code.
This commit is contained in:
Justine Tunney 2021-09-07 11:40:11 -07:00
parent dfa0359b50
commit 559b024e1d
129 changed files with 2798 additions and 13514 deletions

View file

@ -6,6 +6,7 @@
*/
#define PY_SSIZE_T_CLEAN
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/object.h"
@ -282,3 +283,8 @@ PyInit__bisect(void)
{
return PyModule_Create(&_bisectmodule);
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__bisect = {
"_bisect",
PyInit__bisect,
};

View file

@ -9,6 +9,7 @@
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/bytesobject.h"
#include "third_party/python/Include/ceval.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/object.h"
#include "third_party/python/Include/pyerrors.h"
@ -814,3 +815,8 @@ PyInit__bz2(void)
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__bz2 = {
"_bz2",
PyInit__bz2,
};

View file

@ -8,6 +8,7 @@
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/bytesobject.h"
#include "third_party/python/Include/codecs.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/object.h"
#include "third_party/python/Include/pyerrors.h"

View file

@ -4,6 +4,7 @@
#include "third_party/python/Include/ceval.h"
#include "third_party/python/Include/descrobject.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/object.h"

View file

@ -7,6 +7,7 @@
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/descrobject.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/listobject.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
@ -1715,3 +1716,8 @@ PyInit__csv(void)
PyModule_AddObject(module, "Error", _csvstate(module)->error_obj);
return module;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__csv = {
"_csv",
PyInit__csv,
};

View file

@ -1,552 +0,0 @@
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-│
vi: set net ft=c ts=4 sts=4 sw=4 fenc=utf-8 :vi
Python 3
https://docs.python.org/3/license.html │
*/
#include "third_party/python/Include/yoink.h"
/* clang-format off */
PYTHON_PROVIDE("_curses_panel");
PYTHON_PROVIDE("_curses_panel.bottom_panel");
PYTHON_PROVIDE("_curses_panel.error");
PYTHON_PROVIDE("_curses_panel.new_panel");
PYTHON_PROVIDE("_curses_panel.top_panel");
PYTHON_PROVIDE("_curses_panel.update_panels");
PYTHON_PROVIDE("_curses_panel.version");
/*
* Interface to the ncurses panel library
*
* Original version by Thomas Gellekum
*/
/* Release Number */
static const char PyCursesVersion[] = "2.1";
/* Includes */
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/py_curses.h"
typedef struct {
PyObject *PyCursesError;
PyObject *PyCursesPanel_Type;
} _curses_panelstate;
#define _curses_panelstate(o) ((_curses_panelstate *)PyModule_GetState(o))
static int
_curses_panel_clear(PyObject *m)
{
Py_CLEAR(_curses_panelstate(m)->PyCursesError);
return 0;
}
static int
_curses_panel_traverse(PyObject *m, visitproc visit, void *arg)
{
Py_VISIT(_curses_panelstate(m)->PyCursesError);
return 0;
}
static void
_curses_panel_free(void *m)
{
_curses_panel_clear((PyObject *) m);
}
static struct PyModuleDef _curses_panelmodule;
#define _curses_panelstate_global \
((_curses_panelstate *) PyModule_GetState(PyState_FindModule(&_curses_panelmodule)))
/* Utility Functions */
/*
* Check the return code from a curses function and return None
* or raise an exception as appropriate.
*/
static PyObject *
PyCursesCheckERR(int code, const char *fname)
{
if (code != ERR) {
Py_INCREF(Py_None);
return Py_None;
} else {
if (fname == NULL) {
PyErr_SetString(_curses_panelstate_global->PyCursesError, catchall_ERR);
} else {
PyErr_Format(_curses_panelstate_global->PyCursesError, "%s() returned ERR", fname);
}
return NULL;
}
}
/*****************************************************************************
The Panel Object
******************************************************************************/
/* Definition of the panel object and panel type */
typedef struct {
PyObject_HEAD
PANEL *pan;
PyCursesWindowObject *wo; /* for reference counts */
} PyCursesPanelObject;
#define PyCursesPanel_Check(v) \
(Py_TYPE(v) == _curses_panelstate_global->PyCursesPanel_Type)
/* Some helper functions. The problem is that there's always a window
associated with a panel. To ensure that Python's GC doesn't pull
this window from under our feet we need to keep track of references
to the corresponding window object within Python. We can't use
dupwin(oldwin) to keep a copy of the curses WINDOW because the
contents of oldwin is copied only once; code like
win = newwin(...)
pan = win.panel()
win.addstr(some_string)
pan.window().addstr(other_string)
will fail. */
/* We keep a linked list of PyCursesPanelObjects, lop. A list should
suffice, I don't expect more than a handful or at most a few
dozens of panel objects within a typical program. */
typedef struct _list_of_panels {
PyCursesPanelObject *po;
struct _list_of_panels *next;
} list_of_panels;
/* list anchor */
static list_of_panels *lop;
/* Insert a new panel object into lop */
static int
insert_lop(PyCursesPanelObject *po)
{
list_of_panels *new;
if ((new = (list_of_panels *)PyMem_Malloc(sizeof(list_of_panels))) == NULL) {
PyErr_NoMemory();
return -1;
}
new->po = po;
new->next = lop;
lop = new;
return 0;
}
/* Remove the panel object from lop */
static void
remove_lop(PyCursesPanelObject *po)
{
list_of_panels *temp, *n;
temp = lop;
if (temp->po == po) {
lop = temp->next;
PyMem_Free(temp);
return;
}
while (temp->next == NULL || temp->next->po != po) {
if (temp->next == NULL) {
PyErr_SetString(PyExc_RuntimeError,
"remove_lop: can't find Panel Object");
return;
}
temp = temp->next;
}
n = temp->next->next;
PyMem_Free(temp->next);
temp->next = n;
return;
}
/* Return the panel object that corresponds to pan */
static PyCursesPanelObject *
find_po(PANEL *pan)
{
list_of_panels *temp;
for (temp = lop; temp->po->pan != pan; temp = temp->next)
if (temp->next == NULL) return NULL; /* not found!? */
return temp->po;
}
/* Function Prototype Macros - They are ugly but very, very useful. ;-)
X - function name
TYPE - parameter Type
ERGSTR - format string for construction of the return value
PARSESTR - format string for argument parsing */
#define Panel_NoArgNoReturnFunction(X) \
static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self) \
{ return PyCursesCheckERR(X(self->pan), # X); }
#define Panel_NoArgTrueFalseFunction(X) \
static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self) \
{ \
if (X (self->pan) == FALSE) { Py_INCREF(Py_False); return Py_False; } \
else { Py_INCREF(Py_True); return Py_True; } }
#define Panel_TwoArgNoReturnFunction(X, TYPE, PARSESTR) \
static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self, PyObject *args) \
{ \
TYPE arg1, arg2; \
if (!PyArg_ParseTuple(args, PARSESTR, &arg1, &arg2)) return NULL; \
return PyCursesCheckERR(X(self->pan, arg1, arg2), # X); }
/* ------------- PANEL routines --------------- */
Panel_NoArgNoReturnFunction(bottom_panel)
Panel_NoArgNoReturnFunction(hide_panel)
Panel_NoArgNoReturnFunction(show_panel)
Panel_NoArgNoReturnFunction(top_panel)
Panel_NoArgTrueFalseFunction(panel_hidden)
Panel_TwoArgNoReturnFunction(move_panel, int, "ii;y,x")
/* Allocation and deallocation of Panel Objects */
static PyObject *
PyCursesPanel_New(PANEL *pan, PyCursesWindowObject *wo)
{
PyCursesPanelObject *po;
po = PyObject_NEW(PyCursesPanelObject,
(PyTypeObject *)(_curses_panelstate_global)->PyCursesPanel_Type);
if (po == NULL) return NULL;
po->pan = pan;
if (insert_lop(po) < 0) {
po->wo = NULL;
Py_DECREF(po);
return NULL;
}
po->wo = wo;
Py_INCREF(wo);
return (PyObject *)po;
}
static void
PyCursesPanel_Dealloc(PyCursesPanelObject *po)
{
PyObject *obj = (PyObject *) panel_userptr(po->pan);
if (obj) {
(void)set_panel_userptr(po->pan, NULL);
Py_DECREF(obj);
}
(void)del_panel(po->pan);
if (po->wo != NULL) {
Py_DECREF(po->wo);
remove_lop(po);
}
PyObject_DEL(po);
}
/* panel_above(NULL) returns the bottom panel in the stack. To get
this behaviour we use curses.panel.bottom_panel(). */
static PyObject *
PyCursesPanel_above(PyCursesPanelObject *self)
{
PANEL *pan;
PyCursesPanelObject *po;
pan = panel_above(self->pan);
if (pan == NULL) { /* valid output, it means the calling panel
is on top of the stack */
Py_INCREF(Py_None);
return Py_None;
}
po = find_po(pan);
if (po == NULL) {
PyErr_SetString(PyExc_RuntimeError,
"panel_above: can't find Panel Object");
return NULL;
}
Py_INCREF(po);
return (PyObject *)po;
}
/* panel_below(NULL) returns the top panel in the stack. To get
this behaviour we use curses.panel.top_panel(). */
static PyObject *
PyCursesPanel_below(PyCursesPanelObject *self)
{
PANEL *pan;
PyCursesPanelObject *po;
pan = panel_below(self->pan);
if (pan == NULL) { /* valid output, it means the calling panel
is on the bottom of the stack */
Py_INCREF(Py_None);
return Py_None;
}
po = find_po(pan);
if (po == NULL) {
PyErr_SetString(PyExc_RuntimeError,
"panel_below: can't find Panel Object");
return NULL;
}
Py_INCREF(po);
return (PyObject *)po;
}
static PyObject *
PyCursesPanel_window(PyCursesPanelObject *self)
{
Py_INCREF(self->wo);
return (PyObject *)self->wo;
}
static PyObject *
PyCursesPanel_replace_panel(PyCursesPanelObject *self, PyObject *args)
{
PyCursesPanelObject *po;
PyCursesWindowObject *temp;
int rtn;
if (PyTuple_Size(args) != 1) {
PyErr_SetString(PyExc_TypeError, "replace requires one argument");
return NULL;
}
if (!PyArg_ParseTuple(args, "O!;window object",
&PyCursesWindow_Type, &temp))
return NULL;
po = find_po(self->pan);
if (po == NULL) {
PyErr_SetString(PyExc_RuntimeError,
"replace_panel: can't find Panel Object");
return NULL;
}
rtn = replace_panel(self->pan, temp->win);
if (rtn == ERR) {
PyErr_SetString(_curses_panelstate_global->PyCursesError, "replace_panel() returned ERR");
return NULL;
}
Py_INCREF(temp);
Py_SETREF(po->wo, temp);
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
PyCursesPanel_set_panel_userptr(PyCursesPanelObject *self, PyObject *obj)
{
PyObject *oldobj;
int rc;
PyCursesInitialised;
Py_INCREF(obj);
oldobj = (PyObject *) panel_userptr(self->pan);
rc = set_panel_userptr(self->pan, (void*)obj);
if (rc == ERR) {
/* In case of an ncurses error, decref the new object again */
Py_DECREF(obj);
}
Py_XDECREF(oldobj);
return PyCursesCheckERR(rc, "set_panel_userptr");
}
static PyObject *
PyCursesPanel_userptr(PyCursesPanelObject *self)
{
PyObject *obj;
PyCursesInitialised;
obj = (PyObject *) panel_userptr(self->pan);
if (obj == NULL) {
PyErr_SetString(_curses_panelstate_global->PyCursesError, "no userptr set");
return NULL;
}
Py_INCREF(obj);
return obj;
}
/* Module interface */
static PyMethodDef PyCursesPanel_Methods[] = {
{"above", (PyCFunction)PyCursesPanel_above, METH_NOARGS},
{"below", (PyCFunction)PyCursesPanel_below, METH_NOARGS},
{"bottom", (PyCFunction)PyCursesPanel_bottom_panel, METH_NOARGS},
{"hidden", (PyCFunction)PyCursesPanel_panel_hidden, METH_NOARGS},
{"hide", (PyCFunction)PyCursesPanel_hide_panel, METH_NOARGS},
{"move", (PyCFunction)PyCursesPanel_move_panel, METH_VARARGS},
{"replace", (PyCFunction)PyCursesPanel_replace_panel, METH_VARARGS},
{"set_userptr", (PyCFunction)PyCursesPanel_set_panel_userptr, METH_O},
{"show", (PyCFunction)PyCursesPanel_show_panel, METH_NOARGS},
{"top", (PyCFunction)PyCursesPanel_top_panel, METH_NOARGS},
{"userptr", (PyCFunction)PyCursesPanel_userptr, METH_NOARGS},
{"window", (PyCFunction)PyCursesPanel_window, METH_NOARGS},
{NULL, NULL} /* sentinel */
};
/* -------------------------------------------------------*/
static PyType_Slot PyCursesPanel_Type_slots[] = {
{Py_tp_dealloc, PyCursesPanel_Dealloc},
{Py_tp_methods, PyCursesPanel_Methods},
{0, 0},
};
static PyType_Spec PyCursesPanel_Type_spec = {
"_curses_panel.curses panel",
sizeof(PyCursesPanelObject),
0,
Py_TPFLAGS_DEFAULT,
PyCursesPanel_Type_slots
};
/* Wrapper for panel_above(NULL). This function returns the bottom
panel of the stack, so it's renamed to bottom_panel().
panel.above() *requires* a panel object in the first place which
may be undesirable. */
static PyObject *
PyCurses_bottom_panel(PyObject *self)
{
PANEL *pan;
PyCursesPanelObject *po;
PyCursesInitialised;
pan = panel_above(NULL);
if (pan == NULL) { /* valid output, it means
there's no panel at all */
Py_INCREF(Py_None);
return Py_None;
}
po = find_po(pan);
if (po == NULL) {
PyErr_SetString(PyExc_RuntimeError,
"panel_above: can't find Panel Object");
return NULL;
}
Py_INCREF(po);
return (PyObject *)po;
}
static PyObject *
PyCurses_new_panel(PyObject *self, PyObject *args)
{
PyCursesWindowObject *win;
PANEL *pan;
if (!PyArg_ParseTuple(args, "O!", &PyCursesWindow_Type, &win))
return NULL;
pan = new_panel(win->win);
if (pan == NULL) {
PyErr_SetString(_curses_panelstate_global->PyCursesError, catchall_NULL);
return NULL;
}
return (PyObject *)PyCursesPanel_New(pan, win);
}
/* Wrapper for panel_below(NULL). This function returns the top panel
of the stack, so it's renamed to top_panel(). panel.below()
*requires* a panel object in the first place which may be
undesirable. */
static PyObject *
PyCurses_top_panel(PyObject *self)
{
PANEL *pan;
PyCursesPanelObject *po;
PyCursesInitialised;
pan = panel_below(NULL);
if (pan == NULL) { /* valid output, it means
there's no panel at all */
Py_INCREF(Py_None);
return Py_None;
}
po = find_po(pan);
if (po == NULL) {
PyErr_SetString(PyExc_RuntimeError,
"panel_below: can't find Panel Object");
return NULL;
}
Py_INCREF(po);
return (PyObject *)po;
}
static PyObject *PyCurses_update_panels(PyObject *self)
{
PyCursesInitialised;
update_panels();
Py_INCREF(Py_None);
return Py_None;
}
/* List of functions defined in the module */
static PyMethodDef PyCurses_methods[] = {
{"bottom_panel", (PyCFunction)PyCurses_bottom_panel, METH_NOARGS},
{"new_panel", (PyCFunction)PyCurses_new_panel, METH_VARARGS},
{"top_panel", (PyCFunction)PyCurses_top_panel, METH_NOARGS},
{"update_panels", (PyCFunction)PyCurses_update_panels, METH_NOARGS},
{NULL, NULL} /* sentinel */
};
/* Initialization function for the module */
static struct PyModuleDef _curses_panelmodule = {
PyModuleDef_HEAD_INIT,
"_curses_panel",
NULL,
sizeof(_curses_panelstate),
PyCurses_methods,
NULL,
_curses_panel_traverse,
_curses_panel_clear,
_curses_panel_free
};
PyMODINIT_FUNC
PyInit__curses_panel(void)
{
PyObject *m, *d, *v;
/* Create the module and add the functions */
m = PyModule_Create(&_curses_panelmodule);
if (m == NULL)
goto fail;
d = PyModule_GetDict(m);
/* Initialize object type */
v = PyType_FromSpec(&PyCursesPanel_Type_spec);
if (v == NULL)
goto fail;
((PyTypeObject *)v)->tp_new = NULL;
_curses_panelstate(m)->PyCursesPanel_Type = v;
import_curses();
if (PyErr_Occurred())
goto fail;
/* For exception _curses_panel.error */
_curses_panelstate(m)->PyCursesError = PyErr_NewException("_curses_panel.error", NULL, NULL);
PyDict_SetItemString(d, "error", _curses_panelstate(m)->PyCursesError);
/* Make the version available */
v = PyUnicode_FromString(PyCursesVersion);
PyDict_SetItemString(d, "version", v);
PyDict_SetItemString(d, "__version__", v);
Py_DECREF(v);
return m;
fail:
Py_XDECREF(m);
return NULL;
}

File diff suppressed because it is too large Load diff

View file

@ -6041,6 +6041,11 @@ PyInit__datetime(void)
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__datetime = {
"_datetime",
PyInit__datetime,
};
/* ---------------------------------------------------------------------------
Some time zone algebra. For a datetime x, let
x.n = x stripped of its timezone -- its naive time.

View file

@ -5992,7 +5992,7 @@ error:
return NULL; /* GCOV_NOT_REACHED */
}
_Section(".rodata.pytab") struct _inittab _PyImport_Inittab__decimal = {
"_decimal",
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__decimal = {
"_decimal",
PyInit__decimal,
};

View file

@ -4091,3 +4091,8 @@ PyInit__elementtree(void)
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__elementtree = {
"_elementtree",
PyInit__elementtree,
};

View file

@ -10,6 +10,7 @@
#include "third_party/python/Include/classobject.h"
#include "third_party/python/Include/descrobject.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/object.h"

View file

@ -5,8 +5,10 @@
https://docs.python.org/3/license.html │
*/
#define PY_SSIZE_T_CLEAN
#include "third_party/mbedtls/error.h"
#include "third_party/mbedtls/md.h"
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/pystrhex.h"
#include "third_party/python/Include/structmember.h"
#include "third_party/python/Include/yoink.h"
@ -21,15 +23,15 @@ PYTHON_PROVIDE("_hashlib.__name__");
PYTHON_PROVIDE("_hashlib.__package__");
PYTHON_PROVIDE("_hashlib.__spec__");
PYTHON_PROVIDE("_hashlib.new");
PYTHON_PROVIDE("_hashlib.openssl_md5");
PYTHON_PROVIDE("_hashlib.openssl_md_meth_names");
PYTHON_PROVIDE("_hashlib.openssl_sha1");
PYTHON_PROVIDE("_hashlib.openssl_sha224");
PYTHON_PROVIDE("_hashlib.openssl_sha256");
PYTHON_PROVIDE("_hashlib.openssl_sha384");
PYTHON_PROVIDE("_hashlib.openssl_sha512");
PYTHON_PROVIDE("_hashlib.mbedtls_md5");
PYTHON_PROVIDE("_hashlib.mbedtls_md_meth_names");
PYTHON_PROVIDE("_hashlib.mbedtls_sha1");
PYTHON_PROVIDE("_hashlib.mbedtls_sha224");
PYTHON_PROVIDE("_hashlib.mbedtls_sha256");
PYTHON_PROVIDE("_hashlib.mbedtls_sha384");
PYTHON_PROVIDE("_hashlib.mbedtls_sha512");
#include "third_party/python/Modules/clinic/_hashopenssl.inc"
#include "third_party/python/Modules/clinic/_hashmbedtls.inc"
/*[clinic input]
module _hashlib
[clinic start generated code]*/
@ -51,49 +53,26 @@ typedef struct {
} EVPobject;
static PyTypeObject EVPtype;
static PyObject *CONST_md5_name_obj;
static PyObject *CONST_sha1_name_obj;
static PyObject *CONST_sha224_name_obj;
static PyObject *CONST_sha256_name_obj;
static PyObject *CONST_sha384_name_obj;
static PyObject *CONST_sha512_name_obj;
#define DEFINE_CONSTS_FOR_NEW(Name) \
static PyObject *CONST_ ## Name ## _name_obj = NULL; \
static mbedtls_md_context_t *CONST_new_ ## Name ## _ctx_p = NULL;
static mbedtls_md_context_t *CONST_new_ ## Name ## _ctx_p = NULL
DEFINE_CONSTS_FOR_NEW(md5)
DEFINE_CONSTS_FOR_NEW(sha1)
DEFINE_CONSTS_FOR_NEW(sha224)
DEFINE_CONSTS_FOR_NEW(sha256)
DEFINE_CONSTS_FOR_NEW(sha384)
DEFINE_CONSTS_FOR_NEW(sha512)
DEFINE_CONSTS_FOR_NEW(md5);
DEFINE_CONSTS_FOR_NEW(sha1);
DEFINE_CONSTS_FOR_NEW(sha224);
DEFINE_CONSTS_FOR_NEW(sha256);
DEFINE_CONSTS_FOR_NEW(sha384);
DEFINE_CONSTS_FOR_NEW(sha512);
DEFINE_CONSTS_FOR_NEW(blake2b256);
/* LCOV_EXCL_START */
static PyObject *
_setException(PyObject *exc)
_setException(PyObject *exc, int rc)
{
/* unsigned long errcode; */
/* const char *lib, *func, *reason; */
/* errcode = ERR_peek_last_error(); */
/* if (!errcode) { */
/* PyErr_SetString(exc, "unknown reasons"); */
/* return NULL; */
/* } */
/* ERR_clear_error(); */
/* lib = ERR_lib_error_string(errcode); */
/* func = ERR_func_error_string(errcode); */
/* reason = ERR_reason_error_string(errcode); */
/* if (lib && func) { */
/* PyErr_Format(exc, "[%s: %s] %s", lib, func, reason); */
/* } */
/* else if (lib) { */
/* PyErr_Format(exc, "[%s] %s", lib, reason); */
/* } */
/* else { */
/* PyErr_SetString(exc, reason); */
/* } */
PyErr_SetString(exc, "failhouse");
char b[128];
mbedtls_strerror(rc, b, sizeof(b));
PyErr_SetString(exc, b);
return NULL;
}
/* LCOV_EXCL_STOP */
@ -122,6 +101,7 @@ newEVPobject(PyObject *name)
static void
EVP_hash(EVPobject *self, const void *vp, Py_ssize_t len)
{
int rc;
unsigned int process;
const unsigned char *cp = (const unsigned char *)vp;
while (0 < len) {
@ -129,8 +109,8 @@ EVP_hash(EVPobject *self, const void *vp, Py_ssize_t len)
process = MUNCH_SIZE;
else
process = Py_SAFE_DOWNCAST(len, Py_ssize_t, unsigned int);
if (!mbedtls_md_update(self->ctx, (const void*)cp, process)) {
_setException(PyExc_ValueError);
if ((rc = mbedtls_md_update(self->ctx, (const void*)cp, process))) {
_setException(PyExc_ValueError, rc);
break;
}
len -= process;
@ -156,12 +136,11 @@ EVP_dealloc(EVPobject *self)
static int
locked_mbedtls_md_clone(mbedtls_md_context_t *new_ctx_p, EVPobject *self)
{
int result;
int rc;
ENTER_HASHLIB(self);
result = mbedtls_md_clone(new_ctx_p, self->ctx);
result = 0;
rc = mbedtls_md_clone(new_ctx_p, self->ctx);
LEAVE_HASHLIB(self);
return result;
return rc;
}
/* External methods for a hash object */
@ -171,11 +150,12 @@ PyDoc_STRVAR(EVP_copy__doc__, "Return a copy of the hash object.");
static PyObject *
EVP_copy(EVPobject *self, PyObject *unused)
{
int rc;
EVPobject *newobj;
if ( (newobj = newEVPobject(self->name))==NULL)
return NULL;
if (!locked_mbedtls_md_clone(newobj->ctx, self)) {
return _setException(PyExc_ValueError);
if ((rc = locked_mbedtls_md_clone(newobj->ctx, self))) {
return _setException(PyExc_ValueError, rc);
}
return (PyObject *)newobj;
}
@ -186,6 +166,7 @@ PyDoc_STRVAR(EVP_digest__doc__,
static PyObject *
EVP_digest(EVPobject *self, PyObject *unused)
{
int rc;
unsigned char digest[MBEDTLS_MD_MAX_SIZE];
mbedtls_md_context_t *temp_ctx;
PyObject *retval;
@ -195,12 +176,12 @@ EVP_digest(EVPobject *self, PyObject *unused)
PyErr_NoMemory();
return NULL;
}
if (!locked_mbedtls_md_clone(temp_ctx, self)) {
return _setException(PyExc_ValueError);
if ((rc = locked_mbedtls_md_clone(temp_ctx, self))) {
return _setException(PyExc_ValueError, rc);
}
digest_size = mbedtls_md_get_size(temp_ctx->md_info);
if (!mbedtls_md_finish(temp_ctx, digest)) {
_setException(PyExc_ValueError);
if ((rc = mbedtls_md_finish(temp_ctx, digest))) {
_setException(PyExc_ValueError, rc);
return NULL;
}
retval = PyBytes_FromStringAndSize((const char *)digest, digest_size);
@ -214,6 +195,7 @@ PyDoc_STRVAR(EVP_hexdigest__doc__,
static PyObject *
EVP_hexdigest(EVPobject *self, PyObject *unused)
{
int rc;
unsigned char digest[MBEDTLS_MD_MAX_SIZE];
mbedtls_md_context_t *temp_ctx;
unsigned int digest_size;
@ -223,12 +205,12 @@ EVP_hexdigest(EVPobject *self, PyObject *unused)
return NULL;
}
/* Get the raw (binary) digest value */
if (!locked_mbedtls_md_clone(temp_ctx, self)) {
return _setException(PyExc_ValueError);
if ((rc = locked_mbedtls_md_clone(temp_ctx, self))) {
return _setException(PyExc_ValueError, rc);
}
digest_size = mbedtls_md_get_size(temp_ctx->md_info);
if (!mbedtls_md_finish(temp_ctx, digest)) {
_setException(PyExc_ValueError);
if ((rc = mbedtls_md_finish(temp_ctx, digest))) {
_setException(PyExc_ValueError, rc);
return NULL;
}
mbedtls_md_free(temp_ctx);
@ -432,6 +414,7 @@ EVPnew(PyObject *name_obj,
const mbedtls_md_context_t *initial_ctx,
const unsigned char *cp, Py_ssize_t len)
{
int rc;
EVPobject *self;
if (!digest && !initial_ctx) {
PyErr_SetString(PyExc_ValueError, "unsupported hash type");
@ -442,8 +425,8 @@ EVPnew(PyObject *name_obj,
if (initial_ctx) {
mbedtls_md_clone(self->ctx, initial_ctx);
} else {
if (!mbedtls_md_setup(self->ctx, digest, 0)) {
_setException(PyExc_ValueError);
if ((rc = mbedtls_md_setup(self->ctx, digest, 0))) {
_setException(PyExc_ValueError, rc);
Py_DECREF(self);
return NULL;
}
@ -497,8 +480,8 @@ EVP_new(PyObject *self, PyObject *args, PyObject *kwdict)
return ret_obj;
}
#if (OPENSSL_VERSION_NUMBER >= 0x10000000 && !defined(OPENSSL_NO_HMAC) \
&& !defined(OPENSSL_NO_SHA))
#if (MBEDTLS_VERSION_NUMBER >= 0x10000000 && !defined(MBEDTLS_NO_HMAC) \
&& !defined(MBEDTLS_NO_SHA))
#define PY_PBKDF2_HMAC 1
@ -510,7 +493,7 @@ EVP_new(PyObject *self, PyObject *args, PyObject *kwdict)
* more. The improved algorithm is not subject to a Denial-of-Service
* vulnerability with overly large passwords.
*
* Also OpenSSL < 1.0 don't provide PKCS5_PBKDF2_HMAC(), only
* Also Mbedtls < 1.0 don't provide PKCS5_PBKDF2_HMAC(), only
* PKCS5_PBKDF2_SHA1.
*/
static int
@ -680,9 +663,9 @@ pbkdf2_hmac(PyObject *self, PyObject *args, PyObject *kwdict)
#endif
Py_END_ALLOW_THREADS
if (!retval) {
if (retval) {
Py_CLEAR(key_obj);
_setException(PyExc_ValueError);
_setException(PyExc_ValueError, retval);
goto end;
}
@ -694,7 +677,7 @@ pbkdf2_hmac(PyObject *self, PyObject *args, PyObject *kwdict)
#endif
#if OPENSSL_VERSION_NUMBER > 0x10100000L && !defined(OPENSSL_NO_SCRYPT) && !defined(LIBRESSL_VERSION_NUMBER)
#if MBEDTLS_VERSION_NUMBER > 0x10100000L && !defined(MBEDTLS_NO_SCRYPT) && !defined(LIBRESSL_VERSION_NUMBER)
#define PY_SCRYPT 1
/* XXX: Parameters salt, n, r and p should be required keyword-only parameters.
They are optional in the Argument Clinic declaration only due to a
@ -764,8 +747,8 @@ _hashlib_scrypt_impl(PyObject *module, Py_buffer *password, Py_buffer *salt,
return NULL;
}
if (maxmem < 0 || maxmem > INT_MAX) {
/* OpenSSL 1.1.0 restricts maxmem to 32MB. It may change in the
future. The maxmem constant is private to OpenSSL. */
/* Mbedtls 1.1.0 restricts maxmem to 32MB. It may change in the
future. The maxmem constant is private to Mbedtls. */
PyErr_Format(PyExc_ValueError,
"maxmem must be positive and smaller than %d",
INT_MAX);
@ -777,7 +760,7 @@ _hashlib_scrypt_impl(PyObject *module, Py_buffer *password, Py_buffer *salt,
INT_MAX);
return NULL;
}
/* let OpenSSL validate the rest */
/* let Mbedtls validate the rest */
retval = EVP_PBE_scrypt(NULL, 0, NULL, 0, n, r, p, maxmem, NULL, 0);
if (!retval) {
/* sorry, can't do much better */
@ -835,6 +818,7 @@ generate_hash_name_list(void)
static PyObject * \
EVP_new_ ## NAME (PyObject *self, PyObject *args) \
{ \
int rc; \
PyObject *data_obj = NULL; \
Py_buffer view = { 0 }; \
PyObject *ret_obj; \
@ -845,9 +829,10 @@ generate_hash_name_list(void)
\
if (CONST_new_ ## NAME ## _ctx_p == NULL) { \
mbedtls_md_context_t *ctx_p = calloc(1, sizeof(mbedtls_md_context_t)); \
rc = MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE; \
if (!mbedtls_md_info_from_string(#NAME) || \
!mbedtls_md_setup(ctx_p, mbedtls_md_info_from_string(#NAME), 0)) { \
_setException(PyExc_ValueError); \
(rc = mbedtls_md_setup(ctx_p, mbedtls_md_info_from_string(#NAME), 0))) { \
_setException(PyExc_ValueError, rc); \
mbedtls_md_free(ctx_p); \
return NULL; \
} \
@ -871,12 +856,12 @@ generate_hash_name_list(void)
/* a PyMethodDef structure for the constructor */
#define CONSTRUCTOR_METH_DEF(NAME) \
{"openssl_" #NAME, (PyCFunction)EVP_new_ ## NAME, METH_VARARGS, \
{"mbedtls_" #NAME, (PyCFunction)EVP_new_ ## NAME, METH_VARARGS, \
PyDoc_STR("Returns a " #NAME \
" hash object; optionally initialized with a string") \
}
/* used in the init function to setup a constructor: initialize OpenSSL
/* used in the init function to setup a constructor: initialize Mbedtls
constructor constants if they haven't been initialized already. */
#define INIT_CONSTRUCTOR_CONSTANTS(NAME) \
if (CONST_ ## NAME ## _name_obj == NULL) { \
@ -889,6 +874,7 @@ GEN_CONSTRUCTOR(sha224)
GEN_CONSTRUCTOR(sha256)
GEN_CONSTRUCTOR(sha384)
GEN_CONSTRUCTOR(sha512)
GEN_CONSTRUCTOR(blake2b256)
/* List of functions exported by this module */
@ -905,6 +891,7 @@ static struct PyMethodDef EVP_functions[] = {
CONSTRUCTOR_METH_DEF(sha256),
CONSTRUCTOR_METH_DEF(sha384),
CONSTRUCTOR_METH_DEF(sha512),
CONSTRUCTOR_METH_DEF(blake2b256),
{NULL, NULL} /* Sentinel */
};
@ -923,8 +910,8 @@ static struct PyModuleDef _hashlibmodule = {
PyMODINIT_FUNC
PyInit__hashlib(void)
{
PyObject *m, *openssl_md_meth_names;
/* TODO build EVP_functions openssl_* entries dynamically based
PyObject *m, *mbedtls_md_meth_names;
/* TODO build EVP_functions mbedtls_* entries dynamically based
* on what hashes are supported rather than listing many
* but having some be unsupported. Only init appropriate
* constants. */
@ -934,12 +921,12 @@ PyInit__hashlib(void)
m = PyModule_Create(&_hashlibmodule);
if (m == NULL)
return NULL;
openssl_md_meth_names = generate_hash_name_list();
if (openssl_md_meth_names == NULL) {
mbedtls_md_meth_names = generate_hash_name_list();
if (mbedtls_md_meth_names == NULL) {
Py_DECREF(m);
return NULL;
}
if (PyModule_AddObject(m, "openssl_md_meth_names", openssl_md_meth_names)) {
if (PyModule_AddObject(m, "mbedtls_md_meth_names", mbedtls_md_meth_names)) {
Py_DECREF(m);
return NULL;
}
@ -952,5 +939,11 @@ PyInit__hashlib(void)
INIT_CONSTRUCTOR_CONSTANTS(sha256)
INIT_CONSTRUCTOR_CONSTANTS(sha384)
INIT_CONSTRUCTOR_CONSTANTS(sha512)
INIT_CONSTRUCTOR_CONSTANTS(blake2b256)
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__hashlib = {
"_hashlib",
PyInit__hashlib,
};

View file

@ -5,6 +5,7 @@
https://docs.python.org/3/license.html │
*/
#include "libc/assert.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/listobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/pyerrors.h"
@ -683,4 +684,3 @@ PyInit__heapq(void)
PyModule_AddObject(m, "__about__", about);
return m;
}

View file

@ -1,3 +1,9 @@
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-│
vi: set net ft=c ts=4 sts=4 sw=4 fenc=utf-8 :vi
Python 3
https://docs.python.org/3/license.html │
*/
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/accu.h"
#include "third_party/python/Include/boolobject.h"
@ -1971,3 +1977,8 @@ PyInit__json(void)
Py_DECREF(m);
return NULL;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__json = {
"_json",
PyInit__json,
};

View file

@ -5,9 +5,11 @@
https://docs.python.org/3/license.html │
*/
#define PY_SSIZE_T_CLEAN
#include "libc/unicode/langinfo.h"
#include "libc/unicode/locale.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/fileutils.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/listobject.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"

View file

@ -5,6 +5,7 @@
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/floatobject.h"
#include "third_party/python/Include/frameobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/objimpl.h"
@ -900,3 +901,8 @@ PyInit__lsprof(void)
initialized = 1;
return module;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__lsprof = {
"_lsprof",
PyInit__lsprof,
};

View file

@ -224,3 +224,8 @@ PyInit__multiprocessing(void)
return module;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__multiprocessing = {
"_multiprocessing",
PyInit__multiprocessing,
};

View file

@ -5,6 +5,7 @@
https://docs.python.org/3/license.html │
*/
#include "third_party/python/Include/compile.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/object.h"
@ -92,3 +93,8 @@ PyInit__opcode(void)
{
return PyModule_Create(&opcodemodule);
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__opcode = {
"_opcode",
PyInit__opcode,
};

View file

@ -44,6 +44,8 @@ PYTHON_PROVIDE("_pickle.dumps");
PYTHON_PROVIDE("_pickle.load");
PYTHON_PROVIDE("_pickle.loads");
PYTHON_YOINK("encodings.ascii");
PyDoc_STRVAR(pickle_module_doc,
"Optimized C implementation for the Python pickle module.");
@ -7475,3 +7477,8 @@ PyInit__pickle(void)
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__pickle = {
"_pickle",
PyInit__pickle,
};

View file

@ -724,3 +724,8 @@ PyInit__posixsubprocess(void)
{
return PyModule_Create(&_posixsubprocessmodule);
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__posixsubprocess = {
"_posixsubprocess",
PyInit__posixsubprocess,
};

View file

@ -6,6 +6,7 @@
*/
#include "libc/calls/calls.h"
#include "third_party/python/Include/floatobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/objimpl.h"
@ -561,3 +562,8 @@ PyInit__random(void)
PyModule_AddObject(m, "Random", (PyObject *)&Random_Type);
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__random = {
"_random",
PyInit__random,
};

View file

@ -7,17 +7,33 @@
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/bytesobject.h"
#include "third_party/python/Include/descrobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/object.h"
#include "third_party/python/Include/objimpl.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pystrhex.h"
#include "third_party/python/Include/yoink.h"
PYTHON_PROVIDE("_sha3");
PYTHON_PROVIDE("_sha3.__doc__");
PYTHON_PROVIDE("_sha3.__loader__");
PYTHON_PROVIDE("_sha3.__name__");
PYTHON_PROVIDE("_sha3.__package__");
PYTHON_PROVIDE("_sha3.__spec__");
PYTHON_PROVIDE("_sha3.implementation");
PYTHON_PROVIDE("_sha3.keccakopt");
PYTHON_PROVIDE("_sha3.sha3_224");
PYTHON_PROVIDE("_sha3.sha3_256");
PYTHON_PROVIDE("_sha3.sha3_384");
PYTHON_PROVIDE("_sha3.sha3_512");
PYTHON_PROVIDE("_sha3.shake_128");
PYTHON_PROVIDE("_sha3.shake_256");
/*
Ran preprocessor on working build, because spaghetti structure of
upstream Python 3.6 source code was unnaceptably incomprehensible
TODO(jart): Find SHA3 that isn't written in a laugh out loud way!
*/
typedef enum { SUCCESS = 0, FAIL = 1, BAD_HASHLEN = 2 } HashReturn;
@ -35,15 +51,15 @@ typedef struct {
unsigned char delimitedSuffix;
} Keccak_HashInstance;
static const uint64_t KeccakF1600RoundConstants[24] = {
0x0000000000000001ULL, 0x0000000000008082ULL, 0x800000000000808aULL,
0x8000000080008000ULL, 0x000000000000808bULL, 0x0000000080000001ULL,
0x8000000080008081ULL, 0x8000000000008009ULL, 0x000000000000008aULL,
0x0000000000000088ULL, 0x0000000080008009ULL, 0x000000008000000aULL,
0x000000008000808bULL, 0x800000000000008bULL, 0x8000000000008089ULL,
0x8000000000008003ULL, 0x8000000000008002ULL, 0x8000000000000080ULL,
0x000000000000800aULL, 0x800000008000000aULL, 0x8000000080008081ULL,
0x8000000000008080ULL, 0x0000000080000001ULL, 0x8000000080008008ULL,
static const uint64_t kKeccakf[24] = {
0x0000000000000001, 0x0000000000008082, 0x800000000000808a,
0x8000000080008000, 0x000000000000808b, 0x0000000080000001,
0x8000000080008081, 0x8000000000008009, 0x000000000000008a,
0x0000000000000088, 0x0000000080008009, 0x000000008000000a,
0x000000008000808b, 0x800000000000008b, 0x8000000000008089,
0x8000000000008003, 0x8000000000008002, 0x8000000000000080,
0x000000000000800a, 0x800000008000000a, 0x8000000080008081,
0x8000000000008080, 0x0000000080000001, 0x8000000080008008,
};
static void _PySHA3_KeccakP1600_Initialize(void *state) {
@ -203,6 +219,8 @@ static void _PySHA3_KeccakP1600_OverwriteWithZeroes(void *state,
}
static void _PySHA3_KeccakP1600_Permute_24rounds(void *state) {
uint64_t Ca, Ce, Ci, Co, Cu;
uint64_t Da, De, Di, Do, Du;
uint64_t Aba, Abe, Abi, Abo, Abu;
uint64_t Aga, Age, Agi, Ago, Agu;
uint64_t Aka, Ake, Aki, Ako, Aku;
@ -213,8 +231,6 @@ static void _PySHA3_KeccakP1600_Permute_24rounds(void *state) {
uint64_t Bka, Bke, Bki, Bko, Bku;
uint64_t Bma, Bme, Bmi, Bmo, Bmu;
uint64_t Bsa, Bse, Bsi, Bso, Bsu;
uint64_t Ca, Ce, Ci, Co, Cu;
uint64_t Da, De, Di, Do, Du;
uint64_t Eba, Ebe, Ebi, Ebo, Ebu;
uint64_t Ega, Ege, Egi, Ego, Egu;
uint64_t Eka, Eke, Eki, Eko, Eku;
@ -267,7 +283,7 @@ static void _PySHA3_KeccakP1600_Permute_24rounds(void *state) {
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[0];
Eba ^= kKeccakf[0];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -373,7 +389,7 @@ static void _PySHA3_KeccakP1600_Permute_24rounds(void *state) {
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[1];
Aba ^= kKeccakf[1];
Ca = Aba;
Abe = Bbe ^ ((~Bbi) | Bbo);
Ce = Abe;
@ -479,7 +495,7 @@ static void _PySHA3_KeccakP1600_Permute_24rounds(void *state) {
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[2];
Eba ^= kKeccakf[2];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -585,7 +601,7 @@ static void _PySHA3_KeccakP1600_Permute_24rounds(void *state) {
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[3];
Aba ^= kKeccakf[3];
Ca = Aba;
Abe = Bbe ^ ((~Bbi) | Bbo);
Ce = Abe;
@ -691,7 +707,7 @@ static void _PySHA3_KeccakP1600_Permute_24rounds(void *state) {
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[4];
Eba ^= kKeccakf[4];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -797,7 +813,7 @@ static void _PySHA3_KeccakP1600_Permute_24rounds(void *state) {
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[5];
Aba ^= kKeccakf[5];
Ca = Aba;
Abe = Bbe ^ ((~Bbi) | Bbo);
Ce = Abe;
@ -903,7 +919,7 @@ static void _PySHA3_KeccakP1600_Permute_24rounds(void *state) {
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[6];
Eba ^= kKeccakf[6];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -1009,7 +1025,7 @@ static void _PySHA3_KeccakP1600_Permute_24rounds(void *state) {
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[7];
Aba ^= kKeccakf[7];
Ca = Aba;
Abe = Bbe ^ ((~Bbi) | Bbo);
Ce = Abe;
@ -1115,7 +1131,7 @@ static void _PySHA3_KeccakP1600_Permute_24rounds(void *state) {
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[8];
Eba ^= kKeccakf[8];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -1221,7 +1237,7 @@ static void _PySHA3_KeccakP1600_Permute_24rounds(void *state) {
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[9];
Aba ^= kKeccakf[9];
Ca = Aba;
Abe = Bbe ^ ((~Bbi) | Bbo);
Ce = Abe;
@ -1327,7 +1343,7 @@ static void _PySHA3_KeccakP1600_Permute_24rounds(void *state) {
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[10];
Eba ^= kKeccakf[10];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -1433,7 +1449,7 @@ static void _PySHA3_KeccakP1600_Permute_24rounds(void *state) {
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[11];
Aba ^= kKeccakf[11];
Ca = Aba;
Abe = Bbe ^ ((~Bbi) | Bbo);
Ce = Abe;
@ -1539,7 +1555,7 @@ static void _PySHA3_KeccakP1600_Permute_24rounds(void *state) {
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[12];
Eba ^= kKeccakf[12];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -1645,7 +1661,7 @@ static void _PySHA3_KeccakP1600_Permute_24rounds(void *state) {
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[13];
Aba ^= kKeccakf[13];
Ca = Aba;
Abe = Bbe ^ ((~Bbi) | Bbo);
Ce = Abe;
@ -1751,7 +1767,7 @@ static void _PySHA3_KeccakP1600_Permute_24rounds(void *state) {
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[14];
Eba ^= kKeccakf[14];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -1857,7 +1873,7 @@ static void _PySHA3_KeccakP1600_Permute_24rounds(void *state) {
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[15];
Aba ^= kKeccakf[15];
Ca = Aba;
Abe = Bbe ^ ((~Bbi) | Bbo);
Ce = Abe;
@ -1963,7 +1979,7 @@ static void _PySHA3_KeccakP1600_Permute_24rounds(void *state) {
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[16];
Eba ^= kKeccakf[16];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -2069,7 +2085,7 @@ static void _PySHA3_KeccakP1600_Permute_24rounds(void *state) {
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[17];
Aba ^= kKeccakf[17];
Ca = Aba;
Abe = Bbe ^ ((~Bbi) | Bbo);
Ce = Abe;
@ -2175,7 +2191,7 @@ static void _PySHA3_KeccakP1600_Permute_24rounds(void *state) {
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[18];
Eba ^= kKeccakf[18];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -2281,7 +2297,7 @@ static void _PySHA3_KeccakP1600_Permute_24rounds(void *state) {
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[19];
Aba ^= kKeccakf[19];
Ca = Aba;
Abe = Bbe ^ ((~Bbi) | Bbo);
Ce = Abe;
@ -2387,7 +2403,7 @@ static void _PySHA3_KeccakP1600_Permute_24rounds(void *state) {
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[20];
Eba ^= kKeccakf[20];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -2493,7 +2509,7 @@ static void _PySHA3_KeccakP1600_Permute_24rounds(void *state) {
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[21];
Aba ^= kKeccakf[21];
Ca = Aba;
Abe = Bbe ^ ((~Bbi) | Bbo);
Ce = Abe;
@ -2599,7 +2615,7 @@ static void _PySHA3_KeccakP1600_Permute_24rounds(void *state) {
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[22];
Eba ^= kKeccakf[22];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -2705,7 +2721,7 @@ static void _PySHA3_KeccakP1600_Permute_24rounds(void *state) {
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[23];
Aba ^= kKeccakf[23];
Abe = Bbe ^ ((~Bbi) | Bbo);
Abi = Bbi ^ (Bbo & Bbu);
Abo = Bbo ^ (Bbu | Bba);
@ -2862,7 +2878,7 @@ static void _PySHA3_KeccakP1600_Permute_12rounds(void *state) {
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[12];
Eba ^= kKeccakf[12];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -2968,7 +2984,7 @@ static void _PySHA3_KeccakP1600_Permute_12rounds(void *state) {
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[13];
Aba ^= kKeccakf[13];
Ca = Aba;
Abe = Bbe ^ ((~Bbi) | Bbo);
Ce = Abe;
@ -3074,7 +3090,7 @@ static void _PySHA3_KeccakP1600_Permute_12rounds(void *state) {
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[14];
Eba ^= kKeccakf[14];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -3180,7 +3196,7 @@ static void _PySHA3_KeccakP1600_Permute_12rounds(void *state) {
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[15];
Aba ^= kKeccakf[15];
Ca = Aba;
Abe = Bbe ^ ((~Bbi) | Bbo);
Ce = Abe;
@ -3286,7 +3302,7 @@ static void _PySHA3_KeccakP1600_Permute_12rounds(void *state) {
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[16];
Eba ^= kKeccakf[16];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -3392,7 +3408,7 @@ static void _PySHA3_KeccakP1600_Permute_12rounds(void *state) {
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[17];
Aba ^= kKeccakf[17];
Ca = Aba;
Abe = Bbe ^ ((~Bbi) | Bbo);
Ce = Abe;
@ -3498,7 +3514,7 @@ static void _PySHA3_KeccakP1600_Permute_12rounds(void *state) {
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[18];
Eba ^= kKeccakf[18];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -3604,7 +3620,7 @@ static void _PySHA3_KeccakP1600_Permute_12rounds(void *state) {
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[19];
Aba ^= kKeccakf[19];
Ca = Aba;
Abe = Bbe ^ ((~Bbi) | Bbo);
Ce = Abe;
@ -3710,7 +3726,7 @@ static void _PySHA3_KeccakP1600_Permute_12rounds(void *state) {
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[20];
Eba ^= kKeccakf[20];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -3816,7 +3832,7 @@ static void _PySHA3_KeccakP1600_Permute_12rounds(void *state) {
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[21];
Aba ^= kKeccakf[21];
Ca = Aba;
Abe = Bbe ^ ((~Bbi) | Bbo);
Ce = Abe;
@ -3922,7 +3938,7 @@ static void _PySHA3_KeccakP1600_Permute_12rounds(void *state) {
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[22];
Eba ^= kKeccakf[22];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -4028,7 +4044,7 @@ static void _PySHA3_KeccakP1600_Permute_12rounds(void *state) {
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[23];
Aba ^= kKeccakf[23];
Abe = Bbe ^ ((~Bbi) | Bbo);
Abi = Bbi ^ (Bbo & Bbu);
Abo = Bbo ^ (Bbu | Bba);
@ -4423,7 +4439,7 @@ static size_t _PySHA3_KeccakF1600_FastLoop_Absorb(void *state,
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[0];
Eba ^= kKeccakf[0];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -4529,7 +4545,7 @@ static size_t _PySHA3_KeccakF1600_FastLoop_Absorb(void *state,
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[1];
Aba ^= kKeccakf[1];
Ca = Aba;
Abe = Bbe ^ ((~Bbi) | Bbo);
Ce = Abe;
@ -4635,7 +4651,7 @@ static size_t _PySHA3_KeccakF1600_FastLoop_Absorb(void *state,
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[2];
Eba ^= kKeccakf[2];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -4741,7 +4757,7 @@ static size_t _PySHA3_KeccakF1600_FastLoop_Absorb(void *state,
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[3];
Aba ^= kKeccakf[3];
Ca = Aba;
Abe = Bbe ^ ((~Bbi) | Bbo);
Ce = Abe;
@ -4847,7 +4863,7 @@ static size_t _PySHA3_KeccakF1600_FastLoop_Absorb(void *state,
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[4];
Eba ^= kKeccakf[4];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -4953,7 +4969,7 @@ static size_t _PySHA3_KeccakF1600_FastLoop_Absorb(void *state,
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[5];
Aba ^= kKeccakf[5];
Ca = Aba;
Abe = Bbe ^ ((~Bbi) | Bbo);
Ce = Abe;
@ -5059,7 +5075,7 @@ static size_t _PySHA3_KeccakF1600_FastLoop_Absorb(void *state,
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[6];
Eba ^= kKeccakf[6];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -5165,7 +5181,7 @@ static size_t _PySHA3_KeccakF1600_FastLoop_Absorb(void *state,
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[7];
Aba ^= kKeccakf[7];
Ca = Aba;
Abe = Bbe ^ ((~Bbi) | Bbo);
Ce = Abe;
@ -5271,7 +5287,7 @@ static size_t _PySHA3_KeccakF1600_FastLoop_Absorb(void *state,
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[8];
Eba ^= kKeccakf[8];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -5377,7 +5393,7 @@ static size_t _PySHA3_KeccakF1600_FastLoop_Absorb(void *state,
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[9];
Aba ^= kKeccakf[9];
Ca = Aba;
Abe = Bbe ^ ((~Bbi) | Bbo);
Ce = Abe;
@ -5483,7 +5499,7 @@ static size_t _PySHA3_KeccakF1600_FastLoop_Absorb(void *state,
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[10];
Eba ^= kKeccakf[10];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -5589,7 +5605,7 @@ static size_t _PySHA3_KeccakF1600_FastLoop_Absorb(void *state,
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[11];
Aba ^= kKeccakf[11];
Ca = Aba;
Abe = Bbe ^ ((~Bbi) | Bbo);
Ce = Abe;
@ -5695,7 +5711,7 @@ static size_t _PySHA3_KeccakF1600_FastLoop_Absorb(void *state,
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[12];
Eba ^= kKeccakf[12];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -5801,7 +5817,7 @@ static size_t _PySHA3_KeccakF1600_FastLoop_Absorb(void *state,
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[13];
Aba ^= kKeccakf[13];
Ca = Aba;
Abe = Bbe ^ ((~Bbi) | Bbo);
Ce = Abe;
@ -5907,7 +5923,7 @@ static size_t _PySHA3_KeccakF1600_FastLoop_Absorb(void *state,
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[14];
Eba ^= kKeccakf[14];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -6013,7 +6029,7 @@ static size_t _PySHA3_KeccakF1600_FastLoop_Absorb(void *state,
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[15];
Aba ^= kKeccakf[15];
Ca = Aba;
Abe = Bbe ^ ((~Bbi) | Bbo);
Ce = Abe;
@ -6119,7 +6135,7 @@ static size_t _PySHA3_KeccakF1600_FastLoop_Absorb(void *state,
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[16];
Eba ^= kKeccakf[16];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -6225,7 +6241,7 @@ static size_t _PySHA3_KeccakF1600_FastLoop_Absorb(void *state,
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[17];
Aba ^= kKeccakf[17];
Ca = Aba;
Abe = Bbe ^ ((~Bbi) | Bbo);
Ce = Abe;
@ -6331,7 +6347,7 @@ static size_t _PySHA3_KeccakF1600_FastLoop_Absorb(void *state,
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[18];
Eba ^= kKeccakf[18];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -6437,7 +6453,7 @@ static size_t _PySHA3_KeccakF1600_FastLoop_Absorb(void *state,
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[19];
Aba ^= kKeccakf[19];
Ca = Aba;
Abe = Bbe ^ ((~Bbi) | Bbo);
Ce = Abe;
@ -6543,7 +6559,7 @@ static size_t _PySHA3_KeccakF1600_FastLoop_Absorb(void *state,
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[20];
Eba ^= kKeccakf[20];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -6649,7 +6665,7 @@ static size_t _PySHA3_KeccakF1600_FastLoop_Absorb(void *state,
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[21];
Aba ^= kKeccakf[21];
Ca = Aba;
Abe = Bbe ^ ((~Bbi) | Bbo);
Ce = Abe;
@ -6755,7 +6771,7 @@ static size_t _PySHA3_KeccakF1600_FastLoop_Absorb(void *state,
Asu ^= Du;
Bbu = ((((uint64_t)Asu) << 14) ^ (((uint64_t)Asu) >> (64 - 14)));
Eba = Bba ^ (Bbe | Bbi);
Eba ^= KeccakF1600RoundConstants[22];
Eba ^= kKeccakf[22];
Ca = Eba;
Ebe = Bbe ^ ((~Bbi) | Bbo);
Ce = Ebe;
@ -6861,7 +6877,7 @@ static size_t _PySHA3_KeccakF1600_FastLoop_Absorb(void *state,
Esu ^= Du;
Bbu = ((((uint64_t)Esu) << 14) ^ (((uint64_t)Esu) >> (64 - 14)));
Aba = Bba ^ (Bbe | Bbi);
Aba ^= KeccakF1600RoundConstants[23];
Aba ^= kKeccakf[23];
Abe = Bbe ^ ((~Bbi) | Bbo);
Abi = Bbi ^ (Bbo & Bbu);
Abo = Bbo ^ (Bbu | Bba);
@ -7968,3 +7984,8 @@ error:
} while (0);
return 0;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__sha3 = {
"_sha3",
PyInit__sha3,
};

View file

@ -491,3 +491,8 @@ error:
}
return module;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__sqlite3 = {
"_sqlite3",
PyInit__sqlite3,
};

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -9,6 +9,7 @@
#include "libc/calls/weirdtypes.h"
#include "libc/sysv/consts/s.h"
#include "third_party/python/Include/boolobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/methodobject.h"
#include "third_party/python/Include/modsupport.h"
@ -626,3 +627,8 @@ PyInit__stat(void)
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__stat = {
"_stat",
PyInit__stat,
};

View file

@ -12,6 +12,7 @@
#include "third_party/python/Include/descrobject.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/floatobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/objimpl.h"
@ -2398,3 +2399,8 @@ PyInit__struct(void)
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__struct = {
"_struct",
PyInit__struct,
};

View file

@ -230,6 +230,9 @@ PYTHON_PROVIDE("_testcapi.unicode_legacy_string");
PYTHON_PROVIDE("_testcapi.unicode_transformdecimaltoascii");
PYTHON_PROVIDE("_testcapi.with_tp_del");
PYTHON_YOINK("encodings.ascii");
PYTHON_YOINK("encodings.latin_1");
/*
* C Extension module to test Python interpreter C APIs.
*
@ -5216,3 +5219,8 @@ PyInit__testcapi(void)
PyModule_AddObject(m, "error", TestError);
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__testcapi = {
"_testcapi",
PyInit__testcapi,
};

View file

@ -10,6 +10,7 @@
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/fileutils.h"
#include "third_party/python/Include/frameobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/listobject.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
@ -1861,3 +1862,8 @@ PyObject*
return traceback_to_pyobject(traceback, NULL);
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__tracemalloc = {
"_tracemalloc",
PyInit__tracemalloc,
};

View file

@ -5,6 +5,7 @@
https://docs.python.org/3/license.html │
*/
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/listobject.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"

File diff suppressed because it is too large Load diff

View file

@ -3057,3 +3057,8 @@ PyInit_array(void)
{
return PyModuleDef_Init(&arraymodule);
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab_array = {
"array",
PyInit_array,
};

View file

@ -5,6 +5,7 @@
https://docs.python.org/3/license.html │
*/
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/moduleobject.h"
@ -371,3 +372,8 @@ PyInit_atexit(void)
_Py_PyAtExit(atexit_callfuncs);
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab_atexit = {
"atexit",
PyInit_atexit,
};

View file

@ -8,6 +8,7 @@
#include "libc/math.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/floatobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/object.h"
@ -1963,3 +1964,8 @@ PyInit_audioop(void)
PyDict_SetItemString(d,"error",AudioopError);
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab_audioop = {
"audioop",
PyInit_audioop,
};

View file

@ -8,6 +8,7 @@
#include "libc/assert.h"
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/pyctype.h"
@ -1474,3 +1475,8 @@ PyInit_binascii(void)
}
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab_binascii = {
"binascii",
PyInit_binascii,
};

View file

@ -4,6 +4,7 @@
Python 3
https://docs.python.org/3/license.html │
*/
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/yoink.h"
#include "third_party/python/Modules/cjkcodecs/cjkcodecs.h"
#include "third_party/python/Modules/cjkcodecs/mappings_cn.inc"
@ -477,3 +478,8 @@ BEGIN_CODECS_LIST
END_CODECS_LIST
I_AM_A_MODULE_FOR(cn)
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__codecs_cn = {
"_codecs_cn",
PyInit__codecs_cn,
};

View file

@ -5,6 +5,7 @@
https://docs.python.org/3/license.html │
*/
#define USING_IMPORTED_MAPS
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/yoink.h"
#include "third_party/python/Modules/cjkcodecs/cjkcodecs.h"
#include "third_party/python/Modules/cjkcodecs/mappings_hk.inc"
@ -202,3 +203,8 @@ BEGIN_CODECS_LIST
END_CODECS_LIST
I_AM_A_MODULE_FOR(hk)
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__codecs_hk = {
"_codecs_hk",
PyInit__codecs_hk,
};

View file

@ -22,6 +22,7 @@
#include "third_party/python/Modules/cjkcodecs/emu_jisx0213_2000.inc"
#include "third_party/python/Modules/cjkcodecs/cjkcodecs.h"
#include "third_party/python/Include/yoink.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Modules/cjkcodecs/mappings_jisx0213_pair.inc"
PYTHON_PROVIDE("_codecs_iso2022");
@ -1153,3 +1154,8 @@ BEGIN_CODECS_LIST
END_CODECS_LIST
I_AM_A_MODULE_FOR(iso2022)
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__codecs_iso2022 = {
"_codecs_iso2022",
PyInit__codecs_iso2022,
};

View file

@ -19,6 +19,7 @@
#include "third_party/python/Modules/cjkcodecs/mappings_jisx0213_pair.inc"
#include "third_party/python/Modules/cjkcodecs/alg_jisx0201.inc"
#include "third_party/python/Include/yoink.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Modules/cjkcodecs/emu_jisx0213_2000.inc"
PYTHON_PROVIDE("_codecs_jp");
@ -780,3 +781,8 @@ BEGIN_CODECS_LIST
END_CODECS_LIST
I_AM_A_MODULE_FOR(jp)
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__codecs_jp = {
"_codecs_jp",
PyInit__codecs_jp,
};

View file

@ -14,6 +14,7 @@
#include "third_party/python/Modules/cjkcodecs/cjkcodecs.h"
#include "third_party/python/Include/yoink.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Modules/cjkcodecs/mappings_kr.inc"
PYTHON_PROVIDE("_codecs_kr");
@ -481,3 +482,8 @@ BEGIN_CODECS_LIST
END_CODECS_LIST
I_AM_A_MODULE_FOR(kr)
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__codecs_kr = {
"_codecs_kr",
PyInit__codecs_kr,
};

View file

@ -7,6 +7,7 @@
#include "third_party/python/Modules/cjkcodecs/cjkcodecs.h"
#include "third_party/python/Include/yoink.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Modules/cjkcodecs/mappings_tw.inc"
PYTHON_PROVIDE("_codecs_tw");
@ -148,3 +149,8 @@ BEGIN_CODECS_LIST
END_CODECS_LIST
I_AM_A_MODULE_FOR(tw)
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__codecs_tw = {
"_codecs_tw",
PyInit__codecs_tw,
};

View file

@ -8,6 +8,7 @@
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/codecs.h"
#include "third_party/python/Include/descrobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/objimpl.h"
@ -1952,3 +1953,8 @@ PyInit__multibytecodec(void)
}
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__multibytecodec = {
"_multibytecodec",
PyInit__multibytecodec,
};

View file

@ -73,13 +73,13 @@ PyDoc_STRVAR(_winapi_CloseHandle__doc__,
{"CloseHandle", (PyCFunction)_winapi_CloseHandle, METH_O, _winapi_CloseHandle__doc__},
static PyObject *
_winapi_CloseHandle_impl(PyObject *module, HANDLE handle);
_winapi_CloseHandle_impl(PyObject *module, int64_t handle);
static PyObject *
_winapi_CloseHandle(PyObject *module, PyObject *arg)
{
PyObject *return_value = NULL;
HANDLE handle;
int64_t handle;
if (!PyArg_Parse(arg, "" F_HANDLE ":CloseHandle", &handle)) {
goto exit;
@ -99,7 +99,7 @@ PyDoc_STRVAR(_winapi_ConnectNamedPipe__doc__,
{"ConnectNamedPipe", (PyCFunction)_winapi_ConnectNamedPipe, METH_FASTCALL, _winapi_ConnectNamedPipe__doc__},
static PyObject *
_winapi_ConnectNamedPipe_impl(PyObject *module, HANDLE handle,
_winapi_ConnectNamedPipe_impl(PyObject *module, int64_t handle,
int use_overlapped);
static PyObject *
@ -108,7 +108,7 @@ _winapi_ConnectNamedPipe(PyObject *module, PyObject **args, Py_ssize_t nargs, Py
PyObject *return_value = NULL;
static const char * const _keywords[] = {"handle", "overlapped", NULL};
static _PyArg_Parser _parser = {"" F_HANDLE "|i:ConnectNamedPipe", _keywords, 0};
HANDLE handle;
int64_t handle;
int use_overlapped = 0;
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
@ -131,35 +131,35 @@ PyDoc_STRVAR(_winapi_CreateFile__doc__,
#define _WINAPI_CREATEFILE_METHODDEF \
{"CreateFile", (PyCFunction)_winapi_CreateFile, METH_VARARGS, _winapi_CreateFile__doc__},
static HANDLE
_winapi_CreateFile_impl(PyObject *module, LPCTSTR file_name,
DWORD desired_access, DWORD share_mode,
LPSECURITY_ATTRIBUTES security_attributes,
DWORD creation_disposition,
DWORD flags_and_attributes, HANDLE template_file);
static int64_t
_winapi_CreateFile_impl(PyObject *module, const char16_t *file_name,
uint32_t desired_access, uint32_t share_mode,
struct NtSecurityAttributes *security_attributes,
uint32_t creation_disposition,
uint32_t flags_and_attributes, int64_t template_file);
static PyObject *
_winapi_CreateFile(PyObject *module, PyObject *args)
{
PyObject *return_value = NULL;
LPCTSTR file_name;
DWORD desired_access;
DWORD share_mode;
LPSECURITY_ATTRIBUTES security_attributes;
DWORD creation_disposition;
DWORD flags_and_attributes;
HANDLE template_file;
HANDLE _return_value;
const char16_t *file_name;
uint32_t desired_access;
uint32_t share_mode;
struct NtSecurityAttributes *security_attributes;
uint32_t creation_disposition;
uint32_t flags_and_attributes;
int64_t template_file;
int64_t _return_value;
if (!PyArg_ParseTuple(args, "skk" F_POINTER "kk" F_HANDLE ":CreateFile",
&file_name, &desired_access, &share_mode, &security_attributes, &creation_disposition, &flags_and_attributes, &template_file)) {
goto exit;
}
_return_value = _winapi_CreateFile_impl(module, file_name, desired_access, share_mode, security_attributes, creation_disposition, flags_and_attributes, template_file);
if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
if ((_return_value == kNtInvalidHandleValue) && PyErr_Occurred()) {
goto exit;
}
if (_return_value == NULL) {
if (!_return_value) {
Py_RETURN_NONE;
}
return_value = HANDLE_TO_PYNUM(_return_value);
@ -177,15 +177,15 @@ PyDoc_STRVAR(_winapi_CreateJunction__doc__,
{"CreateJunction", (PyCFunction)_winapi_CreateJunction, METH_VARARGS, _winapi_CreateJunction__doc__},
static PyObject *
_winapi_CreateJunction_impl(PyObject *module, LPWSTR src_path,
LPWSTR dst_path);
_winapi_CreateJunction_impl(PyObject *module, char16_t *src_path,
char16_t *dst_path);
static PyObject *
_winapi_CreateJunction(PyObject *module, PyObject *args)
{
PyObject *return_value = NULL;
LPWSTR src_path;
LPWSTR dst_path;
char16_t *src_path;
char16_t *dst_path;
if (!PyArg_ParseTuple(args, "uu:CreateJunction",
&src_path, &dst_path)) {
@ -207,36 +207,36 @@ PyDoc_STRVAR(_winapi_CreateNamedPipe__doc__,
#define _WINAPI_CREATENAMEDPIPE_METHODDEF \
{"CreateNamedPipe", (PyCFunction)_winapi_CreateNamedPipe, METH_VARARGS, _winapi_CreateNamedPipe__doc__},
static HANDLE
_winapi_CreateNamedPipe_impl(PyObject *module, LPCTSTR name, DWORD open_mode,
DWORD pipe_mode, DWORD max_instances,
DWORD out_buffer_size, DWORD in_buffer_size,
DWORD default_timeout,
LPSECURITY_ATTRIBUTES security_attributes);
static int64_t
_winapi_CreateNamedPipe_impl(PyObject *module, const char16_t *name, uint32_t open_mode,
uint32_t pipe_mode, uint32_t max_instances,
uint32_t out_buffer_size, uint32_t in_buffer_size,
uint32_t default_timeout,
struct NtSecurityAttributes *security_attributes);
static PyObject *
_winapi_CreateNamedPipe(PyObject *module, PyObject *args)
{
PyObject *return_value = NULL;
LPCTSTR name;
DWORD open_mode;
DWORD pipe_mode;
DWORD max_instances;
DWORD out_buffer_size;
DWORD in_buffer_size;
DWORD default_timeout;
LPSECURITY_ATTRIBUTES security_attributes;
HANDLE _return_value;
const char16_t *name;
uint32_t open_mode;
uint32_t pipe_mode;
uint32_t max_instances;
uint32_t out_buffer_size;
uint32_t in_buffer_size;
uint32_t default_timeout;
struct NtSecurityAttributes *security_attributes;
int64_t _return_value;
if (!PyArg_ParseTuple(args, "skkkkkk" F_POINTER ":CreateNamedPipe",
&name, &open_mode, &pipe_mode, &max_instances, &out_buffer_size, &in_buffer_size, &default_timeout, &security_attributes)) {
goto exit;
}
_return_value = _winapi_CreateNamedPipe_impl(module, name, open_mode, pipe_mode, max_instances, out_buffer_size, in_buffer_size, default_timeout, security_attributes);
if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
if ((_return_value == kNtInvalidHandleValue) && PyErr_Occurred()) {
goto exit;
}
if (_return_value == NULL) {
if (!_return_value) {
Py_RETURN_NONE;
}
return_value = HANDLE_TO_PYNUM(_return_value);
@ -260,14 +260,14 @@ PyDoc_STRVAR(_winapi_CreatePipe__doc__,
{"CreatePipe", (PyCFunction)_winapi_CreatePipe, METH_VARARGS, _winapi_CreatePipe__doc__},
static PyObject *
_winapi_CreatePipe_impl(PyObject *module, PyObject *pipe_attrs, DWORD size);
_winapi_CreatePipe_impl(PyObject *module, PyObject *pipe_attrs, uint32_t size);
static PyObject *
_winapi_CreatePipe(PyObject *module, PyObject *args)
{
PyObject *return_value = NULL;
PyObject *pipe_attrs;
DWORD size;
uint32_t size;
if (!PyArg_ParseTuple(args, "Ok:CreatePipe",
&pipe_attrs, &size)) {
@ -301,8 +301,8 @@ PyDoc_STRVAR(_winapi_CreateProcess__doc__,
static PyObject *
_winapi_CreateProcess_impl(PyObject *module, Py_UNICODE *application_name,
Py_UNICODE *command_line, PyObject *proc_attrs,
PyObject *thread_attrs, BOOL inherit_handles,
DWORD creation_flags, PyObject *env_mapping,
PyObject *thread_attrs, bool32 inherit_handles,
uint32_t creation_flags, PyObject *env_mapping,
Py_UNICODE *current_directory,
PyObject *startup_info);
@ -314,8 +314,8 @@ _winapi_CreateProcess(PyObject *module, PyObject *args)
Py_UNICODE *command_line;
PyObject *proc_attrs;
PyObject *thread_attrs;
BOOL inherit_handles;
DWORD creation_flags;
bool32 inherit_handles;
uint32_t creation_flags;
PyObject *env_mapping;
Py_UNICODE *current_directory;
PyObject *startup_info;
@ -345,34 +345,34 @@ PyDoc_STRVAR(_winapi_DuplicateHandle__doc__,
#define _WINAPI_DUPLICATEHANDLE_METHODDEF \
{"DuplicateHandle", (PyCFunction)_winapi_DuplicateHandle, METH_VARARGS, _winapi_DuplicateHandle__doc__},
static HANDLE
_winapi_DuplicateHandle_impl(PyObject *module, HANDLE source_process_handle,
HANDLE source_handle,
HANDLE target_process_handle,
DWORD desired_access, BOOL inherit_handle,
DWORD options);
static int64_t
_winapi_DuplicateHandle_impl(PyObject *module, int64_t source_process_handle,
int64_t source_handle,
int64_t target_process_handle,
uint32_t desired_access, bool32 inherit_handle,
uint32_t options);
static PyObject *
_winapi_DuplicateHandle(PyObject *module, PyObject *args)
{
PyObject *return_value = NULL;
HANDLE source_process_handle;
HANDLE source_handle;
HANDLE target_process_handle;
DWORD desired_access;
BOOL inherit_handle;
DWORD options = 0;
HANDLE _return_value;
int64_t source_process_handle;
int64_t source_handle;
int64_t target_process_handle;
uint32_t desired_access;
bool32 inherit_handle;
uint32_t options = 0;
int64_t _return_value;
if (!PyArg_ParseTuple(args, "" F_HANDLE "" F_HANDLE "" F_HANDLE "ki|k:DuplicateHandle",
&source_process_handle, &source_handle, &target_process_handle, &desired_access, &inherit_handle, &options)) {
goto exit;
}
_return_value = _winapi_DuplicateHandle_impl(module, source_process_handle, source_handle, target_process_handle, desired_access, inherit_handle, options);
if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
if ((_return_value == kNtInvalidHandleValue) && PyErr_Occurred()) {
goto exit;
}
if (_return_value == NULL) {
if (!_return_value) {
Py_RETURN_NONE;
}
return_value = HANDLE_TO_PYNUM(_return_value);
@ -390,13 +390,13 @@ PyDoc_STRVAR(_winapi_ExitProcess__doc__,
{"ExitProcess", (PyCFunction)_winapi_ExitProcess, METH_O, _winapi_ExitProcess__doc__},
static PyObject *
_winapi_ExitProcess_impl(PyObject *module, UINT ExitCode);
_winapi_ExitProcess_impl(PyObject *module, unsigned ExitCode);
static PyObject *
_winapi_ExitProcess(PyObject *module, PyObject *arg)
{
PyObject *return_value = NULL;
UINT ExitCode;
unsigned ExitCode;
if (!PyArg_Parse(arg, "I:ExitProcess", &ExitCode)) {
goto exit;
@ -416,20 +416,20 @@ PyDoc_STRVAR(_winapi_GetCurrentProcess__doc__,
#define _WINAPI_GETCURRENTPROCESS_METHODDEF \
{"GetCurrentProcess", (PyCFunction)_winapi_GetCurrentProcess, METH_NOARGS, _winapi_GetCurrentProcess__doc__},
static HANDLE
static int64_t
_winapi_GetCurrentProcess_impl(PyObject *module);
static PyObject *
_winapi_GetCurrentProcess(PyObject *module, PyObject *Py_UNUSED(ignored))
{
PyObject *return_value = NULL;
HANDLE _return_value;
int64_t _return_value;
_return_value = _winapi_GetCurrentProcess_impl(module);
if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
if ((_return_value == kNtInvalidHandleValue) && PyErr_Occurred()) {
goto exit;
}
if (_return_value == NULL) {
if (!_return_value) {
Py_RETURN_NONE;
}
return_value = HANDLE_TO_PYNUM(_return_value);
@ -447,21 +447,21 @@ PyDoc_STRVAR(_winapi_GetExitCodeProcess__doc__,
#define _WINAPI_GETEXITCODEPROCESS_METHODDEF \
{"GetExitCodeProcess", (PyCFunction)_winapi_GetExitCodeProcess, METH_O, _winapi_GetExitCodeProcess__doc__},
static DWORD
_winapi_GetExitCodeProcess_impl(PyObject *module, HANDLE process);
static uint32_t
_winapi_GetExitCodeProcess_impl(PyObject *module, int64_t process);
static PyObject *
_winapi_GetExitCodeProcess(PyObject *module, PyObject *arg)
{
PyObject *return_value = NULL;
HANDLE process;
DWORD _return_value;
int64_t process;
uint32_t _return_value;
if (!PyArg_Parse(arg, "" F_HANDLE ":GetExitCodeProcess", &process)) {
goto exit;
}
_return_value = _winapi_GetExitCodeProcess_impl(module, process);
if ((_return_value == DWORD_MAX) && PyErr_Occurred()) {
if ((_return_value == UINT_MAX) && PyErr_Occurred()) {
goto exit;
}
return_value = Py_BuildValue("k", _return_value);
@ -478,17 +478,17 @@ PyDoc_STRVAR(_winapi_GetLastError__doc__,
#define _WINAPI_GETLASTERROR_METHODDEF \
{"GetLastError", (PyCFunction)_winapi_GetLastError, METH_NOARGS, _winapi_GetLastError__doc__},
static DWORD
static uint32_t
_winapi_GetLastError_impl(PyObject *module);
static PyObject *
_winapi_GetLastError(PyObject *module, PyObject *Py_UNUSED(ignored))
{
PyObject *return_value = NULL;
DWORD _return_value;
uint32_t _return_value;
_return_value = _winapi_GetLastError_impl(module);
if ((_return_value == DWORD_MAX) && PyErr_Occurred()) {
if ((_return_value == UINT_MAX) && PyErr_Occurred()) {
goto exit;
}
return_value = Py_BuildValue("k", _return_value);
@ -514,19 +514,17 @@ PyDoc_STRVAR(_winapi_GetModuleFileName__doc__,
{"GetModuleFileName", (PyCFunction)_winapi_GetModuleFileName, METH_O, _winapi_GetModuleFileName__doc__},
static PyObject *
_winapi_GetModuleFileName_impl(PyObject *module, HMODULE module_handle);
_winapi_GetModuleFileName_impl(PyObject *module, int64_t module_handle);
static PyObject *
_winapi_GetModuleFileName(PyObject *module, PyObject *arg)
{
PyObject *return_value = NULL;
HMODULE module_handle;
int64_t module_handle;
if (!PyArg_Parse(arg, "" F_HANDLE ":GetModuleFileName", &module_handle)) {
goto exit;
}
return_value = _winapi_GetModuleFileName_impl(module, module_handle);
exit:
return return_value;
}
@ -538,31 +536,31 @@ PyDoc_STRVAR(_winapi_GetStdHandle__doc__,
"Return a handle to the specified standard device.\n"
"\n"
" std_handle\n"
" One of STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, or STD_ERROR_HANDLE.\n"
" One of STD_INPUT_int64_t, STD_OUTPUT_int64_t, or STD_ERROR_int64_t.\n"
"\n"
"The integer associated with the handle object is returned.");
#define _WINAPI_GETSTDHANDLE_METHODDEF \
{"GetStdHandle", (PyCFunction)_winapi_GetStdHandle, METH_O, _winapi_GetStdHandle__doc__},
static HANDLE
_winapi_GetStdHandle_impl(PyObject *module, DWORD std_handle);
static int64_t
_winapi_GetStdHandle_impl(PyObject *module, uint32_t std_handle);
static PyObject *
_winapi_GetStdHandle(PyObject *module, PyObject *arg)
{
PyObject *return_value = NULL;
DWORD std_handle;
HANDLE _return_value;
uint32_t std_handle;
int64_t _return_value;
if (!PyArg_Parse(arg, "k:GetStdHandle", &std_handle)) {
goto exit;
}
_return_value = _winapi_GetStdHandle_impl(module, std_handle);
if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
if ((_return_value == kNtInvalidHandleValue) && PyErr_Occurred()) {
goto exit;
}
if (_return_value == NULL) {
if (!_return_value) {
Py_RETURN_NONE;
}
return_value = HANDLE_TO_PYNUM(_return_value);
@ -607,28 +605,28 @@ PyDoc_STRVAR(_winapi_OpenProcess__doc__,
#define _WINAPI_OPENPROCESS_METHODDEF \
{"OpenProcess", (PyCFunction)_winapi_OpenProcess, METH_VARARGS, _winapi_OpenProcess__doc__},
static HANDLE
_winapi_OpenProcess_impl(PyObject *module, DWORD desired_access,
BOOL inherit_handle, DWORD process_id);
static int64_t
_winapi_OpenProcess_impl(PyObject *module, uint32_t desired_access,
bool32 inherit_handle, uint32_t process_id);
static PyObject *
_winapi_OpenProcess(PyObject *module, PyObject *args)
{
PyObject *return_value = NULL;
DWORD desired_access;
BOOL inherit_handle;
DWORD process_id;
HANDLE _return_value;
uint32_t desired_access;
bool32 inherit_handle;
uint32_t process_id;
int64_t _return_value;
if (!PyArg_ParseTuple(args, "kik:OpenProcess",
&desired_access, &inherit_handle, &process_id)) {
goto exit;
}
_return_value = _winapi_OpenProcess_impl(module, desired_access, inherit_handle, process_id);
if ((_return_value == INVALID_HANDLE_VALUE) && PyErr_Occurred()) {
if ((_return_value == kNtInvalidHandleValue) && PyErr_Occurred()) {
goto exit;
}
if (_return_value == NULL) {
if (!_return_value) {
Py_RETURN_NONE;
}
return_value = HANDLE_TO_PYNUM(_return_value);
@ -646,13 +644,13 @@ PyDoc_STRVAR(_winapi_PeekNamedPipe__doc__,
{"PeekNamedPipe", (PyCFunction)_winapi_PeekNamedPipe, METH_VARARGS, _winapi_PeekNamedPipe__doc__},
static PyObject *
_winapi_PeekNamedPipe_impl(PyObject *module, HANDLE handle, int size);
_winapi_PeekNamedPipe_impl(PyObject *module, int64_t handle, int size);
static PyObject *
_winapi_PeekNamedPipe(PyObject *module, PyObject *args)
{
PyObject *return_value = NULL;
HANDLE handle;
int64_t handle;
int size = 0;
if (!PyArg_ParseTuple(args, "" F_HANDLE "|i:PeekNamedPipe",
@ -674,7 +672,7 @@ PyDoc_STRVAR(_winapi_ReadFile__doc__,
{"ReadFile", (PyCFunction)_winapi_ReadFile, METH_FASTCALL, _winapi_ReadFile__doc__},
static PyObject *
_winapi_ReadFile_impl(PyObject *module, HANDLE handle, DWORD size,
_winapi_ReadFile_impl(PyObject *module, int64_t handle, uint32_t size,
int use_overlapped);
static PyObject *
@ -683,8 +681,8 @@ _winapi_ReadFile(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *
PyObject *return_value = NULL;
static const char * const _keywords[] = {"handle", "size", "overlapped", NULL};
static _PyArg_Parser _parser = {"" F_HANDLE "k|i:ReadFile", _keywords, 0};
HANDLE handle;
DWORD size;
int64_t handle;
uint32_t size;
int use_overlapped = 0;
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
@ -707,7 +705,7 @@ PyDoc_STRVAR(_winapi_SetNamedPipeHandleState__doc__,
{"SetNamedPipeHandleState", (PyCFunction)_winapi_SetNamedPipeHandleState, METH_VARARGS, _winapi_SetNamedPipeHandleState__doc__},
static PyObject *
_winapi_SetNamedPipeHandleState_impl(PyObject *module, HANDLE named_pipe,
_winapi_SetNamedPipeHandleState_impl(PyObject *module, int64_t named_pipe,
PyObject *mode,
PyObject *max_collection_count,
PyObject *collect_data_timeout);
@ -716,7 +714,7 @@ static PyObject *
_winapi_SetNamedPipeHandleState(PyObject *module, PyObject *args)
{
PyObject *return_value = NULL;
HANDLE named_pipe;
int64_t named_pipe;
PyObject *mode;
PyObject *max_collection_count;
PyObject *collect_data_timeout;
@ -741,15 +739,15 @@ PyDoc_STRVAR(_winapi_TerminateProcess__doc__,
{"TerminateProcess", (PyCFunction)_winapi_TerminateProcess, METH_VARARGS, _winapi_TerminateProcess__doc__},
static PyObject *
_winapi_TerminateProcess_impl(PyObject *module, HANDLE handle,
UINT exit_code);
_winapi_TerminateProcess_impl(PyObject *module, int64_t handle,
unsigned exit_code);
static PyObject *
_winapi_TerminateProcess(PyObject *module, PyObject *args)
{
PyObject *return_value = NULL;
HANDLE handle;
UINT exit_code;
int64_t handle;
unsigned exit_code;
if (!PyArg_ParseTuple(args, "" F_HANDLE "I:TerminateProcess",
&handle, &exit_code)) {
@ -770,14 +768,14 @@ PyDoc_STRVAR(_winapi_WaitNamedPipe__doc__,
{"WaitNamedPipe", (PyCFunction)_winapi_WaitNamedPipe, METH_VARARGS, _winapi_WaitNamedPipe__doc__},
static PyObject *
_winapi_WaitNamedPipe_impl(PyObject *module, LPCTSTR name, DWORD timeout);
_winapi_WaitNamedPipe_impl(PyObject *module, const char *name, uint32_t timeout);
static PyObject *
_winapi_WaitNamedPipe(PyObject *module, PyObject *args)
{
PyObject *return_value = NULL;
LPCTSTR name;
DWORD timeout;
const char *name;
uint32_t timeout;
if (!PyArg_ParseTuple(args, "sk:WaitNamedPipe",
&name, &timeout)) {
@ -800,15 +798,15 @@ PyDoc_STRVAR(_winapi_WaitForMultipleObjects__doc__,
static PyObject *
_winapi_WaitForMultipleObjects_impl(PyObject *module, PyObject *handle_seq,
BOOL wait_flag, DWORD milliseconds);
bool32 wait_flag, uint32_t milliseconds);
static PyObject *
_winapi_WaitForMultipleObjects(PyObject *module, PyObject *args)
{
PyObject *return_value = NULL;
PyObject *handle_seq;
BOOL wait_flag;
DWORD milliseconds = INFINITE;
bool32 wait_flag;
uint32_t milliseconds = -1;
if (!PyArg_ParseTuple(args, "Oi|k:WaitForMultipleObjects",
&handle_seq, &wait_flag, &milliseconds)) {
@ -834,15 +832,15 @@ PyDoc_STRVAR(_winapi_WaitForSingleObject__doc__,
{"WaitForSingleObject", (PyCFunction)_winapi_WaitForSingleObject, METH_VARARGS, _winapi_WaitForSingleObject__doc__},
static long
_winapi_WaitForSingleObject_impl(PyObject *module, HANDLE handle,
DWORD milliseconds);
_winapi_WaitForSingleObject_impl(PyObject *module, int64_t handle,
uint32_t milliseconds);
static PyObject *
_winapi_WaitForSingleObject(PyObject *module, PyObject *args)
{
PyObject *return_value = NULL;
HANDLE handle;
DWORD milliseconds;
int64_t handle;
uint32_t milliseconds;
long _return_value;
if (!PyArg_ParseTuple(args, "" F_HANDLE "k:WaitForSingleObject",
@ -868,7 +866,7 @@ PyDoc_STRVAR(_winapi_WriteFile__doc__,
{"WriteFile", (PyCFunction)_winapi_WriteFile, METH_FASTCALL, _winapi_WriteFile__doc__},
static PyObject *
_winapi_WriteFile_impl(PyObject *module, HANDLE handle, PyObject *buffer,
_winapi_WriteFile_impl(PyObject *module, int64_t handle, PyObject *buffer,
int use_overlapped);
static PyObject *
@ -877,7 +875,7 @@ _winapi_WriteFile(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject
PyObject *return_value = NULL;
static const char * const _keywords[] = {"handle", "buffer", "overlapped", NULL};
static _PyArg_Parser _parser = {"" F_HANDLE "O|i:WriteFile", _keywords, 0};
HANDLE handle;
int64_t handle;
PyObject *buffer;
int use_overlapped = 0;

View file

@ -11,6 +11,7 @@
#include "third_party/python/Include/complexobject.h"
#include "third_party/python/Include/dtoa.h"
#include "third_party/python/Include/floatobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/object.h"
#include "third_party/python/Include/pyerrors.h"
@ -1456,3 +1457,8 @@ PyInit_cmath(void)
})
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab_cmath = {
"cmath",
PyInit_cmath,
};

View file

@ -4,216 +4,111 @@
Python 3
https://docs.python.org/3/license.html │
*/
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/cosmo.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/pyport.h"
/* clang-format off */
/* Generated automatically from ./Modules/config.c.in by makesetup. */
/* -*- C -*- ***********************************************
Copyright (c) 2000, BeOpen.com.
Copyright (c) 1995-2000, Corporation for National Research Initiatives.
Copyright (c) 1990-1995, Stichting Mathematisch Centrum.
All rights reserved.
See the file "Misc/COPYRIGHT" for information on usage and
redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
******************************************************************/
/* Module configuration */
/* !!! !!! !!! This file is edited by the makesetup script !!! !!! !!! */
/* This file contains the table of built-in modules.
See create_builtin() in import.c. */
#include "third_party/python/Include/pyport.h"
#include "third_party/python/Include/pyport.h"
#include "third_party/python/Include/Python.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/cosmo.h"
PyObject* PyInit__decimal(void);
PyObject* PyInit_audioop(void);
PyObject* PyInit_posix(void);
PyObject* PyInit_errno(void);
PyObject* PyInit_pwd(void);
PyObject* PyInit__sre(void);
PyObject* PyInit__codecs(void);
PyObject* PyInit__functools(void);
PyObject* PyInit__operator(void);
PyObject* PyInit__collections(void);
PyObject* PyInit_itertools(void);
PyObject* PyInit_atexit(void);
PyObject* PyInit__signal(void);
PyObject* PyInit__stat(void);
PyObject* PyInit_time(void);
PyObject* PyInit__locale(void);
PyObject* PyInit__io(void);
PyObject* PyInit_zipimport(void);
PyObject* PyInit_faulthandler(void);
PyObject* PyInit__hashlib(void);
#ifdef MODE_DBG
PyObject* PyInit__tracemalloc(void);
#endif
PyObject* PyInit__symtable(void);
PyObject* PyInit_array(void);
PyObject* PyInit_cmath(void);
PyObject* PyInit_math(void);
PyObject* PyInit__struct(void);
PyObject* PyInit__weakref(void);
PyObject* PyInit__testcapi(void);
PyObject* PyInit__random(void);
PyObject* PyInit__elementtree(void);
PyObject* PyInit__pickle(void);
PyObject* PyInit__datetime(void);
PyObject* PyInit__bisect(void);
PyObject* PyInit__heapq(void);
PyObject* PyInit_unicodedata(void);
PyObject* PyInit_fcntl(void);
PyObject* PyInit__bz2(void);
PyObject* PyInit_grp(void);
PyObject* PyInit_select(void);
PyObject* PyInit_mmap(void);
PyObject* PyInit__csv(void);
PyObject* PyInit__socket(void);
PyObject* PyInit_resource(void);
PyObject* PyInit__posixsubprocess(void);
PyObject* PyInit__multiprocessing(void);
PyObject* PyInit__md5(void);
PyObject* PyInit__sha1(void);
PyObject* PyInit__sha256(void);
PyObject* PyInit__sha512(void);
PyObject* PyInit__sha3(void);
PyObject* PyInit_syslog(void);
PyObject* PyInit_binascii(void);
PyObject* PyInit_parser(void);
PyObject* PyInit_fpectl(void);
PyObject* PyInit_zlib(void);
PyObject* PyInit_pyexpat(void);
PyObject* PyInit__multibytecodec(void);
PyObject* PyInit__codecs_cn(void);
PyObject* PyInit__codecs_hk(void);
PyObject* PyInit__codecs_iso2022(void);
PyObject* PyInit__codecs_jp(void);
PyObject* PyInit__codecs_kr(void);
PyObject* PyInit__codecs_tw(void);
PyObject* PyInit__json(void);
PyObject* PyInit__lsprof(void);
PyObject* PyInit__opcode(void);
PyObject* PyInit_termios(void);
PyObject *PyInit__ast(void);
PyObject *PyInit__bisect(void);
PyObject *PyInit__bz2(void);
PyObject *PyInit__codecs(void);
PyObject *PyInit__codecs_cn(void);
PyObject *PyInit__codecs_hk(void);
PyObject *PyInit__codecs_iso2022(void);
PyObject *PyInit__codecs_jp(void);
PyObject *PyInit__codecs_kr(void);
PyObject *PyInit__codecs_tw(void);
PyObject *PyInit__collections(void);
PyObject *PyInit__csv(void);
PyObject *PyInit__datetime(void);
PyObject *PyInit__decimal(void);
PyObject *PyInit__elementtree(void);
PyObject *PyInit__functools(void);
PyObject *PyInit__hashlib(void);
PyObject *PyInit__heapq(void);
PyObject *PyInit__io(void);
PyObject *PyInit__json(void);
PyObject *PyInit__locale(void);
PyObject *PyInit__lsprof(void);
PyObject *PyInit__md5(void);
PyObject *PyInit__multibytecodec(void);
PyObject *PyInit__multiprocessing(void);
PyObject *PyInit__opcode(void);
PyObject *PyInit__operator(void);
PyObject *PyInit__pickle(void);
PyObject *PyInit__posixsubprocess(void);
PyObject *PyInit__random(void);
PyObject *PyInit__sha1(void);
PyObject *PyInit__sha256(void);
PyObject *PyInit__sha3(void);
PyObject *PyInit__sha512(void);
PyObject *PyInit__signal(void);
PyObject *PyInit__socket(void);
PyObject *PyInit__sqlite3(void);
PyObject *PyInit__sre(void);
PyObject *PyInit__stat(void);
PyObject *PyInit__string(void);
PyObject *PyInit__struct(void);
PyObject *PyInit__symtable(void);
PyObject *PyInit__testcapi(void);
PyObject *PyInit__tracemalloc(void);
PyObject *PyInit__weakref(void);
PyObject *PyInit_array(void);
PyObject *PyInit_atexit(void);
PyObject *PyInit_audioop(void);
PyObject *PyInit_binascii(void);
PyObject *PyInit_cmath(void);
PyObject *PyInit_cosmo(void);
PyObject *PyInit_errno(void);
PyObject *PyInit_faulthandler(void);
PyObject *PyInit_fcntl(void);
PyObject *PyInit_fpectl(void);
PyObject *PyInit_gc(void);
PyObject *PyInit_grp(void);
PyObject *PyInit_imp(void);
PyObject *PyInit_itertools(void);
PyObject *PyInit_math(void);
PyObject *PyInit_mmap(void);
PyObject *PyInit_parser(void);
PyObject *PyInit_posix(void);
PyObject *PyInit_pwd(void);
PyObject *PyInit_pyexpat(void);
PyObject *PyInit_resource(void);
PyObject *PyInit_select(void);
PyObject *PyInit_syslog(void);
PyObject *PyInit_termios(void);
PyObject *PyInit_time(void);
PyObject *PyInit_unicodedata(void);
PyObject *PyInit_zipimport(void);
PyObject *PyInit_zlib(void);
PyObject *PyMarshal_Init(void);
PyObject *_PyWarnings_Init(void);
/* -- ADDMODULE MARKER 1 -- */
PyObject* PyMarshal_Init(void);
PyObject* PyInit_imp(void);
PyObject* PyInit_cosmo(void);
PyObject* PyInit_gc(void);
PyObject* PyInit__ast(void);
PyObject* _PyWarnings_Init(void);
PyObject* PyInit__string(void);
struct _inittab _PyImport_Inittab[] = {
{"_decimal", PyInit__decimal},
_Alignas(16) _Section(".rodata.pytab.0") const struct _inittab _PyImport_Inittab[0];
_Alignas(16) _Section(".rodata.pytab.2") const struct _inittab _PyImport_Inittab2[] = {
{"posix", PyInit_posix},
{"errno", PyInit_errno},
{"pwd", PyInit_pwd},
{"_sre", PyInit__sre},
{"_codecs", PyInit__codecs},
{"_functools", PyInit__functools},
{"_operator", PyInit__operator},
{"_collections", PyInit__collections},
{"itertools", PyInit_itertools},
{"atexit", PyInit_atexit},
{"_signal", PyInit__signal},
{"_stat", PyInit__stat},
{"time", PyInit_time},
{"_locale", PyInit__locale},
{"_io", PyInit__io},
{"faulthandler", PyInit_faulthandler},
#ifdef USE_TRACEMALLOC
{"_tracemalloc", PyInit__tracemalloc},
#endif
{"_symtable", PyInit__symtable},
{"_hashlib", PyInit__hashlib},
{"_bz2module", PyInit__bz2},
{"array", PyInit_array},
{"cmath", PyInit_cmath},
{"math", PyInit_math},
{"_struct", PyInit__struct},
{"_weakref", PyInit__weakref},
{"_testcapi", PyInit__testcapi},
{"_random", PyInit__random},
{"_pickle", PyInit__pickle},
{"_datetime", PyInit__datetime},
{"_bisect", PyInit__bisect},
{"_heapq", PyInit__heapq},
{"unicodedata", PyInit_unicodedata},
{"fcntl", PyInit_fcntl},
{"grp", PyInit_grp},
{"select", PyInit_select},
{"mmap", PyInit_mmap},
{"_csv", PyInit__csv},
{"_socket", PyInit__socket},
{"resource", PyInit_resource},
{"_posixsubprocess", PyInit__posixsubprocess},
{"_multiprocessing", PyInit__multiprocessing},
{"_md5", PyInit__md5},
{"_sha1", PyInit__sha1},
{"_sha256", PyInit__sha256},
{"_sha512", PyInit__sha512},
{"_sha3", PyInit__sha3},
{"syslog", PyInit_syslog},
{"binascii", PyInit_binascii},
{"parser", PyInit_parser},
{"fpectl", PyInit_fpectl},
{"pyexpat", PyInit_pyexpat},
{"_multibytecodec", PyInit__multibytecodec},
{"_json", PyInit__json},
{"_opcode", PyInit__opcode},
{"termios", PyInit_termios},
#if !IsTiny()
{"zlib", PyInit_zlib},
{"sqlite3", PyInit__sqlite3},
{"zipimport", PyInit_zipimport},
{"_elementtree", PyInit__elementtree},
{"_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},
{"audioop", PyInit_audioop},
{"_lsprof", PyInit__lsprof},
#endif
/* -- ADDMODULE MARKER 2 -- */
/* This module lives in marshal.c */
{"marshal", PyMarshal_Init},
/* This lives in import.c */
{"_imp", PyInit_imp},
/* This lives in cosmomodule.c */
{"_cosmo", PyInit_cosmo},
/* This lives in Python/Python-ast.c */
{"_ast", PyInit__ast},
/* These entries are here for sys.builtin_module_names */
{"builtins", NULL},
{"sys", NULL},
/* This lives in gcmodule.c */
{"gc", PyInit_gc},
/* This lives in _warnings.c */
{"_warnings", _PyWarnings_Init},
/* This lives in Objects/unicodeobject.c */
{"_warnings", _PyWarnings_Init},
{"_string", PyInit__string},
/* Sentinel */
{0, 0}
};

View file

@ -8,6 +8,7 @@
#include "libc/errno.h"
#include "libc/nt/errors.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/methodobject.h"
#include "third_party/python/Include/modsupport.h"

View file

@ -1436,3 +1436,8 @@ void _PyFaulthandler_Fini(void)
}
#endif
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab_faulthandler = {
"faulthandler",
PyInit_faulthandler,
};

View file

@ -16,6 +16,7 @@
#include "third_party/python/Include/bytesobject.h"
#include "third_party/python/Include/ceval.h"
#include "third_party/python/Include/fileobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/object.h"
@ -697,3 +698,8 @@ PyInit_fcntl(void)
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab_fcntl = {
"fcntl",
PyInit_fcntl,
};

View file

@ -6,6 +6,7 @@
*/
#include "libc/runtime/runtime.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/methodobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/moduleobject.h"
@ -275,3 +276,8 @@ PyMODINIT_FUNC PyInit_fpectl(void)
PyDict_SetItemString(d, "error", fpe_error);
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab_fpectl = {
"fpectl",
PyInit_fpectl,
};

View file

@ -8,6 +8,7 @@
#include "libc/calls/calls.h"
#include "libc/calls/struct/stat.h"
#include "libc/errno.h"
#include "libc/log/log.h"
#include "libc/mem/alloca.h"
#include "libc/mem/mem.h"
#include "libc/runtime/gc.internal.h"
@ -125,12 +126,12 @@ wchar_t *Py_GetProgramName(void);
#define LANDMARK L"os.py"
#endif
static const wchar_t limited_search_path[] = L"/zip/.python";
#define LIMITED_SEARCH_PATH L"/zip/.python"
static wchar_t *progpath;
static wchar_t *prefix = limited_search_path;
static wchar_t *exec_prefix = limited_search_path;
static wchar_t *module_search_path = limited_search_path;
static wchar_t *prefix = LIMITED_SEARCH_PATH;
static wchar_t *exec_prefix = LIMITED_SEARCH_PATH;
static wchar_t *module_search_path = LIMITED_SEARCH_PATH;
/* Get file status. Encode the path to the locale encoding. */
@ -667,3 +668,11 @@ Py_GetProgramFullPath(void)
}
return progpath;
}
void
Py_LimitedPath(void)
{
prefix = wcscpy(PyMem_RawMalloc((wcslen(LIMITED_SEARCH_PATH) + 1) * 4), LIMITED_SEARCH_PATH);
exec_prefix = wcscpy(PyMem_RawMalloc((wcslen(LIMITED_SEARCH_PATH) + 1) * 4), LIMITED_SEARCH_PATH);
module_search_path = wcscpy(PyMem_RawMalloc((wcslen(LIMITED_SEARCH_PATH) + 1) * 4), LIMITED_SEARCH_PATH);
}

View file

@ -8,6 +8,7 @@
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/bytesobject.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/listobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/object.h"
@ -276,3 +277,8 @@ PyInit_grp(void)
initialized = 1;
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab_grp = {
"grp",
PyInit_grp,
};

View file

@ -9,6 +9,11 @@
#include "third_party/python/Modules/hashtable.h"
/* clang-format off */
asm(".ident\t\"\\n\\n\
cfuhash (bsd-3)\\n\
Copyright (c) 2005 Don Owens\"");
asm(".include \"libc/disclaimer.inc\"");
/* The implementation of the hash table (_Py_hashtable_t) is based on the
cfuhash project:
http://sourceforge.net/projects/libcfu/

View file

@ -8,6 +8,7 @@
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/boolobject.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/objimpl.h"

View file

@ -11,6 +11,7 @@
#include "third_party/python/Include/boolobject.h"
#include "third_party/python/Include/dtoa.h"
#include "third_party/python/Include/floatobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/pyerrors.h"
@ -2227,3 +2228,8 @@ PyInit_math(void)
finally:
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab_math = {
"math",
PyInit_math,
};

View file

@ -8,6 +8,7 @@
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/bytesobject.h"
#include "third_party/python/Include/descrobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/objimpl.h"
@ -596,3 +597,8 @@ PyInit__md5(void)
PyModule_AddObject(m, "MD5Type", (PyObject *)&MD5type);
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__md5 = {
"_md5",
PyInit__md5,
};

View file

@ -18,6 +18,7 @@
#include "third_party/python/Include/descrobject.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/fileutils.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/objimpl.h"
@ -1491,3 +1492,8 @@ PyInit_mmap(void)
setint(dict, "ACCESS_COPY", ACCESS_COPY);
return module;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab_mmap = {
"mmap",
PyInit_mmap,
};

View file

@ -1253,3 +1253,8 @@ PyInit_parser(void)
}
return module;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab_parser = {
"parser",
PyInit_parser,
};

View file

@ -7,6 +7,7 @@
#define PY_SSIZE_T_CLEAN
#include "libc/alg/alg.h"
#include "libc/assert.h"
#include "libc/bits/weaken.h"
#include "libc/calls/calls.h"
#include "libc/calls/internal.h"
#include "libc/calls/makedev.h"
@ -16,6 +17,7 @@
#include "libc/calls/termios.h"
#include "libc/calls/weirdtypes.h"
#include "libc/errno.h"
#include "libc/log/log.h"
#include "libc/nt/dll.h"
#include "libc/nt/enum/sw.h"
#include "libc/runtime/dlfcn.h"
@ -36,6 +38,7 @@
#include "libc/sysv/consts/st.h"
#include "libc/sysv/consts/w.h"
#include "libc/sysv/consts/waitid.h"
#include "libc/sysv/errfuns.h"
#include "libc/time/time.h"
#include "third_party/musl/passwd.h"
#include "third_party/python/Include/abstract.h"
@ -1816,6 +1819,7 @@ posix_do_stat(const char *function_name, path_t *path,
#endif /* HAVE_FSTATAT */
result = STAT(path->narrow, &st);
#endif /* MS_WINDOWS */
Py_END_ALLOW_THREADS
if (result != 0) {

View file

@ -6,6 +6,7 @@
*/
#include "third_party/musl/passwd.h"
#include "third_party/python/Include/bytesobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/listobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/object.h"
@ -264,3 +265,8 @@ PyInit_pwd(void)
PyModule_AddObject(m, "struct_passwd", (PyObject *) &StructPwdType);
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab_pwd = {
"pwd",
PyInit_pwd,
};

View file

@ -11,6 +11,7 @@
#include "third_party/python/Include/ceval.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/frameobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/objimpl.h"
@ -46,6 +47,9 @@ PYTHON_PROVIDE("pyexpat.model");
PYTHON_PROVIDE("pyexpat.native_encoding");
PYTHON_PROVIDE("pyexpat.version_info");
PYTHON_YOINK("encodings.ascii");
PYTHON_YOINK("encodings.utf_8");
/* Do not emit Clinic output to a file as that wreaks havoc with conditionally
included methods. */
/*[clinic input]
@ -2036,3 +2040,8 @@ static struct HandlerInfo handler_info[] = {
dump buffer
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=524ce2e021e4eba6]*/
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab_pyexpat = {
"pyexpat",
PyInit_pyexpat,
};

View file

@ -14,6 +14,7 @@
#include "libc/sysv/consts/rusage.h"
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/floatobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/pyerrors.h"
@ -416,3 +417,8 @@ PyInit_resource(void)
initialized = 1;
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab_resource = {
"resource",
PyInit_resource,
};

View file

@ -21,6 +21,7 @@
#include "third_party/python/Include/descrobject.h"
#include "third_party/python/Include/dictobject.h"
#include "third_party/python/Include/fileobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/objimpl.h"
@ -2604,3 +2605,8 @@ PyInit_select(void)
#endif /* HAVE_KQUEUE */
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab_select = {
"select",
PyInit_select,
};

View file

@ -8,6 +8,7 @@
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/bytesobject.h"
#include "third_party/python/Include/descrobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/objimpl.h"
@ -579,3 +580,8 @@ PyInit__sha1(void)
PyModule_AddObject(m, "SHA1Type", (PyObject *)&SHA1type);
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__sha1 = {
"_sha1",
PyInit__sha1,
};

View file

@ -7,6 +7,7 @@
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/bytesobject.h"
#include "third_party/python/Include/descrobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/objimpl.h"
@ -744,3 +745,8 @@ PyInit__sha256(void)
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__sha256 = {
"_sha256",
PyInit__sha256,
};

View file

@ -7,6 +7,7 @@
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/bytesobject.h"
#include "third_party/python/Include/descrobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/object.h"
@ -818,3 +819,8 @@ PyInit__sha512(void)
PyModule_AddObject(m, "SHA512Type", (PyObject *)&SHA512type);
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__sha512 = {
"_sha512",
PyInit__sha512,
};

View file

@ -40,6 +40,7 @@
#include "third_party/python/Include/descrobject.h"
#include "third_party/python/Include/fileutils.h"
#include "third_party/python/Include/floatobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/objimpl.h"
@ -7196,3 +7197,8 @@ PyInit__socket(void)
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__socket = {
"_socket",
PyInit__socket,
};

View file

@ -6,6 +6,7 @@
*/
#include "third_party/python/Include/Python-ast.h"
#include "third_party/python/Include/code.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/pyerrors.h"
#include "third_party/python/Include/pymacro.h"
@ -133,3 +134,8 @@ PyInit__symtable(void)
}
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab__symtable = {
"_symtable",
PyInit__symtable,
};

View file

@ -7,6 +7,7 @@
#include "libc/sock/syslog.h"
#include "libc/sysv/consts/log.h"
#include "third_party/python/Include/ceval.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/listobject.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
@ -59,6 +60,12 @@ PYTHON_PROVIDE("syslog.openlog");
PYTHON_PROVIDE("syslog.setlogmask");
PYTHON_PROVIDE("syslog.syslog");
asm(".ident\t\"\\n\\n\
syslogmodule (mit)\\n\
Copyright 1994 by Lance Ellinghouse\\n\
Cathedral City, California Republic, United States of America\"");
asm(".include \"libc/disclaimer.inc\"");
/***********************************************************
Copyright 1994 by Lance Ellinghouse,
Cathedral City, California Republic, United States of America.
@ -396,3 +403,8 @@ PyInit_syslog(void)
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab_syslog = {
"syslog",
PyInit_syslog,
};

View file

@ -16,6 +16,7 @@
#include "libc/sysv/consts/termios.h"
#include "third_party/python/Include/bytesobject.h"
#include "third_party/python/Include/fileobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/listobject.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
@ -790,3 +791,8 @@ PyInit_termios(void)
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab_termios = {
"termios",
PyInit_termios,
};

View file

@ -68,6 +68,8 @@ PYTHON_PROVIDE("time.timezone");
PYTHON_PROVIDE("time.tzname");
PYTHON_PROVIDE("time.tzset");
PYTHON_YOINK("_strptime");
typedef int clockid_t;
#undef HAVE_CLOCK_SETTIME
@ -1477,3 +1479,8 @@ pysleep(_PyTime_t secs)
return 0;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab_time = {
"time",
PyInit_time,
};

View file

@ -7,6 +7,7 @@
#define PY_SSIZE_T_CLEAN
#include "libc/fmt/fmt.h"
#include "third_party/python/Include/floatobject.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/objimpl.h"
@ -1410,3 +1411,8 @@ c-basic-offset: 4
indent-tabs-mode: nil
End:
*/
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab_unicodedata = {
"unicodedata",
PyInit_unicodedata,
};

View file

@ -1,55 +1,14 @@
#ifndef Py_WINREPARSE_H
#define Py_WINREPARSE_H
/* clang-format off */
#ifndef COSMOPOLITAN_THIRD_PARTY_PYTHON_MODULES_WINREPARSE_H_
#define COSMOPOLITAN_THIRD_PARTY_PYTHON_MODULES_WINREPARSE_H_
#include "libc/nt/struct/reparsedatabuffer.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
#ifdef MS_WINDOWS
#include <windows.h>
#ifdef __cplusplus
extern "C" {
#endif
/* The following structure was copied from
http://msdn.microsoft.com/en-us/library/ff552012.aspx as the required
include km\ntifs.h isn't present in the Windows SDK (at least as included
with Visual Studio Express). Use unique names to avoid conflicting with
the structure as defined by Min GW. */
typedef struct {
ULONG ReparseTag;
USHORT ReparseDataLength;
USHORT Reserved;
union {
struct {
USHORT SubstituteNameOffset;
USHORT SubstituteNameLength;
USHORT PrintNameOffset;
USHORT PrintNameLength;
ULONG Flags;
WCHAR PathBuffer[1];
} SymbolicLinkReparseBuffer;
struct {
USHORT SubstituteNameOffset;
USHORT SubstituteNameLength;
USHORT PrintNameOffset;
USHORT PrintNameLength;
WCHAR PathBuffer[1];
} MountPointReparseBuffer;
struct {
UCHAR DataBuffer[1];
} GenericReparseBuffer;
};
} _Py_REPARSE_DATA_BUFFER, *_Py_PREPARSE_DATA_BUFFER;
#define _Py_REPARSE_DATA_BUFFER struct NtReparseDataBuffer
#define _Py_PREPARSE_DATA_BUFFER struct NtReparseDataBuffer*
#define _Py_REPARSE_DATA_BUFFER_HEADER_SIZE \
FIELD_OFFSET(_Py_REPARSE_DATA_BUFFER, GenericReparseBuffer)
#define _Py_MAXIMUM_REPARSE_DATA_BUFFER_SIZE ( 16 * 1024 )
offsetof(_Py_REPARSE_DATA_BUFFER, GenericReparseBuffer)
#define _Py_MAXIMUM_REPARSE_DATA_BUFFER_SIZE (16 * 1024)
#ifdef __cplusplus
}
#endif
#endif /* MS_WINDOWS */
#endif /* !Py_WINREPARSE_H */
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_THIRD_PARTY_PYTHON_MODULES_WINREPARSE_H_ */

View file

@ -40,6 +40,10 @@ PYTHON_PROVIDE("zipimport.ZipImportError");
PYTHON_PROVIDE("zipimport._zip_directory_cache");
PYTHON_PROVIDE("zipimport.zipimporter");
PYTHON_YOINK("encodings.ascii");
PYTHON_YOINK("encodings.cp437");
PYTHON_YOINK("encodings.utf_8");
#define IS_SOURCE 0x0
#define IS_BYTECODE 0x1
#define IS_PACKAGE 0x2
@ -1598,3 +1602,8 @@ PyInit_zipimport(void)
return NULL;
return mod;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab_zipimport = {
"zipimport",
PyInit_zipimport,
};

View file

@ -8,6 +8,7 @@
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/bytesobject.h"
#include "third_party/python/Include/ceval.h"
#include "third_party/python/Include/import.h"
#include "third_party/python/Include/longobject.h"
#include "third_party/python/Include/modsupport.h"
#include "third_party/python/Include/objimpl.h"
@ -1454,3 +1455,8 @@ PyInit_zlib(void)
return m;
}
_Section(".rodata.pytab.1") const struct _inittab _PyImport_Inittab_zlib = {
"zlib",
PyInit_zlib,
};