mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 05:42:29 +00:00
parent
2d64b9994b
commit
10fd8bdb70
1397 changed files with 1204 additions and 5031 deletions
1
third_party/python/Include/pydebug.h
vendored
1
third_party/python/Include/pydebug.h
vendored
|
@ -3,6 +3,7 @@
|
|||
#define Py_PYDEBUG_H
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
||||
/* These global variable are defined in pylifecycle.c */
|
||||
/* XXX (ncoghlan): move these declarations to pylifecycle.h? */
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "libc/errno.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
#include "libc/unicode/unicode.h"
|
||||
#include "third_party/python/Modules/_decimal/libmpdec/bits.h"
|
||||
#include "third_party/python/Modules/_decimal/libmpdec/constants.h"
|
||||
#include "third_party/python/Modules/_decimal/libmpdec/io.h"
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
│ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, │
|
||||
│ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/mem/mem.h"
|
||||
#include "third_party/python/Modules/_decimal/libmpdec/mpalloc.h"
|
||||
#include "third_party/python/Modules/_decimal/libmpdec/mpdecimal.h"
|
||||
#include "third_party/python/Modules/_decimal/libmpdec/typearith.h"
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "libc/fmt/conv.h"
|
||||
#include "libc/inttypes.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "third_party/python/pyconfig.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
|
|
1
third_party/python/Modules/_localemodule.c
vendored
1
third_party/python/Modules/_localemodule.c
vendored
|
@ -7,6 +7,7 @@
|
|||
#define PY_SSIZE_T_CLEAN
|
||||
#include "libc/unicode/langinfo.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
#include "libc/unicode/unicode.h"
|
||||
#include "third_party/python/Include/dictobject.h"
|
||||
#include "third_party/python/Include/fileutils.h"
|
||||
#include "third_party/python/Include/import.h"
|
||||
|
|
1
third_party/python/Modules/_testcapimodule.c
vendored
1
third_party/python/Modules/_testcapimodule.c
vendored
|
@ -12,6 +12,7 @@
|
|||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
#include "libc/time/time.h"
|
||||
#include "third_party/python/Include/abstract.h"
|
||||
|
|
1
third_party/python/Modules/_tracemalloc.c
vendored
1
third_party/python/Modules/_tracemalloc.c
vendored
|
@ -6,6 +6,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "third_party/python/Include/boolobject.h"
|
||||
#include "third_party/python/Include/dictobject.h"
|
||||
#include "third_party/python/Include/fileutils.h"
|
||||
|
|
1
third_party/python/Modules/expat/xmlparse.c
vendored
1
third_party/python/Modules/expat/xmlparse.c
vendored
|
@ -3,6 +3,7 @@
|
|||
#include "libc/calls/struct/timeval.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nexgen32e/rdtsc.h"
|
||||
#include "libc/nexgen32e/x86feature.h"
|
||||
#include "libc/rand/rand.h"
|
||||
|
|
1
third_party/python/Modules/resource.c
vendored
1
third_party/python/Modules/resource.c
vendored
|
@ -9,6 +9,7 @@
|
|||
#include "libc/calls/struct/rusage.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/rlim.h"
|
||||
#include "libc/sysv/consts/rlimit.h"
|
||||
#include "libc/sysv/consts/rusage.h"
|
||||
|
|
1
third_party/python/Objects/fileobject.c
vendored
1
third_party/python/Objects/fileobject.c
vendored
|
@ -7,6 +7,7 @@
|
|||
#define PY_SSIZE_T_CLEAN
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/stdio/lock.h"
|
||||
#include "third_party/python/Include/abstract.h"
|
||||
#include "third_party/python/Include/boolobject.h"
|
||||
#include "third_party/python/Include/bytesobject.h"
|
||||
|
|
1
third_party/python/Objects/obmalloc.c
vendored
1
third_party/python/Objects/obmalloc.c
vendored
|
@ -10,6 +10,7 @@
|
|||
#include "libc/dce.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/map.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
|
|
1
third_party/python/Parser/acceler.c
vendored
1
third_party/python/Parser/acceler.c
vendored
|
@ -4,6 +4,7 @@
|
|||
│ Python 3 │
|
||||
│ https://docs.python.org/3/license.html │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "third_party/python/Include/grammar.h"
|
||||
#include "third_party/python/Include/node.h"
|
||||
#include "third_party/python/Include/objimpl.h"
|
||||
|
|
1
third_party/python/Parser/grammar.c
vendored
1
third_party/python/Parser/grammar.c
vendored
|
@ -4,6 +4,7 @@
|
|||
│ Python 3 │
|
||||
│ https://docs.python.org/3/license.html │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/mem/mem.h"
|
||||
#include "third_party/python/Include/grammar.h"
|
||||
#include "third_party/python/Include/objimpl.h"
|
||||
#include "third_party/python/Include/pgenheaders.h"
|
||||
|
|
58
third_party/python/Python/cosmomodule.c
vendored
58
third_party/python/Python/cosmomodule.c
vendored
|
@ -19,7 +19,9 @@
|
|||
#define PY_SSIZE_T_CLEAN
|
||||
#include "dsp/scale/cdecimate2xuint8x8.h"
|
||||
#include "libc/bits/popcnt.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/mem/mem.h"
|
||||
|
@ -27,6 +29,7 @@
|
|||
#include "libc/nexgen32e/rdtsc.h"
|
||||
#include "libc/nexgen32e/rdtscp.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "third_party/python/Include/abstract.h"
|
||||
#include "third_party/python/Include/import.h"
|
||||
#include "third_party/python/Include/longobject.h"
|
||||
|
@ -187,6 +190,59 @@ cosmo_popcount(PyObject *self, PyObject *args)
|
|||
return PyLong_FromSize_t(_countbits(p, n));
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(pledge_doc,
|
||||
"pledge($module, promises, execpromises)\n\
|
||||
--\n\n\
|
||||
Permits syscall operations, e.g.\n\
|
||||
\n\
|
||||
>>> cosmo.pledge('stdio rpath tty', None)\n\
|
||||
\n\
|
||||
This function implements the OpenBSD pledge() API for\n\
|
||||
OpenBSD and Linux, where we use SECCOMP BPF. Read the\n\
|
||||
Cosmopolitan Libc documentation to learn more.");
|
||||
|
||||
static PyObject *
|
||||
cosmo_pledge(PyObject *self, PyObject *args)
|
||||
{
|
||||
int e = errno;
|
||||
const char *x, *y;
|
||||
if (!PyArg_ParseTuple(args, "sz:pledge", &x, &y)) return 0;
|
||||
if (!pledge(x, y)) {
|
||||
Py_RETURN_NONE;
|
||||
} else {
|
||||
PyErr_SetString(PyExc_SystemError, strerror(errno));
|
||||
errno = e;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(unveil_doc,
|
||||
"unveil($module, path, permissions)\n\
|
||||
--\n\n\
|
||||
Permits filesystem operations, e.g.\n\
|
||||
\n\
|
||||
>>> cosmo.unveil('.', 'rwcx')\n\
|
||||
>>> cosmo.unveil(None, None)\n\
|
||||
\n\
|
||||
This function implements the OpenBSD unveil() API for\n\
|
||||
OpenBSD and Linux where we use Landlock LSM. Read the\n\
|
||||
Cosmopolitan Libc documentation to learn more.");
|
||||
|
||||
static PyObject *
|
||||
cosmo_unveil(PyObject *self, PyObject *args)
|
||||
{
|
||||
int e = errno;
|
||||
const char *x, *y;
|
||||
if (!PyArg_ParseTuple(args, "zz:unveil", &x, &y)) return 0;
|
||||
if (!unveil(x, y)) {
|
||||
Py_RETURN_NONE;
|
||||
} else {
|
||||
PyErr_SetString(PyExc_SystemError, strerror(errno));
|
||||
errno = e;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(exit1_doc,
|
||||
"exit1($module)\n\
|
||||
--\n\n\
|
||||
|
@ -269,6 +325,8 @@ static PyMethodDef cosmo_methods[] = {
|
|||
{"exit1", cosmo_exit1, METH_NOARGS, exit1_doc},
|
||||
{"rdtsc", cosmo_rdtsc, METH_NOARGS, rdtsc_doc},
|
||||
{"crc32c", cosmo_crc32c, METH_VARARGS, crc32c_doc},
|
||||
{"pledge", cosmo_pledge, METH_VARARGS, pledge_doc},
|
||||
{"unveil", cosmo_unveil, METH_VARARGS, unveil_doc},
|
||||
{"syscount", cosmo_syscount, METH_NOARGS, syscount_doc},
|
||||
{"popcount", cosmo_popcount, METH_VARARGS, popcount_doc},
|
||||
{"decimate", cosmo_decimate, METH_VARARGS, decimate_doc},
|
||||
|
|
1
third_party/python/Python/dtoa.c
vendored
1
third_party/python/Python/dtoa.c
vendored
|
@ -7,6 +7,7 @@
|
|||
#include "libc/assert.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "third_party/python/Include/pymem.h"
|
||||
#include "third_party/python/Include/pyport.h"
|
||||
/* clang-format off */
|
||||
|
|
1
third_party/python/Python/errors.c
vendored
1
third_party/python/Python/errors.c
vendored
|
@ -5,6 +5,7 @@
|
|||
│ https://docs.python.org/3/license.html │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/errno.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nt/enum/formatmessageflags.h"
|
||||
#include "libc/nt/enum/lang.h"
|
||||
#include "libc/nt/memory.h"
|
||||
|
|
1
third_party/python/Python/fileutils.c
vendored
1
third_party/python/Python/fileutils.c
vendored
|
@ -15,6 +15,7 @@
|
|||
#include "libc/sysv/consts/fio.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
#include "libc/unicode/unicode.h"
|
||||
#include "third_party/python/Include/bytesobject.h"
|
||||
#include "third_party/python/Include/ceval.h"
|
||||
#include "third_party/python/Include/fileutils.h"
|
||||
|
|
5
third_party/python/Python/import.c
vendored
5
third_party/python/Python/import.c
vendored
|
@ -11,14 +11,15 @@
|
|||
#include "libc/calls/struct/stat.macros.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/gc.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/s.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "third_party/python/Include/Python-ast.h"
|
||||
#include "third_party/python/Include/abstract.h"
|
||||
#include "third_party/python/Include/boolobject.h"
|
||||
#include "third_party/python/Include/bltinmodule.h"
|
||||
#include "third_party/python/Include/boolobject.h"
|
||||
#include "third_party/python/Include/ceval.h"
|
||||
#include "third_party/python/Include/code.h"
|
||||
#include "third_party/python/Include/dictobject.h"
|
||||
|
|
1
third_party/python/freeze.c
vendored
1
third_party/python/freeze.c
vendored
|
@ -5,6 +5,7 @@
|
|||
│ https://docs.python.org/3/license.html │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "third_party/python/Include/bytesobject.h"
|
||||
#include "third_party/python/Include/compile.h"
|
||||
#include "third_party/python/Include/fileutils.h"
|
||||
|
|
1
third_party/python/launch.c
vendored
1
third_party/python/launch.c
vendored
|
@ -9,6 +9,7 @@
|
|||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/log/libfatal.internal.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
#include "libc/x/x.h"
|
||||
|
|
2
third_party/python/python.mk
vendored
2
third_party/python/python.mk
vendored
|
@ -4448,7 +4448,7 @@ o/$(MODE)/third_party/python/chibicc.inc: \
|
|||
third_party/python/Include/warnings.h \
|
||||
third_party/python/Include/weakrefobject.h \
|
||||
third_party/python/pyconfig.h
|
||||
@$(COMPILE) -ACHECK.h $(COMPILE.c) -xc -E -P -fdirectives-only -dD -D__chibicc__ -o $@ $<
|
||||
@$(COMPILE) -wACHECK.h $(COMPILE.c) -xc -E -P -fdirectives-only -dD -D__chibicc__ -o $@ $<
|
||||
|
||||
################################################################################
|
||||
# HELLO.COM
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue