sync and try changes

This commit is contained in:
Alexander Nicholi 2021-02-04 08:33:22 -05:00
commit dbd7edba10
No known key found for this signature in database
GPG key ID: B75B2EB05540F74C
811 changed files with 2014 additions and 11694 deletions

View file

@ -50,6 +50,7 @@
#include "libc/str/str.h"
#include "libc/str/thompike.h"
#include "libc/str/tpdecode.internal.h"
#include "libc/str/tpenc.h"
#include "libc/str/tpencode.internal.h"
#include "libc/sysv/consts/auxv.h"
#include "libc/sysv/consts/ex.h"
@ -1957,12 +1958,16 @@ static int GetVidyaByte(unsigned char b) {
}
static void OnVidyaServiceWriteCharacter(void) {
uint64_t w;
int i, n, y, x;
char *p, buf[32];
p = buf;
p += FormatCga(m->bx[0], p);
p = stpcpy(p, "\e7");
p += tpencode(p, 8, GetVidyaByte(m->ax[0]), false);
w = tpenc(GetVidyaByte(m->ax[0]));
do {
*p++ = w;
} while ((w >>= 8));
p = stpcpy(p, "\e8");
for (i = Read16(m->cx); i--;) {
PtyWrite(pty, buf, p - buf);
@ -1984,9 +1989,13 @@ static char16_t VidyaServiceXlatTeletype(uint8_t c) {
static void OnVidyaServiceTeletypeOutput(void) {
int n;
uint64_t w;
char buf[12];
n = FormatCga(m->bx[0], buf);
n += tpencode(buf + n, 6, VidyaServiceXlatTeletype(m->ax[0]), false);
w = tpenc(VidyaServiceXlatTeletype(m->ax[0]));
do {
buf[n++] = w;
} while ((w >>= 8));
PtyWrite(pty, buf, n);
}

View file

@ -21,6 +21,7 @@
#include "libc/errno.h"
#include "libc/fmt/fmt.h"
#include "libc/macros.h"
#include "libc/mem/fmt.h"
#include "libc/mem/mem.h"
#include "libc/str/str.h"
#include "libc/str/tpenc.h"

View file

@ -28,7 +28,7 @@
#include "libc/mem/mem.h"
#include "libc/runtime/runtime.h"
#include "libc/str/str.h"
#include "libc/str/tpencode.internal.h"
#include "libc/str/tpenc.h"
#include "third_party/xed/x86.h"
#include "tool/build/lib/case.h"
#include "tool/build/lib/demangle.h"
@ -134,12 +134,18 @@ static char *DisLineCode(struct Dis *d, char *p) {
static char *DisLineData(struct Dis *d, char *p, const uint8_t *b, size_t n) {
size_t i;
uint64_t w;
p = DisColumn(DisAddr(d, p), p, ADDRLEN);
p = DisColumn(DisByte(p, b, n), p, 64);
p = HighStart(p, g_high.comment);
*p++ = '#';
*p++ = ' ';
for (i = 0; i < n; ++i) p += tpencode(p, 8, bing(b[i], 0), false);
for (i = 0; i < n; ++i) {
w = tpenc(bing(b[i], 0));
do {
*p++ = w;
} while ((w >>= 8));
}
p = HighEnd(p);
*p = '\0';
return p;

View file

@ -21,6 +21,7 @@
#include "libc/calls/calls.h"
#include "libc/log/check.h"
#include "libc/macros.h"
#include "libc/mem/fmt.h"
#include "libc/mem/mem.h"
#include "libc/runtime/gc.h"
#include "libc/runtime/memtrack.h"

View file

@ -140,7 +140,7 @@ void LoadProgram(struct Machine *m, const char *prog, char **args, char **vars,
size_t i, mappedsize;
DCHECK_NOTNULL(prog);
elf->prog = prog;
if ((fd = open(prog, O_RDONLY)) == -1 ||
if ((fd = open(prog, O_RDWR)) == -1 ||
(fstat(fd, &st) == -1 || !st.st_size)) {
fputs(prog, stderr);
fputs(": not found\n", stderr);

View file

@ -466,7 +466,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) {
struct sigaction *dst, const struct sigaction_linux *src) {
if (!src) return NULL;
memset(dst, 0, sizeof(*dst));
ASSIGN(dst->sa_handler, src->sa_handler);
@ -476,8 +476,8 @@ static struct sigaction *CoerceSigactionToCosmo(
return dst;
}
static struct sigaction$linux *CoerceSigactionToLinux(
struct sigaction$linux *dst, const struct sigaction *src) {
static struct sigaction_linux *CoerceSigactionToLinux(
struct sigaction_linux *dst, const struct sigaction *src) {
if (!dst) return NULL;
memset(dst, 0, sizeof(*dst));
ASSIGN(dst->sa_handler, src->sa_handler);
@ -1145,14 +1145,14 @@ static int OpSigaction(struct Machine *m, int sig, int64_t act, int64_t old) {
int rc;
struct OpSigactionMemory {
struct sigaction act, old;
uint8_t b[sizeof(struct sigaction$linux)];
uint8_t b[sizeof(struct sigaction_linux)];
void *p[2];
} * mem;
if (!(mem = malloc(sizeof(*mem)))) return enomem();
if ((rc = sigaction(
XlatSignal(sig),
CoerceSigactionToCosmo(
&mem->act, LoadBuf(m, act, sizeof(struct sigaction$linux))),
&mem->act, LoadBuf(m, act, sizeof(struct sigaction_linux))),
&mem->old)) != -1) {
CoerceSigactionToLinux(BeginStoreNp(m, old, sizeof(mem->b), mem->p, mem->b),
&mem->old);

View file

@ -367,7 +367,7 @@ int ReadResponse(void) {
goto drop;
case kRunitStderr:
CHECK_GE(n, 4);
size = read32be(p), p += 4, n -= 4;
size = READ32BE(p), p += 4, n -= 4;
while (size) {
if (n) {
CHECK_NE(-1, (rc = write(STDERR_FILENO, p, min(n, size))));

View file

@ -263,12 +263,12 @@ void HandleClient(void) {
got = recv(g_clifd, (p = &g_buf[0]), sizeof(g_buf), 0);
CHECK_GE(got, kMinMsgSize);
CHECK_LE(got, sizeof(g_buf));
CHECK_EQ(RUNITD_MAGIC, read32be(p));
CHECK_EQ(RUNITD_MAGIC, READ32BE(p));
p += 4, got -= 4;
CHECK_EQ(kRunitExecute, *p++);
got--;
namesize = read32be(p), p += 4, got -= 4;
filesize = read32be(p), p += 4, got -= 4;
namesize = READ32BE(p), p += 4, got -= 4;
filesize = READ32BE(p), p += 4, got -= 4;
CHECK_GE(got, namesize);
CHECK_LE(namesize, kMaxNameSize);
CHECK_LE(filesize, kMaxFileSize);