mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Make changes needed for new demo
This commit is contained in:
parent
c3440d040c
commit
e6b7c16a53
13 changed files with 96 additions and 47 deletions
31
third_party/python/Python/cosmomodule.c
vendored
31
third_party/python/Python/cosmomodule.c
vendored
|
@ -146,6 +146,18 @@ cosmo_crc32c(PyObject *self, PyObject *args)
|
|||
return PyLong_FromUnsignedLong(crc);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(verynice_doc,
|
||||
"verynice($module)\n\
|
||||
--\n\n\
|
||||
Makes current process as low-priority as possible.");
|
||||
|
||||
static PyObject *
|
||||
cosmo_verynice(PyObject *self, PyObject *args)
|
||||
{
|
||||
verynice();
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(decimate_doc,
|
||||
"decimate($module, bytes)\n\
|
||||
--\n\n\
|
||||
|
@ -202,6 +214,7 @@ PyDoc_STRVAR(pledge_doc,
|
|||
--\n\n\
|
||||
Permits syscall operations, e.g.\n\
|
||||
\n\
|
||||
>>> cosmo.pledge(None, None) # assert support\n\
|
||||
>>> cosmo.pledge('stdio rpath tty', None)\n\
|
||||
\n\
|
||||
This function implements the OpenBSD pledge() API for\n\
|
||||
|
@ -213,7 +226,7 @@ cosmo_pledge(PyObject *self, PyObject *args)
|
|||
{
|
||||
int e = errno;
|
||||
const char *x, *y;
|
||||
if (!PyArg_ParseTuple(args, "sz:pledge", &x, &y)) return 0;
|
||||
if (!PyArg_ParseTuple(args, "zz:pledge", &x, &y)) return 0;
|
||||
__pledge_mode = PLEDGE_PENALTY_RETURN_EPERM;
|
||||
if (!pledge(x, y)) {
|
||||
Py_RETURN_NONE;
|
||||
|
@ -229,8 +242,9 @@ PyDoc_STRVAR(unveil_doc,
|
|||
--\n\n\
|
||||
Permits filesystem operations, e.g.\n\
|
||||
\n\
|
||||
>>> cosmo.unveil('.', 'rwcx')\n\
|
||||
>>> cosmo.unveil(None, None)\n\
|
||||
>>> cosmo.unveil('', None) # assert support\n\
|
||||
>>> cosmo.unveil('.', 'rwcx') # permit current dir\n\
|
||||
>>> cosmo.unveil(None, None) # commit policy\n\
|
||||
\n\
|
||||
This function implements the OpenBSD unveil() API for\n\
|
||||
OpenBSD and Linux where we use Landlock LSM. Read the\n\
|
||||
|
@ -239,11 +253,15 @@ Cosmopolitan Libc documentation to learn more.");
|
|||
static PyObject *
|
||||
cosmo_unveil(PyObject *self, PyObject *args)
|
||||
{
|
||||
int e = errno;
|
||||
const char *x, *y;
|
||||
int abi, e = errno;
|
||||
if (!PyArg_ParseTuple(args, "zz:unveil", &x, &y)) return 0;
|
||||
if (!unveil(x, y)) {
|
||||
Py_RETURN_NONE;
|
||||
if ((abi = unveil(x, y)) != -1) {
|
||||
if (abi) {
|
||||
return PyLong_FromUnsignedLong(abi);
|
||||
} else {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
} else {
|
||||
PyErr_SetString(PyExc_SystemError, strerror(errno));
|
||||
errno = e;
|
||||
|
@ -338,6 +356,7 @@ static PyMethodDef cosmo_methods[] = {
|
|||
{"syscount", cosmo_syscount, METH_NOARGS, syscount_doc},
|
||||
{"popcount", cosmo_popcount, METH_VARARGS, popcount_doc},
|
||||
{"decimate", cosmo_decimate, METH_VARARGS, decimate_doc},
|
||||
{"verynice", cosmo_verynice, METH_VARARGS, verynice_doc},
|
||||
#ifdef __x86_64__
|
||||
{"getcpucore", cosmo_getcpucore, METH_NOARGS, getcpucore_doc},
|
||||
{"getcpunode", cosmo_getcpunode, METH_NOARGS, getcpunode_doc},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue