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

@ -46,5 +46,4 @@ void LoadDebugSymbols(struct Elf *elf) {
}
close(fd);
}
fprintf(stderr, "got here\n");
}

View file

@ -273,7 +273,7 @@ void DisFreeOps(struct DisOps *ops) {
DisFreeOp(&ops->p[i]);
}
free(ops->p);
memset(ops, 0, sizeof(*ops));
bzero(ops, sizeof(*ops));
}
void DisFree(struct Dis *d) {
@ -282,5 +282,5 @@ void DisFree(struct Dis *d) {
free(d->edges.p);
free(d->loads.p);
free(d->syms.p);
memset(d, 0, sizeof(*d));
bzero(d, sizeof(*d));
}

View file

@ -966,7 +966,7 @@ static void OpFrstor(struct Machine *m) {
a = Load(m, m->fpu.dp, sizeof(b), b);
GetFpuEnv(m, a);
for (i = 0; i < 8; ++i) {
memset(&x, 0, sizeof(x));
bzero(&x, sizeof(x));
memcpy(&x, a + 28 + i * 10, 10);
*FpuSt(m, i) = x;
}

View file

@ -44,12 +44,12 @@ static void DeleteLastEmptyLine(char *p, size_t n) {
static void AppendLine(struct Lines *lines) {
lines->p = realloc(lines->p, ++lines->n * sizeof(*lines->p));
memset(lines->p + lines->n - 1, 0, sizeof(*lines->p));
bzero(lines->p + lines->n - 1, sizeof(*lines->p));
}
static void AppendTag(struct JavadownTags *tags) {
tags->p = realloc(tags->p, ++tags->n * sizeof(*tags->p));
memset(tags->p + tags->n - 1, 0, sizeof(*tags->p));
bzero(tags->p + tags->n - 1, sizeof(*tags->p));
}
static unsigned GetSpacePrefixLen(const char *p, size_t n) {
@ -247,7 +247,7 @@ struct Javadown *ParseJavadown(const char *data, size_t size) {
char *p;
struct Lines lines;
struct Javadown *jd;
memset(&lines, 0, sizeof(lines));
bzero(&lines, sizeof(lines));
jd = calloc(1, sizeof(struct Javadown));
p = strndup(data, size);
SplitLines(&lines, p);

View file

@ -112,7 +112,7 @@ static void BootProgram(struct Machine *m, struct Elf *elf, size_t codesize) {
m->ip = 0x7c00;
elf->base = 0x7c00;
CHECK_NE(-1, ReserveReal(m, 0x00f00000));
memset(m->real.p, 0, 0x00f00000);
bzero(m->real.p, 0x00f00000);
Write16(m->real.p + 0x400, 0x3F8);
Write16(m->real.p + 0x40E, 0xb0000 >> 4);
Write16(m->real.p + 0x413, 0xb0000 / 1024);

View file

@ -1454,7 +1454,7 @@ static void OpDoubleShift(struct Machine *m, uint32_t rde) {
static void OpFxsave(struct Machine *m, uint32_t rde) {
int64_t v;
uint8_t buf[32];
memset(buf, 0, 32);
bzero(buf, 32);
Write16(buf + 0, m->fpu.cw);
Write16(buf + 2, m->fpu.sw);
Write8(buf + 4, m->fpu.tw);

View file

@ -160,6 +160,7 @@ struct Machine {
jmp_buf onhalt;
int64_t faultaddr;
bool dlab;
bool ismetal;
struct MachineFds fds;
uint8_t stash[4096];
uint8_t icache[1024][40];

View file

@ -58,7 +58,7 @@ void FreeMachine(struct Machine *m) {
void ResetMem(struct Machine *m) {
FreeMachineRealFree(m);
ResetTlb(m);
memset(&m->memstat, 0, sizeof(m->memstat));
bzero(&m->memstat, sizeof(m->memstat));
m->real.i = 0;
m->cr3 = 0;
}
@ -66,7 +66,7 @@ void ResetMem(struct Machine *m) {
long AllocateLinearPage(struct Machine *m) {
long page;
if ((page = AllocateLinearPageRaw(m)) != -1) {
memset(m->real.p + page, 0, 0x1000);
bzero(m->real.p + page, 0x1000);
}
return page;
}

View file

@ -45,7 +45,7 @@ void PrintMessageBox(int fd, const char *msg, long tyn, long txn) {
w = 4 + GetWidthOfLongestLine(lines) + 4;
x = lrint(txn / 2. - w / 2.);
y = lrint(tyn / 2. - h / 2.);
memset(&b, 0, sizeof(b));
bzero(&b, sizeof(b));
AppendFmt(&b, "\e[%d;%dH", y++, x);
for (i = 0; i < w; ++i) AppendStr(&b, " ");
AppendFmt(&b, "\e[%d;%dH ╔", y++, x);

View file

@ -45,7 +45,7 @@ ssize_t PrintPanels(int fd, long pn, struct Panel *p, long tyn, long txn) {
struct Buffer b, *l;
int x, y, i, j, width;
enum { kUtf8, kAnsi, kAnsiCsi } state;
memset(&b, 0, sizeof(b));
bzero(&b, sizeof(b));
AppendStr(&b, "\e[H");
for (y = 0; y < tyn; ++y) {
if (y) AppendStr(&b, "\r\n");

View file

@ -41,14 +41,14 @@
*
* \t TAB
* \a BELL
* \177 BACKSPACE
* \r CURSOR START
* \b CURSOR LEFT
* \177 CURSOR LEFT
* \b CURSOR LEFT OR CURSOR REWIND
* \n CURSOR DOWN AND START IF OPOST
* \f CURSOR DOWN AND START IF OPOST
* \v CURSOR DOWN AND START IF OPOST
* \eD CURSOR DOWN AND START
* \eE CURSOR DOWN
* \v CURSOR DOWN AND START OR \e[H\e[J
* \eE CURSOR DOWN AND START
* \eD CURSOR DOWN
* \eM CURSOR UP
* \ec FULL RESET
* \e7 SAVE CURSOR POSITION
@ -331,7 +331,7 @@ static void PtySetCodepage(struct Pty *pty, char id) {
void PtyErase(struct Pty *pty, long dst, long n) {
DCHECK_LE(dst + n, pty->yn * pty->xn);
wmemset((void *)(pty->wcs + dst), ' ', n);
wmemset((void *)(pty->prs + dst), 0, n);
bzero((void *)(pty->prs + dst), n);
}
void PtyMemmove(struct Pty *pty, long dst, long src, long n) {
@ -729,7 +729,7 @@ static void PtySelectGraphicsRendition(struct Pty *pty) {
x = 0;
t = kSgr;
p = pty->esc.s;
memset(code, 0, sizeof(code));
bzero(code, sizeof(code));
for (;;) {
c = *p++;
switch (c) {

View file

@ -58,7 +58,7 @@ static void ResetSse(struct Machine *m) {
m->sse.pm = true;
m->sse.rc = RINT;
m->sse.ftz = false;
memset(m->xmm, 0, sizeof(m->xmm));
bzero(m->xmm, sizeof(m->xmm));
}
void ResetInstructionCache(struct Machine *m) {
@ -81,16 +81,16 @@ void ResetCpu(struct Machine *m) {
m->flags = SetFlag(m->flags, FLAGS_F1, true);
m->flags = SetFlag(m->flags, FLAGS_F0, false);
m->flags = SetFlag(m->flags, FLAGS_IOPL, 3);
memset(m->reg, 0, sizeof(m->reg));
memset(m->bofram, 0, sizeof(m->bofram));
memset(&m->freelist, 0, sizeof(m->freelist));
bzero(m->reg, sizeof(m->reg));
bzero(m->bofram, sizeof(m->bofram));
bzero(&m->freelist, sizeof(m->freelist));
ResetSse(m);
ResetFpu(m);
}
void ResetTlb(struct Machine *m) {
m->tlbindex = 0;
memset(m->tlb, 0, sizeof(m->tlb));
bzero(m->tlb, sizeof(m->tlb));
m->codevirt = 0;
m->codehost = 0;
}

View file

@ -779,7 +779,7 @@ static void OpSsePalignrMmx(struct Machine *m, uint32_t rde) {
char t[24];
memcpy(t, GetModrmRegisterXmmPointerRead8(m, rde), 8);
memcpy(t + 8, XmmRexrReg(m, rde), 8);
memset(t + 16, 0, 8);
bzero(t + 16, 8);
memcpy(XmmRexrReg(m, rde), t + MIN(m->xedd->op.uimm0, 16), 8);
}

View file

@ -141,6 +141,13 @@ void OpPopZvq(struct Machine *m, uint32_t rde) {
}
static void OpCall(struct Machine *m, uint32_t rde, uint64_t func) {
if (!func) {
/*
* call null is technically possible but too fringe and disasterous
* to accommodate at least until our debugger has rewind capability
*/
HaltMachine(m, kMachineProtectionFault);
}
Push(m, rde, m->ip);
m->ip = func;
}

View file

@ -470,7 +470,7 @@ static int AppendIovsGuest(struct Machine *m, struct Iovs *iv, int64_t iovaddr,
static struct sigaction *CoerceSigactionToCosmo(
struct sigaction *dst, const struct sigaction_linux *src) {
if (!src) return NULL;
memset(dst, 0, sizeof(*dst));
bzero(dst, sizeof(*dst));
ASSIGN(dst->sa_handler, src->sa_handler);
ASSIGN(dst->sa_restorer, src->sa_restorer);
ASSIGN(dst->sa_flags, src->sa_flags);
@ -481,7 +481,7 @@ static struct sigaction *CoerceSigactionToCosmo(
static struct sigaction_linux *CoerceSigactionToLinux(
struct sigaction_linux *dst, const struct sigaction *src) {
if (!dst) return NULL;
memset(dst, 0, sizeof(*dst));
bzero(dst, sizeof(*dst));
ASSIGN(dst->sa_handler, src->sa_handler);
ASSIGN(dst->sa_restorer, src->sa_restorer);
ASSIGN(dst->sa_flags, src->sa_flags);
@ -1179,7 +1179,7 @@ static int OpSigsuspend(struct Machine *m, int64_t maskaddr) {
void *p;
sigset_t mask;
if (!(p = LoadBuf(m, maskaddr, 8))) return efault();
memset(&mask, 0, sizeof(mask));
bzero(&mask, sizeof(mask));
memcpy(&mask, p, 8);
return sigsuspend(&mask);
}
@ -1246,7 +1246,7 @@ static int OpSigprocmask(struct Machine *m, int how, int64_t setaddr,
sigset_t *set, oldset, ss;
if (setaddr) {
set = &ss;
memset(set, 0, sizeof(ss));
bzero(set, sizeof(ss));
VirtualSendRead(m, set, setaddr, 8);
} else {
set = NULL;
@ -1326,6 +1326,9 @@ static int DoAccept(struct Machine *m, int fd, int64_t addraddr,
void OpSyscall(struct Machine *m, uint32_t rde) {
uint64_t i, ax, di, si, dx, r0, r8, r9;
ax = Read64(m->ax);
if (m->ismetal) {
WARNF("metal syscall 0x%03x", ax);
}
di = Read64(m->di);
si = Read64(m->si);
dx = Read64(m->dx);
@ -1440,7 +1443,7 @@ void OpSyscall(struct Machine *m, uint32_t rde) {
SYSCALL(0x177, vmsplice(di, P(si), dx, r0));
CASE(0xE7, HaltMachine(m, di | 0x100));
default:
VERBOSEF("missing syscall 0x%03x", ax);
WARNF("missing syscall 0x%03x", ax);
ax = enosys();
break;
}

View file

@ -28,7 +28,7 @@
static bool IsHaltingInitialized(struct Machine *m) {
jmp_buf zb;
memset(zb, 0, sizeof(zb));
bzero(zb, sizeof(zb));
return memcmp(m->onhalt, zb, sizeof(m->onhalt)) != 0;
}

View file

@ -18,7 +18,6 @@
*/
#include "libc/errno.h"
#include "libc/mem/mem.h"
#include "libc/runtime/carsort.h"
#include "tool/build/lib/xlaterrno.h"
struct thatispacked LinuxErrno {