diff --git a/build/bootstrap/package.com b/build/bootstrap/package.com index cdf356dd0..6518761ca 100755 Binary files a/build/bootstrap/package.com and b/build/bootstrap/package.com differ diff --git a/build/bootstrap/zipobj.com b/build/bootstrap/zipobj.com index e0bb49481..1980a9018 100755 Binary files a/build/bootstrap/zipobj.com and b/build/bootstrap/zipobj.com differ diff --git a/third_party/python/Python/ceval.c b/third_party/python/Python/ceval.c index a8b5237ad..67bf71c4e 100644 --- a/third_party/python/Python/ceval.c +++ b/third_party/python/Python/ceval.c @@ -824,7 +824,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag) #if __GNUC__ + 0 >= 9 #define HOT_LABEL __attribute__((__hot__)) -#define COLD_LABEL __attribute__((__hot__)) +#define COLD_LABEL __attribute__((__cold__)) #else #define HOT_LABEL #define COLD_LABEL diff --git a/third_party/python/Python/cosmomodule.c b/third_party/python/Python/cosmomodule.c index 6b21a2633..71f795805 100644 --- a/third_party/python/Python/cosmomodule.c +++ b/third_party/python/Python/cosmomodule.c @@ -205,50 +205,44 @@ static bool ftrace_installed = 0; typedef struct { PyObject_HEAD -} TracerObject; +} FtracerObject; -static int TracerObject_init(PyObject* self, PyObject *args, PyObject *kwargs) +static int FtracerObject_init(PyObject* self, PyObject *args, PyObject *kwargs) { - if (!ftrace_installed) { - ftrace_install(); - ftrace_installed = 1; - ftrace_enabled = 0; - } + ftrace_install(); return 0; } -static PyObject* TracerObject_enter(PyObject *self, PyObject *Py_UNUSED(ignored)) +static PyObject* FtracerObject_enter(PyObject *self, PyObject *Py_UNUSED(ignored)) { - ftrace_enabled = 1; + ++g_ftrace; return self; } -static PyObject* TracerObject_exit(PyObject *self, PyObject *args) +static PyObject* FtracerObject_exit(PyObject *self, PyObject *args) { - ftrace_enabled = 0; + --g_ftrace; return self; } -static PyMethodDef TracerObject_methods[] = { - {"__enter__", (PyCFunction) TracerObject_enter, METH_NOARGS, - "enable ftrace to start logging" - }, - {"__exit__", (PyCFunction) TracerObject_exit, METH_VARARGS, - "disable ftrace to stop logging" - }, +static PyMethodDef FtracerObject_methods[] = { + {"__enter__", (PyCFunction) FtracerObject_enter, METH_NOARGS, + "enables c function call logging"}, + {"__exit__", (PyCFunction) FtracerObject_exit, METH_VARARGS, + "disables c function call logging"}, {0} }; -static PyTypeObject TracerType = { +static PyTypeObject FtracerType = { PyVarObject_HEAD_INIT(NULL, 0) - .tp_name = "cosmo.Tracer", + .tp_name = "cosmo.Ftracer", .tp_doc = "wrapping ftrace with a context manager", - .tp_basicsize = sizeof(TracerObject), + .tp_basicsize = sizeof(FtracerObject), .tp_itemsize = 0, .tp_flags = Py_TPFLAGS_DEFAULT, .tp_new = PyType_GenericNew, - .tp_init = (initproc) TracerObject_init, - .tp_methods = TracerObject_methods, + .tp_init = (initproc) FtracerObject_init, + .tp_methods = FtracerObject_methods, }; PyDoc_STRVAR(ftrace_doc, @@ -265,14 +259,12 @@ to work, the concomitant .com.dbg binary needs to be present."); static PyObject * cosmo_ftrace(PyObject *self, PyObject *noargs) { - PyObject *tracer = PyType_GenericNew(&TracerType, NULL, NULL); + PyObject *tracer = PyType_GenericNew(&FtracerType, NULL, NULL); if (tracer == NULL) Py_RETURN_NONE; - TracerObject_init(tracer, NULL, NULL); + FtracerObject_init(tracer, NULL, NULL); return tracer; } - - static PyMethodDef cosmo_methods[] = { {"exit1", cosmo_exit1, METH_NOARGS, exit1_doc}, {"rdtsc", cosmo_rdtsc, METH_NOARGS, rdtsc_doc}, @@ -321,14 +313,14 @@ PyMODINIT_FUNC PyInit_cosmo(void) { PyObject *m; - if (PyType_Ready(&TracerType) < 0) return 0; + if (PyType_Ready(&FtracerType) < 0) return 0; if (!(m = PyModule_Create(&cosmomodule))) return 0; PyModule_AddStringConstant(m, "MODE", MODE); PyModule_AddIntConstant(m, "IMAGE_BASE_VIRTUAL", IMAGE_BASE_VIRTUAL); PyModule_AddStringConstant(m, "kernel", GetKernelName()); PyModule_AddIntConstant(m, "kStartTsc", kStartTsc); - Py_INCREF(&TracerType); + Py_INCREF(&FtracerType); // PyModule_AddObject(m, "Tracer", (PyObject *) &TracerType); return !PyErr_Occurred() ? m : 0; } diff --git a/third_party/python/pyobj.c b/third_party/python/pyobj.c index 91454f8ab..47de11a58 100644 --- a/third_party/python/pyobj.c +++ b/third_party/python/pyobj.c @@ -31,7 +31,9 @@ #include "libc/runtime/runtime.h" #include "libc/stdio/append.internal.h" #include "libc/stdio/stdio.h" +#include "libc/sysv/consts/clock.h" #include "libc/sysv/consts/o.h" +#include "libc/time/time.h" #include "libc/x/x.h" #include "third_party/getopt/getopt.h" #include "third_party/python/Include/abstract.h" @@ -711,6 +713,8 @@ int main(int argc, char *argv[]) { int ec; + timestamp.tv_sec = 1647414000; /* determinism */ + /* clock_gettime(CLOCK_REALTIME, ×tamp); */ GetOpts(argc, argv); Py_NoUserSiteDirectory++; Py_NoSiteFlag++; diff --git a/tool/build/lib/elfwriter_zip.c b/tool/build/lib/elfwriter_zip.c index 789459f47..0f48e0027 100644 --- a/tool/build/lib/elfwriter_zip.c +++ b/tool/build/lib/elfwriter_zip.c @@ -145,6 +145,8 @@ void elfwriter_zip(struct ElfWriter *elf, const char *symbol, const char *name, size_t lfilehdrsize, uncompsize, compsize, commentsize; uint16_t method, gflags, mtime, mdate, iattrs, dosmode; + CHECK_NE(0, mtim.tv_sec); + gflags = 0; iattrs = 0; compsize = size; diff --git a/tool/build/zipobj.c b/tool/build/zipobj.c index 6c8454b98..75ccbed13 100644 --- a/tool/build/zipobj.c +++ b/tool/build/zipobj.c @@ -26,11 +26,13 @@ #include "libc/runtime/gc.internal.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" +#include "libc/sysv/consts/clock.h" #include "libc/sysv/consts/ex.h" #include "libc/sysv/consts/exit.h" #include "libc/sysv/consts/map.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/prot.h" +#include "libc/time/time.h" #include "libc/x/x.h" #include "third_party/getopt/getopt.h" #include "tool/build/lib/elfwriter.h" @@ -166,6 +168,8 @@ void zipobj(int argc, char **argv) { } int main(int argc, char **argv) { + timestamp.tv_sec = 1647414000; /* determinism */ + /* clock_gettime(CLOCK_REALTIME, ×tamp); */ zipobj(argc, argv); return 0; }