mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-02 17:28:30 +00:00
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:
parent
b69f3d2488
commit
6f7d0cb1c3
960 changed files with 4072 additions and 4873 deletions
|
@ -18,7 +18,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "tool/build/lib/endian.h"
|
||||
#include "tool/build/lib/machine.h"
|
||||
|
|
|
@ -16,15 +16,15 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/mem/arraylist2.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/intrin/tpenc.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/arraylist2.internal.h"
|
||||
#include "libc/mem/fmt.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/tpenc.h"
|
||||
#include "tool/build/lib/buffer.h"
|
||||
|
||||
/* TODO(jart): replace with new append*() library */
|
||||
|
@ -55,7 +55,7 @@ void AppendWide(struct Buffer *b, wint_t wc) {
|
|||
uint64_t wb;
|
||||
char buf[8];
|
||||
i = 0;
|
||||
wb = tpenc(wc);
|
||||
wb = _tpenc(wc);
|
||||
do {
|
||||
buf[i++] = wb & 0xFF;
|
||||
wb >>= 8;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/nexgen32e/bsr.h"
|
||||
#include "libc/intrin/bsr.h"
|
||||
#include "libc/nexgen32e/x86feature.h"
|
||||
#include "tool/build/lib/clmul.h"
|
||||
#include "tool/build/lib/endian.h"
|
||||
|
@ -33,7 +33,7 @@ struct clmul {
|
|||
static struct clmul clmul(uint64_t a, uint64_t b) {
|
||||
uint64_t t, x = 0, y = 0;
|
||||
if (a && b) {
|
||||
if (bsrl(a) < bsrl(b)) t = a, a = b, b = t;
|
||||
if (_bsrl(a) < _bsrl(b)) t = a, a = b, b = t;
|
||||
for (t = 0; b; a <<= 1, b >>= 1) {
|
||||
if (b & 1) x ^= a, y ^= t;
|
||||
t = t << 1 | a >> 63;
|
||||
|
|
|
@ -115,7 +115,7 @@ char *Demangle(char *p, const char *symbol, size_t n) {
|
|||
char *r;
|
||||
size_t sn;
|
||||
sn = strlen(symbol);
|
||||
if (startswith(symbol, "_Z")) {
|
||||
if (_startswith(symbol, "_Z")) {
|
||||
if ((r = DemangleCxxFilt(p, n, symbol, sn))) return r;
|
||||
}
|
||||
return CopySymbol(p, n, symbol, sn);
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/fmt/bing.internal.h"
|
||||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/intrin/tpenc.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/mem/arraylist2.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/tpenc.h"
|
||||
#include "third_party/xed/x86.h"
|
||||
#include "tool/build/lib/demangle.h"
|
||||
#include "tool/build/lib/dis.h"
|
||||
|
@ -151,7 +151,7 @@ static char *DisLineData(struct Dis *d, char *p, const uint8_t *b, size_t n) {
|
|||
*p++ = '#';
|
||||
*p++ = ' ';
|
||||
for (i = 0; i < n; ++i) {
|
||||
w = tpenc(bing(b[i], 0));
|
||||
w = _tpenc(bing(b[i], 0));
|
||||
do {
|
||||
*p++ = w;
|
||||
} while ((w >>= 8));
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/mem/alg.h"
|
||||
#include "libc/elf/elf.h"
|
||||
#include "libc/elf/struct/sym.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/alg.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/memtrack.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
|
@ -85,7 +85,7 @@ static void DisLoadElfSyms(struct Dis *d, struct Elf *elf) {
|
|||
for (i = 0; i < n; ++i) {
|
||||
if (ELF64_ST_TYPE(st[i].st_info) == STT_SECTION ||
|
||||
ELF64_ST_TYPE(st[i].st_info) == STT_FILE || !st[i].st_name ||
|
||||
startswith(d->syms.stab + st[i].st_name, "v_") ||
|
||||
_startswith(d->syms.stab + st[i].st_name, "v_") ||
|
||||
!(0 <= st[i].st_name && st[i].st_name < stablen) || !st[i].st_value ||
|
||||
!IsLegalPointer(st[i].st_value)) {
|
||||
continue;
|
||||
|
|
|
@ -158,8 +158,8 @@ static char *DisName(struct Dis *d, char *bp, const char *name,
|
|||
} else {
|
||||
*p++ = 's';
|
||||
}
|
||||
} else if (wantsuffix || (ambiguous && !startswith(name, "f") &&
|
||||
!startswith(name, "set"))) {
|
||||
} else if (wantsuffix || (ambiguous && !_startswith(name, "f") &&
|
||||
!_startswith(name, "set"))) {
|
||||
if (Osz(rde)) {
|
||||
if (ambiguous || Mode(rde) != XED_MODE_REAL) {
|
||||
*p++ = 'w';
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "libc/elf/def.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/mem/arraylist2.internal.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/mem/gc.h"
|
||||
#include "libc/runtime/memtrack.internal.h"
|
||||
#include "libc/stdalign.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
|
@ -29,7 +29,7 @@
|
|||
#include "libc/sysv/consts/msync.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "libc/x/xasprintf.h"
|
||||
#include "tool/build/lib/elfwriter.h"
|
||||
|
||||
static const Elf64_Ehdr kObjHeader = {
|
||||
|
@ -86,8 +86,8 @@ static void MakeRelaSection(struct ElfWriter *elf, size_t section) {
|
|||
elfwriter_align(elf, alignof(Elf64_Rela), sizeof(Elf64_Rela));
|
||||
shdr = elfwriter_startsection(
|
||||
elf,
|
||||
gc(xasprintf("%s%s", ".rela",
|
||||
&elf->shstrtab->p[elf->shdrs->p[section].sh_name])),
|
||||
_gc(xasprintf("%s%s", ".rela",
|
||||
&elf->shstrtab->p[elf->shdrs->p[section].sh_name])),
|
||||
SHT_RELA, SHF_INFO_LINK);
|
||||
elf->shdrs->p[shdr].sh_info = section;
|
||||
elfwriter_reserve(elf, size);
|
||||
|
|
|
@ -22,12 +22,13 @@
|
|||
#include "libc/log/check.h"
|
||||
#include "libc/nexgen32e/crc32.h"
|
||||
#include "libc/nt/enum/fileflagandattributes.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/mem/gc.h"
|
||||
#include "libc/stdio/rand.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/s.h"
|
||||
#include "libc/time/struct/tm.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "libc/x/xasprintf.h"
|
||||
#include "libc/zip.h"
|
||||
#include "third_party/zlib/zlib.h"
|
||||
#include "tool/build/lib/elfwriter.h"
|
||||
|
@ -166,7 +167,7 @@ void elfwriter_zip(struct ElfWriter *elf, const char *symbol, const char *name,
|
|||
/* emit embedded file content w/ pkzip local file header */
|
||||
elfwriter_align(elf, 1, 0);
|
||||
elfwriter_startsection(elf,
|
||||
gc(xasprintf("%s%s", ZIP_LOCALFILE_SECTION, name)),
|
||||
_gc(xasprintf("%s%s", ZIP_LOCALFILE_SECTION, name)),
|
||||
SHT_PROGBITS, SHF_ALLOC);
|
||||
if (method == kZipCompressionDeflate) {
|
||||
CHECK_EQ(Z_OK, deflateInit2(memset(&zs, 0, sizeof(zs)),
|
||||
|
@ -195,9 +196,9 @@ void elfwriter_zip(struct ElfWriter *elf, const char *symbol, const char *name,
|
|||
EmitZipLfileHdr(lfile, name, namesize, crc, era, gflags, method, mtime, mdate,
|
||||
compsize, uncompsize);
|
||||
elfwriter_commit(elf, lfilehdrsize + compsize);
|
||||
lfilesym = elfwriter_appendsym(elf, gc(xasprintf("%s%s", "zip+lfile:", name)),
|
||||
ELF64_ST_INFO(STB_LOCAL, STT_OBJECT),
|
||||
STV_DEFAULT, 0, lfilehdrsize);
|
||||
lfilesym = elfwriter_appendsym(
|
||||
elf, _gc(xasprintf("%s%s", "zip+lfile:", name)),
|
||||
ELF64_ST_INFO(STB_LOCAL, STT_OBJECT), STV_DEFAULT, 0, lfilehdrsize);
|
||||
elfwriter_appendsym(elf, symbol, ELF64_ST_INFO(STB_GLOBAL, STT_OBJECT),
|
||||
STV_DEFAULT, lfilehdrsize, compsize);
|
||||
elfwriter_finishsection(elf);
|
||||
|
@ -205,13 +206,13 @@ void elfwriter_zip(struct ElfWriter *elf, const char *symbol, const char *name,
|
|||
/* emit central directory record */
|
||||
elfwriter_align(elf, 1, 0);
|
||||
elfwriter_startsection(elf,
|
||||
gc(xasprintf("%s%s", ZIP_DIRECTORY_SECTION, name)),
|
||||
_gc(xasprintf("%s%s", ZIP_DIRECTORY_SECTION, name)),
|
||||
SHT_PROGBITS, SHF_ALLOC);
|
||||
EmitZipCdirHdr(
|
||||
(cfile = elfwriter_reserve(elf, kZipCdirHdrLinkableSizeBootstrap)), name,
|
||||
namesize, crc, era, gflags, method, mtime, mdate, iattrs, dosmode, mode,
|
||||
compsize, uncompsize, commentsize, mtim, atim, ctim);
|
||||
elfwriter_appendsym(elf, gc(xasprintf("%s%s", "zip+cdir:", name)),
|
||||
elfwriter_appendsym(elf, _gc(xasprintf("%s%s", "zip+cdir:", name)),
|
||||
ELF64_ST_INFO(STB_LOCAL, STT_OBJECT), STV_DEFAULT, 0,
|
||||
kZipCdirHdrLinkableSizeBootstrap);
|
||||
elfwriter_appendrela(elf, kZipCfileOffsetOffset, lfilesym, R_X86_64_32,
|
||||
|
|
|
@ -18,10 +18,12 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/iovec.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "libc/x/xsigaction.h"
|
||||
#include "net/https/https.h"
|
||||
#include "third_party/mbedtls/net_sockets.h"
|
||||
#include "third_party/mbedtls/ssl.h"
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/bsf.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/nexgen32e/bsf.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "third_party/xed/x86.h"
|
||||
#include "tool/build/lib/address.h"
|
||||
|
@ -33,7 +33,7 @@ static bool IsOpcodeEqual(struct XedDecodedInst *xedd, uint8_t *a) {
|
|||
if (xedd->length) {
|
||||
if (xedd->length <= 7) {
|
||||
w = Read64(a) ^ Read64(xedd->bytes);
|
||||
return !w || bsfl(w) >= (xedd->length << 3);
|
||||
return !w || _bsfl(w) >= (xedd->length << 3);
|
||||
} else {
|
||||
return memcmp(a, xedd->bytes, xedd->length) == 0;
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ static void SplitLines(struct Lines *lines, char *p) {
|
|||
static bool ConsumeFileOverview(struct Lines *lines) {
|
||||
int i;
|
||||
if (lines->n && lines->p[0].n >= strlen(FILEOVERVIEW) &&
|
||||
startswith(lines->p[0].p, FILEOVERVIEW)) {
|
||||
_startswith(lines->p[0].p, FILEOVERVIEW)) {
|
||||
lines->p[0].p += strlen(FILEOVERVIEW);
|
||||
lines->p[0].n -= strlen(FILEOVERVIEW);
|
||||
while (lines->p[0].n &&
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/iovec.h"
|
||||
#include "libc/intrin/bsr.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/nexgen32e/bsr.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/mem/gc.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
|
@ -76,9 +76,9 @@ void PersistObject(const char *path, size_t align,
|
|||
CHECK(IsWithin(sizeof(*obj->abi), obj->abi, obj->size, obj->p));
|
||||
for (n = i = 0; obj->arrays[i].size; ++i) ++n;
|
||||
iovlen = (n + 1) * 2;
|
||||
pad = gc(xcalloc(align, 1));
|
||||
hdr = gc(xmalloc(obj->size));
|
||||
iov = gc(xcalloc(iovlen, sizeof(*iov)));
|
||||
pad = _gc(xcalloc(align, 1));
|
||||
hdr = _gc(xmalloc(obj->size));
|
||||
iov = _gc(xcalloc(iovlen, sizeof(*iov)));
|
||||
bytes = obj->size;
|
||||
iov[0].iov_base = memcpy(hdr, obj->p, obj->size);
|
||||
iov[0].iov_len = bytes;
|
||||
|
@ -94,7 +94,7 @@ void PersistObject(const char *path, size_t align,
|
|||
p2 = obj->arrays[i].pp;
|
||||
arrayptroffset = p2 - p1;
|
||||
arraydataoffset = filesize;
|
||||
CHECK((!len || bsrl(len) + bsrl(size) < 31),
|
||||
CHECK((!len || _bsrl(len) + _bsrl(size) < 31),
|
||||
"path=%s i=%d len=%,lu size=%,lu", path, i, len, size);
|
||||
CHECK(IsWithin(sizeof(void *), pp, obj->size, obj->p));
|
||||
CHECK(!IsOverlapping(pp, pp + sizeof(void *), obj->magic,
|
||||
|
|
|
@ -20,10 +20,12 @@
|
|||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/mem/gc.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "libc/x/xasprintf.h"
|
||||
#include "tool/build/lib/psk.h"
|
||||
|
||||
/**
|
||||
|
@ -33,7 +35,7 @@ void *GetRunitPsk(void) {
|
|||
int fd;
|
||||
char *r, *p;
|
||||
struct stat st;
|
||||
p = gc(xasprintf("%s/.runit.psk", gc(xhomedir())));
|
||||
p = _gc(xasprintf("%s/.runit.psk", _gc(xhomedir())));
|
||||
if (stat(p, &st) == -1 || st.st_size != 32) {
|
||||
fprintf(stderr, "need o//examples/getrandom.com -bn32 >~/.runit.psk\n");
|
||||
exit(1);
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/intrin/safemacros.internal.h"
|
||||
#include "libc/intrin/tpenc.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/mem/arraylist2.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/thompike.h"
|
||||
#include "libc/str/tpenc.h"
|
||||
#include "libc/str/unicode.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
#include "libc/x/x.h"
|
||||
|
@ -1356,7 +1356,7 @@ int PtyAppendLine(struct Pty *pty, struct Buffer *buf, unsigned y) {
|
|||
u = wc;
|
||||
w = 1;
|
||||
} else {
|
||||
u = tpenc(wc);
|
||||
u = _tpenc(wc);
|
||||
w = max(1, wcwidth(wc));
|
||||
}
|
||||
} else {
|
||||
|
@ -1367,7 +1367,7 @@ int PtyAppendLine(struct Pty *pty, struct Buffer *buf, unsigned y) {
|
|||
if (u != ' ') {
|
||||
np ^= kPtyFlip;
|
||||
} else {
|
||||
u = tpenc(u'▂');
|
||||
u = _tpenc(u'▂');
|
||||
if (pty->conf & kPtyBlinkcursor) {
|
||||
np |= kPtyBlink;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nexgen32e/vendor.internal.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "libc/runtime/pc.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sock/select.h"
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "libc/log/check.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/nexgen32e/vendor.internal.h"
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/mem/gc.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "tool/build/lib/address.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue