Make numerous improvements

- Python static hello world now 1.8mb
- Python static fully loaded now 10mb
- Python HTTPS client now uses MbedTLS
- Python REPL now completes import stmts
- Increase stack size for Python for now
- Begin synthesizing posixpath and ntpath
- Restore Python \N{UNICODE NAME} support
- Restore Python NFKD symbol normalization
- Add optimized code path for Intel SHA-NI
- Get more Python unit tests passing faster
- Get Python help() pagination working on NT
- Python hashlib now supports MbedTLS PBKDF2
- Make memcpy/memmove/memcmp/bcmp/etc. faster
- Add Mersenne Twister and Vigna to LIBC_RAND
- Provide privileged __printf() for error code
- Fix zipos opendir() so that it reports ENOTDIR
- Add basic chmod() implementation for Windows NT
- Add Cosmo's best functions to Python cosmo module
- Pin function trace indent depth to that of caller
- Show memory diagram on invalid access in MODE=dbg
- Differentiate stack overflow on crash in MODE=dbg
- Add stb_truetype and tools for analyzing font files
- Upgrade to UNICODE 13 and reduce its binary footprint
- COMPILE.COM now logs resource usage of build commands
- Start implementing basic poll() support on bare metal
- Set getauxval(AT_EXECFN) to GetModuleFileName() on NT
- Add descriptions to strerror() in non-TINY build modes
- Add COUNTBRANCH() macro to help with micro-optimizations
- Make error / backtrace / asan / memory code more unbreakable
- Add fast perfect C implementation of μ-Law and a-Law audio codecs
- Make strtol() functions consistent with other libc implementations
- Improve Linenoise implementation (see also github.com/jart/bestline)
- COMPILE.COM now suppresses stdout/stderr of successful build commands
This commit is contained in:
Justine Tunney 2021-09-27 22:58:51 -07:00
parent fa7b4f5bd1
commit 39bf41f4eb
806 changed files with 77494 additions and 63859 deletions

View file

@ -70,22 +70,22 @@ PyDoc_STRVAR(struct_rusage__doc__,
"or via the attributes ru_utime, ru_stime, ru_maxrss, and so on.");
static PyStructSequence_Field struct_rusage_fields[] = {
{"ru_utime", "user time used"},
{"ru_stime", "system time used"},
{"ru_maxrss", "max. resident set size"},
{"ru_ixrss", "shared memory size"},
{"ru_idrss", "unshared data size"},
{"ru_isrss", "unshared stack size"},
{"ru_minflt", "page faults not requiring I/O"},
{"ru_majflt", "page faults requiring I/O"},
{"ru_nswap", "number of swap outs"},
{"ru_inblock", "block input operations"},
{"ru_oublock", "block output operations"},
{"ru_msgsnd", "IPC messages sent"},
{"ru_msgrcv", "IPC messages received"},
{"ru_nsignals", "signals received"},
{"ru_nvcsw", "voluntary context switches"},
{"ru_nivcsw", "involuntary context switches"},
{"ru_utime", PyDoc_STR("user time used")},
{"ru_stime", PyDoc_STR("system time used")},
{"ru_maxrss", PyDoc_STR("max. resident set size")},
{"ru_ixrss", PyDoc_STR("shared memory size")},
{"ru_idrss", PyDoc_STR("unshared data size")},
{"ru_isrss", PyDoc_STR("unshared stack size")},
{"ru_minflt", PyDoc_STR("page faults not requiring I/O")},
{"ru_majflt", PyDoc_STR("page faults requiring I/O")},
{"ru_nswap", PyDoc_STR("number of swap outs")},
{"ru_inblock", PyDoc_STR("block input operations")},
{"ru_oublock", PyDoc_STR("block output operations")},
{"ru_msgsnd", PyDoc_STR("IPC messages sent")},
{"ru_msgrcv", PyDoc_STR("IPC messages received")},
{"ru_nsignals", PyDoc_STR("signals received")},
{"ru_nvcsw", PyDoc_STR("voluntary context switches")},
{"ru_nivcsw", PyDoc_STR("involuntary context switches")},
{0}
};
@ -104,11 +104,9 @@ resource_getrusage(PyObject *self, PyObject *args)
{
int who;
struct rusage ru;
PyObject *result;
PyObject *r;
if (!PyArg_ParseTuple(args, "i:getrusage", &who))
return NULL;
if (getrusage(who, &ru) == -1) {
if (errno == EINVAL) {
PyErr_SetString(PyExc_ValueError,
@ -118,36 +116,30 @@ resource_getrusage(PyObject *self, PyObject *args)
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
}
result = PyStructSequence_New(&StructRUsageType);
if (!result)
r = PyStructSequence_New(&StructRUsageType);
if (!r)
return NULL;
PyStructSequence_SET_ITEM(result, 0,
PyFloat_FromDouble(doubletime(ru.ru_utime)));
PyStructSequence_SET_ITEM(result, 1,
PyFloat_FromDouble(doubletime(ru.ru_stime)));
PyStructSequence_SET_ITEM(result, 2, PyLong_FromLong(ru.ru_maxrss));
PyStructSequence_SET_ITEM(result, 3, PyLong_FromLong(ru.ru_ixrss));
PyStructSequence_SET_ITEM(result, 4, PyLong_FromLong(ru.ru_idrss));
PyStructSequence_SET_ITEM(result, 5, PyLong_FromLong(ru.ru_isrss));
PyStructSequence_SET_ITEM(result, 6, PyLong_FromLong(ru.ru_minflt));
PyStructSequence_SET_ITEM(result, 7, PyLong_FromLong(ru.ru_majflt));
PyStructSequence_SET_ITEM(result, 8, PyLong_FromLong(ru.ru_nswap));
PyStructSequence_SET_ITEM(result, 9, PyLong_FromLong(ru.ru_inblock));
PyStructSequence_SET_ITEM(result, 10, PyLong_FromLong(ru.ru_oublock));
PyStructSequence_SET_ITEM(result, 11, PyLong_FromLong(ru.ru_msgsnd));
PyStructSequence_SET_ITEM(result, 12, PyLong_FromLong(ru.ru_msgrcv));
PyStructSequence_SET_ITEM(result, 13, PyLong_FromLong(ru.ru_nsignals));
PyStructSequence_SET_ITEM(result, 14, PyLong_FromLong(ru.ru_nvcsw));
PyStructSequence_SET_ITEM(result, 15, PyLong_FromLong(ru.ru_nivcsw));
PyStructSequence_SET_ITEM(r, 0, PyFloat_FromDouble(doubletime(ru.ru_utime)));
PyStructSequence_SET_ITEM(r, 1, PyFloat_FromDouble(doubletime(ru.ru_stime)));
PyStructSequence_SET_ITEM(r, 2, PyLong_FromLong(ru.ru_maxrss));
PyStructSequence_SET_ITEM(r, 3, PyLong_FromLong(ru.ru_ixrss));
PyStructSequence_SET_ITEM(r, 4, PyLong_FromLong(ru.ru_idrss));
PyStructSequence_SET_ITEM(r, 5, PyLong_FromLong(ru.ru_isrss));
PyStructSequence_SET_ITEM(r, 6, PyLong_FromLong(ru.ru_minflt));
PyStructSequence_SET_ITEM(r, 7, PyLong_FromLong(ru.ru_majflt));
PyStructSequence_SET_ITEM(r, 8, PyLong_FromLong(ru.ru_nswap));
PyStructSequence_SET_ITEM(r, 9, PyLong_FromLong(ru.ru_inblock));
PyStructSequence_SET_ITEM(r, 10, PyLong_FromLong(ru.ru_oublock));
PyStructSequence_SET_ITEM(r, 11, PyLong_FromLong(ru.ru_msgsnd));
PyStructSequence_SET_ITEM(r, 12, PyLong_FromLong(ru.ru_msgrcv));
PyStructSequence_SET_ITEM(r, 13, PyLong_FromLong(ru.ru_nsignals));
PyStructSequence_SET_ITEM(r, 14, PyLong_FromLong(ru.ru_nvcsw));
PyStructSequence_SET_ITEM(r, 15, PyLong_FromLong(ru.ru_nivcsw));
if (PyErr_Occurred()) {
Py_DECREF(result);
Py_DECREF(r);
return NULL;
}
return result;
return r;
}
static int
@ -158,7 +150,6 @@ py2rlimit(PyObject *limits, struct rlimit *rl_out)
if (!limits)
/* Here limits is a borrowed reference */
return -1;
if (PyTuple_GET_SIZE(limits) != 2) {
PyErr_SetString(PyExc_ValueError,
"expected a tuple of 2 integers");
@ -182,12 +173,10 @@ py2rlimit(PyObject *limits, struct rlimit *rl_out)
if (rl_out->rlim_max == (rlim_t)-1 && PyErr_Occurred())
goto error;
#endif
Py_DECREF(limits);
rl_out->rlim_cur = rl_out->rlim_cur & RLIM_INFINITY;
rl_out->rlim_max = rl_out->rlim_max & RLIM_INFINITY;
return 0;
error:
Py_DECREF(limits);
return -1;
@ -209,16 +198,13 @@ resource_getrlimit(PyObject *self, PyObject *args)
{
struct rlimit rl;
int resource;
if (!PyArg_ParseTuple(args, "i:getrlimit", &resource))
return NULL;
if (resource < 0 || resource >= RLIM_NLIMITS) {
PyErr_SetString(PyExc_ValueError,
"invalid resource specified");
return NULL;
}
if (getrlimit(resource, &rl) == -1) {
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
@ -232,20 +218,16 @@ resource_setrlimit(PyObject *self, PyObject *args)
struct rlimit rl;
int resource;
PyObject *limits;
if (!PyArg_ParseTuple(args, "iO:setrlimit", &resource, &limits))
return NULL;
if (resource < 0 || resource >= RLIM_NLIMITS) {
PyErr_SetString(PyExc_ValueError,
"invalid resource specified");
return NULL;
}
if (py2rlimit(limits, &rl) < 0) {
return NULL;
}
if (setrlimit(resource, &rl) == -1) {
if (errno == EINVAL)
PyErr_SetString(PyExc_ValueError,
@ -268,17 +250,14 @@ resource_prlimit(PyObject *self, PyObject *args)
int resource, retval;
pid_t pid;
PyObject *limits = NULL;
if (!PyArg_ParseTuple(args, _Py_PARSE_PID "i|O:prlimit",
&pid, &resource, &limits))
return NULL;
if (resource < 0 || resource >= RLIM_NLIMITS) {
PyErr_SetString(PyExc_ValueError,
"invalid resource specified");
return NULL;
}
if (limits != NULL) {
if (py2rlimit(limits, &new_limit) < 0) {
return NULL;
@ -288,7 +267,6 @@ resource_prlimit(PyObject *self, PyObject *args)
else {
retval = prlimit(pid, resource, NULL, &old_limit);
}
if (retval == -1) {
if (errno == EINVAL) {
PyErr_SetString(PyExc_ValueError,
@ -317,11 +295,8 @@ resource_getpagesize(PyObject *self, PyObject *unused)
#endif
#endif
return Py_BuildValue("i", pagesize);
}
/* List of functions */
static struct PyMethodDef
resource_methods[] = {
{"getrusage", resource_getrusage, METH_VARARGS},
@ -334,10 +309,6 @@ resource_methods[] = {
{NULL, NULL} /* sentinel */
};
/* Module initialization */
static struct PyModuleDef resourcemodule = {
PyModuleDef_HEAD_INIT,
"resource",