Pay off more technical debt

This makes breaking changes to add underscores to many non-standard
function names provided by the c library. MODE=tiny is now tinier and
we now use smaller locks that are better for tiny apps in this mode.
Some headers have been renamed to be in the same folder as the build
package, so it'll be easier to know which build dependency is needed.
Certain old misguided interfaces have been removed. Intel intrinsics
headers are now listed in libc/isystem (but not in the amalgamation)
to help further improve open source compatibility. Header complexity
has also been reduced. Lastly, more shell scripts are now available.
This commit is contained in:
Justine Tunney 2022-09-12 23:10:38 -07:00
parent b69f3d2488
commit 6f7d0cb1c3
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
960 changed files with 4072 additions and 4873 deletions

View file

@ -1009,14 +1009,14 @@ PyObject *PyCodec_NameReplaceErrors(PyObject *exc)
return NULL;
for (i = start, ressize = 0; i < end; ++i) {
/* object is guaranteed to be "ready" */
if (!weaken(_PyUnicode_GetUcName)) {
if (!_weaken(_PyUnicode_GetUcName)) {
PyErr_SetString(
PyExc_UnicodeError,
"_PyUnicode_GetUcName() not available");
return NULL;
}
c = PyUnicode_READ_CHAR(object, i);
if (weaken(_PyUnicode_GetUcName)(NULL, c, buffer, sizeof(buffer), 1)) {
if (_weaken(_PyUnicode_GetUcName)(NULL, c, buffer, sizeof(buffer), 1)) {
replsize = 1+1+1+(int)strlen(buffer)+1;
}
else if (c >= 0x10000) {

View file

@ -6,6 +6,7 @@
*/
#include "libc/intrin/weaken.h"
#include "libc/log/log.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/pyerrors.h"
@ -159,6 +160,6 @@ exit:
#if defined(MS_WINDOWS) && defined(_DEBUG)
DebugBreak();
#endif
if (weaken(__die)) weaken(__die)();
if (_weaken(__die)) _weaken(__die)();
abort();
}

View file

@ -4,9 +4,9 @@
Python 3
https://docs.python.org/3/license.html │
*/
#include "libc/intrin/weaken.h"
#include "libc/intrin/cmpxchg.h"
#include "libc/stdio/append.internal.h"
#include "libc/intrin/weaken.h"
#include "libc/stdio/append.h"
#include "libc/str/str.h"
#include "third_party/python/Include/pylifecycle.h"
/* clang-format off */
@ -32,7 +32,7 @@ Py_GetCopyright(void)
static char *res;
if (_cmpxchg(&once, 0, 1)) {
appends(&res, "");
for (p = *weaken(kLegalNotices); *p; p += strlen(p) + 1) {
for (p = *_weaken(kLegalNotices); *p; p += strlen(p) + 1) {
appends(&res, p);
}
}

View file

@ -4,15 +4,15 @@
Python 3
https://docs.python.org/3/license.html │
*/
#include "libc/mem/alg.h"
#include "libc/intrin/bits.h"
#include "libc/calls/calls.h"
#include "libc/calls/struct/stat.h"
#include "libc/calls/struct/stat.macros.h"
#include "libc/fmt/conv.h"
#include "libc/intrin/bits.h"
#include "libc/macros.internal.h"
#include "libc/mem/alg.h"
#include "libc/mem/gc.h"
#include "libc/mem/mem.h"
#include "libc/runtime/gc.h"
#include "libc/sysv/consts/o.h"
#include "libc/sysv/consts/s.h"
#include "libc/x/x.h"
@ -887,7 +887,7 @@ PyImport_ExecCodeModuleWithPathnames(const char *name, PyObject *co,
// cpathobj != NULL means cpathname != NULL
size_t cpathlen = strlen(cpathname);
char *pathname2 = _gc(strdup(cpathname));
if (endswith(pathname2, ".pyc"))
if (_endswith(pathname2, ".pyc"))
{
pathname2[cpathlen-2] = '\0'; // so now ends with .py
if(!stat(pathname2, &stinfo) && (stinfo.st_mode & S_IFMT) == S_IFREG)
@ -2370,7 +2370,7 @@ static PyObject *_imp_source_from_cache(PyObject *module, PyObject *arg) {
Py_ssize_t pathlen = 0;
if (!PyArg_Parse(PyOS_FSPath(arg), "z#:source_from_cache", &path, &pathlen))
return NULL;
if (!path || !endswith(path, ".pyc")) {
if (!path || !_endswith(path, ".pyc")) {
PyErr_Format(PyExc_ValueError, "%s does not end in .pyc", path);
return NULL;
}
@ -2666,7 +2666,7 @@ static PyObject *SFLObject_is_package(SourcelessFileLoader *self,
self->name, name);
return NULL;
}
if (startswith(basename(self->path), "__init__")) {
if (_startswith(basename(self->path), "__init__")) {
Py_RETURN_TRUE;
}
Py_RETURN_FALSE;

View file

@ -9,7 +9,7 @@
#include "libc/calls/calls.h"
#include "libc/calls/weirdtypes.h"
#include "libc/mem/mem.h"
#include "libc/runtime/gc.internal.h"
#include "libc/mem/gc.internal.h"
#include "third_party/python/Include/abstract.h"
#include "third_party/python/Include/boolobject.h"
#include "third_party/python/Include/code.h"

View file

@ -9,7 +9,7 @@
#include "libc/mem/mem.h"
#include "libc/nt/dll.h"
#include "libc/nt/version.h"
#include "libc/runtime/gc.internal.h"
#include "libc/mem/gc.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "libc/str/locale.h"