mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-03-02 23:18:44 +00:00
Productionize new APE loader and more
The APE_NO_MODIFY_SELF loader payload has been moved out of the examples folder and improved so that it works on BSD systems, and permits general elf program headers. This brings its quality up enough that it should be acceptable to use by default for many programs, e.g. Python, Lua, SQLite and Python. It's the responsibility of the user to define an appropriate TMPDIR if /tmp is considered an adversarial environment. Mac OS shall be supported by APE_NO_MODIFY_SELF soon. Fixes and improvements have been made to program_executable_name as it's now the one true way to get the absolute path of the executing image. This change fixes a memory leak in linenoise history loading, introduced by performance optimizations in51904e2687
This change fixes a longstanding regression with Mach system calls, that23ae9dfceb
back in February which impacted our sched_yield() implementation, which is why no one noticed until now. The Blinkenlights PC emulator has been improved. We now fix rendering on XNU and BSD by not making the assumption that the kernel terminal driver understands UTF8 since that seems to break its internal modeling of \r\n which is now being addressed by using \e[𝑦H instead. The paneling is now more compact in real mode so you won't need to make your font as tiny if you're only emulating an 8086 program. The CLMUL ISA is now emulated too This change also makes improvement to time. CLOCK_MONOTONIC now does the right thing on Windows NT. The nanosecond time module functions added in Python 3.7 have been backported. This change doubles the performance of Argon2 password stretching simply by not using its copy_block and xor_block helper functions, as they were trivial to inline thus resulting in us needing to iterate over each 1024 byte block four fewer times. This change makes code size improvements. _PyUnicode_ToNumeric() was 64k in size and now it's 10k. The CJK codec lookup tables now use lazy delta zigzag deflate (δzd) encoding which reduces their size from 600k to 200k plus the code bloat caused by macro abuse in _decimal.c is now addressed so our fully-loaded statically-linked hermetically-sealed Python virtual interpreter container is now 9.4 megs in the default build mode and 5.5m in MODE=tiny which leaves plenty of room for chibicc. The pydoc web server now accommodates the use case of people who work by SSH'ing into a different machine w/ python.com -m pydoc -p8080 -h0.0.0.0 Finally Python Capsulae delenda est and won't be supported in the future
This commit is contained in:
parent
9cb54218ab
commit
47a53e143b
270 changed files with 214544 additions and 23331 deletions
31
ape/ape.S
31
ape/ape.S
|
@ -551,12 +551,15 @@ apesh: .ascii "'\n#'\"\n" # sixth edition shebang
|
|||
// load the APE without modifying it.
|
||||
.ascii "if [ ! -d /Applications ]; then\n"
|
||||
.ascii "t=\"${TMPDIR:-/tmp}/ape-loader\"\n"
|
||||
.ascii "[ -x \"$t\" ] || {\ndd if=\"$o\" of=\"$t\" skip=\""
|
||||
.shstub ape_loader_dd_skip,2
|
||||
.ascii "\" count=\""
|
||||
.shstub ape_loader_dd_count,2
|
||||
.ascii "\" bs=64 2>/dev/null &&\n"
|
||||
.ascii "chmod 700 \"$t\"\n}\n"
|
||||
.ascii "[ -x \"$t\" ] || {\n"
|
||||
.ascii "dd if=\"$o\" of=\"$t.$$\" skip=\""
|
||||
.shstub ape_loader_dd_skip,2
|
||||
.ascii "\" count=\""
|
||||
.shstub ape_loader_dd_count,2
|
||||
.ascii "\" bs=64 2>/dev/null &&\n"
|
||||
.ascii "chmod 755 \"$t.$$\" &&\n"
|
||||
.ascii "mv \"$t.$$\" \"$t\"\n"
|
||||
.ascii "}\n"
|
||||
.ascii "exec \"$t\" \"$o\" \"$@\"\n"
|
||||
.ascii "fi\n"
|
||||
#endif
|
||||
|
@ -564,22 +567,6 @@ apesh: .ascii "'\n#'\"\n" # sixth edition shebang
|
|||
// The default behavior is: to overwrite the header in place.
|
||||
// We prefer this because it's a tiny constant one time cost.
|
||||
// We simply printf a 64-byte header and call execve() again.
|
||||
#ifdef APE_BUILDSAFE
|
||||
// This code is intended for binaries in build/bootstrap/. It
|
||||
// causes them to not self-modify since they're checked-in to
|
||||
// version control. It assumes cosmopolitan's build prefix is
|
||||
// being used by convention and that the program has the noop
|
||||
// flag -n which is used to prime the binary.
|
||||
.ascii "if [ ${o##o/} = $o ]; then\n"
|
||||
.ascii " if ! [ o/$o -nt $o ]; then\n"
|
||||
.ascii " mkdir -p o/${o%/*} || exit\n"
|
||||
.ascii " cp -f $o o/$o.$$ || exit\n"
|
||||
.ascii " o/$o.$$ -n || exit\n"
|
||||
.ascii " mv -f o/$o.$$ o/$o || exit\n"
|
||||
.ascii " fi\n"
|
||||
.ascii " exec o/$o \"$@\"\n"
|
||||
.ascii "fi\n"
|
||||
#endif
|
||||
#else
|
||||
// The alternative behavior is to copy to $TMPDIR and edit.
|
||||
// This imposes a variety of caveats of its own that should
|
||||
|
|
34
ape/ape.mk
34
ape/ape.mk
|
@ -15,14 +15,12 @@
|
|||
|
||||
PKGS += APE
|
||||
|
||||
APE = $(APE_DEPS) \
|
||||
$(APE_OBJS) \
|
||||
APE = o/$(MODE)/ape/ape.o \
|
||||
o/$(MODE)/ape/ape.lds
|
||||
|
||||
APE_BUILDSAFE = \
|
||||
$(APE_DEPS) \
|
||||
o/$(MODE)/ape/ape-buildsafe.o \
|
||||
o/$(MODE)/ape/ape.lds
|
||||
APE_NO_MODIFY_SELF = \
|
||||
o/$(MODE)/ape/ape.lds \
|
||||
o/$(MODE)/ape/ape-no-modify-self.o
|
||||
|
||||
APELINK = \
|
||||
$(COMPILE) \
|
||||
|
@ -34,8 +32,10 @@ APELINK = \
|
|||
APE_FILES := $(wildcard ape/*.*)
|
||||
APE_HDRS = $(filter %.h,$(APE_FILES))
|
||||
APE_INCS = $(filter %.inc,$(APE_FILES))
|
||||
APE_SRCS = $(filter %.S,$(APE_FILES))
|
||||
APE_OBJS = $(APE_SRCS:%.S=o/$(MODE)/%.o)
|
||||
APE_SRCS_C = ape/loader.c
|
||||
APE_SRCS_S = $(filter %.S,$(APE_FILES))
|
||||
APE_SRCS = $(APE_SRCS_C) $(APE_SRCS_S)
|
||||
APE_OBJS = $(APE_SRCS_S:%.S=o/$(MODE)/%.o)
|
||||
APE_CHECKS = $(APE_HDRS:%=o/%.ok)
|
||||
|
||||
o/$(MODE)/ape/ape.lds: \
|
||||
|
@ -48,14 +48,20 @@ o/ape/idata.inc: \
|
|||
ape/idata.internal.h \
|
||||
ape/relocations.h
|
||||
|
||||
$(APE_OBJS): $(BUILD_FILES) \
|
||||
ape/ape.mk
|
||||
o/$(MODE)/ape/ape-no-modify-self.o: ape/ape.S o/$(MODE)/ape/loader.elf
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -DAPE_LOADER="\"o/$(MODE)/ape/loader.elf\"" -DAPE_NO_MODIFY_SELF $<
|
||||
|
||||
o/$(MODE)/ape/ape-no-modify-self.o: ape/ape.S o/$(MODE)/examples/loader.elf
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -DAPE_LOADER="\"o/$(MODE)/examples/loader.elf\"" -DAPE_NO_MODIFY_SELF $<
|
||||
o/$(MODE)/ape/loader.o: ape/loader.c
|
||||
@$(COMPILE) -AOBJECTIFY.c $(CC) $(cpp.flags) -fpie -Os -ffreestanding -mno-red-zone -fno-ident -fno-gnu-unique -c $(OUTPUT_OPTION) $<
|
||||
|
||||
o/$(MODE)/ape/ape-buildsafe.o: ape/ape.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -DAPE_BUILDSAFE $<
|
||||
o/$(MODE)/ape/loader-gcc.asm: ape/loader.c
|
||||
@$(COMPILE) -AOBJECTIFY.c $(CC) $(cpp.flags) -Os -ffreestanding -mno-red-zone -fno-ident -fno-gnu-unique -c -S $(OUTPUT_OPTION) $<
|
||||
|
||||
o/$(MODE)/ape/loader.elf: \
|
||||
o/$(MODE)/ape/loader.o \
|
||||
o/$(MODE)/ape/loader1.o \
|
||||
ape/loader.lds
|
||||
@$(ELFLINK) -s -z max-page-size=0x10
|
||||
|
||||
.PHONY: o/$(MODE)/ape
|
||||
o/$(MODE)/ape: $(APE) \
|
||||
|
|
335
ape/loader.c
Normal file
335
ape/loader.c
Normal file
|
@ -0,0 +1,335 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/calls/struct/metastat.internal.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/elf/def.h"
|
||||
#include "libc/elf/struct/ehdr.h"
|
||||
#include "libc/elf/struct/phdr.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
|
||||
/**
|
||||
* @fileoverview APE embeddable loader for Linux and BSD, e.g.
|
||||
*
|
||||
* m=tiny
|
||||
* make -j8 MODE=$m o/$m/ape o/$m/examples/printargs.com
|
||||
* o/$m/ape/loader.elf o/$m/examples/printargs.com
|
||||
*
|
||||
* @note this can probably be used as a binfmt_misc interpreter
|
||||
*/
|
||||
|
||||
#define LINUX 0
|
||||
#define FREEBSD 1
|
||||
#define NETBSD 2
|
||||
#define OPENBSD 3
|
||||
|
||||
#define O_RDONLY 0
|
||||
#define PROT_READ 1
|
||||
#define PROT_WRITE 2
|
||||
#define PROT_EXEC 4
|
||||
#define MAP_SHARED 1
|
||||
#define MAP_PRIVATE 2
|
||||
#define MAP_FIXED 16
|
||||
#define MAP_ANONYMOUS (os == LINUX ? 32 : 4096)
|
||||
#define AT_EXECFN_LINUX 31
|
||||
#define AT_EXECFN_NETBSD 2014
|
||||
|
||||
#define __NR_read (os == LINUX ? 0 : 3)
|
||||
#define __NR_write (os == LINUX ? 1 : 4)
|
||||
#define __NR_open (os == LINUX ? 2 : 5)
|
||||
#define __NR_close (os == LINUX ? 3 : 6)
|
||||
#define __NR_exit (os == LINUX ? 60 : 1)
|
||||
#define __NR_mmap (os == LINUX ? 9 : os == FREEBSD ? 477 : 197)
|
||||
#define __NR_fstat \
|
||||
(os == LINUX ? 5 : os == FREEBSD ? 551 : os == OPENBSD ? 53 : 440)
|
||||
|
||||
static wontreturn void Exit(int os, long rc) {
|
||||
asm volatile("syscall"
|
||||
: /* no outputs */
|
||||
: "a"(__NR_exit), "D"(rc)
|
||||
: "memory");
|
||||
unreachable;
|
||||
}
|
||||
|
||||
static void Close(int os, long fd) {
|
||||
long ax;
|
||||
asm volatile("syscall"
|
||||
: "=a"(ax)
|
||||
: "0"(__NR_close), "D"(fd)
|
||||
: "rcx", "rdx", "rsi", "r8", "r9", "r10", "r11", "memory", "cc");
|
||||
}
|
||||
|
||||
static long Read(int os, long fd, void *data, unsigned long size) {
|
||||
bool cf;
|
||||
long ax;
|
||||
asm volatile("clc\n\t"
|
||||
"syscall"
|
||||
: "=@ccc"(cf), "=a"(ax)
|
||||
: "1"(__NR_read), "D"(fd), "S"(data), "d"(size)
|
||||
: "rcx", "r8", "r9", "r10", "r11", "memory");
|
||||
if (cf) ax = -ax;
|
||||
return ax;
|
||||
}
|
||||
|
||||
static void Write(int os, long fd, const void *data, unsigned long size) {
|
||||
long ax;
|
||||
asm volatile("syscall"
|
||||
: "=a"(ax)
|
||||
: "0"(__NR_write), "D"(fd), "S"(data), "d"(size)
|
||||
: "rcx", "r8", "r9", "r10", "r11", "memory", "cc");
|
||||
}
|
||||
|
||||
static long Fstat(int os, long fd, union metastat *st) {
|
||||
long ax;
|
||||
asm volatile("syscall"
|
||||
: "=a"(ax)
|
||||
: "0"(__NR_fstat), "D"(fd), "S"(st)
|
||||
: "rcx", "rdx", "r8", "r9", "r10", "r11", "memory");
|
||||
return ax;
|
||||
}
|
||||
|
||||
static void Msyscall(int os, long p, long n) {
|
||||
long ax;
|
||||
if (os == OPENBSD) {
|
||||
asm volatile("syscall"
|
||||
: "=a"(ax)
|
||||
: "0"(37), "D"(p), "S"(n)
|
||||
: "rcx", "rdx", "r8", "r9", "r10", "r11", "memory", "cc");
|
||||
}
|
||||
}
|
||||
|
||||
static long Open(int os, const char *path, long flags, long mode) {
|
||||
bool cf;
|
||||
long ax;
|
||||
asm volatile("clc\n\t"
|
||||
"syscall"
|
||||
: "=@ccc"(cf), "=a"(ax)
|
||||
: "1"(__NR_open), "D"(path), "S"(flags), "d"(mode)
|
||||
: "rcx", "r8", "r9", "r10", "r11", "memory");
|
||||
if (cf) ax = -ax;
|
||||
return ax;
|
||||
}
|
||||
|
||||
static long Mmap(int os, long addr, long size, long prot, long flags, long fd,
|
||||
long off) {
|
||||
bool cf;
|
||||
long ax;
|
||||
register long flags_ asm("r10") = flags;
|
||||
register long fd_ asm("r8") = fd;
|
||||
register long off_ asm("r9") = off;
|
||||
asm volatile("push\t%%r9\n\t"
|
||||
"push\t%%r9\n\t"
|
||||
"clc\n\t"
|
||||
"syscall\n\t"
|
||||
"pop\t%%r9\n\t"
|
||||
"pop\t%%r9"
|
||||
: "=@ccc"(cf), "=a"(ax)
|
||||
: "1"(__NR_mmap), "D"(addr), "S"(size), "d"(prot), "r"(flags_),
|
||||
"r"(fd_), "r"(off_)
|
||||
: "rcx", "r11", "memory");
|
||||
if (cf) ax = -ax;
|
||||
return ax;
|
||||
}
|
||||
|
||||
static size_t GetFdSize(int os, int fd) {
|
||||
union metastat st;
|
||||
if (!Fstat(os, fd, &st)) {
|
||||
if (os == LINUX) {
|
||||
return st.linux.st_size;
|
||||
} else if (os == FREEBSD) {
|
||||
return st.freebsd.st_size;
|
||||
} else if (os == OPENBSD) {
|
||||
return st.openbsd.st_size;
|
||||
} else {
|
||||
return st.netbsd.st_size;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static size_t Length(const char *s) {
|
||||
size_t n = 0;
|
||||
while (*s++) ++n;
|
||||
return n;
|
||||
}
|
||||
|
||||
static void Emit(int os, const char *s) {
|
||||
Write(os, 2, s, Length(s));
|
||||
}
|
||||
|
||||
static void Log(int os, const char *s) {
|
||||
#ifndef NDEBUG
|
||||
Emit(os, "ape loader error: ");
|
||||
Emit(os, s);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void Spawn(int os, int fd, long *sp, char *b, struct Elf64_Ehdr *e) {
|
||||
size_t i;
|
||||
int prot, flags;
|
||||
long code, codesize;
|
||||
struct Elf64_Phdr *p;
|
||||
if (e->e_ident[EI_CLASS] != ELFCLASS64) {
|
||||
Log(os, "EI_CLASS != ELFCLASS64\n");
|
||||
return;
|
||||
}
|
||||
if (e->e_ident[EI_DATA] != ELFDATA2LSB) {
|
||||
Log(os, "EI_CLASS != ELFCLASS64\n");
|
||||
return;
|
||||
}
|
||||
if (e->e_machine != EM_NEXGEN32E) {
|
||||
Log(os, "e_machine != EM_NEXGEN32E\n");
|
||||
return;
|
||||
}
|
||||
if (e->e_type != ET_EXEC) {
|
||||
Log(os, "e_type != ET_EXEC\n");
|
||||
return;
|
||||
}
|
||||
if (e->e_phoff + e->e_phnum * sizeof(*p) > 0x1000) {
|
||||
Log(os, "phnum out of bounds\n");
|
||||
return;
|
||||
}
|
||||
code = 0;
|
||||
codesize = 0;
|
||||
for (p = (struct Elf64_Phdr *)(b + e->e_phoff), i = e->e_phnum; i--;) {
|
||||
if (p[i].p_type != PT_LOAD) continue;
|
||||
if ((p[i].p_vaddr | p[i].p_filesz | p[i].p_memsz | p[i].p_offset) & 0xfff) {
|
||||
Log(os, "ape requires strict page size padding and alignment\n");
|
||||
return;
|
||||
}
|
||||
prot = 0;
|
||||
flags = MAP_FIXED;
|
||||
if (p[i].p_flags & PF_R) {
|
||||
prot |= PROT_READ;
|
||||
}
|
||||
if (p[i].p_flags & PF_W) {
|
||||
prot |= PROT_WRITE;
|
||||
}
|
||||
if (p[i].p_flags & PF_X) {
|
||||
prot |= PROT_EXEC;
|
||||
code = p[i].p_vaddr;
|
||||
codesize = p[i].p_filesz;
|
||||
}
|
||||
if (p[i].p_memsz > p[i].p_filesz) {
|
||||
if (Mmap(os, p[i].p_vaddr + p[i].p_filesz, p[i].p_memsz - p[i].p_filesz,
|
||||
prot, flags | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) < 0) {
|
||||
Log(os, "bss mmap failed\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (p[i].p_filesz) {
|
||||
flags |= prot & PROT_WRITE ? MAP_PRIVATE : MAP_SHARED;
|
||||
if (Mmap(os, p[i].p_vaddr, p[i].p_filesz, prot, flags, fd,
|
||||
p[i].p_offset) < 0) {
|
||||
Log(os, "image mmap failed\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
Close(os, fd);
|
||||
Msyscall(os, code, codesize);
|
||||
sp[1] = sp[0] - 1;
|
||||
++sp;
|
||||
asm volatile("mov\t%2,%%rsp\n\t"
|
||||
"jmpq\t*%1"
|
||||
: /* no outputs */
|
||||
: "D"(os == FREEBSD ? sp : 0), "S"(e->e_entry), "d"(sp)
|
||||
: "memory");
|
||||
unreachable;
|
||||
}
|
||||
|
||||
void loader(long di, long *sp) {
|
||||
size_t size;
|
||||
long rc, *auxv;
|
||||
char *p, **argv;
|
||||
int c, i, fd, os, argc;
|
||||
union {
|
||||
struct Elf64_Ehdr ehdr;
|
||||
char p[0x1000];
|
||||
} u;
|
||||
os = 0;
|
||||
if (di) {
|
||||
os = FREEBSD;
|
||||
sp = (long *)di;
|
||||
}
|
||||
argc = *sp;
|
||||
argv = (char **)(sp + 1);
|
||||
auxv = (long *)(argv + argc + 1);
|
||||
for (;;) {
|
||||
if (!*auxv++) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!auxv[0]) {
|
||||
os = OPENBSD;
|
||||
}
|
||||
for (; auxv[0]; auxv += 2) {
|
||||
if (!os) {
|
||||
if (auxv[0] == AT_EXECFN_NETBSD) {
|
||||
os = NETBSD;
|
||||
if (argc > 1) {
|
||||
auxv[1] = (long)argv[1];
|
||||
}
|
||||
} else if (auxv[0] == AT_EXECFN_LINUX) {
|
||||
if (argc > 1) {
|
||||
auxv[1] = (long)argv[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (argc < 2) {
|
||||
Emit(os, "usage: loader PROG [ARGS...]\n");
|
||||
} else if ((fd = Open(os, argv[1], O_RDONLY, 0)) < 0) {
|
||||
Log(os, "open failed\n");
|
||||
} else if ((rc = Read(os, fd, u.p, sizeof(u.p))) < 0) {
|
||||
Log(os, "read failed\n");
|
||||
} else if (rc != sizeof(u.p)) {
|
||||
Log(os, "file too small\n");
|
||||
} else if (READ32LE(u.p) == READ32LE("\177ELF")) {
|
||||
Spawn(os, fd, sp, u.p, &u.ehdr);
|
||||
} else {
|
||||
for (p = u.p; p < u.p + sizeof(u.p); ++p) {
|
||||
if (READ64LE(p) == READ64LE("printf '")) {
|
||||
for (i = 0, p += 8; p + 3 < u.p + sizeof(u.p) && (c = *p++) != '\'';) {
|
||||
if (c == '\\') {
|
||||
if ('0' <= *p && *p <= '7') {
|
||||
c = *p++ - '0';
|
||||
if ('0' <= *p && *p <= '7') {
|
||||
c *= 8;
|
||||
c += *p++ - '0';
|
||||
if ('0' <= *p && *p <= '7') {
|
||||
c *= 8;
|
||||
c += *p++ - '0';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
u.p[i++] = c;
|
||||
}
|
||||
if (i >= 64 && READ32LE(u.p) == READ32LE("\177ELF")) {
|
||||
Spawn(os, fd, sp, u.p, &u.ehdr);
|
||||
Exit(os, 127);
|
||||
}
|
||||
}
|
||||
}
|
||||
Log(os, "could not find printf elf in first page\n");
|
||||
}
|
||||
Exit(os, 127);
|
||||
}
|
|
@ -16,50 +16,16 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
|
||||
ENTRY(_start)
|
||||
OUTPUT_FORMAT(binary)
|
||||
|
||||
SECTIONS {
|
||||
|
||||
. = 0x200000 + SIZEOF_HEADERS;
|
||||
|
||||
. = 0x200000;
|
||||
.text : {
|
||||
*(.text .text.*)
|
||||
*(.text)
|
||||
*(.rodata .rodata.*)
|
||||
*(.data .data.*)
|
||||
*(.bss .bss.*)
|
||||
}
|
||||
|
||||
.gnu_debuglink 0 : { *(.gnu_debuglink) }
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.debug 0 : { *(.debug) }
|
||||
.line 0 : { *(.line) }
|
||||
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) }
|
||||
.debug_frame 0 : { *(.debug_frame) }
|
||||
.debug_str 0 : { *(.debug_str) }
|
||||
.debug_loc 0 : { *(.debug_loc) }
|
||||
.debug_macinfo 0 : { *(.debug_macinfo) }
|
||||
.debug_weaknames 0 : { *(.debug_weaknames) }
|
||||
.debug_funcnames 0 : { *(.debug_funcnames) }
|
||||
.debug_typenames 0 : { *(.debug_typenames) }
|
||||
.debug_varnames 0 : { *(.debug_varnames) }
|
||||
.debug_pubtypes 0 : { *(.debug_pubtypes) }
|
||||
.debug_ranges 0 : { *(.debug_ranges) }
|
||||
.debug_macro 0 : { *(.debug_macro) }
|
||||
.debug_addr 0 : { *(.debug_addr) }
|
||||
.gnu.attributes 0 : { KEEP(*(.gnu.attributes)) }
|
||||
|
||||
filesz = . - ehdr;
|
||||
/DISCARD/ : {
|
||||
*(.*)
|
||||
}
|
95
ape/loader1.S
Normal file
95
ape/loader1.S
Normal file
|
@ -0,0 +1,95 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/elf/def.h"
|
||||
#include "libc/macros.internal.h"
|
||||
|
||||
// APE Loader Executable Structure
|
||||
// Linux, FreeBSD, NetBSD, OpenBSD
|
||||
|
||||
.align 8
|
||||
ehdr: .ascii "\177ELF"
|
||||
.byte ELFCLASS64
|
||||
.byte ELFDATA2LSB
|
||||
.byte 1
|
||||
.byte ELFOSABI_FREEBSD
|
||||
.quad 0
|
||||
.word ET_EXEC # e_type
|
||||
.word EM_NEXGEN32E # e_machine
|
||||
.long 1 # e_version
|
||||
.quad _start # e_entry
|
||||
.quad phdrs - ehdr # e_phoff
|
||||
.quad 0 # e_shoff
|
||||
.long 0 # e_flags
|
||||
.word 64 # e_ehsize
|
||||
.word 56 # e_phentsize
|
||||
.word 3 # e_phnum
|
||||
.word 0 # e_shentsize
|
||||
.word 0 # e_shnum
|
||||
.word 0 # e_shstrndx
|
||||
.endobj ehdr,globl
|
||||
|
||||
// memcpy(0x200000, loader); xor %eax,%eax; jmp 0x200000
|
||||
jg47h: .org 0x47
|
||||
.endobj jg47h
|
||||
|
||||
_start: mov %rsp,%rsi
|
||||
jmp loader
|
||||
.endfn _start,globl
|
||||
|
||||
.align 8
|
||||
phdrs: .long PT_LOAD # p_type
|
||||
.long PF_R|PF_X # p_flags
|
||||
.quad 0 # p_offset
|
||||
.quad ehdr # p_vaddr
|
||||
.quad ehdr # p_paddr
|
||||
.quad filesz # p_filesz
|
||||
.quad filesz # p_memsz
|
||||
.quad PAGESIZE # p_align
|
||||
.long PT_GNU_STACK # p_type
|
||||
.long PF_R|PF_W # p_flags
|
||||
.quad 0 # p_offset
|
||||
.quad 0 # p_vaddr
|
||||
.quad 0 # p_paddr
|
||||
.quad 0 # p_filesz
|
||||
.quad 0 # p_memsz
|
||||
.quad 16 # p_align
|
||||
.long PT_NOTE # p_type
|
||||
.long PF_R # p_flags
|
||||
.quad note - ehdr # p_offset
|
||||
.quad note # p_vaddr
|
||||
.quad note # p_paddr
|
||||
.quad notesize # p_filesz
|
||||
.quad notesize # p_memsz
|
||||
.quad 8 # p_align
|
||||
.endobj phdrs
|
||||
|
||||
note: .long 2f-1f
|
||||
.long 4f-3f
|
||||
.long 1
|
||||
1: .asciz "OpenBSD"
|
||||
2: .align 4
|
||||
3: .long 0
|
||||
4: .long 2f-1f
|
||||
.long 4f-3f
|
||||
.long 1
|
||||
1: .asciz "NetBSD"
|
||||
2: .align 4
|
||||
3: .long 901000000
|
||||
4: .endobj note
|
||||
notesize = . - note
|
|
@ -165,7 +165,7 @@ DEFAULT_LDFLAGS = \
|
|||
--gc-sections \
|
||||
--build-id=none \
|
||||
--no-dynamic-linker \
|
||||
-zmax-page-size=0x1000 --cref -Map=$@.map
|
||||
-zmax-page-size=0x1000
|
||||
|
||||
ZIPOBJ_FLAGS = \
|
||||
-b$(IMAGE_BASE_VIRTUAL)
|
||||
|
|
|
@ -14,4 +14,4 @@
|
|||
# so it grants many small performance improvements.
|
||||
|
||||
mkdir -p o/tmp
|
||||
echo o/tmp
|
||||
echo $PWD/o/tmp
|
||||
|
|
|
@ -30,8 +30,7 @@ EXAMPLES_COMS = \
|
|||
|
||||
EXAMPLES_BINS = \
|
||||
$(EXAMPLES_COMS) \
|
||||
$(EXAMPLES_COMS:%=%.dbg) \
|
||||
o/$(MODE)/examples/loader.elf
|
||||
$(EXAMPLES_COMS:%=%.dbg)
|
||||
|
||||
EXAMPLES_DIRECTDEPS = \
|
||||
DSP_CORE \
|
||||
|
@ -134,11 +133,6 @@ o/$(MODE)/examples/nesemu1.com.dbg: \
|
|||
|
||||
o/$(MODE)/examples/nesemu1.o: QUOTA += -M512m
|
||||
|
||||
o/$(MODE)/examples/loader.elf: \
|
||||
o/$(MODE)/examples/loader.o \
|
||||
examples/loader.lds
|
||||
@$(ELFLINK) -s -z max-page-size=0x10
|
||||
|
||||
$(EXAMPLES_OBJS): examples/examples.mk
|
||||
|
||||
usr/share/dict/words: usr/share/dict/words.gz
|
||||
|
|
21
examples/exec.c
Normal file
21
examples/exec.c
Normal file
|
@ -0,0 +1,21 @@
|
|||
#if 0
|
||||
/*─────────────────────────────────────────────────────────────────╗
|
||||
│ To the extent possible under law, Justine Tunney has waived │
|
||||
│ all copyright and related or neighboring rights to this file, │
|
||||
│ as it is written in the following disclaimers: │
|
||||
│ • http://unlicense.org/ │
|
||||
│ • http://creativecommons.org/publicdomain/zero/1.0/ │
|
||||
╚─────────────────────────────────────────────────────────────────*/
|
||||
#endif
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if (argc < 3) {
|
||||
fputs("USAGE: EXEC.COM PROG ARGV₀ [ARGV₁...]\n", stderr);
|
||||
return 1;
|
||||
}
|
||||
execv(argv[1], argv + 2);
|
||||
return 127;
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
#if 0
|
||||
/*─────────────────────────────────────────────────────────────────╗
|
||||
│ To the extent possible under law, Justine Tunney has waived │
|
||||
│ all copyright and related or neighboring rights to this file, │
|
||||
│ as it is written in the following disclaimers: │
|
||||
│ • http://unlicense.org/ │
|
||||
│ • http://creativecommons.org/publicdomain/zero/1.0/ │
|
||||
╚─────────────────────────────────────────────────────────────────*/
|
||||
#endif
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/elf/def.h"
|
||||
#include "libc/elf/struct/ehdr.h"
|
||||
#include "libc/elf/struct/phdr.h"
|
||||
#include "libc/linux/close.h"
|
||||
#include "libc/linux/exit.h"
|
||||
#include "libc/linux/fstat.h"
|
||||
#include "libc/linux/mmap.h"
|
||||
#include "libc/linux/open.h"
|
||||
|
||||
/**
|
||||
* @fileoverview 704-byte APE executing payload for Linux, e.g.
|
||||
*
|
||||
* m=tiny
|
||||
* make -j8 MODE=$m o/$m/examples
|
||||
* o/$m/examples/loader.elf o/$m/examples/printargs.com
|
||||
*
|
||||
* @note this can probably be used as a binfmt_misc interpreter
|
||||
*/
|
||||
|
||||
#define O_RDONLY 0
|
||||
#define PROT_READ 1
|
||||
#define PROT_WRITE 2
|
||||
#define PROT_EXEC 4
|
||||
#define MAP_SHARED 1
|
||||
#define MAP_PRIVATE 2
|
||||
#define MAP_FIXED 16
|
||||
#define MAP_ANONYMOUS 32
|
||||
|
||||
asm(".globl\t_start\n\t"
|
||||
"_start:\n\t"
|
||||
"mov\t%rsp,%rdi\n\t"
|
||||
"jmp\tloader");
|
||||
|
||||
static noinstrument noasan noubsan void spawn(long *sp, char *b) {
|
||||
struct Elf64_Ehdr *e;
|
||||
struct Elf64_Phdr *h;
|
||||
e = (void *)b;
|
||||
h = (void *)(b + e->e_phoff);
|
||||
if (LinuxMmap((void *)(h[1].p_vaddr + h[1].p_filesz),
|
||||
h[1].p_memsz - h[1].p_filesz, PROT_READ | PROT_WRITE,
|
||||
MAP_PRIVATE | MAP_FIXED | MAP_ANONYMOUS, -1, 0) > 0) {
|
||||
sp[1] = sp[0] - 1;
|
||||
asm volatile("mov\t%2,%%rsp\n\t"
|
||||
"jmpq\t*%1"
|
||||
: /* no outputs */
|
||||
: "D"(0), "S"((void *)e->e_entry), "d"(sp + 1)
|
||||
: "memory");
|
||||
unreachable;
|
||||
}
|
||||
}
|
||||
|
||||
noinstrument noasan noubsan void loader(long *sp) {
|
||||
struct stat st;
|
||||
int c, i, fd, argc;
|
||||
char *b, *p, *q, **argv;
|
||||
argc = *sp;
|
||||
argv = (char **)(sp + 1);
|
||||
if (argc > 1 && (fd = LinuxOpen(argv[1], O_RDONLY, 0)) >= 0 &&
|
||||
!LinuxFstat(fd, &st) &&
|
||||
(b = (char *)LinuxMmap((void *)0x400000, st.st_size,
|
||||
PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||
MAP_PRIVATE | MAP_FIXED, fd, 0)) > 0) {
|
||||
LinuxClose(fd);
|
||||
if (READ32LE(b) == READ32LE("\177ELF")) {
|
||||
spawn(sp, b);
|
||||
} else {
|
||||
for (p = b; p < b + st.st_size; ++p) {
|
||||
if (READ64LE(p) == READ64LE("printf '")) {
|
||||
for (q = b, p += 8; (c = *p++) != '\'';) {
|
||||
if (c == '\\') {
|
||||
c = *p++ - '0';
|
||||
if ('0' <= *p && *p <= '7') c *= 8, c += *p++ - '0';
|
||||
if ('0' <= *p && *p <= '7') c *= 8, c += *p++ - '0';
|
||||
}
|
||||
*q++ = c;
|
||||
}
|
||||
if (READ32LE(b) == READ32LE("\177ELF")) {
|
||||
spawn(sp, b);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
LinuxExit(127);
|
||||
}
|
|
@ -95,5 +95,6 @@ int main(int argc, char *argv[], char **envp) {
|
|||
printf(" ☼ kTmpPath = %`'s\n", kTmpPath);
|
||||
printf(" ☼ kNtSystemDirectory = %`'s\n", kNtSystemDirectory);
|
||||
printf(" ☼ kNtWindowsDirectory = %`'s\n", kNtWindowsDirectory);
|
||||
printf(" ☼ program_executable_name = %`'s\n", program_executable_name);
|
||||
return 0;
|
||||
}
|
||||
|
|
55
libc/calls/clock_gettime-nt.c
Normal file
55
libc/calls/clock_gettime-nt.c
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/nexgen32e/rdtsc.h"
|
||||
#include "libc/nt/synchronization.h"
|
||||
#include "libc/sysv/consts/clock.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
textwindows int sys_clock_gettime_nt(int clockid, struct timespec *ts) {
|
||||
int64_t ms;
|
||||
struct timespec res;
|
||||
struct NtFileTime ft;
|
||||
static struct timespec mono;
|
||||
if (clockid == CLOCK_REALTIME) {
|
||||
GetSystemTimeAsFileTime(&ft);
|
||||
*ts = FileTimeToTimeSpec(ft);
|
||||
return 0;
|
||||
} else if (clockid == CLOCK_MONOTONIC || clockid == CLOCK_MONOTONIC_RAW) {
|
||||
ms = GetTickCount64();
|
||||
res.tv_sec = ms / 1000;
|
||||
res.tv_nsec = ms % 1000 * 1000000;
|
||||
res.tv_nsec += rdtsc() / 3 % 1000000000;
|
||||
if (res.tv_nsec > 1000000000) {
|
||||
res.tv_nsec -= 1000000000;
|
||||
res.tv_sec += 1;
|
||||
}
|
||||
if (res.tv_sec > mono.tv_sec ||
|
||||
(res.tv_sec == mono.tv_sec && res.tv_nsec > mono.tv_nsec)) {
|
||||
mono = res;
|
||||
} else {
|
||||
res = mono;
|
||||
}
|
||||
*ts = res;
|
||||
return 0;
|
||||
} else {
|
||||
return einval();
|
||||
}
|
||||
}
|
|
@ -42,7 +42,6 @@
|
|||
int clock_gettime(int clockid, struct timespec *ts) {
|
||||
int rc;
|
||||
axdx_t ad;
|
||||
struct NtFileTime ft;
|
||||
if (!ts) return efault();
|
||||
if (IsAsan() && !__asan_is_valid(ts, sizeof(*ts))) return efault();
|
||||
if (clockid == -1) return einval();
|
||||
|
@ -59,8 +58,6 @@ int clock_gettime(int clockid, struct timespec *ts) {
|
|||
}
|
||||
return rc;
|
||||
} else {
|
||||
GetSystemTimeAsFileTime(&ft);
|
||||
*ts = FileTimeToTimeSpec(ft);
|
||||
return 0;
|
||||
return sys_clock_gettime_nt(clockid, ts);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/sysdebug.internal.h"
|
||||
#include "libc/dce.h"
|
||||
|
||||
/**
|
||||
|
@ -29,9 +30,12 @@
|
|||
* @vforksafe
|
||||
*/
|
||||
int dup(int fd) {
|
||||
int fd2;
|
||||
if (!IsWindows()) {
|
||||
return sys_dup(fd);
|
||||
fd2 = sys_dup(fd);
|
||||
} else {
|
||||
return sys_dup_nt(fd, -1, 0);
|
||||
fd2 = sys_dup_nt(fd, -1, 0);
|
||||
}
|
||||
SYSDEBUG("dup(%d) -> %d", fd, fd2);
|
||||
return fd2;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/sysdebug.internal.h"
|
||||
#include "libc/dce.h"
|
||||
|
||||
/**
|
||||
|
@ -31,6 +32,7 @@
|
|||
* @vforksafe
|
||||
*/
|
||||
int dup2(int oldfd, int newfd) {
|
||||
SYSDEBUG("dup2(%d, %d)", oldfd, newfd);
|
||||
if (oldfd == newfd) return newfd;
|
||||
if (!IsWindows()) {
|
||||
return sys_dup3(oldfd, newfd, 0);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/sysdebug.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
|
@ -35,6 +36,7 @@
|
|||
* @see dup(), dup2()
|
||||
*/
|
||||
int dup3(int oldfd, int newfd, int flags) {
|
||||
SYSDEBUG("dup3(%d, %d, %d)", oldfd, newfd, flags);
|
||||
if (!IsWindows()) {
|
||||
return sys_dup3(oldfd, newfd, flags);
|
||||
} else {
|
||||
|
|
|
@ -32,8 +32,8 @@
|
|||
*
|
||||
* @param buf is where UTF-8 NUL-terminated path string gets written,
|
||||
* which may be NULL to ask this function to malloc a buffer
|
||||
* @param size is number of bytes available in buf, e.g. PATH_MAX,
|
||||
* which may be 0 if buf NULL
|
||||
* @param size is number of bytes available in buf, e.g. PATH_MAX+1,
|
||||
* which may be 0 if buf is NULL
|
||||
* @return buf containing system-normative path or NULL w/ errno
|
||||
* @error ERANGE, EINVAL, ENOMEM
|
||||
*/
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
*
|
||||
* @param tv points to timeval that receives result if non-NULL
|
||||
* @param tz receives UTC timezone if non-NULL
|
||||
* @return always zero
|
||||
* @see clock_gettime() for nanosecond precision
|
||||
* @see strftime() for string formatting
|
||||
*/
|
||||
|
|
|
@ -301,26 +301,27 @@ ssize_t sys_write_nt(struct Fd *, const struct iovec *, size_t, ssize_t) hidden;
|
|||
│ cosmopolitan § syscalls » windows nt » support ─╬─│┼
|
||||
╚────────────────────────────────────────────────────────────────────────────│*/
|
||||
|
||||
int64_t ntreturn(uint32_t);
|
||||
void WinMainForked(void) hidden;
|
||||
void *GetProcAddressModule(const char *, const char *) hidden;
|
||||
int sys_getsetpriority_nt(int, int, int, int (*)(int));
|
||||
void ntcontext2linux(struct ucontext *, const struct NtContext *) hidden;
|
||||
struct NtOverlapped *offset2overlap(int64_t, struct NtOverlapped *) hidden;
|
||||
bool32 ntsetprivilege(i64, const char16_t *, u32) hidden;
|
||||
void __winalarm(void *, uint32_t, uint32_t) hidden;
|
||||
int ntaccesscheck(const char16_t *, u32) paramsnonnull() hidden;
|
||||
int64_t __winerr(void) nocallback privileged;
|
||||
int __mkntpath(const char *, char16_t[hasatleast PATH_MAX - 16]) hidden;
|
||||
int __mkntpath2(const char *, char16_t[hasatleast PATH_MAX - 16], int) hidden;
|
||||
int __mkntpathat(int, const char *, int, char16_t[PATH_MAX]) hidden;
|
||||
unsigned __wincrash_nt(struct NtExceptionPointers *);
|
||||
ssize_t sys_readv_nt(struct Fd *, const struct iovec *, int) hidden;
|
||||
ssize_t sys_writev_nt(struct Fd *, const struct iovec *, int) hidden;
|
||||
char16_t *CreatePipeName(char16_t *) hidden;
|
||||
bool isdirectory_nt(const char *) hidden;
|
||||
bool isregularfile_nt(const char *) hidden;
|
||||
bool issymlink_nt(const char *) hidden;
|
||||
bool32 ntsetprivilege(i64, const char16_t *, u32) hidden;
|
||||
char16_t *CreatePipeName(char16_t *) hidden;
|
||||
int __mkntpath(const char *, char16_t[hasatleast PATH_MAX - 16]) hidden;
|
||||
int __mkntpath2(const char *, char16_t[hasatleast PATH_MAX - 16], int) hidden;
|
||||
int __mkntpathat(int, const char *, int, char16_t[PATH_MAX]) hidden;
|
||||
int sys_clock_gettime_nt(int, struct timespec *) hidden;
|
||||
int ntaccesscheck(const char16_t *, u32) paramsnonnull() hidden;
|
||||
int sys_getsetpriority_nt(int, int, int, int (*)(int));
|
||||
int64_t __winerr(void) nocallback privileged;
|
||||
int64_t ntreturn(uint32_t);
|
||||
ssize_t sys_readv_nt(struct Fd *, const struct iovec *, int) hidden;
|
||||
ssize_t sys_writev_nt(struct Fd *, const struct iovec *, int) hidden;
|
||||
struct NtOverlapped *offset2overlap(int64_t, struct NtOverlapped *) hidden;
|
||||
unsigned __wincrash_nt(struct NtExceptionPointers *);
|
||||
void *GetProcAddressModule(const char *, const char *) hidden;
|
||||
void WinMainForked(void) hidden;
|
||||
void __winalarm(void *, uint32_t, uint32_t) hidden;
|
||||
void ntcontext2linux(struct ucontext *, const struct NtContext *) hidden;
|
||||
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
||||
│ cosmopolitan § syscalls » metal ─╬─│┼
|
||||
|
|
|
@ -38,18 +38,23 @@ static long double GetTimeSample(void) {
|
|||
uint64_t tick1, tick2;
|
||||
long double time1, time2;
|
||||
sched_yield();
|
||||
time1 = dtime(CLOCK_MONOTONIC);
|
||||
time1 = dtime(CLOCK_REALTIME);
|
||||
tick1 = rdtsc();
|
||||
nanosleep(&(struct timespec){0, 100000}, NULL);
|
||||
time2 = dtime(CLOCK_MONOTONIC);
|
||||
time2 = dtime(CLOCK_REALTIME);
|
||||
tick2 = rdtsc();
|
||||
return (time2 - time1) * 1e9 / MAX(1, tick2 - tick1);
|
||||
}
|
||||
|
||||
static long double MeasureNanosPerCycle(void) {
|
||||
int i;
|
||||
int i, n;
|
||||
long double avg, samp;
|
||||
for (avg = 1.0L, i = 1; i < 5; ++i) {
|
||||
if (IsWindows()) {
|
||||
n = 20;
|
||||
} else {
|
||||
n = 5;
|
||||
}
|
||||
for (avg = 1.0L, i = 1; i < n; ++i) {
|
||||
samp = GetTimeSample();
|
||||
avg += (samp - avg) / i;
|
||||
}
|
||||
|
|
|
@ -3,10 +3,17 @@
|
|||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
char *sleb64(char *, int64_t);
|
||||
char *zleb64(char *, int64_t);
|
||||
char *uleb64(char *, uint64_t);
|
||||
int unzleb64(const char *, size_t, int64_t *);
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
int sleb128(const void *, size_t, int128_t);
|
||||
char *sleb128(char *, int128_t);
|
||||
char *zleb128(char *, int128_t);
|
||||
char *uleb128(char *, uint128_t);
|
||||
int unsleb128(const void *, size_t, int128_t *);
|
||||
#endif /* ANSI */
|
||||
#endif /* __STRICT_ANSI__ */
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
|
@ -19,20 +19,18 @@
|
|||
#include "libc/fmt/leb128.h"
|
||||
|
||||
/**
|
||||
* Encodes sleb-128 signed integer.
|
||||
* Encodes signed leb128 integer.
|
||||
*/
|
||||
int sleb128(const void *buf, size_t size, int128_t x) {
|
||||
char *sleb128(char *p, int128_t x) {
|
||||
int c;
|
||||
unsigned i;
|
||||
for (i = 0; i < size; ++i) {
|
||||
c = x & 0x7f;
|
||||
for (;;) {
|
||||
c = x & 127;
|
||||
x >>= 7;
|
||||
if ((x == 0 && !(c & 0x40)) || (x == -1 && (c & 0x40))) {
|
||||
break;
|
||||
if ((x == 0 && !(c & 64)) || (x == -1 && (c & 64))) {
|
||||
*p++ = c;
|
||||
return p;
|
||||
} else {
|
||||
c |= 0x80;
|
||||
*p++ = c | 128;
|
||||
}
|
||||
((char *)buf)[i] = c;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
|
51
libc/fmt/sleb64.c
Normal file
51
libc/fmt/sleb64.c
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/fmt/leb128.h"
|
||||
|
||||
/**
|
||||
* Encodes signed integer to array.
|
||||
*
|
||||
* uleb64 INT64_MAX l: 10𝑐 3𝑛𝑠
|
||||
* zleb64 INT64_MAX l: 13𝑐 4𝑛𝑠
|
||||
* sleb64 INT64_MAX l: 16𝑐 5𝑛𝑠
|
||||
* uleb128 INT64_MAX l: 18𝑐 6𝑛𝑠
|
||||
* zleb128 INT64_MAX l: 18𝑐 6𝑛𝑠
|
||||
* sleb128 INT64_MAX l: 24𝑐 8𝑛𝑠
|
||||
* zleb64 INT64_MIN l: 13𝑐 4𝑛𝑠
|
||||
* sleb64 INT64_MIN l: 16𝑐 5𝑛𝑠
|
||||
* zleb128 INT64_MIN l: 19𝑐 6𝑛𝑠
|
||||
* sleb128 INT64_MIN l: 24𝑐 8𝑛𝑠
|
||||
*
|
||||
* @param p is output array
|
||||
* @param x is number
|
||||
* @return p + i
|
||||
*/
|
||||
char *sleb64(char *p, int64_t x) {
|
||||
int c;
|
||||
for (;;) {
|
||||
c = x & 127;
|
||||
x >>= 7;
|
||||
if ((x == 0 && !(c & 64)) || (x == -1 && (c & 64))) {
|
||||
*p++ = c;
|
||||
return p;
|
||||
} else {
|
||||
*p++ = c | 64;
|
||||
}
|
||||
}
|
||||
}
|
35
libc/fmt/uleb128.c
Normal file
35
libc/fmt/uleb128.c
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/fmt/leb128.h"
|
||||
|
||||
/**
|
||||
* Encodes unsigned leb128 integer.
|
||||
*/
|
||||
char *uleb128(char *p, uint128_t x) {
|
||||
int c;
|
||||
for (;;) {
|
||||
c = x & 127;
|
||||
if (!(x >>= 7)) {
|
||||
*p++ = c;
|
||||
return p;
|
||||
} else {
|
||||
*p++ = c | 128;
|
||||
}
|
||||
}
|
||||
}
|
50
libc/fmt/uleb64.c
Normal file
50
libc/fmt/uleb64.c
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/fmt/leb128.h"
|
||||
|
||||
/**
|
||||
* Encodes unsigned integer to array.
|
||||
*
|
||||
* uleb64 INT64_MAX l: 10𝑐 3𝑛𝑠
|
||||
* zleb64 INT64_MAX l: 13𝑐 4𝑛𝑠
|
||||
* sleb64 INT64_MAX l: 16𝑐 5𝑛𝑠
|
||||
* uleb128 INT64_MAX l: 18𝑐 6𝑛𝑠
|
||||
* zleb128 INT64_MAX l: 18𝑐 6𝑛𝑠
|
||||
* sleb128 INT64_MAX l: 24𝑐 8𝑛𝑠
|
||||
* zleb64 INT64_MIN l: 13𝑐 4𝑛𝑠
|
||||
* sleb64 INT64_MIN l: 16𝑐 5𝑛𝑠
|
||||
* zleb128 INT64_MIN l: 19𝑐 6𝑛𝑠
|
||||
* sleb128 INT64_MIN l: 24𝑐 8𝑛𝑠
|
||||
*
|
||||
* @param p is output array
|
||||
* @param x is number
|
||||
* @return p + i
|
||||
*/
|
||||
char *uleb64(char *p, uint64_t x) {
|
||||
int c;
|
||||
for (;;) {
|
||||
c = x & 127;
|
||||
if (!(x >>= 7)) {
|
||||
*p++ = c;
|
||||
return p;
|
||||
} else {
|
||||
*p++ = c | 128;
|
||||
}
|
||||
}
|
||||
}
|
60
libc/fmt/unzleb64.c
Normal file
60
libc/fmt/unzleb64.c
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
▄ ▄▄▄
|
||||
▄▄▓▓██▀░ ▄ ▄▓▌▀▀▀███▒
|
||||
▄ ░██░ ░▀▀ ▓▓█▓█▌ ▄▄▄██▀░ ▄▄░
|
||||
░▄▓██░ ░██▄ ▄▄▓▌ ▄▓███░ ░▄█▀▄▓▒
|
||||
░░▓█▓▄ ░▀██▒ ░▀█▄ ░▓██▓▄▒▄▄▀▀ ▄█▓▀▐██░
|
||||
▄███ ▀██▄ ▀▓█▓▄▄▓▀ ▀▀▀▀ ░▄▄█▀░▒▓██▓ ░░▄▄▄▄▄▄
|
||||
▄▄▓▀▐██ ░ ▓██▓▒ ▀▀ ▀▀▀ ▄▄██░ ▄▓██▓▀░░▀█░
|
||||
▀▒▓░ ▐██▓ ▓▓▒ ▀▀░ ▀▀▀█▒ ▓█▓▀░ ▄█▓▓░
|
||||
▒▀ ▒██▒░▄█▓▀ VARIABLE LENGTH INTEGER DECODING ▓█░ ▐▓▄ ░ ▓
|
||||
░███▓▀ ▀▓▓██▀▀░
|
||||
░▀░ */
|
||||
#include "libc/fmt/leb128.h"
|
||||
#include "libc/macros.internal.h"
|
||||
|
||||
/**
|
||||
* Decodes array to signed integer w/ zig-zag encoding.
|
||||
*
|
||||
* @param p is array
|
||||
* @param n is byte length of array
|
||||
* @param o optionally receives decoded integer
|
||||
* @return bytes decoded or -1 on error
|
||||
* @see zleb64()
|
||||
*/
|
||||
int unzleb64(const char *p, size_t n, int64_t *o) {
|
||||
int c;
|
||||
size_t i;
|
||||
uint64_t u, t;
|
||||
i = 0;
|
||||
u = 0;
|
||||
do {
|
||||
if (i == n) return -1;
|
||||
c = p[i] & 255;
|
||||
t = c & 127;
|
||||
if (i < 10) {
|
||||
t <<= i * 7;
|
||||
u |= t;
|
||||
}
|
||||
++i;
|
||||
} while (c & 128);
|
||||
if (o) *o = (u >> 1) ^ -(u & 1);
|
||||
return i;
|
||||
}
|
39
libc/fmt/zleb128.c
Normal file
39
libc/fmt/zleb128.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/fmt/leb128.h"
|
||||
|
||||
/**
|
||||
* Encodes signed integer to array.
|
||||
*/
|
||||
char *zleb128(char *p, int128_t x) {
|
||||
int c;
|
||||
uint128_t u;
|
||||
u = x;
|
||||
u <<= 1;
|
||||
u ^= x >> 127;
|
||||
for (;;) {
|
||||
c = u & 127;
|
||||
if (!(u >>= 7)) {
|
||||
*p++ = c;
|
||||
return p;
|
||||
} else {
|
||||
*p++ = c | 128;
|
||||
}
|
||||
}
|
||||
}
|
62
libc/fmt/zleb64.c
Normal file
62
libc/fmt/zleb64.c
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚──────────────────────────────────────────────────────────────────────────────╝
|
||||
▄ ▄▄▄
|
||||
▄▄▓▓██▀░ ▄ ▄▓▌▀▀▀███▒
|
||||
▄ ░██░ ░▀▀ ▓▓█▓█▌ ▄▄▄██▀░ ▄▄░
|
||||
░▄▓██░ ░██▄ ▄▄▓▌ ▄▓███░ ░▄█▀▄▓▒
|
||||
░░▓█▓▄ ░▀██▒ ░▀█▄ ░▓██▓▄▒▄▄▀▀ ▄█▓▀▐██░
|
||||
▄███ ▀██▄ ▀▓█▓▄▄▓▀ ▀▀▀▀ ░▄▄█▀░▒▓██▓ ░░▄▄▄▄▄▄
|
||||
▄▄▓▀▐██ ░ ▓██▓▒ ▀▀ ▀▀▀ ▄▄██░ ▄▓██▓▀░░▀█░
|
||||
▀▒▓░ ▐██▓ ▓▓▒ ▀▀░ ▀▀▀█▒ ▓█▓▀░ ▄█▓▓░
|
||||
▒▀ ▒██▒░▄█▓▀ VARIABLE LENGTH INTEGER ENCODING ▓█░ ▐▓▄ ░ ▓
|
||||
░███▓▀ ▀▓▓██▀▀░
|
||||
░▀░ */
|
||||
#include "libc/fmt/leb128.h"
|
||||
|
||||
/**
|
||||
* Encodes signed integer to array w/ zig-zag encoding.
|
||||
*
|
||||
* uleb64 INT64_MAX l: 10𝑐 3𝑛𝑠
|
||||
* zleb64 INT64_MAX l: 13𝑐 4𝑛𝑠
|
||||
* sleb64 INT64_MAX l: 16𝑐 5𝑛𝑠
|
||||
* uleb128 INT64_MAX l: 18𝑐 6𝑛𝑠
|
||||
* zleb128 INT64_MAX l: 18𝑐 6𝑛𝑠
|
||||
* sleb128 INT64_MAX l: 24𝑐 8𝑛𝑠
|
||||
*
|
||||
* @param p is output array which should have 10 items
|
||||
* @param x is number
|
||||
* @return p + i
|
||||
* @see unzleb64()
|
||||
*/
|
||||
char *zleb64(char *p, int64_t x) {
|
||||
int c;
|
||||
uint64_t u;
|
||||
u = x;
|
||||
u <<= 1;
|
||||
u ^= x >> 63;
|
||||
for (;;) {
|
||||
c = u & 127;
|
||||
if (!(u >>= 7)) {
|
||||
*p++ = c;
|
||||
return p;
|
||||
} else {
|
||||
*p++ = c | 128;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -388,7 +388,13 @@ static ssize_t __asan_write_string(const char *s) {
|
|||
|
||||
wontreturn void __asan_die(const char *msg) {
|
||||
__asan_write_string(msg);
|
||||
if (weaken(__die)) weaken(__die)();
|
||||
if (weaken(__die)) {
|
||||
weaken(__die)();
|
||||
} else {
|
||||
__printf("this binary needs\n"
|
||||
"\tSTATIC_YOINK(\"__die\");\n"
|
||||
"if you want to see backtraces\n");
|
||||
}
|
||||
__asan_exit(134);
|
||||
}
|
||||
|
||||
|
@ -607,6 +613,8 @@ static const char *__asan_describe_access_poison(char kind) {
|
|||
return "protected";
|
||||
case kAsanStackGuard:
|
||||
return "stack overflow";
|
||||
case kAsanNullPage:
|
||||
return "null page access";
|
||||
default:
|
||||
return "poisoned";
|
||||
}
|
||||
|
@ -1151,6 +1159,8 @@ textstartup void __asan_init(int argc, char **argv, char **envp,
|
|||
}
|
||||
__asan_shadow_existing_mappings();
|
||||
__asan_map_shadow((uintptr_t)_base, _end - _base);
|
||||
__asan_map_shadow(0, 4096);
|
||||
__asan_poison(0, PAGESIZE, kAsanNullPage);
|
||||
__asan_shadow_string_list(argv);
|
||||
__asan_shadow_string_list(envp);
|
||||
__asan_shadow_auxv(auxv);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#define kAsanUnmapped -13 /* M */
|
||||
#define kAsanProtected -14 /* P */
|
||||
#define kAsanStackGuard -15 /* _ */
|
||||
#define kAsanNullPage -16
|
||||
|
||||
#define SHADOW(x) ((signed char *)(((uintptr_t)(x) >> kAsanScale) + kAsanMagic))
|
||||
#define UNSHADOW(x) ((void *)(((uintptr_t)(x) + 0x7fff8000) << 3))
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
bsr %rdi,%rax
|
|
@ -57,6 +57,7 @@ o//libc/intrin/memmove.o: \
|
|||
-fno-toplevel-reorder
|
||||
|
||||
o//libc/intrin/bzero.o \
|
||||
o//libc/intrin/memcmp.o \
|
||||
o//libc/intrin/memset.o \
|
||||
o//libc/intrin/memmove.o: \
|
||||
OVERRIDE_CFLAGS += \
|
||||
|
|
|
@ -190,7 +190,7 @@ void *memmove(void *dst, const void *src, size_t n) {
|
|||
if (d == s) return d;
|
||||
if (n < kHalfCache3 || !kHalfCache3) {
|
||||
if (d > s) {
|
||||
if (IsAsan() || n < 1024 || !X86_HAVE(ERMS)) {
|
||||
if (IsAsan() || n < 900 || !X86_HAVE(ERMS)) {
|
||||
do {
|
||||
n -= 32;
|
||||
v = *(const xmm_t *)(s + n);
|
||||
|
@ -207,7 +207,7 @@ void *memmove(void *dst, const void *src, size_t n) {
|
|||
return r;
|
||||
}
|
||||
} else {
|
||||
if (IsAsan() || n < 1024 || !X86_HAVE(ERMS)) {
|
||||
if (IsAsan() || n < 900 || !X86_HAVE(ERMS)) {
|
||||
i = 0;
|
||||
do {
|
||||
v = *(const xmm_t *)(s + i);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/limits.h"
|
||||
#include "libc/log/libfatal.internal.h"
|
||||
#include "libc/nexgen32e/bsr.h"
|
||||
#include "libc/nexgen32e/uart.internal.h"
|
||||
|
@ -39,7 +40,7 @@ privileged noasan noinstrument void __printf(const char *fmt, ...) {
|
|||
unsigned long x;
|
||||
unsigned char al;
|
||||
const char16_t *S;
|
||||
int n, t, w, plus;
|
||||
int i, n, t, w, plus;
|
||||
char c, f, *p, *e, b[2048];
|
||||
w = 0;
|
||||
p = b;
|
||||
|
@ -58,6 +59,7 @@ privileged noasan noinstrument void __printf(const char *fmt, ...) {
|
|||
w = 0;
|
||||
f = ' ';
|
||||
plus = 0;
|
||||
n = INT_MAX;
|
||||
NeedMoar:
|
||||
switch ((c = *fmt++)) {
|
||||
case '\0':
|
||||
|
@ -107,6 +109,9 @@ privileged noasan noinstrument void __printf(const char *fmt, ...) {
|
|||
}
|
||||
}
|
||||
break;
|
||||
case 'S':
|
||||
n = va_arg(va, int);
|
||||
/* fallthrough */
|
||||
case 's':
|
||||
s = va_arg(va, const char *);
|
||||
if (!s) {
|
||||
|
@ -117,19 +122,22 @@ privileged noasan noinstrument void __printf(const char *fmt, ...) {
|
|||
d = (intptr_t)s;
|
||||
goto ApiAbuse;
|
||||
}
|
||||
for (n = 0; s[n];) ++n;
|
||||
for (i = 0; i < n; ++i) {
|
||||
if (!s[i]) {
|
||||
n = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (w-- > n) {
|
||||
if (p < e) {
|
||||
*p++ = f;
|
||||
}
|
||||
}
|
||||
while ((t = *s++)) {
|
||||
if (p < e) {
|
||||
*p++ = t;
|
||||
}
|
||||
for (i = 0; i < n && p < e; ++i) {
|
||||
*p++ = s[i];
|
||||
}
|
||||
break;
|
||||
case 'S':
|
||||
case 'u':
|
||||
S = va_arg(va, const char16_t *);
|
||||
if (!S) goto EmitNullString;
|
||||
while ((t = *S++)) {
|
||||
|
|
|
@ -78,7 +78,7 @@ forceinline void *__mempcpy(void *d, const void *s, size_t n) {
|
|||
return (char *)d + n;
|
||||
}
|
||||
|
||||
forceinline char *__uintcpy(char p[static 21], uint64_t x) {
|
||||
forceinline char *__uintcpy(char p[hasatleast 21], uint64_t x) {
|
||||
char t;
|
||||
size_t i, a, b;
|
||||
i = 0;
|
||||
|
@ -97,7 +97,7 @@ forceinline char *__uintcpy(char p[static 21], uint64_t x) {
|
|||
return p + i;
|
||||
}
|
||||
|
||||
forceinline char *__intcpy(char p[static 21], int64_t x) {
|
||||
forceinline char *__intcpy(char p[hasatleast 21], int64_t x) {
|
||||
if (x < 0) *p++ = '-', x = -(uint64_t)x;
|
||||
return __uintcpy(p, x);
|
||||
}
|
||||
|
|
|
@ -134,7 +134,8 @@ crc32_pclmul:
|
|||
pand %xmm2,%xmm0
|
||||
pclmullqlqdq %xmm3,%xmm0
|
||||
pxor %xmm1,%xmm0
|
||||
pextrd $1,%xmm0,%eax
|
||||
movq %xmm0,%rax
|
||||
shr $32,%rax
|
||||
.leafepilogue
|
||||
.endfn crc32_pclmul,globl,hidden
|
||||
.source __FILE__
|
||||
|
|
|
@ -1,2 +1,12 @@
|
|||
.include "o/libc/nt/codegen.inc"
|
||||
.imp kernel32,__imp_GetSystemTimeAdjustment,GetSystemTimeAdjustment,0
|
||||
|
||||
.text.windows
|
||||
GetSystemTimeAdjustment:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov __imp_GetSystemTimeAdjustment(%rip),%rax
|
||||
jmp __sysv2nt
|
||||
.endfn GetSystemTimeAdjustment,globl
|
||||
.previous
|
||||
|
|
|
@ -1,2 +1,15 @@
|
|||
.include "o/libc/nt/codegen.inc"
|
||||
.imp kernel32,__imp_QueryPerformanceCounter,QueryPerformanceCounter,1098
|
||||
|
||||
.text.windows
|
||||
QueryPerformanceCounter:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov %rdi,%rcx
|
||||
sub $32,%rsp
|
||||
call *__imp_QueryPerformanceCounter(%rip)
|
||||
leave
|
||||
ret
|
||||
.endfn QueryPerformanceCounter,globl
|
||||
.previous
|
||||
|
|
|
@ -1,2 +1,15 @@
|
|||
.include "o/libc/nt/codegen.inc"
|
||||
.imp kernel32,__imp_QueryPerformanceFrequency,QueryPerformanceFrequency,1099
|
||||
|
||||
.text.windows
|
||||
QueryPerformanceFrequency:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
.profilable
|
||||
mov %rdi,%rcx
|
||||
sub $32,%rsp
|
||||
call *__imp_QueryPerformanceFrequency(%rip)
|
||||
leave
|
||||
ret
|
||||
.endfn QueryPerformanceFrequency,globl
|
||||
.previous
|
||||
|
|
|
@ -2616,7 +2616,7 @@ imp 'GetSystemPreferredUILanguages' GetSystemPreferredUILanguages kernel32
|
|||
imp 'GetSystemRegistryQuota' GetSystemRegistryQuota kernel32 746
|
||||
imp 'GetSystemStateRootFolder' GetSystemStateRootFolder KernelBase 746
|
||||
imp 'GetSystemTime' GetSystemTime kernel32 0 1 # KernelBase
|
||||
imp 'GetSystemTimeAdjustment' GetSystemTimeAdjustment kernel32 0 # KernelBase
|
||||
imp 'GetSystemTimeAdjustment' GetSystemTimeAdjustment kernel32 0 3 # KernelBase
|
||||
imp 'GetSystemTimeAdjustmentPrecise' GetSystemTimeAdjustmentPrecise KernelBase 749
|
||||
imp 'GetSystemTimeAsFileTime' GetSystemTimeAsFileTime kernel32 0 1 # KernelBase
|
||||
imp 'GetSystemTimePreciseAsFileTime' GetSystemTimePreciseAsFileTime kernel32 0 1 # KernelBase
|
||||
|
@ -4411,8 +4411,8 @@ imp 'QueryIoRateControlInformationJobObject' QueryIoRateControlInformationJobOb
|
|||
imp 'QueryLocalUserServiceName' QueryLocalUserServiceName advapi32 1582
|
||||
imp 'QueryMemoryResourceNotification' QueryMemoryResourceNotification kernel32 0 # KernelBase
|
||||
imp 'QueryOptionalDelayLoadedAPI' QueryOptionalDelayLoadedAPI KernelBase 1265
|
||||
imp 'QueryPerformanceCounter' QueryPerformanceCounter kernel32 1098
|
||||
imp 'QueryPerformanceFrequency' QueryPerformanceFrequency kernel32 1099
|
||||
imp 'QueryPerformanceCounter' QueryPerformanceCounter kernel32 1098 1
|
||||
imp 'QueryPerformanceFrequency' QueryPerformanceFrequency kernel32 1099 1
|
||||
imp 'QueryProcessAffinityUpdateMode' QueryProcessAffinityUpdateMode kernel32 0 # KernelBase
|
||||
imp 'QueryProcessCycleTime' QueryProcessCycleTime kernel32 0 # KernelBase
|
||||
imp 'QueryProtectedPolicy' QueryProtectedPolicy kernel32 0 # KernelBase
|
||||
|
|
|
@ -109,6 +109,12 @@ void TryAcquireSRWLockShared(intptr_t *);
|
|||
|
||||
uint64_t GetTickCount64(void);
|
||||
|
||||
bool32 QueryPerformanceFrequency(int64_t *lpFrequency);
|
||||
bool32 QueryPerformanceCounter(int64_t *lpPerformanceCount);
|
||||
bool32 GetSystemTimeAdjustment(uint32_t *lpTimeAdjustment,
|
||||
uint32_t *lpTimeIncrement,
|
||||
bool32 *lpTimeAdjustmentDisabled);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_NT_SYNCHRONIZATION_H_ */
|
||||
|
|
|
@ -154,7 +154,7 @@ textwindows int sys_fork_nt(void) {
|
|||
startinfo.hStdInput = g_fds.p[0].handle;
|
||||
startinfo.hStdOutput = g_fds.p[1].handle;
|
||||
startinfo.hStdError = g_fds.p[2].handle;
|
||||
if (ntspawn((char *)getauxval(AT_EXECFN), __argv, environ, forkvar,
|
||||
if (ntspawn(program_executable_name, __argv, environ, forkvar,
|
||||
&kNtIsInheritable, NULL, true, 0, NULL, &startinfo,
|
||||
&procinfo) != -1) {
|
||||
CloseHandle(reader);
|
||||
|
|
|
@ -19,54 +19,106 @@
|
|||
#include "libc/assert.h"
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/alloca.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/tpenc.h"
|
||||
#include "libc/str/utf16.h"
|
||||
#include "libc/sysv/consts/at.h"
|
||||
#include "libc/sysv/consts/auxv.h"
|
||||
#include "libc/sysv/consts/ok.h"
|
||||
|
||||
#define CTL_KERN 1
|
||||
#define KERN_PROC 14
|
||||
#define KERN_PROC_PATHNAME_FREEBSD 12
|
||||
#define KERN_PROC_PATHNAME_NETBSD 5
|
||||
|
||||
/**
|
||||
* Contains absolute path of executable.
|
||||
* Absolute path of executable.
|
||||
*
|
||||
* This variable is initialized automatically at startup. It always
|
||||
* holds a correct absolute path name which is not guaranteed to be
|
||||
* canonical.
|
||||
* This variable is initialized automatically at startup. The path is
|
||||
* guaranteed to exist, except on XNU and OpenBSD. It may be a symlink.
|
||||
* It may be spoofed.
|
||||
*/
|
||||
char program_executable_name[PATH_MAX];
|
||||
char program_executable_name[1024];
|
||||
|
||||
static textwindows bool GetNtExePath(void) {
|
||||
uint64_t w;
|
||||
wint_t x, y;
|
||||
uint32_t i, j;
|
||||
char16_t path16[PATH_MAX + 1];
|
||||
if (!GetModuleFileName(0, path16, ARRAYLEN(path16))) return 0;
|
||||
for (i = j = 0; (x = path16[i++] & 0xffff);) {
|
||||
if (!IsUcs2(x)) {
|
||||
y = path16[i++] & 0xffff;
|
||||
x = MergeUtf16(x, y);
|
||||
}
|
||||
if (x == '\\') x = '/';
|
||||
w = tpenc(x);
|
||||
do {
|
||||
program_executable_name[j] = w;
|
||||
if (++j == sizeof(program_executable_name)) {
|
||||
return false;
|
||||
}
|
||||
} while ((w >>= 8));
|
||||
}
|
||||
program_executable_name[j] = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
textstartup void program_executable_name_init(int argc, char **argv,
|
||||
char **envp, intptr_t *auxv) {
|
||||
size_t n;
|
||||
size_t m;
|
||||
ssize_t n;
|
||||
int cmd[4];
|
||||
char *p, *t;
|
||||
static bool once;
|
||||
if (!cmpxchg(&once, 0, 1)) return;
|
||||
for (p = argv[0]; auxv[0]; auxv += 2) {
|
||||
if (auxv[0] == AT_EXECFN) {
|
||||
p = (char *)auxv[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (IsWindows() && GetNtExePath()) return;
|
||||
n = 0;
|
||||
if (!_isabspath(p)) {
|
||||
if (getcwd(program_executable_name, PATH_MAX - 2)) {
|
||||
n = strlen(program_executable_name);
|
||||
program_executable_name[n++] = '/';
|
||||
p = argv[0];
|
||||
if (fileexists(p)) {
|
||||
if (!_isabspath(p)) {
|
||||
if (getcwd(program_executable_name,
|
||||
sizeof(program_executable_name) - 1)) {
|
||||
n = strlen(program_executable_name);
|
||||
program_executable_name[n++] = '/';
|
||||
}
|
||||
}
|
||||
} else if ((n = sys_readlinkat(AT_FDCWD, "/proc/self/exe",
|
||||
program_executable_name,
|
||||
sizeof(program_executable_name) - 1)) > 0) {
|
||||
program_executable_name[n] = 0;
|
||||
return;
|
||||
} else if ((n = sys_readlinkat(AT_FDCWD, "/proc/curproc/file",
|
||||
program_executable_name,
|
||||
sizeof(program_executable_name) - 1)) > 0) {
|
||||
program_executable_name[n] = 0;
|
||||
return;
|
||||
} else if (IsFreebsd() || IsNetbsd()) {
|
||||
cmd[0] = CTL_KERN;
|
||||
cmd[1] = KERN_PROC;
|
||||
if (IsFreebsd()) {
|
||||
cmd[2] = KERN_PROC_PATHNAME_FREEBSD;
|
||||
} else {
|
||||
cmd[2] = KERN_PROC_PATHNAME_NETBSD;
|
||||
}
|
||||
cmd[3] = -1;
|
||||
m = sizeof(program_executable_name);
|
||||
if (sysctl(cmd, ARRAYLEN(cmd), program_executable_name, &m, 0, 0) != -1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
memccpy(program_executable_name + n, p, '\0', PATH_MAX - n);
|
||||
#ifndef NDEBUG
|
||||
if (IsMetal()) return; /* TODO(jart): do metal */
|
||||
if (!_isabspath(program_executable_name) ||
|
||||
!fileexists(program_executable_name)) {
|
||||
p = t = alloca(PATH_MAX + 32);
|
||||
p = stpcpy(p, "could not find executable: ");
|
||||
p = stpcpy(p, program_executable_name);
|
||||
*p++ = '\n';
|
||||
write(2, t, p - t);
|
||||
_exit(1);
|
||||
for (; *p; ++p) {
|
||||
if (n + 1 < sizeof(program_executable_name)) {
|
||||
program_executable_name[n++] = *p;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
program_executable_name[n] = 0;
|
||||
}
|
||||
|
||||
const void *const program_executable_name_init_ctor[] initarray = {
|
||||
|
|
|
@ -64,10 +64,6 @@ struct WinArgs {
|
|||
intptr_t auxv[2][2];
|
||||
char argblock[ARG_MAX];
|
||||
char envblock[ARG_MAX];
|
||||
union {
|
||||
char execfn[PATH_MAX * 2];
|
||||
char16_t execfn16[PATH_MAX];
|
||||
};
|
||||
};
|
||||
|
||||
uint32_t __ntconsolemode;
|
||||
|
@ -90,27 +86,6 @@ static noasan textwindows noinstrument void MakeLongDoubleLongAgain(void) {
|
|||
asm volatile("fldcw\t%0" : /* no outputs */ : "m"(x87cw));
|
||||
}
|
||||
|
||||
static noasan textwindows noinstrument bool GetExePath(struct WinArgs *wa) {
|
||||
uint64_t w;
|
||||
wint_t x, y;
|
||||
uint32_t i, j;
|
||||
if (!GetModuleFileName(0, wa->execfn16, ARRAYLEN(wa->execfn16))) return 0;
|
||||
for (i = j = 0; (x = wa->execfn16[i++] & 0xffff);) {
|
||||
if (!IsUcs2(x)) {
|
||||
y = wa->execfn16[i++] & 0xffff;
|
||||
x = MergeUtf16(x, y);
|
||||
}
|
||||
if (x == '\\') x = '/';
|
||||
w = tpenc(x);
|
||||
do {
|
||||
if (j + 1 >= i * sizeof(char16_t)) return false;
|
||||
wa->execfn[j++] = w;
|
||||
} while ((w >>= 8));
|
||||
}
|
||||
wa->execfn[j] = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static noasan textwindows wontreturn noinstrument void WinMainNew(void) {
|
||||
int64_t h;
|
||||
int version;
|
||||
|
@ -164,10 +139,8 @@ static noasan textwindows wontreturn noinstrument void WinMainNew(void) {
|
|||
GetDosEnviron(env16, wa->envblock, ARRAYLEN(wa->envblock) - 8, wa->envp,
|
||||
ARRAYLEN(wa->envp) - 1);
|
||||
FreeEnvironmentStrings(env16);
|
||||
if (GetExePath(wa)) {
|
||||
wa->auxv[0][0] = pushpop(AT_EXECFN);
|
||||
wa->auxv[0][1] = (intptr_t)wa->execfn;
|
||||
}
|
||||
wa->auxv[0][0] = pushpop(AT_EXECFN);
|
||||
wa->auxv[0][1] = (intptr_t)wa->argv[0];
|
||||
_jmpstack((char *)addr + STACKSIZE, cosmo, count, wa->argv, wa->envp,
|
||||
wa->auxv);
|
||||
}
|
||||
|
|
|
@ -75,6 +75,7 @@ o/$(MODE)/libc/str/iswseparator.o: \
|
|||
OVERRIDE_CFLAGS += \
|
||||
-fno-jump-tables
|
||||
|
||||
o/$(MODE)/libc/str/bcmp.o \
|
||||
o/$(MODE)/libc/str/windowsdurationtotimeval.o \
|
||||
o/$(MODE)/libc/str/windowsdurationtotimespec.o \
|
||||
o/$(MODE)/libc/str/timevaltowindowstime.o \
|
||||
|
|
|
@ -18,9 +18,11 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/bits/weaken.h"
|
||||
#include "libc/intrin/repmovsb.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/nexgen32e/kompressor.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/undeflate.h"
|
||||
|
||||
|
@ -137,11 +139,12 @@ ssize_t undeflate(void *output, size_t outputsize, void *input,
|
|||
struct DeflateHold hold;
|
||||
bool isfinalblock;
|
||||
size_t i, nlit, ndist;
|
||||
uint8_t *ip, *op, *si, b, al, last, compressiontype;
|
||||
uint8_t *ip, *ipe, *op, *si, b, al, last, compressiontype;
|
||||
uint32_t j, l, len, sym, tlit, tdist, tlen, nlen;
|
||||
|
||||
op = output;
|
||||
ip = input;
|
||||
ipe = ip + inputsize;
|
||||
hold.word = 0;
|
||||
hold.bits = 0;
|
||||
isfinalblock = 0;
|
||||
|
|
|
@ -1,5 +1,24 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 sw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/macros.internal.h"
|
||||
/* clang-format off */
|
||||
|
||||
.macro .syscon group:req name:req linux:req xnu:req freebsd:req openbsd:req netbsd:req windows:req
|
||||
yoink _init_systemfive
|
||||
|
|
|
@ -20,63 +20,70 @@ dir=libc/sysv/machcalls
|
|||
. libc/sysv/gen.sh
|
||||
|
||||
# NeXSTEP Carnegie Melon Mach Microkernel
|
||||
# » so many context switches GNU/Systemd┐
|
||||
# Mac OS X┐ │
|
||||
# FreeBSD┐ │ │
|
||||
# OpenBSD┐ │ ┌─│───│── XnuClass{1:Mach,2:Unix}
|
||||
# ┌─┴┐┌─┴┐│┌┴┐┌─┴┐
|
||||
scall _kernelrpc_mach_vm_allocate_trap 0xffffffff100affff globl
|
||||
scall _kernelrpc_mach_vm_purgable_control_trap 0xffffffff100bffff globl
|
||||
scall _kernelrpc_mach_vm_deallocate_trap 0xffffffff100cffff globl
|
||||
scall _kernelrpc_mach_vm_protect_trap 0xffffffff100effff globl
|
||||
scall _kernelrpc_mach_vm_map_trap 0xffffffff100fffff globl
|
||||
scall _kernelrpc_mach_port_allocate_trap 0xffffffff1010ffff globl
|
||||
scall _kernelrpc_mach_port_destroy_trap 0xffffffff1011ffff globl
|
||||
scall _kernelrpc_mach_port_deallocate_trap 0xffffffff1012ffff globl
|
||||
scall _kernelrpc_mach_port_mod_refs_trap 0xffffffff1013ffff globl
|
||||
scall _kernelrpc_mach_port_move_member_trap 0xffffffff1014ffff globl
|
||||
scall _kernelrpc_mach_port_insert_right_trap 0xffffffff1015ffff globl
|
||||
scall _kernelrpc_mach_port_insert_member_trap 0xffffffff1016ffff globl
|
||||
scall _kernelrpc_mach_port_extract_member_trap 0xffffffff1017ffff globl
|
||||
scall _kernelrpc_mach_port_construct_trap 0xffffffff1018ffff globl
|
||||
scall _kernelrpc_mach_port_destruct_trap 0xffffffff1019ffff globl
|
||||
scall mach_reply_port 0xffffffff101affff globl
|
||||
scall thread_self_trap 0xffffffff101bffff globl
|
||||
scall task_self_trap 0xffffffff101cffff globl
|
||||
scall host_self_trap 0xffffffff101dffff globl
|
||||
scall mach_msg_trap 0xffffffff101fffff globl
|
||||
scall mach_msg_overwrite_trap 0xffffffff1020ffff globl
|
||||
scall semaphore_signal_trap 0xffffffff1021ffff globl
|
||||
scall semaphore_signal_all_trap 0xffffffff1022ffff globl
|
||||
scall semaphore_signal_thread_trap 0xffffffff1023ffff globl
|
||||
scall semaphore_wait_trap 0xffffffff1024ffff globl
|
||||
scall semaphore_wait_signal_trap 0xffffffff1025ffff globl
|
||||
scall semaphore_timedwait_trap 0xffffffff1026ffff globl
|
||||
scall semaphore_timedwait_signal_trap 0xffffffff1027ffff globl
|
||||
scall _kernelrpc_mach_port_guard_trap 0xffffffff1029ffff globl
|
||||
scall _kernelrpc_mach_port_unguard_trap 0xffffffff102affff globl
|
||||
scall mach_generate_activity_id 0xffffffff102bffff globl
|
||||
scall task_name_for_pid 0xffffffff102cffff globl
|
||||
scall task_for_pid 0xffffffff102dffff globl
|
||||
scall pid_for_task 0xffffffff102effff globl
|
||||
scall macx_swapon 0xffffffff1030ffff globl
|
||||
scall macx_swapoff 0xffffffff1031ffff globl
|
||||
scall thread_get_special_reply_port 0xffffffff1032ffff globl
|
||||
scall macx_triggers 0xffffffff1033ffff globl
|
||||
scall macx_backing_store_suspend 0xffffffff1034ffff globl
|
||||
scall macx_backing_store_recovery 0xffffffff1035ffff globl
|
||||
scall pfz_exit 0xffffffff103affff globl
|
||||
scall swtch_pri 0xffffffff103bffff globl
|
||||
scall swtch 0xffffffff103cffff globl
|
||||
scall thread_switch 0xffffffff103dffff globl
|
||||
scall clock_sleep_trap 0xffffffff103effff globl
|
||||
scall host_create_mach_voucher_trap 0xffffffff1046ffff globl
|
||||
scall mach_voucher_extract_attr_recipe_trap 0xffffffff1048ffff globl
|
||||
scall mach_timebase_info_trap 0xffffffff1059ffff globl
|
||||
scall mach_wait_until_trap 0xffffffff105affff globl
|
||||
scall mk_timer_create_trap 0xffffffff105bffff globl
|
||||
scall mk_timer_destroy_trap 0xffffffff105cffff globl
|
||||
scall mk_timer_arm_trap 0xffffffff105dffff globl
|
||||
scall mk_timer_cancel_trap 0xffffffff105effff globl
|
||||
scall mk_timer_arm_leeway_trap 0xffffffff105fffff globl
|
||||
scall iokit_user_client_trap 0xffffffff1064ffff globl
|
||||
# » so many context switches
|
||||
# GNU/Systemd┐
|
||||
# 2.6.18+│
|
||||
# Mac OS X┐ │
|
||||
# 15.6+│ │
|
||||
# FreeBSD┐ │ │
|
||||
# 12+│ ┌─│──│── XnuClass{1:Mach,2:Unix}
|
||||
# OpenBSD┐ │ │ │ │
|
||||
# 6.4+│ │ │ │ │
|
||||
# NetBSD┐ │ │ │ │ │
|
||||
# 9.1+│ │ │ │ │ │
|
||||
# ┌┴┐┌┴┐┌┴┐│┬┴┐┌┴┐
|
||||
scall _kernelrpc_mach_vm_allocate_trap 0xfffffffff100afff globl
|
||||
scall _kernelrpc_mach_vm_purgable_control_trap 0xfffffffff100bfff globl
|
||||
scall _kernelrpc_mach_vm_deallocate_trap 0xfffffffff100cfff globl
|
||||
scall _kernelrpc_mach_vm_protect_trap 0xfffffffff100efff globl
|
||||
scall _kernelrpc_mach_vm_map_trap 0xfffffffff100ffff globl
|
||||
scall _kernelrpc_mach_port_allocate_trap 0xfffffffff1010fff globl
|
||||
scall _kernelrpc_mach_port_destroy_trap 0xfffffffff1011fff globl
|
||||
scall _kernelrpc_mach_port_deallocate_trap 0xfffffffff1012fff globl
|
||||
scall _kernelrpc_mach_port_mod_refs_trap 0xfffffffff1013fff globl
|
||||
scall _kernelrpc_mach_port_move_member_trap 0xfffffffff1014fff globl
|
||||
scall _kernelrpc_mach_port_insert_right_trap 0xfffffffff1015fff globl
|
||||
scall _kernelrpc_mach_port_insert_member_trap 0xfffffffff1016fff globl
|
||||
scall _kernelrpc_mach_port_extract_member_trap 0xfffffffff1017fff globl
|
||||
scall _kernelrpc_mach_port_construct_trap 0xfffffffff1018fff globl
|
||||
scall _kernelrpc_mach_port_destruct_trap 0xfffffffff1019fff globl
|
||||
scall mach_reply_port 0xfffffffff101afff globl
|
||||
scall thread_self_trap 0xfffffffff101bfff globl
|
||||
scall task_self_trap 0xfffffffff101cfff globl
|
||||
scall host_self_trap 0xfffffffff101dfff globl
|
||||
scall mach_msg_trap 0xfffffffff101ffff globl
|
||||
scall mach_msg_overwrite_trap 0xfffffffff1020fff globl
|
||||
scall semaphore_signal_trap 0xfffffffff1021fff globl
|
||||
scall semaphore_signal_all_trap 0xfffffffff1022fff globl
|
||||
scall semaphore_signal_thread_trap 0xfffffffff1023fff globl
|
||||
scall semaphore_wait_trap 0xfffffffff1024fff globl
|
||||
scall semaphore_wait_signal_trap 0xfffffffff1025fff globl
|
||||
scall semaphore_timedwait_trap 0xfffffffff1026fff globl
|
||||
scall semaphore_timedwait_signal_trap 0xfffffffff1027fff globl
|
||||
scall _kernelrpc_mach_port_guard_trap 0xfffffffff1029fff globl
|
||||
scall _kernelrpc_mach_port_unguard_trap 0xfffffffff102afff globl
|
||||
scall mach_generate_activity_id 0xfffffffff102bfff globl
|
||||
scall task_name_for_pid 0xfffffffff102cfff globl
|
||||
scall task_for_pid 0xfffffffff102dfff globl
|
||||
scall pid_for_task 0xfffffffff102efff globl
|
||||
scall macx_swapon 0xfffffffff1030fff globl
|
||||
scall macx_swapoff 0xfffffffff1031fff globl
|
||||
scall thread_get_special_reply_port 0xfffffffff1032fff globl
|
||||
scall macx_triggers 0xfffffffff1033fff globl
|
||||
scall macx_backing_store_suspend 0xfffffffff1034fff globl
|
||||
scall macx_backing_store_recovery 0xfffffffff1035fff globl
|
||||
scall pfz_exit 0xfffffffff103afff globl
|
||||
scall swtch_pri 0xfffffffff103bfff globl
|
||||
scall swtch 0xfffffffff103cfff globl
|
||||
scall thread_switch 0xfffffffff103dfff globl
|
||||
scall clock_sleep_trap 0xfffffffff103efff globl
|
||||
scall host_create_mach_voucher_trap 0xfffffffff1046fff globl
|
||||
scall mach_voucher_extract_attr_recipe_trap 0xfffffffff1048fff globl
|
||||
scall mach_timebase_info_trap 0xfffffffff1059fff globl
|
||||
scall mach_wait_until_trap 0xfffffffff105afff globl
|
||||
scall mk_timer_create_trap 0xfffffffff105bfff globl
|
||||
scall mk_timer_destroy_trap 0xfffffffff105cfff globl
|
||||
scall mk_timer_arm_trap 0xfffffffff105dfff globl
|
||||
scall mk_timer_cancel_trap 0xfffffffff105efff globl
|
||||
scall mk_timer_arm_leeway_trap 0xfffffffff105ffff globl
|
||||
scall iokit_user_client_trap 0xfffffffff1064fff globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall _kernelrpc_mach_port_allocate_trap,0xffffffff1010ffff,globl
|
||||
.scall _kernelrpc_mach_port_allocate_trap,0xfffffffff1010fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall _kernelrpc_mach_port_construct_trap,0xffffffff1018ffff,globl
|
||||
.scall _kernelrpc_mach_port_construct_trap,0xfffffffff1018fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall _kernelrpc_mach_port_deallocate_trap,0xffffffff1012ffff,globl
|
||||
.scall _kernelrpc_mach_port_deallocate_trap,0xfffffffff1012fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall _kernelrpc_mach_port_destroy_trap,0xffffffff1011ffff,globl
|
||||
.scall _kernelrpc_mach_port_destroy_trap,0xfffffffff1011fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall _kernelrpc_mach_port_destruct_trap,0xffffffff1019ffff,globl
|
||||
.scall _kernelrpc_mach_port_destruct_trap,0xfffffffff1019fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall _kernelrpc_mach_port_extract_member_trap,0xffffffff1017ffff,globl
|
||||
.scall _kernelrpc_mach_port_extract_member_trap,0xfffffffff1017fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall _kernelrpc_mach_port_guard_trap,0xffffffff1029ffff,globl
|
||||
.scall _kernelrpc_mach_port_guard_trap,0xfffffffff1029fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall _kernelrpc_mach_port_insert_member_trap,0xffffffff1016ffff,globl
|
||||
.scall _kernelrpc_mach_port_insert_member_trap,0xfffffffff1016fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall _kernelrpc_mach_port_insert_right_trap,0xffffffff1015ffff,globl
|
||||
.scall _kernelrpc_mach_port_insert_right_trap,0xfffffffff1015fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall _kernelrpc_mach_port_mod_refs_trap,0xffffffff1013ffff,globl
|
||||
.scall _kernelrpc_mach_port_mod_refs_trap,0xfffffffff1013fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall _kernelrpc_mach_port_move_member_trap,0xffffffff1014ffff,globl
|
||||
.scall _kernelrpc_mach_port_move_member_trap,0xfffffffff1014fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall _kernelrpc_mach_port_unguard_trap,0xffffffff102affff,globl
|
||||
.scall _kernelrpc_mach_port_unguard_trap,0xfffffffff102afff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall _kernelrpc_mach_vm_allocate_trap,0xffffffff100affff,globl
|
||||
.scall _kernelrpc_mach_vm_allocate_trap,0xfffffffff100afff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall _kernelrpc_mach_vm_deallocate_trap,0xffffffff100cffff,globl
|
||||
.scall _kernelrpc_mach_vm_deallocate_trap,0xfffffffff100cfff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall _kernelrpc_mach_vm_map_trap,0xffffffff100fffff,globl
|
||||
.scall _kernelrpc_mach_vm_map_trap,0xfffffffff100ffff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall _kernelrpc_mach_vm_protect_trap,0xffffffff100effff,globl
|
||||
.scall _kernelrpc_mach_vm_protect_trap,0xfffffffff100efff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall _kernelrpc_mach_vm_purgable_control_trap,0xffffffff100bffff,globl
|
||||
.scall _kernelrpc_mach_vm_purgable_control_trap,0xfffffffff100bfff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall clock_sleep_trap,0xffffffff103effff,globl
|
||||
.scall clock_sleep_trap,0xfffffffff103efff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall host_create_mach_voucher_trap,0xffffffff1046ffff,globl
|
||||
.scall host_create_mach_voucher_trap,0xfffffffff1046fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall host_self_trap,0xffffffff101dffff,globl
|
||||
.scall host_self_trap,0xfffffffff101dfff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall iokit_user_client_trap,0xffffffff1064ffff,globl
|
||||
.scall iokit_user_client_trap,0xfffffffff1064fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall mach_generate_activity_id,0xffffffff102bffff,globl
|
||||
.scall mach_generate_activity_id,0xfffffffff102bfff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall mach_msg_overwrite_trap,0xffffffff1020ffff,globl
|
||||
.scall mach_msg_overwrite_trap,0xfffffffff1020fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall mach_msg_trap,0xffffffff101fffff,globl
|
||||
.scall mach_msg_trap,0xfffffffff101ffff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall mach_reply_port,0xffffffff101affff,globl
|
||||
.scall mach_reply_port,0xfffffffff101afff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall mach_timebase_info_trap,0xffffffff1059ffff,globl
|
||||
.scall mach_timebase_info_trap,0xfffffffff1059fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall mach_voucher_extract_attr_recipe_trap,0xffffffff1048ffff,globl
|
||||
.scall mach_voucher_extract_attr_recipe_trap,0xfffffffff1048fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall mach_wait_until_trap,0xffffffff105affff,globl
|
||||
.scall mach_wait_until_trap,0xfffffffff105afff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall macx_backing_store_recovery,0xffffffff1035ffff,globl
|
||||
.scall macx_backing_store_recovery,0xfffffffff1035fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall macx_backing_store_suspend,0xffffffff1034ffff,globl
|
||||
.scall macx_backing_store_suspend,0xfffffffff1034fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall macx_swapoff,0xffffffff1031ffff,globl
|
||||
.scall macx_swapoff,0xfffffffff1031fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall macx_swapon,0xffffffff1030ffff,globl
|
||||
.scall macx_swapon,0xfffffffff1030fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall macx_triggers,0xffffffff1033ffff,globl
|
||||
.scall macx_triggers,0xfffffffff1033fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall mk_timer_arm_leeway_trap,0xffffffff105fffff,globl
|
||||
.scall mk_timer_arm_leeway_trap,0xfffffffff105ffff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall mk_timer_arm_trap,0xffffffff105dffff,globl
|
||||
.scall mk_timer_arm_trap,0xfffffffff105dfff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall mk_timer_cancel_trap,0xffffffff105effff,globl
|
||||
.scall mk_timer_cancel_trap,0xfffffffff105efff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall mk_timer_create_trap,0xffffffff105bffff,globl
|
||||
.scall mk_timer_create_trap,0xfffffffff105bfff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall mk_timer_destroy_trap,0xffffffff105cffff,globl
|
||||
.scall mk_timer_destroy_trap,0xfffffffff105cfff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall pfz_exit,0xffffffff103affff,globl
|
||||
.scall pfz_exit,0xfffffffff103afff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall pid_for_task,0xffffffff102effff,globl
|
||||
.scall pid_for_task,0xfffffffff102efff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall semaphore_signal_all_trap,0xffffffff1022ffff,globl
|
||||
.scall semaphore_signal_all_trap,0xfffffffff1022fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall semaphore_signal_thread_trap,0xffffffff1023ffff,globl
|
||||
.scall semaphore_signal_thread_trap,0xfffffffff1023fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall semaphore_signal_trap,0xffffffff1021ffff,globl
|
||||
.scall semaphore_signal_trap,0xfffffffff1021fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall semaphore_timedwait_signal_trap,0xffffffff1027ffff,globl
|
||||
.scall semaphore_timedwait_signal_trap,0xfffffffff1027fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall semaphore_timedwait_trap,0xffffffff1026ffff,globl
|
||||
.scall semaphore_timedwait_trap,0xfffffffff1026fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall semaphore_wait_signal_trap,0xffffffff1025ffff,globl
|
||||
.scall semaphore_wait_signal_trap,0xfffffffff1025fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall semaphore_wait_trap,0xffffffff1024ffff,globl
|
||||
.scall semaphore_wait_trap,0xfffffffff1024fff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall swtch,0xffffffff103cffff,globl
|
||||
.scall swtch,0xfffffffff103cfff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall swtch_pri,0xffffffff103bffff,globl
|
||||
.scall swtch_pri,0xfffffffff103bfff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall task_for_pid,0xffffffff102dffff,globl
|
||||
.scall task_for_pid,0xfffffffff102dfff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall task_name_for_pid,0xffffffff102cffff,globl
|
||||
.scall task_name_for_pid,0xfffffffff102cfff,globl
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall task_self_trap,0xffffffff101cffff,globl
|
||||
.scall task_self_trap,0xfffffffff101cfff,globl
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue