diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index e29dce9b5..ea4774c94 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -41,8 +41,8 @@ "interruptfn=", "optimizespeed=", "forcealignargpointer=", - "noasan=", - "noubsan=", + "dontasan=", + "dontubsan=", "donothing=", "nosideeffect=", "unreachable=",, diff --git a/README.md b/README.md index e7da543dd..acc04989b 100644 --- a/README.md +++ b/README.md @@ -143,8 +143,8 @@ machine](https://github.com/jart/blink) by adding the following to the top of your main.c file: ```c -STATIC_YOINK("blink_linux_aarch64"); // for raspberry pi -STATIC_YOINK("blink_xnu_aarch64"); // is apple silicon +__static_yoink("blink_linux_aarch64"); // for raspberry pi +__static_yoink("blink_xnu_aarch64"); // is apple silicon ``` The benefit is you'll have single file executables that'll run on both diff --git a/ape/aarch64.lds b/ape/aarch64.lds index 6ccda2ed5..b19d6b879 100644 --- a/ape/aarch64.lds +++ b/ape/aarch64.lds @@ -72,7 +72,9 @@ SECTIONS { KEEP(*(SORT_NONE(.fini))) } =0x1f2003d5 - .privileged ALIGN(CONSTANT(COMMONPAGESIZE)) : { + . += CONSTANT(COMMONPAGESIZE); + + .privileged : { __privileged_start = .; *(.privileged*) } =0x1f2003d6 @@ -119,7 +121,7 @@ SECTIONS { _etext = .; PROVIDE(etext = .); - . = ALIGN(CONSTANT(COMMONPAGESIZE)); + . += CONSTANT(COMMONPAGESIZE); . = DATA_SEGMENT_ALIGN(CONSTANT(COMMONPAGESIZE), CONSTANT(COMMONPAGESIZE)); .eh_frame : ONLY_IF_RW { diff --git a/ape/ape-m1.c b/ape/ape-m1.c index 39a657efc..86c282074 100644 --- a/ape/ape-m1.c +++ b/ape/ape-m1.c @@ -190,6 +190,19 @@ static int StrCmp(const char *l, const char *r) { return (l[i] & 255) - (r[i] & 255); } +static const char *BaseName(const char *s) { + int c; + const char *b = ""; + if (s) { + while ((c = *s++)) { + if (c == '/') { + b = s; + } + } + } + return b; +} + static void Bzero(void *a, unsigned long n) { long z; char *p, *e; @@ -848,7 +861,7 @@ int main(int argc, char **argv, char **envp) { } else if (argc < 2) { Emit("usage: ape PROG [ARGV1,ARGV2,...]\n" " ape - PROG [ARGV0,ARGV1,...]\n" - "actually portable executable loader silicon 1.4\n" + "actually portable executable loader silicon 1.5\n" "copyright 2023 justine alexandra roberts tunney\n" "https://justine.lol/ape.html\n"); _exit(1); @@ -871,7 +884,8 @@ int main(int argc, char **argv, char **envp) { pe = M->ehdr.buf + rc; // resolve argv[0] to reflect path search - if (argc > 0 && *prog != '/' && *exe == '/' && !StrCmp(prog, argv[0])) { + if ((argc > 0 && *prog != '/' && *exe == '/' && !StrCmp(prog, argv[0])) || + !StrCmp(BaseName(prog), argv[0])) { tp -= (n = StrLen(exe) + 1); MemMove(tp, exe, n); argv[0] = tp; diff --git a/ape/ape.S b/ape/ape.S index 41ef92d89..a2b5b1c17 100644 --- a/ape/ape.S +++ b/ape/ape.S @@ -610,7 +610,7 @@ apesh: .ascii "\n@\n#'\"\n" // sixth edition shebang // extract the loader into a temp folder, and use it to // load the APE without modifying it. .ascii "[ x\"$1\" != x--assimilate ] && {\n" - .ascii "t=\"${TMPDIR:-${HOME:-.}}/.ape-1.4\"\n" + .ascii "t=\"${TMPDIR:-${HOME:-.}}/.ape-1.5\"\n" .ascii "[ -x \"$t\" ] || {\n" .ascii "mkdir -p \"${t%/*}\" &&\n" .ascii "dd if=\"$o\" of=\"$t.$$\" skip=" @@ -717,8 +717,8 @@ emush: .ascii "\n@\n#'\"\n" .previous // ... // decentralized section (.emush) -// - STATIC_YOINK("blink_linux_aarch64"); // for raspberry pi -// - STATIC_YOINK("blink_xnu_aarch64"); // is apple silicon +// - __static_yoink("blink_linux_aarch64"); // for raspberry pi +// - __static_yoink("blink_xnu_aarch64"); // is apple silicon // ... .section .emushepilogue,"a",@progbits .ascii "echo \"$0: this ape binary lacks $m support\" >&2\n" @@ -818,7 +818,7 @@ ape.ident: .long 1 1: .asciz "APE" 2: .balign 4 -3: .long 104000000 +3: .long 105000000 4: .size ape.ident,.-ape.ident .type ape.ident,@object .previous diff --git a/ape/ape.lds b/ape/ape.lds index 34fdfb73b..095ddf17c 100644 --- a/ape/ape.lds +++ b/ape/ape.lds @@ -432,6 +432,7 @@ SECTIONS { KEEP(*(SORT_BY_NAME(.piro.data.sort.*))) KEEP(*(.piro.pad.data)) KEEP(*(.dataepilogue)) + . = ALIGN(512); /*END: NT FORK COPYING */ _edata = .; PROVIDE(edata = .); diff --git a/ape/ape.mk b/ape/ape.mk index c9b6a1524..767404ab9 100644 --- a/ape/ape.mk +++ b/ape/ape.mk @@ -35,7 +35,7 @@ APELINK = \ $(FIXUPOBJ) \ $@ -APE_SRCS = ape/ape.S +APE_SRCS = ape/ape.S ape/start.S ape/launch.S ape/systemcall.S APE_OBJS = o/$(MODE)/ape/ape.o APE_NO_MODIFY_SELF = $(APE) APE_COPY_SELF = $(APE) @@ -52,6 +52,54 @@ o/$(MODE)/ape/aarch64.lds: \ libc/macros.internal.h \ libc/str/str.h +APE_LOADER_LDFLAGS = \ + -pie \ + -static \ + -nostdlib \ + --no-dynamic-linker \ + -z norelro \ + -z common-page-size=0x4000 \ + -z max-page-size=0x4000 + +APE_LOADER_FLAGS = \ + -DNDEBUG \ + -iquote. \ + -Wall \ + -Wextra \ + -fpie \ + -Os \ + -ffreestanding \ + -mgeneral-regs-only \ + -fno-asynchronous-unwind-tables \ + -fno-stack-protector \ + -fno-ident \ + -fno-gnu-unique \ + -c \ + $(OUTPUT_OPTION) \ + $< + +o/$(MODE)/ape/ape.elf: o/$(MODE)/ape/ape.elf.dbg + $(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -g $< $@ + +o/$(MODE)/ape/ape.elf.dbg: \ + o/$(MODE)/ape/start.o \ + o/$(MODE)/ape/loader.o \ + o/$(MODE)/ape/launch.o \ + o/$(MODE)/ape/systemcall.o + @$(COMPILE) -ALINK.elf $(LD) $(APE_LOADER_LDFLAGS) -o $@ $(patsubst %.lds,-T %.lds,$^) + +o/$(MODE)/ape/loader.o: ape/loader.c + @$(COMPILE) -AOBJECTIFY.c $(CC) -DSUPPORT_VECTOR=1 -g $(APE_LOADER_FLAGS) +o/$(MODE)/ape/start.o: ape/start.S + @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< +o/$(MODE)/ape/launch.o: ape/launch.S + @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< +o/$(MODE)/ape/systemcall.o: ape/systemcall.S + @$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $< + +.PHONY: o/$(MODE)/ape +o/$(MODE)/ape: o/$(MODE)/ape/ape.elf + else APE = o/$(MODE)/ape/ape.o \ diff --git a/ape/apeuninstall.sh b/ape/apeuninstall.sh index 69a18d568..4279e219e 100755 --- a/ape/apeuninstall.sh +++ b/ape/apeuninstall.sh @@ -37,6 +37,7 @@ for x in .ape \ .ape-1.1 \ .ape-1.3 \ .ape-1.4 \ + .ape-1.5 \ .ape-blink-0.9.2 \ .ape-blink-1.0.0; do rm -f \ diff --git a/ape/launch.S b/ape/launch.S index 581f66996..cbbe02abf 100644 --- a/ape/launch.S +++ b/ape/launch.S @@ -34,7 +34,44 @@ // @param rdx is stack pointer (becomes zero) // @param rcx is passed through as-is // @noreturn -Launch: xor %r8d,%r8d +Launch: +#ifdef __aarch64__ + + mov x16,x1 + mov sp,x2 + mov x1,0 + mov x2,0 + mov x3,0 + mov x4,0 + mov x5,0 + mov x6,0 + mov x7,0 + mov x8,0 + mov x9,0 + mov x10,0 + mov x11,0 + mov x12,0 + mov x13,0 + mov x14,0 + mov x15,0 + mov x17,0 + mov x19,0 + mov x20,0 + mov x21,0 + mov x22,0 + mov x23,0 + mov x24,0 + mov x25,0 + mov x26,0 + mov x27,0 + mov x28,0 + mov x29,0 + mov x30,0 + br x16 + +#else + + xor %r8d,%r8d xor %r9d,%r9d xor %r10d,%r10d xor %r11d,%r11d @@ -50,4 +87,6 @@ Launch: xor %r8d,%r8d xor %ebx,%ebx xor %eax,%eax ret + +#endif .endfn Launch,globl diff --git a/ape/loader.c b/ape/loader.c index a02d675b3..40e6f8d04 100644 --- a/ape/loader.c +++ b/ape/loader.c @@ -98,6 +98,12 @@ #define IsOpenbsd() (SupportsOpenbsd() && os == OPENBSD) #define IsNetbsd() (SupportsNetbsd() && os == NETBSD) +#ifdef __aarch64__ +#define IsAarch64() 1 +#else +#define IsAarch64() 0 +#endif + #define O_RDONLY 0 #define PROT_NONE 0 #define PROT_READ 1 @@ -111,6 +117,7 @@ #define ELFCLASS32 1 #define ELFDATA2LSB 1 #define EM_NEXGEN32E 62 +#define EM_AARCH64 183 #define ET_EXEC 2 #define ET_DYN 3 #define PT_LOAD 1 @@ -229,6 +236,19 @@ static int StrCmp(const char *l, const char *r) { return (l[i] & 255) - (r[i] & 255); } +static const char *BaseName(const char *s) { + int c; + const char *b = ""; + if (s) { + while ((c = *s++)) { + if (c == '/') { + b = s; + } + } + } + return b; +} + static void Bzero(void *a, unsigned long n) { long z; char *p, *e; @@ -354,42 +374,86 @@ __attribute__((__noinline__)) static long CallSystem(long arg1, long arg2, } __attribute__((__noreturn__)) static void Exit(long rc, int os) { - CallSystem(rc, 0, 0, 0, 0, 0, 0, IsLinux() ? 60 : 1, os); + int numba; + if (IsLinux()) { + if (IsAarch64()) { + numba = 94; + } else { + numba = 60; + } + } else { + numba = 1; + } + CallSystem(rc, 0, 0, 0, 0, 0, 0, numba, os); __builtin_unreachable(); } static int Close(int fd, int os) { - return CallSystem(fd, 0, 0, 0, 0, 0, 0, IsLinux() ? 3 : 6, os); + int numba; + if (IsLinux()) { + if (IsAarch64()) { + numba = 57; + } else { + numba = 3; + } + } else { + numba = 6; + } + return CallSystem(fd, 0, 0, 0, 0, 0, 0, numba, os); } static long Pread(int fd, void *data, unsigned long size, long off, int os) { - long magi; + long numba; if (IsLinux()) { - magi = 0x011; + if (IsAarch64()) { + numba = 0x043; + } else { + numba = 0x011; + } } else if (IsXnu()) { - magi = 0x2000099; + numba = 0x2000099; } else if (IsFreebsd()) { - magi = 0x1db; + numba = 0x1db; } else if (IsOpenbsd()) { - magi = 0x0a9; /* OpenBSD v7.3+ */ + numba = 0x0a9; /* OpenBSD v7.3+ */ } else if (IsNetbsd()) { - magi = 0x0ad; + numba = 0x0ad; } else { __builtin_unreachable(); } - return SystemCall(fd, (long)data, size, off, off, 0, 0, magi); + return SystemCall(fd, (long)data, size, off, off, 0, 0, numba); } static long Write(int fd, const void *data, unsigned long size, int os) { - return CallSystem(fd, (long)data, size, 0, 0, 0, 0, IsLinux() ? 1 : 4, os); + int numba; + if (IsLinux()) { + if (IsAarch64()) { + numba = 64; + } else { + numba = 1; + } + } else { + numba = 4; + } + return CallSystem(fd, (long)data, size, 0, 0, 0, 0, numba, os); } static int Execve(const char *prog, char **argv, char **envp, int os) { - return CallSystem((long)prog, (long)argv, (long)envp, 0, 0, 0, 0, 59, os); + int numba; + if (IsLinux() && IsAarch64()) { + numba = 221; + } else { + numba = 59; + } + return CallSystem((long)prog, (long)argv, (long)envp, 0, 0, 0, 0, numba, os); } static int Access(const char *path, int mode, int os) { - return CallSystem((long)path, mode, 0, 0, 0, 0, 0, IsLinux() ? 21 : 33, os); + if (IsLinux() && IsAarch64()) { + return SystemCall(-100, (long)path, mode, 0, 0, 0, 0, 48); + } else { + return CallSystem((long)path, mode, 0, 0, 0, 0, 0, IsLinux() ? 21 : 33, os); + } } static int Msyscall(long p, unsigned long n, int os) { @@ -401,31 +465,49 @@ static int Msyscall(long p, unsigned long n, int os) { } static int Open(const char *path, int flags, int mode, int os) { - return CallSystem((long)path, flags, mode, 0, 0, 0, 0, IsLinux() ? 2 : 5, os); + if (IsLinux() && IsAarch64()) { + return SystemCall(-100, (long)path, flags, mode, 0, 0, 0, 56); + } else { + return CallSystem((long)path, flags, mode, 0, 0, 0, 0, IsLinux() ? 2 : 5, + os); + } } static int Mprotect(void *addr, unsigned long size, int prot, int os) { - return CallSystem((long)addr, size, prot, 0, 0, 0, 0, IsLinux() ? 10 : 74, - os); + int numba; + if (IsLinux()) { + if (IsAarch64()) { + numba = 226; + } else { + numba = 10; + } + } else { + numba = 74; + } + return CallSystem((long)addr, size, prot, 0, 0, 0, 0, numba, os); } static long Mmap(void *addr, unsigned long size, int prot, int flags, int fd, long off, int os) { - long magi; + long numba; if (IsLinux()) { - magi = 9; + if (IsAarch64()) { + numba = 222; + } else { + numba = 9; + } } else if (IsXnu()) { - magi = 0x2000000 | 197; + numba = 0x2000000 | 197; } else if (IsFreebsd()) { - magi = 477; + numba = 477; } else if (IsOpenbsd()) { - magi = 49; /* OpenBSD v7.3+ */ + numba = 49; /* OpenBSD v7.3+ */ } else if (IsNetbsd()) { - magi = 197; + numba = 197; } else { __builtin_unreachable(); } - return SystemCall((long)addr, size, prot, flags, fd, off, off, magi); + return SystemCall((long)addr, size, prot, flags, fd, off, off, numba); } static long Print(int os, int fd, const char *s, ...) { @@ -703,9 +785,15 @@ static const char *TryElf(struct ApeLoader *M, const char *exe, int fd, if (e->e_type != ET_EXEC && e->e_type != ET_DYN) { return "ELF not ET_EXEC or ET_DYN"; } +#ifdef __aarch64__ + if (e->e_machine != EM_AARCH64) { + return "couldn't find ELF header with AARCH64 machine type"; + } +#else if (e->e_machine != EM_NEXGEN32E) { return "couldn't find ELF header with x86-64 machine type"; } +#endif if (e->e_phentsize != sizeof(struct ElfPhdr)) { Pexit(os, exe, 0, "e_phentsize is wrong"); } @@ -796,7 +884,7 @@ static __attribute__((__noreturn__)) void ShowUsage(int os, int fd, int rc) { Print(os, fd, "NAME\n" "\n" - " actually portable executable loader version 1.4\n" + " actually portable executable loader version 1.5\n" " copyright 2023 justine alexandra roberts tunney\n" " https://justine.lol/ape.html\n" "\n" @@ -814,10 +902,10 @@ static __attribute__((__noreturn__)) void ShowUsage(int os, int fd, int rc) { Exit(rc, os); } -__attribute__((__noreturn__)) void ApeLoader(long di, long *sp, char dl) { +__attribute__((__noreturn__)) // +void ApeLoader(long di, long *sp, char dl) { int rc; unsigned i, n; - int usetheforce; int c, fd, os, argc; struct ApeLoader *M; unsigned long pagesz; @@ -879,14 +967,11 @@ __attribute__((__noreturn__)) void ApeLoader(long di, long *sp, char dl) { } /* parse flags */ - usetheforce = 0; while (argc > 1) { if (argv[1][0] != '-') break; /* normal argument */ if (!argv[1][1]) break; /* hyphen argument */ if (!StrCmp(argv[1], "-h") || !StrCmp(argv[1], "--help")) { ShowUsage(os, 1, 0); - } else if (!StrCmp(argv[1], "-f")) { - usetheforce = 1; } else { Print(os, 2, ape, ": invalid flag (pass -h for help)\n", 0l); Exit(1, os); @@ -926,25 +1011,16 @@ __attribute__((__noreturn__)) void ApeLoader(long di, long *sp, char dl) { pe = M->ehdr.buf + rc; /* change argv[0] to resolved path if it's ambiguous */ - if (argc > 0 && *prog != '/' && *exe == '/' && !StrCmp(prog, argv[0])) { + if ((argc > 0 && *prog != '/' && *exe == '/' && !StrCmp(prog, argv[0])) || + !StrCmp(BaseName(prog), argv[0])) { argv[0] = exe; } /* ape intended behavior - 1. if file is a native executable, try to run it natively - 2. if ape, will scan shell script for elf printf statements - 3. shell script may have multiple lines producing elf headers - 4. all elf printf lines must exist in the first 8192 bytes of file - 5. elf program headers may appear anywhere in the binary */ - if (!usetheforce && - ((IsXnu() && READ32(M->ehdr.buf) == 0xFEEDFACE + 1) || - (!IsXnu() && READ32(M->ehdr.buf) == READ32("\177ELF")))) { - Close(fd, os); - Execve(exe, argv, envp, os); - if ((fd = Open(exe, O_RDONLY, 0, os)) < 0) { - Pexit(os, exe, rc, "execve and open failed"); - } - } + 1. if ape, will scan shell script for elf printf statements + 2. shell script may have multiple lines producing elf headers + 3. all elf printf lines must exist in the first 8192 bytes of file + 4. elf program headers may appear anywhere in the binary */ if (READ64(M->ehdr.buf) == READ64("MZqFpD='") || READ64(M->ehdr.buf) == READ64("jartsr='") || READ64(M->ehdr.buf) == READ64("APEDBG='")) { diff --git a/ape/start.S b/ape/start.S index 32b61543f..c04b33d43 100644 --- a/ape/start.S +++ b/ape/start.S @@ -19,6 +19,15 @@ #include "libc/dce.h" #include "libc/macros.internal.h" +#ifdef __aarch64__ + +_start: mov x1,sp + mov x29,0 + bl ApeLoader + .endfn _start,globl + +#else + XnuEntrypoint: mov $_HOSTXNU,%dl // xnu's not unix! ElfEntrypoint: @@ -56,6 +65,8 @@ ape.ident: .long 1 1: .asciz "APE" 2: .balign 4 -3: .long 104000000 +3: .long 105000000 4: .size ape.ident,.-ape.ident .type ape.ident,@object + +#endif diff --git a/ape/systemcall.S b/ape/systemcall.S index 22652d800..4e0afc39a 100644 --- a/ape/systemcall.S +++ b/ape/systemcall.S @@ -28,6 +28,16 @@ // errors are returned as `-errno`. BSD systems are normalized // to follow this convention automatically. SystemCall: +#ifdef __aarch64__ + mov x8,x7 + mov x9,0 + adds x9,x9,0 + svc 0 + bcs 1f + ret +1: neg x0,x0 + ret +#else mov %rcx,%r10 mov 16(%rsp),%eax clc @@ -35,4 +45,5 @@ SystemCall: jnc 1f neg %rax 1: ret +#endif .endfn SystemCall,globl diff --git a/build/bootstrap/ape.aarch64 b/build/bootstrap/ape.aarch64 new file mode 100755 index 000000000..a46b1f515 Binary files /dev/null and b/build/bootstrap/ape.aarch64 differ diff --git a/build/bootstrap/ape.elf b/build/bootstrap/ape.elf index 5c1720dcd..f2e65048e 100755 Binary files a/build/bootstrap/ape.elf and b/build/bootstrap/ape.elf differ diff --git a/build/bootstrap/ape.macho b/build/bootstrap/ape.macho index 3a8fecf40..7be50986c 100755 Binary files a/build/bootstrap/ape.macho and b/build/bootstrap/ape.macho differ diff --git a/build/bootstrap/ape.silicon b/build/bootstrap/ape.silicon index d918ddea4..179a84f94 100755 Binary files a/build/bootstrap/ape.silicon and b/build/bootstrap/ape.silicon differ diff --git a/dsp/tty/quant.h b/dsp/tty/quant.h index 5cf1d084d..a0422ebf4 100644 --- a/dsp/tty/quant.h +++ b/dsp/tty/quant.h @@ -75,7 +75,7 @@ extern char *ttyraster(char *, const struct TtyRgb *, size_t, size_t, #ifndef ttyquant #define ttyquant() (&g_ttyquant_) -#define TTYQUANT() VEIL("r", &g_ttyquant_) +#define TTYQUANT() __veil("r", &g_ttyquant_) #define rgb2tty(...) (ttyquant()->rgb2tty(__VA_ARGS__)) #define tty2rgb(...) (ttyquant()->tty2rgb(__VA_ARGS__)) #define rgb2ttyf(...) (ttyquant()->rgb2ttyf(__VA_ARGS__)) diff --git a/examples/certapp.c b/examples/certapp.c index bd4253839..d68b45e04 100644 --- a/examples/certapp.c +++ b/examples/certapp.c @@ -25,7 +25,7 @@ #include "third_party/mbedtls/ssl.h" #include "third_party/mbedtls/x509_crt.h" -STATIC_YOINK("ssl_root_support"); +__static_yoink("ssl_root_support"); #define MODE_NONE 0 #define MODE_FILE 1 diff --git a/examples/check.c b/examples/check.c index 293ab01e5..769421ecc 100644 --- a/examples/check.c +++ b/examples/check.c @@ -75,8 +75,8 @@ * the following functions to further expand the information shown by * the NDEBUG check failure: * - * STATIC_YOINK("__die"); - * STATIC_YOINK("strerror"); + * __static_yoink("__die"); + * __static_yoink("strerror"); * * Please note that backtraces aren't ever available in MODE=tiny. */ diff --git a/examples/crashreport.c b/examples/crashreport.c index 35f656557..788832098 100644 --- a/examples/crashreport.c +++ b/examples/crashreport.c @@ -25,7 +25,7 @@ * o//examples/crashreport.com */ -noubsan int main(int argc, char *argv[]) { +dontubsan int main(int argc, char *argv[]) { kprintf("----------------\n"); kprintf(" THIS IS A TEST \n"); kprintf("SIMULATING CRASH\n"); diff --git a/examples/exec.c b/examples/exec.c index 8ad300d1b..a690c6adb 100644 --- a/examples/exec.c +++ b/examples/exec.c @@ -13,7 +13,7 @@ #include "libc/stdio/stdio.h" #include "libc/sysv/consts/sig.h" -STATIC_YOINK("strerror"); +__static_yoink("strerror"); int main(int argc, char *argv[]) { sigset_t ss; diff --git a/examples/nesemu1.cc b/examples/nesemu1.cc index 8c79aed9b..c6699f556 100644 --- a/examples/nesemu1.cc +++ b/examples/nesemu1.cc @@ -48,7 +48,7 @@ #include "third_party/libcxx/vector" #include "tool/viz/lib/knobs.h" -STATIC_YOINK("zipos"); +__static_yoink("zipos"); #define USAGE \ " [ROM] [FMV]\n\ diff --git a/examples/system.c b/examples/system.c index 8050067d8..aecfcbfe5 100644 --- a/examples/system.c +++ b/examples/system.c @@ -15,8 +15,8 @@ * Yes this works on Windows. */ -STATIC_YOINK("_tr"); -STATIC_YOINK("_sed"); +__static_yoink("_tr"); +__static_yoink("_sed"); int main(int argc, char *argv[]) { system("x=world\n" diff --git a/examples/vga.c b/examples/vga.c index f26d4a6a1..3a39e7f12 100644 --- a/examples/vga.c +++ b/examples/vga.c @@ -28,12 +28,12 @@ * Please note that, by default, APE binaries only use the serial port * for stdio. To get the VGA console as an added bonus: * - * STATIC_YOINK("vga_console"); + * __static_yoink("vga_console"); * * Should be added to the top of your main() program source file. */ -STATIC_YOINK("vga_console"); +__static_yoink("vga_console"); int main(int argc, char *argv[]) { volatile long double x = -.5; diff --git a/examples/vga2.c b/examples/vga2.c index 859b14364..3bc90bd1b 100644 --- a/examples/vga2.c +++ b/examples/vga2.c @@ -24,9 +24,9 @@ * qemu-system-x86_64 -hda o//examples/vga2.com -serial stdio */ -STATIC_YOINK("vga_console"); -STATIC_YOINK("_idt"); -STATIC_YOINK("EfiMain"); +__static_yoink("vga_console"); +__static_yoink("_idt"); +__static_yoink("EfiMain"); int main(int argc, char *argv[]) { int i; diff --git a/libc/assert.h b/libc/assert.h index dc587df3c..0579e193a 100644 --- a/libc/assert.h +++ b/libc/assert.h @@ -18,8 +18,8 @@ void __assert_fail(const char *, const char *, int) relegated; #ifdef COSMO extern bool __assert_disable; #ifndef NDEBUG -#define _unassert(x) __assert_macro(x, #x) -#define _npassert(x) __assert_macro(x, #x) +#define unassert(x) __assert_macro(x, #x) +#define npassert(x) __assert_macro(x, #x) #define __assert_macro(x, s) \ ({ \ if (__builtin_expect(!(x), 0)) { \ @@ -29,14 +29,14 @@ extern bool __assert_disable; (void)0; \ }) #else -#define _npassert(x) \ +#define npassert(x) \ ({ \ if (__builtin_expect(!(x), 0)) { \ __builtin_trap(); \ } \ (void)0; \ }) -#define _unassert(x) \ +#define unassert(x) \ ({ \ if (__builtin_expect(!(x), 0)) { \ __builtin_unreachable(); \ diff --git a/libc/calls/alarm.c b/libc/calls/alarm.c index 17828d9be..d76257986 100644 --- a/libc/calls/alarm.c +++ b/libc/calls/alarm.c @@ -35,7 +35,7 @@ unsigned alarm(unsigned seconds) { struct itimerval it; bzero(&it, sizeof(it)); it.it_value.tv_sec = seconds; - _npassert(!setitimer(ITIMER_REAL, &it, &it)); + npassert(!setitimer(ITIMER_REAL, &it, &it)); if (!it.it_value.tv_sec && !it.it_value.tv_usec) { return 0; } else { diff --git a/libc/calls/clock_nanosleep.c b/libc/calls/clock_nanosleep.c index 7b8646ef0..01157780c 100644 --- a/libc/calls/clock_nanosleep.c +++ b/libc/calls/clock_nanosleep.c @@ -80,11 +80,11 @@ static struct timespec GetNanosleepLatency(void) { if (!(nanos = g_nanosleep_latency)) { BLOCK_CANCELLATIONS; for (cgt = __clock_gettime_get(0);;) { - _npassert(!cgt(CLOCK_REALTIME_PRECISE, &x)); + npassert(!cgt(CLOCK_REALTIME_PRECISE, &x)); rc = sys_clock_nanosleep(CLOCK_REALTIME, 0, &w, 0); - _npassert(!rc || rc == EINTR); + npassert(!rc || rc == EINTR); if (!rc) { - _npassert(!cgt(CLOCK_REALTIME_PRECISE, &y)); + npassert(!cgt(CLOCK_REALTIME_PRECISE, &y)); nanos = timespec_tonanos(timespec_sub(y, x)); g_nanosleep_latency = nanos; break; @@ -115,10 +115,10 @@ static errno_t SpinNanosleep(int clock, int flags, const struct timespec *req, return rc; } cgt = __clock_gettime_get(0); - _npassert(!cgt(CLOCK_REALTIME, &start)); + npassert(!cgt(CLOCK_REALTIME, &start)); for (;;) { sched_yield(); - _npassert(!cgt(CLOCK_REALTIME, &now)); + npassert(!cgt(CLOCK_REALTIME, &now)); if (flags & TIMER_ABSTIME) { if (timespec_cmp(now, *req) >= 0) { return 0; diff --git a/libc/calls/dup-nt.c b/libc/calls/dup-nt.c index 05d041eda..b0bbec3cc 100644 --- a/libc/calls/dup-nt.c +++ b/libc/calls/dup-nt.c @@ -31,7 +31,7 @@ // Implements dup(), dup2(), dup3(), and F_DUPFD for Windows. textwindows int sys_dup_nt(int oldfd, int newfd, int flags, int start) { int64_t rc, proc, handle; - _unassert(!(flags & ~O_CLOEXEC)); + unassert(!(flags & ~O_CLOEXEC)); __fds_lock(); diff --git a/libc/calls/dup3-sysv.c b/libc/calls/dup3-sysv.c index 0c331420b..4cb873e83 100644 --- a/libc/calls/dup3-sysv.c +++ b/libc/calls/dup3-sysv.c @@ -45,9 +45,9 @@ static void sys_dup3_test(void) { int32_t sys_dup3(int32_t oldfd, int32_t newfd, int flags) { int how; - _unassert(oldfd >= 0); - _unassert(newfd >= 0); - _unassert(!(flags & ~O_CLOEXEC)); + unassert(oldfd >= 0); + unassert(newfd >= 0); + unassert(!(flags & ~O_CLOEXEC)); if (IsFreebsd()) { if (flags & O_CLOEXEC) { diff --git a/libc/calls/execve-sysv.c b/libc/calls/execve-sysv.c index e989f9109..18eb8da32 100644 --- a/libc/calls/execve-sysv.c +++ b/libc/calls/execve-sysv.c @@ -85,8 +85,8 @@ int sys_execve(const char *prog, char *const argv[], char *const envp[]) { (CanExecute((ape = "/usr/bin/ape")) || CanExecute((ape = Join(firstnonnull(getenv("TMPDIR"), firstnonnull(getenv("HOME"), ".")), - ".ape-1.4", buf))) || - CanExecute((ape = Join(firstnonnull(getenv("HOME"), "."), ".ape-1.4", + ".ape-1.5", buf))) || + CanExecute((ape = Join(firstnonnull(getenv("HOME"), "."), ".ape-1.5", buf))))) { shargs[0] = ape; shargs[1] = "-"; diff --git a/libc/calls/fadvise.c b/libc/calls/fadvise.c index 2c89cb1ae..2a5b13ddb 100644 --- a/libc/calls/fadvise.c +++ b/libc/calls/fadvise.c @@ -52,7 +52,7 @@ int fadvise(int fd, uint64_t offset, uint64_t len, int advice) { } else { rc = sys_fadvise_netbsd(fd, offset, offset, len, advice); } - _npassert(rc >= 0); + npassert(rc >= 0); if (rc) { errno = rc; rc = -1; diff --git a/libc/calls/fexecve.c b/libc/calls/fexecve.c index c2b5b208c..9b26dfed2 100644 --- a/libc/calls/fexecve.c +++ b/libc/calls/fexecve.c @@ -158,7 +158,7 @@ static int fd_to_mem_fd(const int infd, char *path) { if (path) { FormatInt32(stpcpy(path, "COSMOPOLITAN_INIT_ZIPOS="), fd); } - _unassert(readRc == st.st_size); + unassert(readRc == st.st_size); return fd; } else if (!success) { errno = e; diff --git a/libc/calls/fixupnewfd.c b/libc/calls/fixupnewfd.c index fd61c2486..0ceacb768 100644 --- a/libc/calls/fixupnewfd.c +++ b/libc/calls/fixupnewfd.c @@ -29,12 +29,12 @@ int __fixupnewfd(int fd, int flags) { int file_mode; if (fd != -1) { if (flags & O_CLOEXEC) { - _unassert((file_mode = __sys_fcntl(fd, F_GETFD)) != -1); - _unassert(!__sys_fcntl(fd, F_SETFD, file_mode | FD_CLOEXEC)); + unassert((file_mode = __sys_fcntl(fd, F_GETFD)) != -1); + unassert(!__sys_fcntl(fd, F_SETFD, file_mode | FD_CLOEXEC)); } if (flags & O_NONBLOCK) { - _unassert((file_mode = __sys_fcntl(fd, F_GETFL)) != -1); - _unassert(!__sys_fcntl(fd, F_SETFL, file_mode | O_NONBLOCK)); + unassert((file_mode = __sys_fcntl(fd, F_GETFL)) != -1); + unassert(!__sys_fcntl(fd, F_SETFL, file_mode | O_NONBLOCK)); } } return fd; diff --git a/libc/calls/ftruncate-nt.c b/libc/calls/ftruncate-nt.c index 17c1adbf2..5332441b4 100644 --- a/libc/calls/ftruncate-nt.c +++ b/libc/calls/ftruncate-nt.c @@ -31,7 +31,7 @@ textwindows int sys_ftruncate_nt(int64_t handle, uint64_t length) { if ((ok = SetFilePointerEx(handle, 0, &tell, kNtFileCurrent))) { ok = SetFilePointerEx(handle, length, NULL, kNtFileBegin) && SetEndOfFile(handle); - _npassert(SetFilePointerEx(handle, tell, NULL, kNtFileBegin)); + npassert(SetFilePointerEx(handle, tell, NULL, kNtFileBegin)); } if (ok) { return 0; diff --git a/libc/calls/getcwd.greg.c b/libc/calls/getcwd.greg.c index 8a2934d36..a5f0cba30 100644 --- a/libc/calls/getcwd.greg.c +++ b/libc/calls/getcwd.greg.c @@ -52,7 +52,7 @@ char *getcwd(char *buf, size_t size) { return 0; } } else if (_weaken(malloc)) { - _unassert(!__vforked); + unassert(!__vforked); if (!size) size = PATH_MAX; if (!(p = _weaken(malloc)(size))) { STRACE("getcwd(%p, %'zu) %m", buf, size); @@ -60,7 +60,7 @@ char *getcwd(char *buf, size_t size) { } } else { einval(); - STRACE("getcwd() needs buf≠0 or STATIC_YOINK(\"malloc\")"); + STRACE("getcwd() needs buf≠0 or __static_yoink(\"malloc\")"); return 0; } *p = '\0'; diff --git a/libc/calls/getppid.c b/libc/calls/getppid.c index e5e1b0efc..52df29760 100644 --- a/libc/calls/getppid.c +++ b/libc/calls/getppid.c @@ -44,7 +44,7 @@ int getppid(void) { } else { rc = sys_getppid_nt(); } - _npassert(rc >= 0); + npassert(rc >= 0); STRACE("%s() → %d", "getppid", rc); return rc; } diff --git a/libc/calls/getuid.c b/libc/calls/getuid.c index 3eb6ce978..666224b6d 100644 --- a/libc/calls/getuid.c +++ b/libc/calls/getuid.c @@ -63,7 +63,7 @@ uint32_t getuid(void) { } else { rc = GetUserNameHash(); } - _npassert(rc >= 0); + npassert(rc >= 0); STRACE("%s() → %d", "getuid", rc); return rc; } @@ -88,7 +88,7 @@ uint32_t getgid(void) { } else { rc = GetUserNameHash(); } - _npassert(rc >= 0); + npassert(rc >= 0); STRACE("%s() → %d", "getgid", rc); return rc; } diff --git a/libc/calls/ioctl.c b/libc/calls/ioctl.c index abc510e6a..82550f954 100644 --- a/libc/calls/ioctl.c +++ b/libc/calls/ioctl.c @@ -291,7 +291,7 @@ static textwindows int createHostInfo( char name[IFNAMSIZ]; int count, i; /* __hostInfo must be empty */ - _unassert(__hostInfo == NULL); + unassert(__hostInfo == NULL); for (aa = firstAdapter; aa; aa = aa->Next) { /* Skip all the interfaces with no address and the ones that are not AF_INET */ diff --git a/libc/calls/metalfile.c b/libc/calls/metalfile.c index aec4e225f..3b46de96e 100644 --- a/libc/calls/metalfile.c +++ b/libc/calls/metalfile.c @@ -47,12 +47,12 @@ #define MAP_FIXED_linux 0x00000010 #define MAP_SHARED_linux 0x00000001 -STATIC_YOINK("_init_metalfile"); +__static_yoink("_init_metalfile"); void *__ape_com_base; size_t __ape_com_size = 0; -textstartup noasan void InitializeMetalFile(void) { +textstartup dontasan void InitializeMetalFile(void) { if (IsMetal()) { /* * Copy out a pristine image of the program — before the program might @@ -61,7 +61,7 @@ textstartup noasan void InitializeMetalFile(void) { * This code is included if a symbol "file:/proc/self/exe" is defined * (see libc/calls/metalfile.internal.h & libc/calls/metalfile_init.S). * The zipos code will automatically arrange to do this. Alternatively, - * user code can STATIC_YOINK this symbol. + * user code can __static_yoink this symbol. */ size_t size = ROUNDUP(_ezip - __executable_start, 4096); // TODO(jart): Restore support for ZIPOS on metal. @@ -70,7 +70,7 @@ textstartup noasan void InitializeMetalFile(void) { dm = sys_mmap_metal(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED_linux | MAP_ANONYMOUS_linux, -1, 0); copied_base = dm.addr; - _npassert(copied_base != (void *)-1); + npassert(copied_base != (void *)-1); memcpy(copied_base, (void *)(BANE + IMAGE_BASE_PHYSICAL), size); __ape_com_base = copied_base; __ape_com_size = size; diff --git a/libc/calls/munmap-metal.c b/libc/calls/munmap-metal.c index b4d69e11a..5bdbdcae8 100644 --- a/libc/calls/munmap-metal.c +++ b/libc/calls/munmap-metal.c @@ -20,7 +20,7 @@ #include "libc/runtime/pc.internal.h" #ifdef __x86_64__ -noasan int sys_munmap_metal(void *addr, size_t size) { +dontasan int sys_munmap_metal(void *addr, size_t size) { size_t i; uint64_t *e, paddr; struct mman *mm = __get_mm(); diff --git a/libc/calls/now.c b/libc/calls/now.c index 237ae58e3..d079d46ee 100644 --- a/libc/calls/now.c +++ b/libc/calls/now.c @@ -92,7 +92,7 @@ static long double nowl_art(void) { static long double nowl_vdso(void) { long double secs; struct timespec tv; - _unassert(__gettime); + unassert(__gettime); __gettime(CLOCK_REALTIME_PRECISE, &tv); secs = tv.tv_nsec; secs *= 1 / 1e9L; diff --git a/libc/calls/open-nt.c b/libc/calls/open-nt.c index bcc7c032d..e8b41e580 100644 --- a/libc/calls/open-nt.c +++ b/libc/calls/open-nt.c @@ -53,7 +53,7 @@ static textwindows int sys_open_nt_console(int dirfd, -1) { g_fds.p[fd].extra = sys_open_nt_impl(dirfd, mp->conout, (flags & ~O_ACCMODE) | O_WRONLY, mode); - _npassert(g_fds.p[fd].extra != -1); + npassert(g_fds.p[fd].extra != -1); } else { return -1; } diff --git a/libc/calls/openat.c b/libc/calls/openat.c index f9204d4bb..803eb409a 100644 --- a/libc/calls/openat.c +++ b/libc/calls/openat.c @@ -54,7 +54,7 @@ * * If your main() source file has this statement: * - * STATIC_YOINK("zipos"); + * __static_yoink("zipos"); * * Then you can read zip assets by adding a `"/zip/..."` prefix to `file`, e.g. * diff --git a/libc/calls/openpty.c b/libc/calls/openpty.c index 18981d827..8382ff2e3 100644 --- a/libc/calls/openpty.c +++ b/libc/calls/openpty.c @@ -66,8 +66,8 @@ static int openpty_impl(int *mfd, int *sfd, char *name, *mfd = m; *sfd = s; if (name) strcpy(name, t.sname); - if (tio) _npassert(!tcsetattr(s, TCSAFLUSH, tio)); - if (wsz) _npassert(!tcgetwinsize(s, wsz)); + if (tio) npassert(!tcsetattr(s, TCSAFLUSH, tio)); + if (wsz) npassert(!tcgetwinsize(s, wsz)); return 0; OnError: if (m != -1) sys_close(m); diff --git a/libc/calls/posix_fadvise.c b/libc/calls/posix_fadvise.c index 3fb293c53..8582b720e 100644 --- a/libc/calls/posix_fadvise.c +++ b/libc/calls/posix_fadvise.c @@ -51,10 +51,10 @@ errno_t posix_fadvise(int fd, int64_t offset, int64_t len, int advice) { rc = sys_fadvise(fd, offset, len, advice); } else if (IsFreebsd()) { rc = sys_fadvise(fd, offset, len, advice); - _unassert(rc >= 0); + unassert(rc >= 0); } else if (IsNetbsd()) { rc = sys_fadvise_netbsd(fd, offset, offset, len, advice); - _unassert(rc >= 0); + unassert(rc >= 0); } else if (IsWindows()) { rc = sys_fadvise_nt(fd, offset, len, advice); } else { diff --git a/libc/calls/pread.c b/libc/calls/pread.c index b114b272e..2c36ca99d 100644 --- a/libc/calls/pread.c +++ b/libc/calls/pread.c @@ -76,7 +76,7 @@ ssize_t pread(int fd, void *buf, size_t size, int64_t offset) { } else { rc = ebadf(); } - _npassert(rc == -1 || (size_t)rc <= size); + npassert(rc == -1 || (size_t)rc <= size); END_CANCELLATION_POINT; DATATRACE("pread(%d, [%#.*hhs%s], %'zu, %'zd) → %'zd% m", fd, diff --git a/libc/calls/pwrite.c b/libc/calls/pwrite.c index 022a4b29d..fd5c23981 100644 --- a/libc/calls/pwrite.c +++ b/libc/calls/pwrite.c @@ -69,9 +69,9 @@ ssize_t pwrite(int fd, const void *buf, size_t size, int64_t offset) { if (rc != -1) { wrote = (size_t)rc; if (!wrote) { - _npassert(size == 0); + npassert(size == 0); } else { - _npassert(wrote <= size); + npassert(wrote <= size); } } diff --git a/libc/calls/raise.c b/libc/calls/raise.c index 4bfe30cf4..d0777c3f2 100644 --- a/libc/calls/raise.c +++ b/libc/calls/raise.c @@ -31,7 +31,7 @@ static textwindows inline bool HasWorkingConsole(void) { return !!(__ntconsolemode[0] | __ntconsolemode[1] | __ntconsolemode[2]); } -static noubsan void RaiseSigFpe(void) { +static dontubsan void RaiseSigFpe(void) { volatile int x = 0; x = 1 / x; } diff --git a/libc/calls/read-nt.c b/libc/calls/read-nt.c index 23c411b12..4f965661a 100644 --- a/libc/calls/read-nt.c +++ b/libc/calls/read-nt.c @@ -81,7 +81,7 @@ static textwindows ssize_t sys_read_nt_impl(struct Fd *fd, void *data, if (!ok && GetLastError() == kNtErrorIoPending) ok = true; if (ok) ok = GetOverlappedResult(fd->handle, &overlap, &got, true); // restore file pointer which windows clobbers, even on error - _unassert(SetFilePointerEx(fd->handle, position, 0, SEEK_SET)); + unassert(SetFilePointerEx(fd->handle, position, 0, SEEK_SET)); } if (ok) { return got; diff --git a/libc/calls/realpath.c b/libc/calls/realpath.c index 37d046dc1..e038e7211 100644 --- a/libc/calls/realpath.c +++ b/libc/calls/realpath.c @@ -181,7 +181,7 @@ skip_readlink: continue; } k = rc; - _npassert(k <= p); + npassert(k <= p); if (k==p) goto toolong; if (!k) { diff --git a/libc/calls/sigaction.c b/libc/calls/sigaction.c index 84ff0e99f..fcd9d4285 100644 --- a/libc/calls/sigaction.c +++ b/libc/calls/sigaction.c @@ -49,13 +49,13 @@ #include "libc/sysv/errfuns.h" #ifdef SYSDEBUG -STATIC_YOINK("strsignal"); // for kprintf() +__static_yoink("strsignal"); // for kprintf() #endif #if SupportsWindows() -STATIC_YOINK("_init_onntconsoleevent"); -STATIC_YOINK("_check_sigwinch"); -STATIC_YOINK("_init_wincrash"); +__static_yoink("_init_onntconsoleevent"); +__static_yoink("_check_sigwinch"); +__static_yoink("_init_wincrash"); #endif #define SA_RESTORER 0x04000000 diff --git a/libc/calls/sigsetmask.c b/libc/calls/sigsetmask.c index a6618ae0c..c43e11180 100644 --- a/libc/calls/sigsetmask.c +++ b/libc/calls/sigsetmask.c @@ -28,7 +28,7 @@ sigset_t _sigsetmask(sigset_t neu) { if (IsMetal() || IsWindows()) { __sig_mask(SIG_SETMASK, &neu, &res); } else { - _npassert(!sys_sigprocmask(SIG_SETMASK, &neu, &res)); + npassert(!sys_sigprocmask(SIG_SETMASK, &neu, &res)); } return res; } diff --git a/libc/calls/sleep.c b/libc/calls/sleep.c index d2c044b07..681009db9 100644 --- a/libc/calls/sleep.c +++ b/libc/calls/sleep.c @@ -42,7 +42,7 @@ unsigned sleep(unsigned seconds) { struct timespec tv = {seconds}; if (!(rc = clock_nanosleep(CLOCK_REALTIME, 0, &tv, &tv))) return 0; if (rc == ECANCELED) return -1u; - _npassert(rc == EINTR); + npassert(rc == EINTR); unslept = tv.tv_sec; if (tv.tv_nsec && unslept < UINT_MAX) { ++unslept; diff --git a/libc/calls/timespec_mono.c b/libc/calls/timespec_mono.c index a37e7b2ae..88ee549f2 100644 --- a/libc/calls/timespec_mono.c +++ b/libc/calls/timespec_mono.c @@ -29,6 +29,6 @@ */ struct timespec timespec_mono(void) { struct timespec ts; - _npassert(!clock_gettime(CLOCK_MONOTONIC, &ts)); + npassert(!clock_gettime(CLOCK_MONOTONIC, &ts)); return ts; } diff --git a/libc/calls/timespec_real.c b/libc/calls/timespec_real.c index dbebd20c5..37034dcc9 100644 --- a/libc/calls/timespec_real.c +++ b/libc/calls/timespec_real.c @@ -31,6 +31,6 @@ */ struct timespec timespec_real(void) { struct timespec ts; - _npassert(!clock_gettime(CLOCK_REALTIME, &ts)); + npassert(!clock_gettime(CLOCK_REALTIME, &ts)); return ts; } diff --git a/libc/calls/timespec_sleep.c b/libc/calls/timespec_sleep.c index bbf65f79c..710b87e67 100644 --- a/libc/calls/timespec_sleep.c +++ b/libc/calls/timespec_sleep.c @@ -34,7 +34,7 @@ struct timespec timespec_sleep(struct timespec delay) { BLOCK_CANCELLATIONS; bzero(&remain, sizeof(remain)); if ((rc = clock_nanosleep(CLOCK_REALTIME, 0, &delay, &remain))) { - _npassert(rc == EINTR); + npassert(rc == EINTR); } ALLOW_CANCELLATIONS; return remain; diff --git a/libc/calls/timespec_sleep_until.c b/libc/calls/timespec_sleep_until.c index 277b2d45d..3dc9d5bee 100644 --- a/libc/calls/timespec_sleep_until.c +++ b/libc/calls/timespec_sleep_until.c @@ -33,6 +33,6 @@ errno_t timespec_sleep_until(struct timespec abs_deadline) { errno_t rc; rc = clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &abs_deadline, 0); - _npassert(!rc || rc == EINTR || rc == ECANCELED); + npassert(!rc || rc == EINTR || rc == ECANCELED); return rc; } diff --git a/libc/calls/timeval_real.c b/libc/calls/timeval_real.c index cfffbcdd0..e0af46e76 100644 --- a/libc/calls/timeval_real.c +++ b/libc/calls/timeval_real.c @@ -26,6 +26,6 @@ */ struct timeval timeval_real(void) { struct timeval tv; - _npassert(!gettimeofday(&tv, 0)); + npassert(!gettimeofday(&tv, 0)); return tv; } diff --git a/libc/calls/uname.c b/libc/calls/uname.c index fc105eaa8..253abff12 100644 --- a/libc/calls/uname.c +++ b/libc/calls/uname.c @@ -76,15 +76,15 @@ static textwindows void GetNtName(char *name, int kind) { } } -static inline textwindows noasan int GetNtMajorVersion(void) { +static inline textwindows dontasan int GetNtMajorVersion(void) { return NtGetPeb()->OSMajorVersion; } -static inline textwindows noasan int GetNtMinorVersion(void) { +static inline textwindows dontasan int GetNtMinorVersion(void) { return NtGetPeb()->OSMinorVersion; } -static inline textwindows noasan int GetNtBuildNumber(void) { +static inline textwindows dontasan int GetNtBuildNumber(void) { return NtGetPeb()->OSBuildNumber; } diff --git a/libc/calls/unveil.c b/libc/calls/unveil.c index b7802ce8d..0891cc0f4 100644 --- a/libc/calls/unveil.c +++ b/libc/calls/unveil.c @@ -473,10 +473,10 @@ int unveil(const char *path, const char *permissions) { if (permissions) return einval(); if (IsOpenbsd()) return 0; if (landlock_abi_version != -1) { - _unassert(landlock_abi_version >= 1); + unassert(landlock_abi_version >= 1); return landlock_abi_version; } else { - _unassert(landlock_abi_errno); + unassert(landlock_abi_errno); errno = landlock_abi_errno; return -1; } diff --git a/libc/calls/write-nt.c b/libc/calls/write-nt.c index c2c4e5e89..7986db3f3 100644 --- a/libc/calls/write-nt.c +++ b/libc/calls/write-nt.c @@ -60,7 +60,7 @@ static textwindows ssize_t sys_write_nt_impl(int fd, void *data, size_t size, if (!ok && GetLastError() == kNtErrorIoPending) ok = true; if (ok) ok = GetOverlappedResult(handle, &overlap, &sent, true); // restore file pointer which windows clobbers, even on error - _unassert(SetFilePointerEx(handle, position, 0, SEEK_SET)); + unassert(SetFilePointerEx(handle, position, 0, SEEK_SET)); } if (ok) { return sent; diff --git a/libc/fmt/bing.c b/libc/fmt/bing.c index 9dcc6215c..80e88699d 100644 --- a/libc/fmt/bing.c +++ b/libc/fmt/bing.c @@ -55,6 +55,6 @@ * @see unbing() for inverse */ int bing(int b, int intent) { - _unassert(0 <= b && b < 256); + unassert(0 <= b && b < 256); return kCp437[b & 0xff]; } diff --git a/libc/fmt/itoa64fixed16.greg.c b/libc/fmt/itoa64fixed16.greg.c index ace624ba7..aeb761d1b 100644 --- a/libc/fmt/itoa64fixed16.greg.c +++ b/libc/fmt/itoa64fixed16.greg.c @@ -21,7 +21,7 @@ size_t uint64toarray_fixed16(uint64_t x, char b[hasatleast 17], uint8_t k) { char *p; - _unassert(k <= 64 && !(k & 3)); + unassert(k <= 64 && !(k & 3)); for (p = b; k > 0;) *p++ = "0123456789abcdef"[(x >> (k -= 4)) & 15]; *p = '\0'; return p - b; diff --git a/libc/integral/c.inc b/libc/integral/c.inc index 5a67eee7f..68cb18191 100644 --- a/libc/integral/c.inc +++ b/libc/integral/c.inc @@ -194,19 +194,22 @@ typedef struct { #endif #ifndef privileged -#if !defined(__STRICT_ANSI__) && \ - (__has_attribute(__visibility__) || defined(__GNUC__)) -#define privileged _Section(".privileged") -#else -#define privileged _Section(".privileged") -#endif +#define privileged \ + _Section(".privileged") dontinline dontinstrument dontubsan dontasan #endif #ifndef dontinstrument #if !defined(__STRICT_ANSI__) && \ (__has_attribute(__no_instrument_function__) || \ (__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 204) +#if ((__GNUC__ + 0) >= 7 && !defined(__chibicc__)) || \ + __has_attribute(__patchable_function_entry__) +#define dontinstrument \ + __attribute__((__no_instrument_function__, \ + __patchable_function_entry__(0, 0))) +#else #define dontinstrument __attribute__((__no_instrument_function__)) +#endif #else #define dontinstrument #endif @@ -569,17 +572,17 @@ typedef struct { #if ((__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 408 || \ __has_attribute(__no_sanitize_address__)) && \ !defined(__STRICT_ANSI__) -#define noasan __attribute__((__no_sanitize_address__)) +#define dontasan __attribute__((__no_sanitize_address__)) #else -#define noasan +#define dontasan #endif #if ((__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 408 || \ __has_attribute(__no_sanitize_undefined__)) && \ !defined(__STRICT_ANSI__) -#define noubsan __attribute__((__no_sanitize_undefined__)) +#define dontubsan __attribute__((__no_sanitize_undefined__)) #else -#define noubsan +#define dontubsan #endif #ifdef __STRICT_ANSI__ @@ -645,11 +648,7 @@ void abort(void) wontreturn; #endif #ifndef _Section -#if !defined(__STRICT_ANSI__) && !defined(__APPLE__) #define _Section(s) __attribute__((__section__(s))) -#else -#define _Section(s) -#endif #endif #if defined(__x86_64__) && !defined(__llvm__) @@ -772,69 +771,69 @@ void abort(void) wontreturn; #endif #ifndef __STRICT_ANSI__ -#define VEIL(CONSTRAINT, EXPRESSION) \ +#define __veil(CONSTRAINT, EXPRESSION) \ ({ \ autotype(EXPRESSION) VeiledValue = (EXPRESSION); \ asm("" : "=" CONSTRAINT ""(VeiledValue) : "0"(VeiledValue)); \ VeiledValue; \ }) #else -#define VEIL(CONSTRAINT, EXPRESSION) (EXPRESSION) +#define __veil(CONSTRAINT, EXPRESSION) (EXPRESSION) #endif #ifndef __STRICT_ANSI__ -#define CONCEAL(CONSTRAINT, EXPRESSION) \ +#define __conceal(CONSTRAINT, EXPRESSION) \ ({ \ autotype(EXPRESSION) VeiledValue = (EXPRESSION); \ asm volatile("" : "=" CONSTRAINT ""(VeiledValue) : "0"(VeiledValue)); \ VeiledValue; \ }) #else -#define CONCEAL(CONSTRAINT, EXPRESSION) (EXPRESSION) +#define __conceal(CONSTRAINT, EXPRESSION) (EXPRESSION) #endif #ifndef __STRICT_ANSI__ -#define EXPROPRIATE(EXPRESSION) \ +#define __expropriate(EXPRESSION) \ ({ \ asm volatile("" ::"g"(EXPRESSION) : "memory"); \ 0; \ }) #else -#define EXPROPRIATE(EXPRESSION) (EXPRESSION) +#define __expropriate(EXPRESSION) (EXPRESSION) #endif #if !defined(__STRICT_ANSI__) && !defined(__APPLE__) && defined(__x86_64__) -#define YOINK(SYMBOL) \ +#define __yoink(SYMBOL) \ asm(".section .yoink\n\tnopl\t%0\n\t.previous" : : "m"(SYMBOL)) #elif defined(__aarch64__) -#define YOINK(SYMBOL) \ +#define __yoink(SYMBOL) \ asm(".section .yoink\n\tb\t%0\n\t.previous" : : "m"(SYMBOL)) #else -#define YOINK(SYMBOL) (void)0 +#define __yoink(SYMBOL) (void)0 #endif #if !defined(__STRICT_ANSI__) && !defined(__APPLE__) && defined(__x86_64__) -#define STATIC_YOINK(SYMBOLSTR) \ +#define __static_yoink(SYMBOLSTR) \ asm(".section .yoink\n\tnopl\t\"" SYMBOLSTR "\"\n\t.previous") #elif defined(__aarch64__) -#define STATIC_YOINK(SYMBOLSTR) \ +#define __static_yoink(SYMBOLSTR) \ asm(".section .yoink\n\tb\t\"" SYMBOLSTR "\"\n\t.previous") #else -#define STATIC_YOINK(SYMBOLSTR) +#define __static_yoink(SYMBOLSTR) #endif #if !defined(IM_FEELING_NAUGHTY) -#define STATIC_YOINK_SOURCE(PATH) STATIC_YOINK(PATH) +#define __static_yoink_source(PATH) __static_yoink(PATH) #else -#define STATIC_YOINK_SOURCE(PATH) +#define __static_yoink_source(PATH) #endif #define __strong_reference(sym, aliassym) \ - extern typeof(sym) aliassym __attribute__((__alias__(#sym))) -#define __weak_reference(sym, alias) \ - asm(".weak\t" #alias "\n\t" \ - ".equ\t" #alias ", " #sym "\n\t" \ - ".type\t" #alias ",@notype") + extern __typeof(sym) aliassym __attribute__((__alias__(#sym))) +#define __weak_reference(sym, alias) \ + __asm__(".weak\t" #alias "\n\t" \ + ".equ\t" #alias ", " #sym "\n\t" \ + ".type\t" #alias ",@notype") #define __funline \ extern __inline \ diff --git a/libc/integral/normalize.inc b/libc/integral/normalize.inc index 2bbad5297..d75c0a053 100644 --- a/libc/integral/normalize.inc +++ b/libc/integral/normalize.inc @@ -82,8 +82,7 @@ #else #define APE_STACKSIZE 4194304 /* default 4mb stack */ #endif -#define APE_PAGESIZE 0x10000 /* i386+ */ -#define APE_GUARDSIZE 0x4000 /* b/c apple m1 */ +#define APE_PAGESIZE 0x10000 /* i386+ */ #define BUFSIZ 0x1000 /* best stdio default */ #define CHAR_BIT 8 /* b/c von neumann */ diff --git a/libc/intrin/_getauxval.c b/libc/intrin/_getauxval.c index 9934c262f..c2f2753b1 100644 --- a/libc/intrin/_getauxval.c +++ b/libc/intrin/_getauxval.c @@ -20,19 +20,15 @@ #include "libc/runtime/runtime.h" /** - * Returns auxiliary value, or zero if kernel didn't provide it. - * - * This function is typically regarded as a libc implementation detail; - * thus, the source code is the documentation. + * Returns auxiliary value better. * * @param at is `AT_...` search key * @return true if value was found * @see libc/sysv/consts.sh * @see System Five Application Binary Interface § 3.4.3 - * @error ENOENT when value not found * @asyncsignalsafe */ -struct AuxiliaryValue _getauxval(unsigned long at) { +dontasan struct AuxiliaryValue _getauxval(unsigned long at) { unsigned long *ap; for (ap = __auxv; ap[0]; ap += 2) { if (at == ap[0]) { diff --git a/libc/intrin/arememoryintervalsok.c b/libc/intrin/arememoryintervalsok.c index 30ad421a9..e5e8f4599 100644 --- a/libc/intrin/arememoryintervalsok.c +++ b/libc/intrin/arememoryintervalsok.c @@ -19,7 +19,7 @@ #include "libc/intrin/strace.internal.h" #include "libc/runtime/memtrack.internal.h" -noasan bool AreMemoryIntervalsOk(const struct MemoryIntervals *mm) { +dontasan bool AreMemoryIntervalsOk(const struct MemoryIntervals *mm) { /* asan runtime depends on this function */ int i; size_t wantsize; diff --git a/libc/intrin/asan.c b/libc/intrin/asan.c index afcfefe0f..110fdf141 100644 --- a/libc/intrin/asan.c +++ b/libc/intrin/asan.c @@ -52,7 +52,7 @@ #include "third_party/dlmalloc/dlmalloc.h" #ifdef __x86_64__ -STATIC_YOINK("_init_asan"); +__static_yoink("_init_asan"); #if IsModeDbg() // MODE=dbg @@ -342,7 +342,7 @@ static char *__asan_hexcpy(char *p, uint64_t x, uint8_t k) { static void __asan_exit(void) { kprintf("your asan runtime needs\n" - "\tSTATIC_YOINK(\"__die\");\n" + "\t__static_yoink(\"__die\");\n" "in order to show you backtraces\n"); _Exitr(99); } @@ -457,7 +457,7 @@ static struct AsanFault __asan_checka(const signed char *s, long ndiv8) { * This is normally abstracted by the compiler. In some cases, it may be * desirable to perform an ASAN memory safety check explicitly, e.g. for * system call wrappers that need to vet memory passed to the kernel, or - * string library routines that use the `noasan` keyword due to compiler + * string library routines that use the `dontasan` keyword due to compiler * generated ASAN being too costly. This function is fast especially for * large memory ranges since this takes a few picoseconds for each byte. * @@ -766,11 +766,11 @@ static void __asan_report_memory_origin_image(intptr_t a, int z) { kprintf("\tunknown please supply .com.dbg symbols or set COMDBG\n"); } } else { - kprintf("\tunknown please STATIC_YOINK(\"GetSymbolTable\");\n"); + kprintf("\tunknown please __static_yoink(\"GetSymbolTable\");\n"); } } -static noasan void __asan_onmemory(void *x, void *y, size_t n, void *a) { +static dontasan void __asan_onmemory(void *x, void *y, size_t n, void *a) { const unsigned char *p = x; struct ReportOriginHeap *t = a; if ((p <= t->a && t->a < p + n) || @@ -790,7 +790,7 @@ static void __asan_report_memory_origin_heap(const unsigned char *a, int z) { t.z = z; _weaken(malloc_inspect_all)(__asan_onmemory, &t); } else { - kprintf("\tunknown please STATIC_YOINK(\"malloc_inspect_all\");\n"); + kprintf("\tunknown please __static_yoink(\"malloc_inspect_all\");\n"); } } @@ -1117,7 +1117,7 @@ int __asan_print_trace(void *p) { kprintf("\n%*lx %s", 12, e->bt.p[i], _weaken(GetSymbolByAddr) ? _weaken(GetSymbolByAddr)(e->bt.p[i]) - : "please STATIC_YOINK(\"GetSymbolByAddr\")"); + : "please __static_yoink(\"GetSymbolByAddr\")"); } return 0; } @@ -1482,7 +1482,8 @@ static textstartup void __asan_shadow_mapping(struct MemoryIntervals *m, static textstartup void __asan_shadow_existing_mappings(void) { __asan_shadow_mapping(&_mmi, 0); __asan_map_shadow(GetStackAddr(), GetStackSize()); - __asan_poison((void *)GetStackAddr(), APE_GUARDSIZE, kAsanStackOverflow); + __asan_poison((void *)GetStackAddr(), getauxval(AT_PAGESZ), + kAsanStackOverflow); } forceinline ssize_t __write_str(const char *s) { @@ -1509,7 +1510,7 @@ void __asan_init(int argc, char **argv, char **envp, intptr_t *auxv) { __asan_shadow_existing_mappings(); __asan_map_shadow((uintptr_t)__executable_start, _end - __executable_start); __asan_map_shadow(0, 4096); - __asan_poison(0, APE_GUARDSIZE, kAsanNullPage); + __asan_poison(0, getauxval(AT_PAGESZ), kAsanNullPage); if (!IsWindows()) { sys_mprotect((void *)0x7fff8000, 0x10000, PROT_READ); } diff --git a/libc/intrin/bt.c b/libc/intrin/bt.c index a1f0c22eb..6d61f0177 100644 --- a/libc/intrin/bt.c +++ b/libc/intrin/bt.c @@ -49,7 +49,7 @@ void _bt(const char *fmt, ...) { errno = e; } else { kprintf("_bt() can't show backtrace because you need:\n" - "\tSTATIC_YOINK(\"ShowBacktrace\");\n" + "\t__static_yoink(\"ShowBacktrace\");\n" "to be linked.\n"); if (_weaken(PrintBacktraceUsingSymbols) && _weaken(GetSymbolTable)) { e = errno; @@ -58,8 +58,8 @@ void _bt(const char *fmt, ...) { errno = e; } else { kprintf("_bt() can't show backtrace because you need:\n" - "\tSTATIC_YOINK(\"PrintBacktraceUsingSymbols\");\n" - "\tSTATIC_YOINK(\"GetSymbolTable\");\n" + "\t__static_yoink(\"PrintBacktraceUsingSymbols\");\n" + "\t__static_yoink(\"GetSymbolTable\");\n" "to be linked.\n"); } } diff --git a/libc/intrin/cxaatexit.c b/libc/intrin/cxaatexit.c index 589264d08..31428f057 100644 --- a/libc/intrin/cxaatexit.c +++ b/libc/intrin/cxaatexit.c @@ -26,7 +26,7 @@ #include "libc/runtime/runtime.h" #include "libc/sysv/errfuns.h" -STATIC_YOINK("__cxa_finalize"); +__static_yoink("__cxa_finalize"); /** * Adds global destructor. @@ -42,7 +42,7 @@ STATIC_YOINK("__cxa_finalize"); * @return 0 on success or nonzero w/ errno * @note folks have forked libc in past just to unbloat atexit() */ -noasan int __cxa_atexit(void *fp, void *arg, void *pred) { +dontasan int __cxa_atexit(void *fp, void *arg, void *pred) { /* asan runtime depends on this function */ unsigned i; struct CxaAtexitBlock *b, *b2; @@ -61,7 +61,7 @@ noasan int __cxa_atexit(void *fp, void *arg, void *pred) { } } i = _bsr(~b->mask); - _unassert(i < ARRAYLEN(b->p)); + unassert(i < ARRAYLEN(b->p)); b->mask |= 1u << i; b->p[i].fp = fp; b->p[i].arg = arg; diff --git a/libc/intrin/cxafinalize.c b/libc/intrin/cxafinalize.c index 8e42bf7b5..064399c9d 100644 --- a/libc/intrin/cxafinalize.c +++ b/libc/intrin/cxafinalize.c @@ -60,7 +60,7 @@ StartOverLocked: if (!pred) { b2 = b->next; if (b2) { - _unassert(b != &__cxa_blocks.root); + unassert(b != &__cxa_blocks.root); if (_weaken(free)) { _weaken(free)(b); } diff --git a/libc/intrin/directmap-metal.c b/libc/intrin/directmap-metal.c index d6b82395c..463ac7637 100644 --- a/libc/intrin/directmap-metal.c +++ b/libc/intrin/directmap-metal.c @@ -32,15 +32,15 @@ static uint64_t sys_mmap_metal_break; -noasan static struct DirectMap bad_mmap(void) { +dontasan static struct DirectMap bad_mmap(void) { struct DirectMap res; res.addr = (void *)-1; res.maphandle = -1; return res; } -noasan struct DirectMap sys_mmap_metal(void *vaddr, size_t size, int prot, - int flags, int fd, int64_t off) { +dontasan struct DirectMap sys_mmap_metal(void *vaddr, size_t size, int prot, + int flags, int fd, int64_t off) { /* asan runtime depends on this function */ size_t i; struct mman *mm; diff --git a/libc/intrin/directmap-nt.c b/libc/intrin/directmap-nt.c index c1ed049e8..1ae1d17bb 100644 --- a/libc/intrin/directmap-nt.c +++ b/libc/intrin/directmap-nt.c @@ -72,7 +72,7 @@ textwindows struct DirectMap sys_mmap_nt(void *addr, size_t size, int prot, } } } else { - _unassert(flags & MAP_ANONYMOUS); + unassert(flags & MAP_ANONYMOUS); fl = (struct ProtectNt){kNtPageExecuteReadwrite, kNtFileMapWrite | kNtFileMapExecute}; } diff --git a/libc/intrin/extend.c b/libc/intrin/extend.c index 72435e2cf..c13a6e650 100644 --- a/libc/intrin/extend.c +++ b/libc/intrin/extend.c @@ -43,11 +43,11 @@ static void *_mapframe(void *p, int f) { if (!rc) { return p; } else { - _unassert(errno == ENOMEM); + unassert(errno == ENOMEM); return 0; } } else { - _unassert(errno == ENOMEM); + unassert(errno == ENOMEM); return 0; } } @@ -71,14 +71,14 @@ static void *_mapframe(void *p, int f) { * @return new value for `e` or null w/ errno * @raise ENOMEM if we require more vespene gas */ -noasan void *_extend(void *p, size_t n, void *e, int f, intptr_t h) { +dontasan void *_extend(void *p, size_t n, void *e, int f, intptr_t h) { char *q; - _unassert(!((uintptr_t)SHADOW(p) & (G - 1))); - _unassert((uintptr_t)p + (G << kAsanScale) <= h); + unassert(!((uintptr_t)SHADOW(p) & (G - 1))); + unassert((uintptr_t)p + (G << kAsanScale) <= h); // TODO(jart): Make this spin less in non-ASAN mode. for (q = e; q < ((char *)p + n); q += 8) { if (!((uintptr_t)q & (G - 1))) { - _unassert(q + G <= (char *)h); + unassert(q + G <= (char *)h); if (!_mapframe(q, f)) return 0; if (IsAsan()) { if (!((uintptr_t)SHADOW(q) & (G - 1))) { diff --git a/libc/intrin/findmemoryinterval.c b/libc/intrin/findmemoryinterval.c index 8891e5814..30d28690d 100644 --- a/libc/intrin/findmemoryinterval.c +++ b/libc/intrin/findmemoryinterval.c @@ -19,7 +19,7 @@ #include "libc/assert.h" #include "libc/runtime/memtrack.internal.h" -noasan unsigned FindMemoryInterval(const struct MemoryIntervals *mm, int x) { +dontasan unsigned FindMemoryInterval(const struct MemoryIntervals *mm, int x) { unsigned l, m, r; l = 0; r = mm->i; @@ -31,6 +31,6 @@ noasan unsigned FindMemoryInterval(const struct MemoryIntervals *mm, int x) { r = m; } } - _unassert(l == mm->i || x <= mm->p[l].y); + unassert(l == mm->i || x <= mm->p[l].y); return l; } diff --git a/libc/intrin/g_fds.c b/libc/intrin/g_fds.c index 7a9e4963e..db5f9ce8c 100644 --- a/libc/intrin/g_fds.c +++ b/libc/intrin/g_fds.c @@ -31,7 +31,7 @@ #include "libc/thread/thread.h" #ifdef __x86_64__ -STATIC_YOINK("_init_g_fds"); +__static_yoink("_init_g_fds"); #endif struct Fds g_fds; @@ -49,7 +49,7 @@ static textwindows dontinline void SetupWinStd(struct Fds *fds, int i, int x) { textstartup void __init_fds(void) { struct Fds *fds; __fds_lock_obj._type = PTHREAD_MUTEX_RECURSIVE; - fds = VEIL("r", &g_fds); + fds = __veil("r", &g_fds); fds->n = 4; atomic_store_explicit(&fds->f, 3, memory_order_relaxed); if (_weaken(_extend)) { @@ -73,9 +73,9 @@ textstartup void __init_fds(void) { fds->p[1].kind = pushpop(kFdSerial); fds->p[2].kind = pushpop(kFdSerial); } - fds->p[0].handle = VEIL("r", 0x3F8ull); - fds->p[1].handle = VEIL("r", 0x3F8ull); - fds->p[2].handle = VEIL("r", 0x3F8ull); + fds->p[0].handle = __veil("r", 0x3F8ull); + fds->p[1].handle = __veil("r", 0x3F8ull); + fds->p[2].handle = __veil("r", 0x3F8ull); } else if (IsWindows()) { SetupWinStd(fds, 0, kNtStdInputHandle); SetupWinStd(fds, 1, kNtStdOutputHandle); diff --git a/libc/intrin/getauxval.c b/libc/intrin/getauxval.c index f1fb2e2d4..986014305 100644 --- a/libc/intrin/getauxval.c +++ b/libc/intrin/getauxval.c @@ -16,28 +16,33 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/errno.h" +#include "libc/intrin/_getauxval.internal.h" #include "libc/runtime/runtime.h" -#include "libc/sysv/errfuns.h" +#include "libc/sysv/consts/auxv.h" /** - * Returns auxiliary value, or zero if kernel didn't provide it. + * Returns auxiliary value. * - * This function is typically regarded as a libc implementation detail; - * thus, the source code is the documentation. - * - * @return auxiliary value or 0 if `at` not found + * @return auxiliary value or 0 if `key` not found * @see libc/sysv/consts.sh * @see System Five Application Binary Interface § 3.4.3 * @error ENOENT when value not found * @asyncsignalsafe */ -unsigned long getauxval(unsigned long at) { - unsigned long res, *ap; - for (ap = __auxv; ap[0]; ap += 2) { - if (at == ap[0]) { - return ap[1]; +unsigned long getauxval(unsigned long key) { + struct AuxiliaryValue x; + x = _getauxval(key); + if (key == AT_PAGESZ) { + if (!x.isfound) { + x.value = 16384; } + x.isfound = true; + } + if (x.isfound) { + return x.value; + } else { + errno = ENOENT; + return 0; } - enoent(); - return 0; } diff --git a/libc/intrin/isdebuggerpresent.c b/libc/intrin/isdebuggerpresent.c index cf43ca0ef..321ed74a5 100644 --- a/libc/intrin/isdebuggerpresent.c +++ b/libc/intrin/isdebuggerpresent.c @@ -31,7 +31,7 @@ #define kBufSize 1024 #define kPid "TracerPid:\t" -static textwindows noasan bool IsBeingDebugged(void) { +static textwindows dontasan bool IsBeingDebugged(void) { return !!NtGetPeb()->BeingDebugged; } diff --git a/libc/intrin/iswsl.c b/libc/intrin/iswsl.c index 04bfca4e2..75a3ef391 100644 --- a/libc/intrin/iswsl.c +++ b/libc/intrin/iswsl.c @@ -38,9 +38,9 @@ bool IsWsl1(void) { if (res) return res & 1; if (!IsLinux()) return res = 2, false; int e = errno; - _unassert(__sys_mmap((void *)1, 4096, PROT_READ | PROT_WRITE, - MAP_FIXED | MAP_PRIVATE | ANONYMOUS | GROWSDOWN, -1, 0, - 0) == MAP_FAILED); + unassert(__sys_mmap((void *)1, 4096, PROT_READ | PROT_WRITE, + MAP_FIXED | MAP_PRIVATE | ANONYMOUS | GROWSDOWN, -1, 0, + 0) == MAP_FAILED); bool tmp = errno == ENOTSUP; errno = e; res = 2 | tmp; diff --git a/libc/intrin/kmalloc.c b/libc/intrin/kmalloc.c index aad715cd7..342e047f0 100644 --- a/libc/intrin/kmalloc.c +++ b/libc/intrin/kmalloc.c @@ -82,7 +82,7 @@ void *kmalloc(size_t size) { } __kmalloc_unlock(); if (p) { - _unassert(!((intptr_t)(p + i) & (KMALLOC_ALIGN - 1))); + unassert(!((intptr_t)(p + i) & (KMALLOC_ALIGN - 1))); if (IsAsan()) __asan_poison(p + i + size, n - size, kAsanHeapOverrun); return p + i; } else { diff --git a/libc/intrin/kprintf.greg.c b/libc/intrin/kprintf.greg.c index b6f9d8a11..b1436aa23 100644 --- a/libc/intrin/kprintf.greg.c +++ b/libc/intrin/kprintf.greg.c @@ -57,6 +57,7 @@ #include "libc/str/str.h" #include "libc/str/tab.internal.h" #include "libc/str/utf16.h" +#include "libc/sysv/consts/auxv.h" #include "libc/sysv/consts/nr.h" #include "libc/sysv/consts/prot.h" #include "libc/thread/tls.h" @@ -187,7 +188,7 @@ privileged bool kisdangerous(const void *p) { if (IsStackFrame(frame)) return false; if (kismapped(frame)) return false; } - if (GetStackAddr() + APE_GUARDSIZE <= (uintptr_t)p && + if (GetStackAddr() + 16384 <= (uintptr_t)p && (uintptr_t)p < GetStackAddr() + GetStackSize()) { return false; } diff --git a/libc/intrin/leaky.internal.h b/libc/intrin/leaky.internal.h index 225671a9a..da18dbc2d 100644 --- a/libc/intrin/leaky.internal.h +++ b/libc/intrin/leaky.internal.h @@ -4,7 +4,7 @@ COSMOPOLITAN_C_START_ #define IGNORE_LEAKS(FUNC) \ - STATIC_YOINK("_leaky_start"); \ + __static_yoink("_leaky_start"); \ void *_leaky_##FUNC[] _Section(".piro.relo.sort.leaky.2." #FUNC \ ",\"aw\",@init_array #") = {FUNC} diff --git a/libc/intrin/memchr.c b/libc/intrin/memchr.c index 807111263..16c0897fa 100644 --- a/libc/intrin/memchr.c +++ b/libc/intrin/memchr.c @@ -36,9 +36,9 @@ static inline const unsigned char *memchr_pure(const unsigned char *s, } #ifdef __x86_64__ -noasan static inline const unsigned char *memchr_sse(const unsigned char *s, - unsigned char c, - size_t n) { +dontasan static inline const unsigned char *memchr_sse(const unsigned char *s, + unsigned char c, + size_t n) { size_t i; unsigned k; unsigned m; diff --git a/libc/intrin/memrchr.c b/libc/intrin/memrchr.c index ea09e8c08..8e7f95714 100644 --- a/libc/intrin/memrchr.c +++ b/libc/intrin/memrchr.c @@ -36,9 +36,9 @@ static inline const unsigned char *memrchr_pure(const unsigned char *s, } #ifdef __x86_64__ -noasan static inline const unsigned char *memrchr_sse(const unsigned char *s, - unsigned char c, - size_t n) { +dontasan static inline const unsigned char *memrchr_sse(const unsigned char *s, + unsigned char c, + size_t n) { size_t i; unsigned k, m; xmm_t v, t = {c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c}; diff --git a/libc/intrin/memtrack.greg.c b/libc/intrin/memtrack.greg.c index 94ff2ad11..8713d0793 100644 --- a/libc/intrin/memtrack.greg.c +++ b/libc/intrin/memtrack.greg.c @@ -50,7 +50,7 @@ static void *MoveMemoryIntervals(struct MemoryInterval *d, const struct MemoryInterval *s, int n) { int i; - _unassert(n >= 0); + unassert(n >= 0); if (d > s) { for (i = n; i--;) { d[i] = s[i]; @@ -64,8 +64,8 @@ static void *MoveMemoryIntervals(struct MemoryInterval *d, } static void RemoveMemoryIntervals(struct MemoryIntervals *mm, int i, int n) { - _unassert(i >= 0); - _unassert(i + n <= mm->i); + unassert(i >= 0); + unassert(i + n <= mm->i); MoveMemoryIntervals(mm->p + i, mm->p + i + n, mm->i - (i + n)); mm->i -= n; } @@ -109,9 +109,9 @@ static bool ExtendMemoryIntervals(struct MemoryIntervals *mm) { } int CreateMemoryInterval(struct MemoryIntervals *mm, int i) { - _unassert(i >= 0); - _unassert(i <= mm->i); - _unassert(mm->n >= 0); + unassert(i >= 0); + unassert(i <= mm->i); + unassert(mm->n >= 0); if (UNLIKELY(mm->i == mm->n) && !ExtendMemoryIntervals(mm)) return enomem(); MoveMemoryIntervals(mm->p + i + 1, mm->p + i, mm->i++ - i); return 0; @@ -130,7 +130,7 @@ int ReleaseMemoryIntervals(struct MemoryIntervals *mm, int x, int y, void wf(struct MemoryIntervals *, int, int)) { unsigned l, r; ASSERT_MEMTRACK(); - _unassert(y >= x); + unassert(y >= x); if (!mm->i) return 0; // binary search for the lefthand side l = FindMemoryInterval(mm, x); @@ -140,8 +140,8 @@ int ReleaseMemoryIntervals(struct MemoryIntervals *mm, int x, int y, // binary search for the righthand side r = FindMemoryInterval(mm, y); if (r == mm->i || (r > l && y < mm->p[r].x)) --r; - _unassert(r >= l); - _unassert(x <= mm->p[r].y); + unassert(r >= l); + unassert(x <= mm->p[r].y); // remove the middle of an existing map // @@ -162,11 +162,11 @@ int ReleaseMemoryIntervals(struct MemoryIntervals *mm, int x, int y, // ----|mmmm|----------------- after // if (x > mm->p[l].x && x <= mm->p[l].y) { - _unassert(y >= mm->p[l].y); + unassert(y >= mm->p[l].y); if (IsWindows()) return einval(); mm->p[l].size -= (size_t)(mm->p[l].y - (x - 1)) * FRAMESIZE; mm->p[l].y = x - 1; - _unassert(mm->p[l].x <= mm->p[l].y); + unassert(mm->p[l].x <= mm->p[l].y); ++l; } @@ -177,11 +177,11 @@ int ReleaseMemoryIntervals(struct MemoryIntervals *mm, int x, int y, // ---------------|mm|-------- after // if (y >= mm->p[r].x && y < mm->p[r].y) { - _unassert(x <= mm->p[r].x); + unassert(x <= mm->p[r].x); if (IsWindows()) return einval(); mm->p[r].size -= (size_t)((y + 1) - mm->p[r].x) * FRAMESIZE; mm->p[r].x = y + 1; - _unassert(mm->p[r].x <= mm->p[r].y); + unassert(mm->p[r].x <= mm->p[r].y); --r; } @@ -199,7 +199,7 @@ int TrackMemoryInterval(struct MemoryIntervals *mm, int x, int y, long h, long offset, long size) { unsigned i; ASSERT_MEMTRACK(); - _unassert(y >= x); + unassert(y >= x); i = FindMemoryInterval(mm, x); // try to extend the righthand side of the lefthand entry diff --git a/libc/intrin/mman.greg.c b/libc/intrin/mman.greg.c index 70bcb9cd3..1c8523538 100644 --- a/libc/intrin/mman.greg.c +++ b/libc/intrin/mman.greg.c @@ -54,14 +54,14 @@ struct ReclaimedPage { /** * Allocates new page of physical memory. */ -noasan texthead uint64_t __new_page(struct mman *mm) { +dontasan texthead uint64_t __new_page(struct mman *mm) { uint64_t p = mm->frp; if (p != NOPAGE) { uint64_t q; struct ReclaimedPage *rp = (struct ReclaimedPage *)(BANE + p); - _unassert(p == (p & PAGE_TA)); + unassert(p == (p & PAGE_TA)); q = rp->next; - _unassert(q == (q & PAGE_TA) || q == NOPAGE); + unassert(q == (q & PAGE_TA) || q == NOPAGE); mm->frp = q; return p; } @@ -81,8 +81,8 @@ noasan texthead uint64_t __new_page(struct mman *mm) { * Returns pointer to page table entry for page at virtual address. * Additional page tables are allocated if needed as a side-effect. */ -noasan textreal uint64_t *__get_virtual(struct mman *mm, uint64_t *t, - int64_t vaddr, bool maketables) { +dontasan textreal uint64_t *__get_virtual(struct mman *mm, uint64_t *t, + int64_t vaddr, bool maketables) { uint64_t *e, p; unsigned char h; for (h = 39;; h -= 9) { @@ -101,7 +101,7 @@ noasan textreal uint64_t *__get_virtual(struct mman *mm, uint64_t *t, /** * Sorts, rounds, and filters BIOS memory map. */ -static noasan textreal void __normalize_e820(struct mman *mm, uint64_t top) { +static dontasan textreal void __normalize_e820(struct mman *mm, uint64_t top) { uint64_t a, b; uint64_t x, y; unsigned i, j, n; @@ -134,9 +134,10 @@ static noasan textreal void __normalize_e820(struct mman *mm, uint64_t top) { /** * Identity maps an area of physical memory to its negative address. */ -noasan textreal uint64_t *__invert_memory_area(struct mman *mm, uint64_t *pml4t, - uint64_t ps, uint64_t size, - uint64_t pte_flags) { +dontasan textreal uint64_t *__invert_memory_area(struct mman *mm, + uint64_t *pml4t, uint64_t ps, + uint64_t size, + uint64_t pte_flags) { uint64_t pe = ps + size, p, *m = NULL; ps = ROUNDDOWN(ps, 4096); pe = ROUNDUP(pe, 4096); @@ -152,7 +153,7 @@ noasan textreal uint64_t *__invert_memory_area(struct mman *mm, uint64_t *pml4t, /** * Increments the reference count for a page of physical memory. */ -noasan void __ref_page(struct mman *mm, uint64_t *pml4t, uint64_t p) { +dontasan void __ref_page(struct mman *mm, uint64_t *pml4t, uint64_t p) { uint64_t *m, e; m = __invert_memory_area(mm, pml4t, p, 4096, PAGE_RW | PAGE_XD); if (m) { @@ -167,8 +168,8 @@ noasan void __ref_page(struct mman *mm, uint64_t *pml4t, uint64_t p) { /** * Increments the reference counts for an area of physical memory. */ -noasan void __ref_pages(struct mman *mm, uint64_t *pml4t, uint64_t ps, - uint64_t size) { +dontasan void __ref_pages(struct mman *mm, uint64_t *pml4t, uint64_t ps, + uint64_t size) { uint64_t p = ROUNDDOWN(ps, 4096), e = ROUNDUP(ps + size, 4096); while (p != e) { __ref_page(mm, pml4t, p); @@ -179,9 +180,9 @@ noasan void __ref_pages(struct mman *mm, uint64_t *pml4t, uint64_t ps, /** * Reclaims a page of physical memory for later use. */ -static noasan void __reclaim_page(struct mman *mm, uint64_t p) { +static dontasan void __reclaim_page(struct mman *mm, uint64_t p) { struct ReclaimedPage *rp = (struct ReclaimedPage *)(BANE + p); - _unassert(p == (p & PAGE_TA)); + unassert(p == (p & PAGE_TA)); rp->next = mm->frp; mm->frp = p; } @@ -191,7 +192,7 @@ static noasan void __reclaim_page(struct mman *mm, uint64_t p) { * page if there are no virtual addresses (excluding the negative space) * referring to it. */ -noasan void __unref_page(struct mman *mm, uint64_t *pml4t, uint64_t p) { +dontasan void __unref_page(struct mman *mm, uint64_t *pml4t, uint64_t p) { uint64_t *m, e; m = __invert_memory_area(mm, pml4t, p, 4096, PAGE_RW | PAGE_XD); if (m) { @@ -207,7 +208,8 @@ noasan void __unref_page(struct mman *mm, uint64_t *pml4t, uint64_t p) { /** * Identity maps all usable physical memory to its negative address. */ -static noasan textreal void __invert_memory(struct mman *mm, uint64_t *pml4t) { +static dontasan textreal void __invert_memory(struct mman *mm, + uint64_t *pml4t) { uint64_t i, j, *m, p, pe; for (i = 0; i < mm->e820n; ++i) { uint64_t ps = mm->e820[i].addr, size = mm->e820[i].size; @@ -230,8 +232,8 @@ static noasan textreal void __invert_memory(struct mman *mm, uint64_t *pml4t) { : "i"(offsetof(type, member))); \ } while (0) -noasan textreal void __setup_mman(struct mman *mm, uint64_t *pml4t, - uint64_t top) { +dontasan textreal void __setup_mman(struct mman *mm, uint64_t *pml4t, + uint64_t top) { export_offsetof(struct mman, pc_drive_base_table); export_offsetof(struct mman, pc_drive_last_sector); export_offsetof(struct mman, pc_drive_last_head); @@ -257,8 +259,8 @@ noasan textreal void __setup_mman(struct mman *mm, uint64_t *pml4t, /** * Maps APE-defined ELF program headers into memory and clears BSS. */ -noasan textreal void __map_phdrs(struct mman *mm, uint64_t *pml4t, uint64_t b, - uint64_t top) { +dontasan textreal void __map_phdrs(struct mman *mm, uint64_t *pml4t, uint64_t b, + uint64_t top) { struct Elf64_Phdr *p; uint64_t i, f, v, m, *e; extern char ape_phdrs[] __attribute__((__weak__)); @@ -292,8 +294,9 @@ noasan textreal void __map_phdrs(struct mman *mm, uint64_t *pml4t, uint64_t b, * Reclaims memory pages which were used at boot time but which can now be * made available for the application. */ -noasan textreal void __reclaim_boot_pages(struct mman *mm, uint64_t skip_start, - uint64_t skip_end) { +dontasan textreal void __reclaim_boot_pages(struct mman *mm, + uint64_t skip_start, + uint64_t skip_end) { uint64_t p = mm->frp, q = IMAGE_BASE_REAL, i, n = mm->e820n, b, e; for (i = 0; i < n; ++i) { b = mm->e820[i].addr; diff --git a/libc/intrin/mmi.c b/libc/intrin/mmi.c index 4ba2a87ca..500946218 100644 --- a/libc/intrin/mmi.c +++ b/libc/intrin/mmi.c @@ -21,7 +21,7 @@ #include "libc/thread/thread.h" #ifdef __x86_64__ -STATIC_YOINK("_init__mmi"); +__static_yoink("_init__mmi"); #endif struct MemoryIntervals _mmi; diff --git a/libc/intrin/nocolor.c b/libc/intrin/nocolor.c index 316f3eda6..60ad3efa9 100644 --- a/libc/intrin/nocolor.c +++ b/libc/intrin/nocolor.c @@ -48,9 +48,9 @@ */ bool __nocolor; -optimizesize textstartup noasan void __nocolor_init(int argc, char **argv, - char **envp, - intptr_t *auxv) { +optimizesize textstartup dontasan void __nocolor_init(int argc, char **argv, + char **envp, + intptr_t *auxv) { char *s; __nocolor = (IsWindows() && !IsAtLeastWindows10()) || ((s = getenv("TERM")) && IsDumb(s)); diff --git a/libc/intrin/ntgetversion.c b/libc/intrin/ntgetversion.c index f6741ad10..5b88bce1c 100644 --- a/libc/intrin/ntgetversion.c +++ b/libc/intrin/ntgetversion.c @@ -27,7 +27,7 @@ * * @see IsAtLeastWindows10() */ -textwindows noasan int NtGetVersion(void) { +textwindows dontasan int NtGetVersion(void) { return (NtGetPeb()->OSMajorVersion & 0xff) << 8 | NtGetPeb()->OSMinorVersion; } diff --git a/libc/intrin/pthread_cleanup_pop.c b/libc/intrin/pthread_cleanup_pop.c index a6c9bb255..abe8de4a8 100644 --- a/libc/intrin/pthread_cleanup_pop.c +++ b/libc/intrin/pthread_cleanup_pop.c @@ -24,7 +24,7 @@ void(pthread_cleanup_pop)(struct _pthread_cleanup_buffer *cb, int execute) { struct PosixThread *pt; if (__tls_enabled && (pt = (struct PosixThread *)__get_tls()->tib_pthread)) { - _unassert(cb == pt->cleanup); + unassert(cb == pt->cleanup); pt->cleanup = cb->__prev; } if (execute) { diff --git a/libc/intrin/pthread_getspecific.c b/libc/intrin/pthread_getspecific.c index da02050e9..abcc81eb9 100644 --- a/libc/intrin/pthread_getspecific.c +++ b/libc/intrin/pthread_getspecific.c @@ -35,7 +35,7 @@ void *pthread_getspecific(pthread_key_t k) { // pthread_key_create() or after key has been deleted with // pthread_key_delete() is undefined." // ──Quoth POSIX.1-2017 - _unassert(0 <= k && k < PTHREAD_KEYS_MAX); - _unassert(atomic_load_explicit(_pthread_key_dtor + k, memory_order_acquire)); + unassert(0 <= k && k < PTHREAD_KEYS_MAX); + unassert(atomic_load_explicit(_pthread_key_dtor + k, memory_order_acquire)); return __get_tls()->tib_keys[k]; } diff --git a/libc/intrin/pthread_key_delete.c b/libc/intrin/pthread_key_delete.c index 67d3c3db5..fce775dd1 100644 --- a/libc/intrin/pthread_key_delete.c +++ b/libc/intrin/pthread_key_delete.c @@ -35,8 +35,8 @@ */ int pthread_key_delete(pthread_key_t k) { uint64_t mask; - _unassert(0 <= k && k < PTHREAD_KEYS_MAX); - _unassert(atomic_load_explicit(_pthread_key_dtor + k, memory_order_acquire)); + unassert(0 <= k && k < PTHREAD_KEYS_MAX); + unassert(atomic_load_explicit(_pthread_key_dtor + k, memory_order_acquire)); atomic_store_explicit(_pthread_key_dtor + k, 0, memory_order_release); return 0; } diff --git a/libc/intrin/pthread_setspecific.c b/libc/intrin/pthread_setspecific.c index 2a5295307..92ee5088b 100644 --- a/libc/intrin/pthread_setspecific.c +++ b/libc/intrin/pthread_setspecific.c @@ -35,8 +35,8 @@ int pthread_setspecific(pthread_key_t k, const void *val) { // pthread_key_create() or after key has been deleted with // pthread_key_delete() is undefined." // ──Quoth POSIX.1-2017 - _unassert(0 <= k && k < PTHREAD_KEYS_MAX); - _unassert(atomic_load_explicit(_pthread_key_dtor + k, memory_order_acquire)); + unassert(0 <= k && k < PTHREAD_KEYS_MAX); + unassert(atomic_load_explicit(_pthread_key_dtor + k, memory_order_acquire)); __get_tls()->tib_keys[k] = val; return 0; } diff --git a/libc/intrin/pthread_spin_lock.c b/libc/intrin/pthread_spin_lock.c index 1fce825df..ef5e978de 100644 --- a/libc/intrin/pthread_spin_lock.c +++ b/libc/intrin/pthread_spin_lock.c @@ -48,14 +48,14 @@ errno_t(pthread_spin_lock)(pthread_spinlock_t *spin) { LOCKTRACE("pthread_spin_lock(%t)", spin); break; } - _unassert(x == 1); + unassert(x == 1); LOCKTRACE("pthread_spin_lock(%t) trying...", spin); } #else for (;;) { x = atomic_exchange_explicit(&spin->_lock, 1, memory_order_acquire); if (!x) break; - _unassert(x == 1); + unassert(x == 1); } #endif return 0; diff --git a/libc/intrin/pthread_spin_trylock.c b/libc/intrin/pthread_spin_trylock.c index 34376fabb..66c36f9bc 100644 --- a/libc/intrin/pthread_spin_trylock.c +++ b/libc/intrin/pthread_spin_trylock.c @@ -34,6 +34,6 @@ errno_t(pthread_spin_trylock)(pthread_spinlock_t *spin) { int x; x = atomic_exchange_explicit(&spin->_lock, 1, memory_order_acquire); if (!x) return 0; - _unassert(x == 1); + unassert(x == 1); return EBUSY; } diff --git a/libc/intrin/stpcpy.c b/libc/intrin/stpcpy.c index 0dab9b320..8d1fa3999 100644 --- a/libc/intrin/stpcpy.c +++ b/libc/intrin/stpcpy.c @@ -33,7 +33,7 @@ typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16))); * @return pointer to nul byte * @asyncsignalsafe */ -noasan char *stpcpy(char *d, const char *s) { +dontasan char *stpcpy(char *d, const char *s) { size_t i = 0; if (IsAsan()) { __asan_verify(d, strlen(s) + 1); diff --git a/libc/intrin/strchr.c b/libc/intrin/strchr.c index 4190b9191..60cc9cdd5 100644 --- a/libc/intrin/strchr.c +++ b/libc/intrin/strchr.c @@ -32,7 +32,7 @@ static inline const char *strchr_pure(const char *s, int c) { #ifdef __x86_64__ typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16))); -noasan static inline const char *strchr_sse(const char *s, unsigned char c) { +dontasan static inline const char *strchr_sse(const char *s, unsigned char c) { unsigned k; unsigned m; xmm_t v, *p; @@ -55,7 +55,7 @@ noasan static inline const char *strchr_sse(const char *s, unsigned char c) { } #endif -static noasan inline const char *strchr_x64(const char *p, uint64_t c) { +static dontasan inline const char *strchr_x64(const char *p, uint64_t c) { unsigned a, b; uint64_t w, x, y; for (c *= 0x0101010101010101;; p += 8) { @@ -103,7 +103,7 @@ char *strchr(const char *s, int c) { } else { r = strchr_pure(s, c); } - _unassert(!r || *r || !(c & 255)); + unassert(!r || *r || !(c & 255)); return (char *)r; #else char *r; @@ -112,7 +112,7 @@ char *strchr(const char *s, int c) { if (!*s) return NULL; } r = strchr_x64(s, c); - _unassert(!r || *r || !c); + unassert(!r || *r || !c); return r; #endif } diff --git a/libc/intrin/strchrnul.c b/libc/intrin/strchrnul.c index f3571b042..7861219f6 100644 --- a/libc/intrin/strchrnul.c +++ b/libc/intrin/strchrnul.c @@ -32,7 +32,8 @@ static inline const char *strchrnul_pure(const char *s, int c) { #ifdef __x86_64__ typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16))); -noasan static inline const char *strchrnul_sse(const char *s, unsigned char c) { +dontasan static inline const char *strchrnul_sse(const char *s, + unsigned char c) { unsigned k; unsigned m; xmm_t v, *p; @@ -52,7 +53,7 @@ noasan static inline const char *strchrnul_sse(const char *s, unsigned char c) { } #endif -noasan static const char *strchrnul_x64(const char *p, uint64_t c) { +dontasan static const char *strchrnul_x64(const char *p, uint64_t c) { unsigned a, b; uint64_t w, x, y; for (c *= 0x0101010101010101;; p += 8) { @@ -101,7 +102,7 @@ char *strchrnul(const char *s, int c) { } else { r = strchrnul_pure(s, c); } - _unassert((*r & 255) == (c & 255) || !*r); + unassert((*r & 255) == (c & 255) || !*r); return (char *)r; #else char *r; diff --git a/libc/intrin/strcmp.c b/libc/intrin/strcmp.c index c93cdfb00..484ed0a8e 100644 --- a/libc/intrin/strcmp.c +++ b/libc/intrin/strcmp.c @@ -29,7 +29,7 @@ * @return is <0, 0, or >0 based on uint8_t comparison * @asyncsignalsafe */ -noasan int strcmp(const char *a, const char *b) { +dontasan int strcmp(const char *a, const char *b) { int c; size_t i = 0; uint64_t v, w, d; diff --git a/libc/intrin/strcpy.c b/libc/intrin/strcpy.c index b4f4e907e..48a4a22f4 100644 --- a/libc/intrin/strcpy.c +++ b/libc/intrin/strcpy.c @@ -34,7 +34,7 @@ typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16))); * @return original dest * @asyncsignalsafe */ -noasan char *strcpy(char *d, const char *s) { +dontasan char *strcpy(char *d, const char *s) { size_t i = 0; if (IsAsan()) { __asan_verify(d, strlen(s) + 1); diff --git a/libc/intrin/strlen.c b/libc/intrin/strlen.c index 30d2a4db4..0bdaa3f14 100644 --- a/libc/intrin/strlen.c +++ b/libc/intrin/strlen.c @@ -28,7 +28,7 @@ * @return number of bytes (excluding NUL) * @asyncsignalsafe */ -noasan size_t strlen(const char *s) { +dontasan size_t strlen(const char *s) { if (IsAsan()) __asan_verify_str(s); #ifdef __x86_64__ typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16))); diff --git a/libc/intrin/strnlen.c b/libc/intrin/strnlen.c index 9411ae1fb..02dd4aee4 100644 --- a/libc/intrin/strnlen.c +++ b/libc/intrin/strnlen.c @@ -23,7 +23,7 @@ #include "libc/str/str.h" #ifndef __aarch64__ -static noasan size_t strnlen_x64(const char *s, size_t n, size_t i) { +static dontasan size_t strnlen_x64(const char *s, size_t n, size_t i) { uint64_t w; for (; i + 8 < n; i += 8) { w = *(uint64_t *)(s + i); @@ -43,7 +43,7 @@ static noasan size_t strnlen_x64(const char *s, size_t n, size_t i) { * @return byte length * @asyncsignalsafe */ -noasan size_t strnlen(const char *s, size_t n) { +dontasan size_t strnlen(const char *s, size_t n) { size_t i; if (IsAsan() && n) __asan_verify(s, 1); for (i = 0; (uintptr_t)(s + i) & 7; ++i) { @@ -53,7 +53,7 @@ noasan size_t strnlen(const char *s, size_t n) { for (;; ++i) { if (i == n || !s[i]) break; } - _unassert(i == n || (i < n && !s[i])); + unassert(i == n || (i < n && !s[i])); if (IsAsan()) __asan_verify(s, i); return i; } diff --git a/libc/intrin/ubsan.c b/libc/intrin/ubsan.c index 35d8c101c..9b128584a 100644 --- a/libc/intrin/ubsan.c +++ b/libc/intrin/ubsan.c @@ -204,7 +204,7 @@ static wontreturn void __ubsan_unreachable(void) { static void __ubsan_exit(void) { kprintf("your ubsan runtime needs\n" - "\tSTATIC_YOINK(\"__die\");\n" + "\t__static_yoink(\"__die\");\n" "in order to show you backtraces\n"); _Exitr(99); } diff --git a/libc/intrin/wsarecv.c b/libc/intrin/wsarecv.c index 4f52c3e61..89cbf35bf 100644 --- a/libc/intrin/wsarecv.c +++ b/libc/intrin/wsarecv.c @@ -44,7 +44,7 @@ textwindows int WSARecv( // Use NULL for this parameter if the lpOverlapped parameter is not // NULL to avoid potentially erroneous results. This parameter can // be NULL only if the lpOverlapped parameter is not NULL. - _unassert(!opt_out_lpNumberOfBytesRecvd); + unassert(!opt_out_lpNumberOfBytesRecvd); } #if defined(SYSDEBUG) && _NTTRACE uint32_t NumberOfBytesRecvd; diff --git a/libc/log/backtrace3.c b/libc/log/backtrace3.c index 2ca2270ae..a95921f32 100644 --- a/libc/log/backtrace3.c +++ b/libc/log/backtrace3.c @@ -45,7 +45,7 @@ * @param st is open symbol table for current executable * @return -1 w/ errno if error happened */ -dontinstrument noasan int PrintBacktraceUsingSymbols( +dontinstrument dontasan int PrintBacktraceUsingSymbols( int fd, const struct StackFrame *bp, struct SymbolTable *st) { bool ok; size_t gi; diff --git a/libc/log/checkfail.c b/libc/log/checkfail.c index c2d04900b..e4112eabe 100644 --- a/libc/log/checkfail.c +++ b/libc/log/checkfail.c @@ -31,7 +31,7 @@ #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" -STATIC_YOINK("strerror_wr"); +__static_yoink("strerror_wr"); /** * Handles failure of CHECK_xx() macros. diff --git a/libc/log/countexpr_report.c b/libc/log/countexpr_report.c index 4f13555cf..5ad8f431d 100644 --- a/libc/log/countexpr_report.c +++ b/libc/log/countexpr_report.c @@ -53,7 +53,7 @@ static void PrintHistogram(const long *h, size_t n, long t) { unsigned long logos; for (i = 0; i < n; ++i) { p = (h[i] * 10000 + (t >> 1)) / t; - _unassert(0 <= p && p <= 10000); + unassert(0 <= p && p <= 10000); if (p) { for (j = 0; j < p / 100; ++j) s[j] = '#'; s[j] = 0; diff --git a/libc/log/die.c b/libc/log/die.c index 15c064847..b8b739abe 100644 --- a/libc/log/die.c +++ b/libc/log/die.c @@ -32,7 +32,7 @@ #include "libc/thread/thread.h" #if SupportsMetal() -STATIC_YOINK("_idt"); +__static_yoink("_idt"); #endif /** diff --git a/libc/log/leaks.c b/libc/log/leaks.c index 75cffaaab..d39ba5eb2 100644 --- a/libc/log/leaks.c +++ b/libc/log/leaks.c @@ -28,14 +28,14 @@ #include "libc/runtime/runtime.h" #include "libc/testlib/testlib.h" -STATIC_YOINK("GetSymbolByAddr"); +__static_yoink("GetSymbolByAddr"); #define MAXLEAKS 1000 static bool once; static bool hasleaks; -static noasan void CheckLeak(void *x, void *y, size_t n, void *a) { +static dontasan void CheckLeak(void *x, void *y, size_t n, void *a) { if (n) { if (IsAsan()) { if (__asan_get_heap_size(x) && !__asan_is_leaky(x)) { @@ -47,7 +47,7 @@ static noasan void CheckLeak(void *x, void *y, size_t n, void *a) { } } -static noasan void OnMemory(void *x, void *y, size_t n, void *a) { +static dontasan void OnMemory(void *x, void *y, size_t n, void *a) { static int i; if (n) { if (MAXLEAKS) { @@ -67,7 +67,7 @@ static noasan void OnMemory(void *x, void *y, size_t n, void *a) { } } -static noasan bool HasLeaks(void) { +static dontasan bool HasLeaks(void) { malloc_inspect_all(CheckLeak, 0); return hasleaks; } @@ -79,7 +79,7 @@ static noasan bool HasLeaks(void) { * services that depend on malloc() cannot be used, after calling this * function. */ -noasan void CheckForMemoryLeaks(void) { +dontasan void CheckForMemoryLeaks(void) { struct mallinfo mi; if (!IsAsan()) return; // we need traces to exclude leaky if (!_cmpxchg(&once, false, true)) { diff --git a/libc/log/memlog.c b/libc/log/memlog.c index fc0de9cbe..f631276f2 100644 --- a/libc/log/memlog.c +++ b/libc/log/memlog.c @@ -35,7 +35,7 @@ * * If you put the following in your main file: * - * STATIC_YOINK("enable_memory_log"); + * __static_yoink("enable_memory_log"); * * Then memory allocations with constant backtraces will be logged to * standard error. The columns printed are @@ -146,7 +146,7 @@ static void __memlog_update(void *p2, void *p) { __memlog.usage += n - __memlog.allocs.p[i].size; __memlog.allocs.p[i].addr = p2; __memlog.allocs.p[i].size = n; - _unassert(__memlog.usage >= 0); + unassert(__memlog.usage >= 0); return; } } @@ -170,20 +170,20 @@ static void __memlog_free(void *p) { __memlog.allocs.p[i].addr = 0; __memlog.usage -= __memlog.allocs.p[i].size; __memlog.allocs.f = MIN(__memlog.allocs.f, i); - _unassert(__memlog.usage >= 0); + unassert(__memlog.usage >= 0); } else { kprintf("memlog could not find %p\n", p); notpossible; } __memlog_unlock(); - _unassert(__memlog.free); + unassert(__memlog.free); __memlog.free(p); __memlog_log(__builtin_frame_address(0), "free", 0, p, n); } static void *__memlog_malloc(size_t n) { void *res; - _unassert(__memlog.malloc); + unassert(__memlog.malloc); if ((res = __memlog.malloc(n))) { __memlog_lock(); __memlog_insert(res); @@ -195,7 +195,7 @@ static void *__memlog_malloc(size_t n) { static void *__memlog_calloc(size_t n, size_t z) { void *res; - _unassert(__memlog.calloc); + unassert(__memlog.calloc); if ((res = __memlog.calloc(n, z))) { __memlog_lock(); __memlog_insert(res); @@ -207,7 +207,7 @@ static void *__memlog_calloc(size_t n, size_t z) { static void *__memlog_memalign(size_t l, size_t n) { void *res; - _unassert(__memlog.memalign); + unassert(__memlog.memalign); if ((res = __memlog.memalign(l, n))) { __memlog_lock(); __memlog_insert(res); @@ -221,7 +221,7 @@ static void *__memlog_realloc_impl(void *p, size_t n, void *(*f)(void *, size_t), struct StackFrame *frame) { void *res; - _unassert(f); + unassert(f); if ((res = f(p, n))) { __memlog_lock(); if (p) { diff --git a/libc/log/oncrash_amd64.c b/libc/log/oncrash_amd64.c index 803f7f46c..6e3ae0d5f 100644 --- a/libc/log/oncrash_amd64.c +++ b/libc/log/oncrash_amd64.c @@ -45,13 +45,14 @@ #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" +#include "libc/sysv/consts/auxv.h" #include "libc/sysv/consts/sig.h" #include "libc/thread/thread.h" #include "libc/thread/tls.h" #ifdef __x86_64__ -STATIC_YOINK("strerror_wr"); // for kprintf %m -STATIC_YOINK("strsignal_r"); // for kprintf %G +__static_yoink("strerror_wr"); // for kprintf %m +__static_yoink("strsignal_r"); // for kprintf %G static const char kGregOrder[17] forcealign(1) = { 13, 11, 8, 14, 12, 9, 10, 15, 16, 0, 1, 2, 3, 4, 5, 6, 7, @@ -219,7 +220,7 @@ relegated void ShowCrashReport(int err, int sig, struct siginfo *si, uname(&names); errno = err; // TODO(jart): Buffer the WHOLE crash report with backtrace for atomic write. - _npassert((p = buf = kmalloc((n = 1024 * 1024)))); + npassert((p = buf = kmalloc((n = 1024 * 1024)))); p += ksnprintf( p, n, "\n%serror%s: Uncaught %G (%s) on %s pid %d tid %d\n" @@ -227,8 +228,9 @@ relegated void ShowCrashReport(int err, int sig, struct siginfo *si, " %s\n" " %s %s %s %s\n", !__nocolor ? "\e[30;101m" : "", !__nocolor ? "\e[0m" : "", sig, - (ctx && (ctx->uc_mcontext.rsp >= GetStaticStackAddr(0) && - ctx->uc_mcontext.rsp <= GetStaticStackAddr(0) + APE_GUARDSIZE)) + (ctx && + (ctx->uc_mcontext.rsp >= GetStaticStackAddr(0) && + ctx->uc_mcontext.rsp <= GetStaticStackAddr(0) + getauxval(AT_PAGESZ))) ? "Stack Overflow" : GetSiCodeName(sig, si->si_code), host, getpid(), gettid(), program_invocation_name, strerror(err), diff --git a/libc/log/oncrash_arm64.c b/libc/log/oncrash_arm64.c index 8a6249416..82232a32d 100644 --- a/libc/log/oncrash_arm64.c +++ b/libc/log/oncrash_arm64.c @@ -39,12 +39,13 @@ #include "libc/runtime/symbols.internal.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" +#include "libc/sysv/consts/auxv.h" #include "libc/sysv/consts/sig.h" #include "libc/thread/thread.h" #ifdef __aarch64__ -STATIC_YOINK("strerror_wr"); // for kprintf %m -STATIC_YOINK("strsignal_r"); // for kprintf %G +__static_yoink("strerror_wr"); // for kprintf %m +__static_yoink("strsignal_r"); // for kprintf %G #define RESET "\e[0m" #define BOLD "\e[1m" @@ -197,7 +198,8 @@ relegated void __oncrash_arm64(int sig, struct siginfo *si, void *arg) { gethostname(host, sizeof(host)); reset = !__nocolor ? RESET : ""; strong = !__nocolor ? STRONG : ""; - if (ctx && (ctx->uc_mcontext.sp & (GetStackSize() - 1)) <= APE_GUARDSIZE) { + if (ctx && + (ctx->uc_mcontext.sp & (GetStackSize() - 1)) <= getauxval(AT_PAGESZ)) { kind = "Stack Overflow"; } else { kind = GetSiCodeName(sig, si->si_code); diff --git a/libc/log/showcrashreports.c b/libc/log/showcrashreports.c index d17a2ce6d..97500f6aa 100644 --- a/libc/log/showcrashreports.c +++ b/libc/log/showcrashreports.c @@ -37,13 +37,13 @@ #include "libc/sysv/consts/sig.h" #include "libc/sysv/consts/ss.h" -STATIC_YOINK("zipos"); // for symtab -STATIC_YOINK("__die"); // for backtracing -STATIC_YOINK("ShowBacktrace"); // for backtracing -STATIC_YOINK("GetSymbolTable"); // for backtracing -STATIC_YOINK("PrintBacktraceUsingSymbols"); // for backtracing -STATIC_YOINK("malloc_inspect_all"); // for asan memory origin -STATIC_YOINK("GetSymbolByAddr"); // for asan memory origin +__static_yoink("zipos"); // for symtab +__static_yoink("__die"); // for backtracing +__static_yoink("ShowBacktrace"); // for backtracing +__static_yoink("GetSymbolTable"); // for backtracing +__static_yoink("PrintBacktraceUsingSymbols"); // for backtracing +__static_yoink("malloc_inspect_all"); // for asan memory origin +__static_yoink("GetSymbolByAddr"); // for asan memory origin struct CrashHandler { int sig; @@ -147,8 +147,8 @@ void ShowCrashReports(void) { ss.ss_size = GetStackSize(); // FreeBSD sigaltstack() will EFAULT if we use MAP_STACK here // OpenBSD sigaltstack() auto-applies MAP_STACK to the memory - _npassert((ss.ss_sp = _mapanon(GetStackSize()))); - _npassert(!sigaltstack(&ss, 0)); + npassert((ss.ss_sp = _mapanon(GetStackSize()))); + npassert(!sigaltstack(&ss, 0)); } InstallCrashHandler(SIGQUIT, __got_sigquit, ef); // ctrl+\ aka ctrl+break InstallCrashHandler(SIGFPE, __got_sigfpe, ef); // 1 / 0 diff --git a/libc/log/showcrashreportsearly.S b/libc/log/showcrashreportsearly.S index e6cd7ed1b..e29871fa4 100644 --- a/libc/log/showcrashreportsearly.S +++ b/libc/log/showcrashreportsearly.S @@ -22,7 +22,7 @@ // there's a crash in a constructor, this will help with // troubleshooting it. You need to add: // -// STATIC_YOINK("ShowCrashReportsEarly"); +// __static_yoink("ShowCrashReportsEarly"); // // To the top of your main module to use this. diff --git a/libc/mem/arena.c b/libc/mem/arena.c index 4bab05c88..7bb14cb8e 100644 --- a/libc/mem/arena.c +++ b/libc/mem/arena.c @@ -64,12 +64,12 @@ static wontreturn void __arena_die(void) { } forceinline void __arena_check(void) { - _unassert(__arena.depth); + unassert(__arena.depth); } forceinline void __arena_check_pointer(void *p) { - _unassert(BASE + __arena.offset[__arena.depth - 1] <= (uintptr_t)p && - (uintptr_t)p < BASE + __arena.offset[__arena.depth]); + unassert(BASE + __arena.offset[__arena.depth - 1] <= (uintptr_t)p && + (uintptr_t)p < BASE + __arena.offset[__arena.depth]); } forceinline bool __arena_is_arena_pointer(void *p) { @@ -322,7 +322,7 @@ void __arena_push(void) { if (!__arena.depth) { __arena_install(); } else { - _unassert(__arena.depth < ARRAYLEN(__arena.offset) - 1); + unassert(__arena.depth < ARRAYLEN(__arena.offset) - 1); } __arena.offset[__arena.depth + 1] = __arena.offset[__arena.depth]; ++__arena.depth; diff --git a/libc/mem/gc.c b/libc/mem/gc.c index ab0c2697b..538f38361 100644 --- a/libc/mem/gc.c +++ b/libc/mem/gc.c @@ -93,8 +93,8 @@ static void DeferFunction(struct StackFrame *frame, void *fn, void *arg) { void __defer(void *rbp, void *fn, void *arg) { struct StackFrame *f, *frame = rbp; f = __builtin_frame_address(0); - _unassert(f->next == frame); - _unassert(PointerNotOwnedByParentStackFrame(f, frame, arg)); + unassert(f->next == frame); + unassert(PointerNotOwnedByParentStackFrame(f, frame, arg)); DeferFunction(frame, fn, arg); } diff --git a/libc/mem/sortedints.c b/libc/mem/sortedints.c index 074e0956a..cc4fc1663 100644 --- a/libc/mem/sortedints.c +++ b/libc/mem/sortedints.c @@ -51,8 +51,8 @@ int LeftmostInt(const struct SortedInts *t, int k) { r = m; } } - _unassert(l == 0 || k >= t->p[l - 1]); - _unassert(l == t->n || k <= t->p[l]); + unassert(l == 0 || k >= t->p[l - 1]); + unassert(l == t->n || k <= t->p[l]); return l; } @@ -70,8 +70,8 @@ int CountInt(const struct SortedInts *t, int k) { bool InsertInt(struct SortedInts *t, int k, bool u) { int l; - _unassert(t->n >= 0); - _unassert(t->n <= t->c); + unassert(t->n >= 0); + unassert(t->n <= t->c); if (t->n == t->c) { ++t->c; if (!IsModeDbg()) { diff --git a/libc/nexgen32e/blink_linux_aarch64.S b/libc/nexgen32e/blink_linux_aarch64.S index 8fcbcd86f..0f084488d 100644 --- a/libc/nexgen32e/blink_linux_aarch64.S +++ b/libc/nexgen32e/blink_linux_aarch64.S @@ -23,7 +23,7 @@ // If you want to support Raspberry Pi by embedding an emulator // in your APE binary that runs automatically, then put this: // -// STATIC_YOINK("blink_linux_aarch64"); +// __static_yoink("blink_linux_aarch64"); // // In your main.c file, to pull it into linkage from the static // archive. Alternatively, you may simply add blink_linux_aarch64.o diff --git a/libc/nexgen32e/blink_xnu_aarch64.S b/libc/nexgen32e/blink_xnu_aarch64.S index 5620420e4..2544af91b 100644 --- a/libc/nexgen32e/blink_xnu_aarch64.S +++ b/libc/nexgen32e/blink_xnu_aarch64.S @@ -23,7 +23,7 @@ // If you want to support Apple M1 by embedding an emulator in // your APE binary that runs automatically, then put this: // -// STATIC_YOINK("blink_xnu_aarch64"); +// __static_yoink("blink_xnu_aarch64"); // // In your main.c file, to pull it into linkage from the static // archive. Alternatively, you may simply add blink_xnu_aarch64.o diff --git a/libc/nt/struct/imagesectionheader.internal.h b/libc/nt/struct/imagesectionheader.internal.h index 23c733606..7da391fac 100644 --- a/libc/nt/struct/imagesectionheader.internal.h +++ b/libc/nt/struct/imagesectionheader.internal.h @@ -3,14 +3,60 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) struct NtImageSectionHeader { + uint8_t Name[8]; + union { + uint32_t PhysicalAddress; + + /* + * The total size of the section when loaded into memory. If this + * value is greater than SizeOfRawData, the section is zero-padded. + * This field is valid only for executable images and should be set + * to zero for object files. + */ uint32_t VirtualSize; + } Misc; + + /* + * In an image file, the VAs for sections must be assigned by the + * linker so that they are in ascending order and adjacent, and they + * must be a multiple of the SectionAlignment value in the optional + * header. + * + * For executable images, the address of the first byte of the section + * relative to the image base when the section is loaded into memory. + * For object files, this field is the address of the first byte + * before relocation is applied; for simplicity, compilers should set + * this to zero. Otherwise, it is an arbitrary value that is + * subtracted from offsets during relocation. + */ uint32_t VirtualAddress; + + /* + * The size of the section (for object files) or the size of the + * initialized data on disk (for image files). For executable images, + * this must be a multiple of FileAlignment from the optional header. + * If this is less than VirtualSize, the remainder of the section is + * zero-filled. Because the SizeOfRawData field is rounded but the + * VirtualSize field is not, it is possible for SizeOfRawData to be + * greater than VirtualSize as well. When a section contains only + * uninitialized data, this field should be zero. + */ uint32_t SizeOfRawData; + + /* + * The file pointer to the first page of the section within the COFF + * file. For executable images, this must be a multiple of + * FileAlignment from the optional header. For object files, the value + * should be aligned on a 4-byte boundary for best performance. When a + * section contains only uninitialized data, this field should be + * zero. + */ uint32_t PointerToRawData; + uint32_t PointerToRelocations; uint32_t PointerToLinenumbers; uint16_t NumberOfRelocations; diff --git a/libc/nt/struct/teb.h b/libc/nt/struct/teb.h index a8e056175..8b643af79 100644 --- a/libc/nt/struct/teb.h +++ b/libc/nt/struct/teb.h @@ -7,7 +7,7 @@ /* * These macros address directly into NT's TEB a.k.a. TIB - * Any function that does this needs the `noasan` keyword + * Any function that does this needs the `dontasan` keyword */ #define NtGetPeb() gs((struct NtPeb **)(0x60ULL)) #define NtGetTeb() gs((void **)(0x30)) /* %gs:0 linear address */ diff --git a/libc/runtime/__sigsetjmp_tail.c b/libc/runtime/__sigsetjmp_tail.c index c564416bc..3eb4f87cc 100644 --- a/libc/runtime/__sigsetjmp_tail.c +++ b/libc/runtime/__sigsetjmp_tail.c @@ -28,7 +28,7 @@ int __sigsetjmp_tail(sigjmp_buf jb, int rc) { sizeof(sigjmp_buf) == sizeof(jmp_buf) + 8 + 8 + sizeof(sigset_t), "please recompute sigjmp_buf w.r.t. sigset_t"); void *p = (char *)jb + sizeof(jmp_buf) + 8 + 8; - _npassert(!sigprocmask(SIG_SETMASK, rc ? p : 0, rc ? 0 : p)); + npassert(!sigprocmask(SIG_SETMASK, rc ? p : 0, rc ? 0 : p)); return rc; } diff --git a/libc/runtime/clone.c b/libc/runtime/clone.c index 03e01040c..860e77d1e 100644 --- a/libc/runtime/clone.c +++ b/libc/runtime/clone.c @@ -113,11 +113,11 @@ int WinThreadLaunch(void *arg, // rdi // 2. windows owns the stack memory right now // we need win32 raw imports because: // 1. generated thunks are function logged -noasan dontinstrument static textwindows wontreturn void // -WinThreadEntry(int rdi, // rcx - int rsi, // rdx - int rdx, // r8 - struct CloneArgs *wt) { // r9 +dontasan dontinstrument static textwindows wontreturn void // +WinThreadEntry(int rdi, // rcx + int rsi, // rdx + int rdx, // r8 + struct CloneArgs *wt) { // r9 int rc; if (wt->tls) __set_tls_win32(wt->tls); *wt->ctid = wt->tid; @@ -143,7 +143,7 @@ static textwindows errno_t CloneWindows(int (*func)(void *, int), char *stk, wt->func = func; wt->arg = arg; wt->tls = flags & CLONE_SETTLS ? tls : 0; - if ((h = CreateThread(0, 4096, (void *)WinThreadEntry, wt, 0, &wt->utid))) { + if ((h = CreateThread(0, 65536, (void *)WinThreadEntry, wt, 0, &wt->utid))) { CloseHandle(h); if (flags & CLONE_PARENT_SETTID) { *ptid = wt->tid; @@ -216,7 +216,7 @@ static errno_t CloneXnu(int (*fn)(void *), char *stk, size_t stksz, int flags, static bool once; struct CloneArgs *wt; if (!once) { - _npassert(sys_bsdthread_register(XnuThreadThunk, 0, 0, 0, 0, 0, 0) != -1); + npassert(sys_bsdthread_register(XnuThreadThunk, 0, 0, 0, 0, 0, 0) != -1); once = true; } wt = AllocateCloneArgs(stk, stksz); @@ -286,7 +286,7 @@ static errno_t CloneFreebsd(int (*func)(void *, int), char *stk, size_t stksz, // we can't use address sanitizer because: // 1. __asan_handle_no_return wipes stack [todo?] -noasan static wontreturn void OpenbsdThreadMain(void *p) { +dontasan static wontreturn void OpenbsdThreadMain(void *p) { struct CloneArgs *wt = p; *wt->ctid = wt->tid; wt->func(wt->arg, wt->tid); @@ -325,7 +325,7 @@ static errno_t CloneOpenbsd(int (*func)(void *, int), char *stk, size_t stksz, tf->tf_tcb = flags & CLONE_SETTLS ? tls : 0; tf->tf_tid = &wt->tid; if ((rc = __tfork_thread(tf, sizeof(*tf), OpenbsdThreadMain, wt)) >= 0) { - _npassert(rc); + npassert(rc); if (flags & CLONE_PARENT_SETTID) { *ptid = rc; } @@ -376,7 +376,7 @@ static int CloneNetbsd(int (*func)(void *, int), char *stk, size_t stksz, : CFLAG_CONSTRAINT(failed), "=a"(ax) : "1"(__NR_getcontext_netbsd), "D"(&netbsd_clone_template) : "rcx", "rdx", "r8", "r9", "r10", "r11", "memory"); - _npassert(!failed); + npassert(!failed); once = true; } sp = (intptr_t)(stk + stksz); @@ -425,7 +425,7 @@ static int CloneNetbsd(int (*func)(void *, int), char *stk, size_t stksz, : "1"(__NR__lwp_create), "D"(ctx), "S"(LWP_DETACHED), "2"(tid) : "rcx", "r8", "r9", "r10", "r11", "memory"); if (!failed) { - _npassert(*tid); + npassert(*tid); if (flags & CLONE_PARENT_SETTID) { *ptid = *tid; } diff --git a/libc/runtime/cocmd.c b/libc/runtime/cocmd.c index b9ea56d7f..9664d4c17 100644 --- a/libc/runtime/cocmd.c +++ b/libc/runtime/cocmd.c @@ -137,7 +137,7 @@ static void UnsetEnv(char **p, const char *k) { } static void Append(int c) { - _npassert(q + 1 < argbuf + sizeof(argbuf)); + npassert(q + 1 < argbuf + sizeof(argbuf)); *q++ = c; } @@ -234,6 +234,54 @@ static int Echo(void) { return 0; } +static int Cat(void) { + int i, fd; + ssize_t rc; + char buf[512]; + if (n < 2) { + for (;;) { + rc = read(0, buf, sizeof(buf)); + if (rc == -1) { + perror("read"); + return 1; + } + if (!rc) break; + rc = write(1, buf, rc); + if (rc == -1) { + perror("write"); + return 1; + } + } + } else { + for (i = 1; i < n; ++i) { + if ((fd = open(args[i], O_RDONLY)) == -1) { + perror(args[i]); + return 1; + } + for (;;) { + rc = read(fd, buf, sizeof(buf)); + if (rc == -1) { + perror(args[i]); + close(fd); + return 1; + } + if (!rc) break; + rc = write(1, buf, rc); + if (rc == -1) { + perror("write"); + close(fd); + return 1; + } + } + if (close(fd)) { + perror(args[i]); + return 1; + } + } + } + return 0; +} + static int Read(void) { unsigned char c; int i, j, rc = 1; @@ -522,6 +570,7 @@ static int TryBuiltin(void) { if (!strcmp(args[0], "cd")) return Cd(); if (!strcmp(args[0], "rm")) return Rm(); if (!strcmp(args[0], "[")) return Test(); + if (!strcmp(args[0], "cat")) return Cat(); if (!strcmp(args[0], "env")) return Env(); if (!strcmp(args[0], "exec")) return Exec(); if (!strcmp(args[0], "wait")) return Wait(); @@ -562,14 +611,14 @@ static void Pipe(void) { _Exit(127); } if (!pid) { - _unassert(dup2(pfds[1], 1) == 1); + unassert(dup2(pfds[1], 1) == 1); // we can't rely on cloexec because builtins - if (pfds[0] != 1) _unassert(!close(pfds[0])); - if (pfds[1] != 1) _unassert(!close(pfds[1])); + if (pfds[0] != 1) unassert(!close(pfds[0])); + if (pfds[1] != 1) unassert(!close(pfds[1])); _Exit(ShellExec()); } - _unassert(!dup2(pfds[0], 0)); - if (pfds[1]) _unassert(!close(pfds[1])); + unassert(!dup2(pfds[0], 0)); + if (pfds[1]) unassert(!close(pfds[1])); n = 0; } @@ -619,7 +668,7 @@ static const char *GetVar(const char *key) { } else if (key[0] == '?' && !key[1]) { return IntToStr(exitstatus); } else if (!strcmp(key, "PWD")) { - _npassert(getcwd(vbuf, sizeof(vbuf))); + npassert(getcwd(vbuf, sizeof(vbuf))); return vbuf; } else if (!strcmp(key, "UID")) { FormatInt32(vbuf, getuid()); @@ -644,14 +693,14 @@ static bool CopyVar(void) { size_t j; const char *s; if (IsVarName(*p)) { - _npassert(vari + 1 < sizeof(var)); + npassert(vari + 1 < sizeof(var)); var[vari++] = *p; var[vari] = 0; return false; } if ((s = GetVar(var))) { if ((j = strlen(s))) { - _npassert(q + j < argbuf + sizeof(argbuf)); + npassert(q + j < argbuf + sizeof(argbuf)); q = mempcpy(q, s, j); } } @@ -855,7 +904,7 @@ int _cocmd(int argc, char **argv, char **envp) { int envi = 0; if (envp) { for (; envp[envi]; ++envi) { - _npassert(envi + 1 < ARRAYLEN(envs)); + npassert(envi + 1 < ARRAYLEN(envs)); envs[envi] = envp[envi]; } } diff --git a/libc/runtime/daemon.c b/libc/runtime/daemon.c index 91bd6aa59..93d34c9af 100644 --- a/libc/runtime/daemon.c +++ b/libc/runtime/daemon.c @@ -52,15 +52,15 @@ int daemon(int nochdir, int noclose) { } if (!nochdir) { - _unassert(!chdir("/")); + unassert(!chdir("/")); } if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR)) != -1) { - _unassert(dup2(fd, 0) == 0); - _unassert(dup2(fd, 1) == 1); - _unassert(dup2(fd, 2) == 2); + unassert(dup2(fd, 0) == 0); + unassert(dup2(fd, 1) == 1); + unassert(dup2(fd, 2) == 2); if (fd > 2) { - _unassert(!close(fd)); + unassert(!close(fd)); } } diff --git a/libc/runtime/efimain.greg.c b/libc/runtime/efimain.greg.c index 777f6eca8..7089224f0 100644 --- a/libc/runtime/efimain.greg.c +++ b/libc/runtime/efimain.greg.c @@ -125,7 +125,7 @@ static void EfiInitVga(struct mman *mm, EFI_SYSTEM_TABLE *SystemTable) { * So if you want to trade away Windows so that you can use * UEFI instead of the normal BIOS boot process, do this: * - * STATIC_YOINK("EfiMain"); + * __static_yoink("EfiMain"); * int main() { ... } * * You can use QEMU to test this, but please note that UEFI @@ -141,8 +141,8 @@ static void EfiInitVga(struct mman *mm, EFI_SYSTEM_TABLE *SystemTable) { * * @see libc/dce.h */ -__msabi noasan EFI_STATUS EfiMain(EFI_HANDLE ImageHandle, - EFI_SYSTEM_TABLE *SystemTable) { +__msabi dontasan EFI_STATUS EfiMain(EFI_HANDLE ImageHandle, + EFI_SYSTEM_TABLE *SystemTable) { int type, x87cw = 0x037f; struct mman *mm; uint32_t DescVersion; diff --git a/libc/runtime/enable_threads.c b/libc/runtime/enable_threads.c index 177a67207..a7b342ffb 100644 --- a/libc/runtime/enable_threads.c +++ b/libc/runtime/enable_threads.c @@ -25,7 +25,7 @@ extern int __threadcalls_end[] __attribute__((__weak__)); extern int __threadcalls_start[] __attribute__((__weak__)); -static privileged dontinline void FixupLockNops(void) { +static privileged void FixupLockNops(void) { __morph_begin(); /* * _NOPL("__threadcalls", func) diff --git a/libc/runtime/enable_tls.c b/libc/runtime/enable_tls.c index fd6f91157..ea7bf1a07 100644 --- a/libc/runtime/enable_tls.c +++ b/libc/runtime/enable_tls.c @@ -116,8 +116,8 @@ textstartup void __enable_tls(void) { // _tbss_start + _tbss_size: // _tdata_start + _tls_size: // - _unassert(_tbss_start == _tdata_start + I(_tbss_offset)); - _unassert(_tbss_start + I(_tbss_size) == _tdata_start + I(_tls_size)); + unassert(_tbss_start == _tdata_start + I(_tbss_offset)); + unassert(_tbss_start + I(_tbss_size) == _tdata_start + I(_tls_size)); #ifdef __x86_64__ @@ -130,12 +130,12 @@ textstartup void __enable_tls(void) { } else { // if this binary needs a hefty tls block then we'll bank on // malloc() being linked, which links _mapanon(). otherwise - // if you exceed this, you need to STATIC_YOINK("_mapanon"). + // if you exceed this, you need to __static_yoink("_mapanon"). // please note that it's probably too early to call calloc() - _npassert(_weaken(_mapanon)); + npassert(_weaken(_mapanon)); siz = ROUNDUP(siz, FRAMESIZE); mem = _weaken(_mapanon)(siz); - _npassert(mem); + npassert(mem); } if (IsAsan()) { @@ -154,10 +154,10 @@ textstartup void __enable_tls(void) { if (siz <= sizeof(__static_tls)) { mem = __static_tls; } else { - _npassert(_weaken(_mapanon)); + npassert(_weaken(_mapanon)); siz = ROUNDUP(siz, FRAMESIZE); mem = _weaken(_mapanon)(siz); - _npassert(mem); + npassert(mem); } if (IsAsan()) { @@ -205,7 +205,7 @@ textstartup void __enable_tls(void) { _pthread_main.tib = tib; _pthread_main.flags = PT_STATIC; _pthread_main.list.prev = _pthread_main.list.next = // - _pthread_list = VEIL("r", &_pthread_main.list); + _pthread_list = __veil("r", &_pthread_main.list); atomic_store_explicit(&_pthread_main.ptid, tid, memory_order_relaxed); // copy in initialized data section diff --git a/libc/runtime/fork-nt.c b/libc/runtime/fork-nt.c index e0ee91e3c..42fe50e14 100644 --- a/libc/runtime/fork-nt.c +++ b/libc/runtime/fork-nt.c @@ -61,7 +61,7 @@ #ifdef __x86_64__ -STATIC_YOINK("_check_sigchld"); +__static_yoink("_check_sigchld"); extern int64_t __wincrashearly; bool32 __onntconsoleevent_nt(uint32_t); @@ -231,7 +231,7 @@ textwindows void WinMainForked(void) { // rewrap the stdin named pipe hack // since the handles closed on fork - struct Fds *fds = VEIL("r", &g_fds); + struct Fds *fds = __veil("r", &g_fds); fds->p[0].handle = GetStdHandle(kNtStdInputHandle); fds->p[1].handle = GetStdHandle(kNtStdOutputHandle); fds->p[2].handle = GetStdHandle(kNtStdErrorHandle); diff --git a/libc/runtime/getdosargv.c b/libc/runtime/getdosargv.c index 233585a55..b66a35a90 100644 --- a/libc/runtime/getdosargv.c +++ b/libc/runtime/getdosargv.c @@ -30,7 +30,7 @@ struct DosArgv { wint_t wc; }; -textwindows noasan void DecodeDosArgv(int ignore, struct DosArgv *st) { +textwindows dontasan void DecodeDosArgv(int ignore, struct DosArgv *st) { wint_t x, y; for (;;) { if (!(x = *st->s++)) break; @@ -46,7 +46,7 @@ textwindows noasan void DecodeDosArgv(int ignore, struct DosArgv *st) { st->wc = x; } -static textwindows noasan void AppendDosArgv(wint_t wc, struct DosArgv *st) { +static textwindows dontasan void AppendDosArgv(wint_t wc, struct DosArgv *st) { uint64_t w; w = _tpenc(wc); do { @@ -55,7 +55,7 @@ static textwindows noasan void AppendDosArgv(wint_t wc, struct DosArgv *st) { } while (w >>= 8); } -static textwindows noasan int Count(int c, struct DosArgv *st) { +static textwindows dontasan int Count(int c, struct DosArgv *st) { int ignore, n = 0; asm("" : "=g"(ignore)); while (st->wc == c) { @@ -82,8 +82,8 @@ static textwindows noasan int Count(int c, struct DosArgv *st) { // @see test/libc/dosarg_test.c // @see libc/runtime/ntspawn.c // @note kudos to Simon Tatham for figuring out quoting behavior -textwindows noasan int GetDosArgv(const char16_t *cmdline, char *buf, - size_t size, char **argv, size_t max) { +textwindows dontasan int GetDosArgv(const char16_t *cmdline, char *buf, + size_t size, char **argv, size_t max) { bool inquote; int i, argc, slashes, quotes, ignore; static struct DosArgv st_; diff --git a/libc/runtime/getdosenviron.c b/libc/runtime/getdosenviron.c index aa2b30751..e46c7a3e6 100644 --- a/libc/runtime/getdosenviron.c +++ b/libc/runtime/getdosenviron.c @@ -36,7 +36,7 @@ forceinline char *MemChr(const char *s, unsigned char c, unsigned long n) { return 0; } -static textwindows noasan dontinstrument axdx_t +static textwindows dontasan dontinstrument axdx_t Recode16to8(char *dst, size_t dstsize, const char16_t *src) { bool v; axdx_t r; @@ -70,7 +70,7 @@ Recode16to8(char *dst, size_t dstsize, const char16_t *src) { return r; } -textwindows dontinstrument noasan void FixPath(char *path) { +textwindows dontinstrument dontasan void FixPath(char *path) { char *p; size_t i; @@ -110,9 +110,9 @@ textwindows dontinstrument noasan void FixPath(char *path) { // @param envp stores NULL-terminated string pointer list (optional) // @param max is the pointer count capacity of envp // @return number of variables decoded, excluding NULL-terminator -textwindows noasan dontinstrument int GetDosEnviron(const char16_t *env, - char *buf, size_t size, - char **envp, size_t max) { +textwindows dontasan dontinstrument int GetDosEnviron(const char16_t *env, + char *buf, size_t size, + char **envp, size_t max) { int i; char *p; axdx_t r; diff --git a/libc/runtime/getmemtracksize.c b/libc/runtime/getmemtracksize.c index d47136b33..af76f2a53 100644 --- a/libc/runtime/getmemtracksize.c +++ b/libc/runtime/getmemtracksize.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/runtime/memtrack.internal.h" -noasan size_t GetMemtrackSize(struct MemoryIntervals *mm) { +dontasan size_t GetMemtrackSize(struct MemoryIntervals *mm) { size_t i, n; for (n = i = 0; i < mm->i; ++i) { n += ((size_t)(mm->p[i].y - mm->p[i].x) + 1) << 16; diff --git a/libc/runtime/getsymbol.c b/libc/runtime/getsymbol.c index 8852b2200..7d36c5de7 100644 --- a/libc/runtime/getsymbol.c +++ b/libc/runtime/getsymbol.c @@ -27,7 +27,7 @@ extern struct SymbolTable *__symtab; * @param t if null will be auto-populated only if already open * @return index or -1 if nothing found */ -dontinstrument privileged int __get_symbol(struct SymbolTable *t, intptr_t a) { +privileged int __get_symbol(struct SymbolTable *t, intptr_t a) { // we need privileged because: // kprintf is privileged and it depends on this // we don't want function tracing because: diff --git a/libc/runtime/getsymbolbyaddr.c b/libc/runtime/getsymbolbyaddr.c index ab62f9869..9416e13e5 100644 --- a/libc/runtime/getsymbolbyaddr.c +++ b/libc/runtime/getsymbolbyaddr.c @@ -23,7 +23,7 @@ /** * Returns name of symbol at address. */ -noasan char *GetSymbolByAddr(int64_t addr) { +dontasan char *GetSymbolByAddr(int64_t addr) { /* asan runtime depends on this function */ int i; struct SymbolTable *st; diff --git a/libc/runtime/getsymbolname.c b/libc/runtime/getsymbolname.c index b9ba568e9..7fffbb805 100644 --- a/libc/runtime/getsymbolname.c +++ b/libc/runtime/getsymbolname.c @@ -18,8 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/runtime/symbols.internal.h" -privileged dontinstrument noasan noubsan char *__get_symbol_name( - struct SymbolTable *t, int s) { +privileged char *__get_symbol_name(struct SymbolTable *t, int s) { /* asan runtime depends on this function */ if (t && s != -1) { return t->name_base + t->names[s]; diff --git a/libc/runtime/getsymboltable.c b/libc/runtime/getsymboltable.c index 6639c5101..464a2ac3d 100644 --- a/libc/runtime/getsymboltable.c +++ b/libc/runtime/getsymboltable.c @@ -32,7 +32,7 @@ #include "libc/zipos/zipos.internal.h" #include "third_party/puff/puff.h" -STATIC_YOINK("__get_symbol"); +__static_yoink("__get_symbol"); static pthread_spinlock_t g_lock; struct SymbolTable *__symtab; // for kprintf @@ -111,7 +111,7 @@ static struct SymbolTable *GetSymbolTableFromElf(void) { * This uses multiple strategies to find the symbol table. The first * strategy, depends on whether or not the following is linked: * - * STATIC_YOINK("__zipos_get"); + * __static_yoink("__zipos_get"); * * In that case, the symbol table may be read from `/zip/.symtab` which * is generated by `o//tool/build/symtab.com`. The second strategy is to diff --git a/libc/runtime/grow.c b/libc/runtime/grow.c index e0132e159..dac2f89b5 100644 --- a/libc/runtime/grow.c +++ b/libc/runtime/grow.c @@ -38,9 +38,9 @@ bool __grow(void *pp, size_t *capacity, size_t itemsize, size_t extra) { size_t t1, t2; extra += GUARANTEE_TERMINATOR; p = (void **)pp; - _unassert(itemsize); - _unassert((*p && *capacity) || (!*p && !*capacity)); - _unassert(!_isheap(*p) || ((intptr_t)*p & 15) == 0); + unassert(itemsize); + unassert((*p && *capacity) || (!*p && !*capacity)); + unassert(!_isheap(*p) || ((intptr_t)*p & 15) == 0); p1 = _isheap(*p) ? *p : NULL; p2 = NULL; n1 = *capacity; diff --git a/libc/runtime/hook.greg.c b/libc/runtime/hook.greg.c index 4dacb9c38..c781336e5 100644 --- a/libc/runtime/hook.greg.c +++ b/libc/runtime/hook.greg.c @@ -106,8 +106,7 @@ static privileged void HookFunction(code_t *func, void *dest) { * @param st can be obtained using `GetSymbolTable()` * @see ape/ape.lds */ -privileged dontinstrument noasan int __hook(void *dest, - struct SymbolTable *st) { +privileged int __hook(void *dest, struct SymbolTable *st) { long i; code_t *p, *pe; intptr_t lowest; diff --git a/libc/runtime/internal.h b/libc/runtime/internal.h index 44cba05a2..966e2feca 100644 --- a/libc/runtime/internal.h +++ b/libc/runtime/internal.h @@ -48,8 +48,8 @@ int GetDosEnviron(const char16_t *, char *, size_t, char **, size_t); bool __intercept_flag(int *, char *[], const char *); int sys_mprotect_nt(void *, size_t, int); int __inflate(void *, size_t, const void *, size_t); -noasan void *_Mmap(void *, size_t, int, int, int, int64_t); -noasan int _Munmap(char *, size_t); +void *_Mmap(void *, size_t, int, int, int, int64_t) dontasan; +int _Munmap(char *, size_t) dontasan; void __on_arithmetic_overflow(void); void __init_fds(void); diff --git a/libc/runtime/isheap.c b/libc/runtime/isheap.c index 6d3796e43..a13b77bcd 100644 --- a/libc/runtime/isheap.c +++ b/libc/runtime/isheap.c @@ -26,7 +26,7 @@ * @assume stack addresses are always greater than heap addresses * @assume stack memory isn't stored beneath %rsp (-mno-red-zone) */ -optimizesize noasan bool _isheap(void *p) { +optimizesize dontasan bool _isheap(void *p) { intptr_t x, y; x = kAutomapStart; y = x + kAutomapSize; diff --git a/libc/runtime/memtracknt.c b/libc/runtime/memtracknt.c index 75c5a6ff3..9f963903f 100644 --- a/libc/runtime/memtracknt.c +++ b/libc/runtime/memtracknt.c @@ -23,14 +23,14 @@ #include "libc/runtime/memtrack.internal.h" #include "libc/runtime/runtime.h" -static inline noasan void *GetFrameAddr(int f) { +static inline dontasan void *GetFrameAddr(int f) { intptr_t a; a = f; a *= FRAMESIZE; return (void *)a; } -noasan void ReleaseMemoryNt(struct MemoryIntervals *mm, int l, int r) { +dontasan void ReleaseMemoryNt(struct MemoryIntervals *mm, int l, int r) { int i; for (i = l; i <= r; ++i) { UnmapViewOfFile(GetFrameAddr(mm->p[i].x)); diff --git a/libc/runtime/mmap.c b/libc/runtime/mmap.c index 878296a6c..6164c63b7 100644 --- a/libc/runtime/mmap.c +++ b/libc/runtime/mmap.c @@ -28,7 +28,6 @@ #include "libc/intrin/bsr.h" #include "libc/intrin/describeflags.internal.h" #include "libc/intrin/directmap.internal.h" -#include "libc/intrin/kprintf.h" #include "libc/intrin/likely.h" #include "libc/intrin/safemacros.internal.h" #include "libc/intrin/strace.internal.h" @@ -47,9 +46,11 @@ #include "libc/stdckdint.h" #include "libc/stdio/rand.h" #include "libc/str/str.h" +#include "libc/sysv/consts/auxv.h" #include "libc/sysv/consts/map.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/prot.h" +#include "libc/sysv/consts/ss.h" #include "libc/sysv/errfuns.h" #include "libc/thread/thread.h" #include "libc/zipos/zipos.internal.h" @@ -76,9 +77,9 @@ static wontreturn void OnUnrecoverableMmapError(const char *s) { _Exitr(199); } -static noasan inline bool OverlapsExistingMapping(char *p, size_t n) { +static dontasan inline bool OverlapsExistingMapping(char *p, size_t n) { int a, b, i; - _unassert(n > 0); + unassert(n > 0); a = FRAME(p); b = FRAME(p + (n - 1)); i = FindMemoryInterval(&_mmi, a); @@ -90,10 +91,10 @@ static noasan inline bool OverlapsExistingMapping(char *p, size_t n) { return false; } -static noasan bool ChooseMemoryInterval(int x, int n, int align, int *res) { +static dontasan bool ChooseMemoryInterval(int x, int n, int align, int *res) { // TODO: improve performance int i, start, end; - _unassert(align > 0); + unassert(align > 0); if (_mmi.i) { // find the start of the automap memory region @@ -151,14 +152,14 @@ static noasan bool ChooseMemoryInterval(int x, int n, int align, int *res) { return false; } -noasan static bool Automap(int count, int align, int *res) { +dontasan static bool Automap(int count, int align, int *res) { return ChooseMemoryInterval(FRAME(kAutomapStart), count, align, res) && *res + count <= FRAME(kAutomapStart + (kAutomapSize - 1)); } -static noasan void *FinishMemory(void *addr, size_t size, int prot, int flags, - int fd, int64_t off, int f, int x, int n, - struct DirectMap dm) { +static dontasan void *FinishMemory(void *addr, size_t size, int prot, int flags, + int fd, int64_t off, int f, int x, int n, + struct DirectMap dm) { if (!IsWindows() && (flags & MAP_FIXED)) { if (UntrackMemoryIntervals(addr, size)) { OnUnrecoverableMmapError("FIXED UNTRACK FAILED"); @@ -177,8 +178,8 @@ static noasan void *FinishMemory(void *addr, size_t size, int prot, int flags, return addr; } -static noasan void *MapMemory(void *addr, size_t size, int prot, int flags, - int fd, int64_t off, int f, int x, int n) { +static dontasan void *MapMemory(void *addr, size_t size, int prot, int flags, + int fd, int64_t off, int f, int x, int n) { struct DirectMap dm; dm = sys_mmap(addr, size, prot, f, fd, off); if (VERY_UNLIKELY(dm.addr == MAP_FAILED)) { @@ -200,17 +201,18 @@ static noasan void *MapMemory(void *addr, size_t size, int prot, int flags, * This is useful on Windows since it allows us to partially unmap or * punch holes into existing mappings. */ -static textwindows dontinline noasan void *MapMemories(char *addr, size_t size, - int prot, int flags, - int fd, int64_t off, - int f, int x, int n) { +static textwindows dontinline dontasan void *MapMemories(char *addr, + size_t size, int prot, + int flags, int fd, + int64_t off, int f, + int x, int n) { size_t i, m; int64_t oi, sz; struct DirectMap dm; bool iscow, readonlyfile; m = (size_t)(n - 1) << 16; - _unassert(m < size); - _unassert(m + FRAMESIZE >= size); + unassert(m < size); + unassert(m + FRAMESIZE >= size); oi = fd == -1 ? 0 : off + m; sz = size - m; dm = sys_mmap(addr + m, sz, prot, f, fd, oi); @@ -239,12 +241,13 @@ static textwindows dontinline noasan void *MapMemories(char *addr, size_t size, return addr; } -noasan inline void *_Mmap(void *addr, size_t size, int prot, int flags, int fd, - int64_t off) { +dontasan inline void *_Mmap(void *addr, size_t size, int prot, int flags, + int fd, int64_t off) { char *p = addr; struct DirectMap dm; int a, b, i, f, m, n, x; bool needguard, clashes; + unsigned long guardsize; size_t virtualused, virtualneed; if (VERY_UNLIKELY(!size)) { @@ -332,6 +335,7 @@ noasan inline void *_Mmap(void *addr, size_t size, int prot, int flags, int fd, } needguard = false; + guardsize = getauxval(AT_PAGESZ); p = (char *)ADDR_32_TO_48(x); if ((f & MAP_TYPE) == MAP_STACK) { if (~f & MAP_ANONYMOUS) { @@ -355,7 +359,7 @@ noasan inline void *_Mmap(void *addr, size_t size, int prot, int flags, int fd, // make sure there's no existing stuff existing between our stack // starting page and the bottom guard page, since that would stop // our stack page from growing down. - _npassert(!sys_munmap(p, size)); + npassert(!sys_munmap(p, size)); // by default MAP_GROWSDOWN will auto-allocate 10mb of pages. it's // supposed to stop growing if an adjacent allocation exists, to // prevent your stacks from overlapping on each other. we're not @@ -367,12 +371,12 @@ noasan inline void *_Mmap(void *addr, size_t size, int prot, int flags, int fd, // however this 1mb behavior oddly enough is smart enough to not // apply if the mapping is a manually-created guard page. int e = errno; - if ((dm = sys_mmap(p + size - APE_GUARDSIZE, APE_GUARDSIZE, prot, + if ((dm = sys_mmap(p + size - SIGSTKSZ, SIGSTKSZ, prot, f | MAP_GROWSDOWN_linux, fd, off)) .addr != MAP_FAILED) { - _npassert(sys_mmap(p, APE_GUARDSIZE, PROT_NONE, - MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) - .addr == p); + npassert(sys_mmap(p, guardsize, PROT_NONE, + MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) + .addr == p); dm.addr = p; return FinishMemory(p, size, prot, flags, fd, off, f, x, n, dm); } else if (errno == ENOTSUP) { @@ -398,11 +402,11 @@ noasan inline void *_Mmap(void *addr, size_t size, int prot, int flags, int fd, if (needguard) { if (!IsWindows()) { // make windows fork() code simpler - mprotect(p, APE_GUARDSIZE, PROT_NONE); + mprotect(p, guardsize, PROT_NONE); } if (IsAsan()) { __repstosb((void *)(((intptr_t)p >> 3) + 0x7fff8000), - kAsanStackOverflow, APE_GUARDSIZE / 8); + kAsanStackOverflow, guardsize / 8); } } } @@ -435,15 +439,7 @@ noasan inline void *_Mmap(void *addr, size_t size, int prot, int flags, int fd, * - `MAP_PRIVATE` for copy-on-write behavior of writeable pages * - `MAP_SHARED` to create shared memory between processes * - `MAP_STACK` to create a grows-down alloc, where a guard page - * is automatically protected at the bottom: FreeBSD's behavior - * is polyfilled across platforms; uses MAP_GROWSDOWN on Linux - * too for extra oomph (do not use MAP_GROWSDOWN!) and this is - * completely mandatory on OpenBSD but helps perf elsewhere if - * you need to create 10,000 threads. This flag is the reason - * why `STACK_FRAME_UNLIMITED` toil is important, because this - * only allocates a 4096-byte guard page, thus we need the GCC - * compile-time checks to ensure some char[8192] vars will not - * create an undetectable overflow into another thread's stack + * is automatically protected at the bottom, sized as AT_PAGESZ * Your `flags` may optionally bitwise or any of the following: * - `MAP_ANONYMOUS` in which case `fd` and `off` are ignored * - `MAP_FIXED` in which case `addr` becomes more than a hint diff --git a/libc/runtime/msync-nt.c b/libc/runtime/msync-nt.c index 2ff616586..bda786812 100644 --- a/libc/runtime/msync-nt.c +++ b/libc/runtime/msync-nt.c @@ -25,7 +25,7 @@ #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/prot.h" -noasan textwindows int sys_msync_nt(char *addr, size_t size, int flags) { +dontasan textwindows int sys_msync_nt(char *addr, size_t size, int flags) { int i, rc = 0; char *a, *b, *x, *y; __mmi_lock(); diff --git a/libc/runtime/msync.c b/libc/runtime/msync.c index a857a6045..a5b0cc91f 100644 --- a/libc/runtime/msync.c +++ b/libc/runtime/msync.c @@ -43,7 +43,7 @@ int msync(void *addr, size_t size, int flags) { int rc; BEGIN_CANCELLATION_POINT; - _unassert(((flags & MS_SYNC) ^ (flags & MS_ASYNC)) || !(MS_SYNC && MS_ASYNC)); + unassert(((flags & MS_SYNC) ^ (flags & MS_ASYNC)) || !(MS_SYNC && MS_ASYNC)); if (!IsWindows()) { rc = sys_msync(addr, size, flags); } else { diff --git a/libc/runtime/munmap.c b/libc/runtime/munmap.c index 024fe3b3f..9a842d6e0 100644 --- a/libc/runtime/munmap.c +++ b/libc/runtime/munmap.c @@ -39,7 +39,7 @@ #define ALIGNED(p) (!(IP(p) & (FRAMESIZE - 1))) #define FRAME(x) ((int)((intptr_t)(x) >> 16)) -static noasan void MunmapShadow(char *p, size_t n) { +static dontasan void MunmapShadow(char *p, size_t n) { intptr_t a, b, x, y; KERNTRACE("MunmapShadow(%p, %'zu)", p, n); a = ((intptr_t)p >> 3) + 0x7fff8000; @@ -66,7 +66,7 @@ static noasan void MunmapShadow(char *p, size_t n) { // our api supports doing things like munmap(0, 0x7fffffffffff) but some // platforms (e.g. openbsd) require that we know the specific intervals // or else it returns EINVAL. so we munmap a piecewise. -static noasan void MunmapImpl(char *p, size_t n) { +static dontasan void MunmapImpl(char *p, size_t n) { char *q; size_t m; intptr_t a, b, c; @@ -102,7 +102,7 @@ static noasan void MunmapImpl(char *p, size_t n) { q = (char *)a; m = MIN(b, c) - a; if (!IsWindows()) { - _npassert(!sys_munmap(q, m)); + npassert(!sys_munmap(q, m)); } else { // Handled by UntrackMemoryIntervals() on Windows } @@ -112,11 +112,11 @@ static noasan void MunmapImpl(char *p, size_t n) { } } -noasan int _Munmap(char *p, size_t n) { +dontasan int _Munmap(char *p, size_t n) { unsigned i; char poison; intptr_t a, b, x, y; - _unassert(!__vforked); + unassert(!__vforked); if (UNLIKELY(!n)) { STRACE("munmap n is 0"); return einval(); diff --git a/libc/runtime/printargs.c b/libc/runtime/printargs.c index 96b2cce8b..d54fde198 100644 --- a/libc/runtime/printargs.c +++ b/libc/runtime/printargs.c @@ -63,8 +63,8 @@ #include "tool/decode/lib/idname.h" #include "tool/decode/lib/x86idnames.h" -STATIC_YOINK("strerror"); // for kprintf() -STATIC_YOINK("strsignal"); // for kprintf() +__static_yoink("strerror"); // for kprintf() +__static_yoink("strsignal"); // for kprintf() #define PRINT(FMT, ...) \ do { \ @@ -72,49 +72,6 @@ STATIC_YOINK("strsignal"); // for kprintf() kprintf(FMT "\n", ##__VA_ARGS__); \ } while (0) -static const struct AuxiliaryValue { - const char *fmt; - long *id; - const char *name; -} kAuxiliaryValues[] = { - {"%-14p", &AT_EXECFD, "AT_EXECFD"}, - {"%-14p", &AT_PHDR, "AT_PHDR"}, - {"%-14p", &AT_PHENT, "AT_PHENT"}, - {"%-14p", &AT_PHNUM, "AT_PHNUM"}, - {"%-14p", &AT_PAGESZ, "AT_PAGESZ"}, - {"%-14p", &AT_BASE, "AT_BASE"}, - {"%-14p", &AT_ENTRY, "AT_ENTRY"}, - {"%-14p", &AT_NOTELF, "AT_NOTELF"}, - {"%-14d", &AT_UID, "AT_UID"}, - {"%-14d", &AT_EUID, "AT_EUID"}, - {"%-14d", &AT_GID, "AT_GID"}, - {"%-14d", &AT_EGID, "AT_EGID"}, - {"%-14d", &AT_CLKTCK, "AT_CLKTCK"}, - {"%-14d", &AT_OSRELDATE, "AT_OSRELDATE"}, - {"%-14p", &AT_PLATFORM, "AT_PLATFORM"}, - {"%-14p", &AT_DCACHEBSIZE, "AT_DCACHEBSIZE"}, - {"%-14p", &AT_ICACHEBSIZE, "AT_ICACHEBSIZE"}, - {"%-14p", &AT_UCACHEBSIZE, "AT_UCACHEBSIZE"}, - {"%-14p", &AT_SECURE, "AT_SECURE"}, - {"%-14s", &AT_BASE_PLATFORM, "AT_BASE_PLATFORM"}, - {"%-14p", &AT_RANDOM, "AT_RANDOM"}, - {"%-14s", &AT_EXECFN, "AT_EXECFN"}, - {"%-14p", &AT_SYSINFO_EHDR, "AT_SYSINFO_EHDR"}, - {"%-14p", &AT_FLAGS, "AT_FLAGS"}, - {"%-14p", &AT_HWCAP, "AT_HWCAP"}, - {"%-14p", &AT_HWCAP2, "AT_HWCAP2"}, - {"%-14p", &AT_STACKBASE, "AT_STACKBASE"}, - {"%-14p", &AT_CANARY, "AT_CANARY"}, - {"%-14p", &AT_CANARYLEN, "AT_CANARYLEN"}, - {"%-14ld", &AT_NCPUS, "AT_NCPUS"}, - {"%-14p", &AT_PAGESIZES, "AT_PAGESIZES"}, - {"%-14d", &AT_PAGESIZESLEN, "AT_PAGESIZESLEN"}, - {"%-14p", &AT_TIMEKEEP, "AT_TIMEKEEP"}, - {"%-14p", &AT_STACKPROT, "AT_STACKPROT"}, - {"%-14p", &AT_EHDRFLAGS, "AT_EHDRFLAGS"}, - {"%-14d", &AT_MINSIGSTKSZ, "AT_MINSIGSTKSZ"}, -}; - static const char *FindNameById(const struct IdName *names, unsigned long id) { for (; names->name; names++) { if (names->id == id) { @@ -124,17 +81,7 @@ static const char *FindNameById(const struct IdName *names, unsigned long id) { return NULL; } -static const struct AuxiliaryValue *DescribeAuxv(unsigned long x) { - int i; - for (i = 0; i < ARRAYLEN(kAuxiliaryValues); ++i) { - if (*kAuxiliaryValues[i].id && x == *kAuxiliaryValues[i].id) { - return kAuxiliaryValues + i; - } - } - return NULL; -} - -static noasan void PrintDependencies(const char *prologue) { +static dontasan void PrintDependencies(const char *prologue) { struct NtLinkedList *head = &NtGetPeb()->Ldr->InLoadOrderModuleList; struct NtLinkedList *ldr = head->Next; do { @@ -145,7 +92,7 @@ static noasan void PrintDependencies(const char *prologue) { } while ((ldr = ldr->Next) && ldr != head); } -static noasan void Print(const char *prologue) { +static dontasan void Print(const char *prologue) { } /** @@ -158,6 +105,50 @@ static noasan void Print(const char *prologue) { * @param prologue needs to be a .rodata kprintf string */ textstartup void __printargs(const char *prologue) { + + const struct AuxiliaryValue { + const char *fmt; + unsigned long id; + const char *name; + } kAuxiliaryValues[] = { + {"%-14p", AT_EXECFD, "AT_EXECFD"}, + {"%-14p", AT_PHDR, "AT_PHDR"}, + {"%-14p", AT_PHENT, "AT_PHENT"}, + {"%-14p", AT_PHNUM, "AT_PHNUM"}, + {"%-14p", AT_PAGESZ, "AT_PAGESZ"}, + {"%-14p", AT_BASE, "AT_BASE"}, + {"%-14p", AT_ENTRY, "AT_ENTRY"}, + {"%-14p", AT_NOTELF, "AT_NOTELF"}, + {"%-14d", AT_UID, "AT_UID"}, + {"%-14d", AT_EUID, "AT_EUID"}, + {"%-14d", AT_GID, "AT_GID"}, + {"%-14d", AT_EGID, "AT_EGID"}, + {"%-14d", AT_CLKTCK, "AT_CLKTCK"}, + {"%-14d", AT_OSRELDATE, "AT_OSRELDATE"}, + {"%-14p", AT_PLATFORM, "AT_PLATFORM"}, + {"%-14p", AT_DCACHEBSIZE, "AT_DCACHEBSIZE"}, + {"%-14p", AT_ICACHEBSIZE, "AT_ICACHEBSIZE"}, + {"%-14p", AT_UCACHEBSIZE, "AT_UCACHEBSIZE"}, + {"%-14p", AT_SECURE, "AT_SECURE"}, + {"%-14s", AT_BASE_PLATFORM, "AT_BASE_PLATFORM"}, + {"%-14p", AT_RANDOM, "AT_RANDOM"}, + {"%-14s", AT_EXECFN, "AT_EXECFN"}, + {"%-14p", AT_SYSINFO_EHDR, "AT_SYSINFO_EHDR"}, + {"%-14p", AT_FLAGS, "AT_FLAGS"}, + {"%-14p", AT_HWCAP, "AT_HWCAP"}, + {"%-14p", AT_HWCAP2, "AT_HWCAP2"}, + {"%-14p", AT_STACKBASE, "AT_STACKBASE"}, + {"%-14p", AT_CANARY, "AT_CANARY"}, + {"%-14p", AT_CANARYLEN, "AT_CANARYLEN"}, + {"%-14ld", AT_NCPUS, "AT_NCPUS"}, + {"%-14p", AT_PAGESIZES, "AT_PAGESIZES"}, + {"%-14d", AT_PAGESIZESLEN, "AT_PAGESIZESLEN"}, + {"%-14p", AT_TIMEKEEP, "AT_TIMEKEEP"}, + {"%-14p", AT_STACKPROT, "AT_STACKPROT"}, + {"%-14p", AT_EHDRFLAGS, "AT_EHDRFLAGS"}, + {"%-14d", AT_MINSIGSTKSZ, "AT_MINSIGSTKSZ"}, + }; + long key; char **env; sigset_t ss; @@ -412,7 +403,14 @@ textstartup void __printargs(const char *prologue) { if (*__auxv) { if (*__auxv) { for (auxp = __auxv; *auxp; auxp += 2) { - if ((auxinfo = DescribeAuxv(auxp[0]))) { + auxinfo = 0; + for (i = 0; i < ARRAYLEN(kAuxiliaryValues); ++i) { + if (kAuxiliaryValues[i].id && auxp[0] == kAuxiliaryValues[i].id) { + auxinfo = kAuxiliaryValues + i; + break; + } + } + if (auxinfo) { ksnprintf(u.path, sizeof(u.path), auxinfo->fmt, auxp[1]); PRINT(" ☼ %16s[%4ld] = %s", auxinfo->name, auxp[0], u.path); } else { diff --git a/libc/runtime/runtime.mk b/libc/runtime/runtime.mk index 0c73ec109..8c7ce0884 100644 --- a/libc/runtime/runtime.mk +++ b/libc/runtime/runtime.mk @@ -130,8 +130,7 @@ o/$(MODE)/libc/runtime/morph_tls.o: private \ CFLAGS += \ -ffreestanding \ -fno-sanitize=all \ - -fno-stack-protector \ - -fpatchable-function-entry=0,0 + -fno-stack-protector # TODO(jart): We need a way to avoid WinThreadEntry() being hooked. o/$(MODE)/libc/runtime/clone.o: private \ diff --git a/libc/runtime/set_tls.c b/libc/runtime/set_tls.c index eeb0a4957..29b98e89c 100644 --- a/libc/runtime/set_tls.c +++ b/libc/runtime/set_tls.c @@ -36,7 +36,7 @@ textstartup void __set_tls(struct CosmoTib *tib) { int ax, dx; if (IsWindows()) { __tls_index = TlsAlloc(); - _npassert(0 <= __tls_index && __tls_index < 64); + npassert(0 <= __tls_index && __tls_index < 64); asm("mov\t%1,%%gs:%0" : "=m"(*((long *)0x1480 + __tls_index)) : "r"(tib)); } else if (IsFreebsd()) { sys_set_tls(129 /*AMD64_SET_FSBASE*/, tib); diff --git a/libc/runtime/stack.h b/libc/runtime/stack.h index 374425ca9..d9d82c25c 100644 --- a/libc/runtime/stack.h +++ b/libc/runtime/stack.h @@ -13,7 +13,7 @@ * * If you want to know how much stack your programs needs, then * - * STATIC_YOINK("stack_usage_logging"); + * __static_yoink("stack_usage_logging"); * * will install an atexit() handler that appends to `o/$MODE/stack.log` * @@ -125,7 +125,7 @@ extern char ape_stack_align[] __attribute__((__weak__)); * Returns true if at least `n` bytes of stack are available. */ #define HaveStackMemory(n) \ - ((intptr_t)__builtin_frame_address(0) >= GetStackAddr() + APE_GUARDSIZE + (n)) + ((intptr_t)__builtin_frame_address(0) >= GetStackAddr() + 16384 + (n)) forceinline void CheckLargeStackAllocation(void *p, ssize_t n) { for (; n > 0; n -= 4096) { diff --git a/libc/runtime/stackuse.c b/libc/runtime/stackuse.c index c7d520b33..606820935 100644 --- a/libc/runtime/stackuse.c +++ b/libc/runtime/stackuse.c @@ -29,7 +29,7 @@ static char stacklog[1024]; -noasan size_t GetStackUsage(char *s, size_t n) { +dontasan size_t GetStackUsage(char *s, size_t n) { // RHEL5 MAP_GROWSDOWN seems to only grow to 68kb :'( // So we count non-zero bytes down from the top // First clear 64 bytes is considered the end diff --git a/libc/runtime/untrackmemoryintervals.c b/libc/runtime/untrackmemoryintervals.c index dfca2efe6..73221926e 100644 --- a/libc/runtime/untrackmemoryintervals.c +++ b/libc/runtime/untrackmemoryintervals.c @@ -23,7 +23,7 @@ int UntrackMemoryIntervals(void *addr, size_t size) { int a, b; - _unassert(size > 0); + unassert(size > 0); a = ROUNDDOWN((intptr_t)addr, FRAMESIZE) >> 16; b = ROUNDDOWN((intptr_t)addr + size - 1, FRAMESIZE) >> 16; return ReleaseMemoryIntervals(&_mmi, a, b, diff --git a/libc/sock/accept4-sysv.c b/libc/sock/accept4-sysv.c index a1a0c6113..f61d2d9fb 100644 --- a/libc/sock/accept4-sysv.c +++ b/libc/sock/accept4-sysv.c @@ -41,14 +41,14 @@ int sys_accept4(int server, struct sockaddr_storage *addr, int flags) { if ((client = __sys_accept(server, addr, &size, 0)) != -1) { // __sys_accept() has inconsistent flag inheritence across platforms // this is one of the issues that accept4() was invented for solving - _unassert((file_mode = __sys_fcntl(client, F_GETFD)) != -1); - _unassert(!__sys_fcntl(client, F_SETFD, - ((file_mode & ~FD_CLOEXEC) | - (flags & SOCK_CLOEXEC ? FD_CLOEXEC : 0)))); - _unassert((file_mode = __sys_fcntl(client, F_GETFL)) != -1); - _unassert(!__sys_fcntl(client, F_SETFL, - ((file_mode & ~O_NONBLOCK) | - (flags & SOCK_NONBLOCK ? O_NONBLOCK : 0)))); + unassert((file_mode = __sys_fcntl(client, F_GETFD)) != -1); + unassert(!__sys_fcntl(client, F_SETFD, + ((file_mode & ~FD_CLOEXEC) | + (flags & SOCK_CLOEXEC ? FD_CLOEXEC : 0)))); + unassert((file_mode = __sys_fcntl(client, F_GETFL)) != -1); + unassert(!__sys_fcntl(client, F_SETFL, + ((file_mode & ~O_NONBLOCK) | + (flags & SOCK_NONBLOCK ? O_NONBLOCK : 0)))); } } return client; diff --git a/libc/sock/bind-nt.c b/libc/sock/bind-nt.c index 2add613dc..dfc336bfa 100644 --- a/libc/sock/bind-nt.c +++ b/libc/sock/bind-nt.c @@ -25,7 +25,7 @@ textwindows int sys_bind_nt(struct Fd *fd, const void *addr, uint32_t addrsize) { - _npassert(fd->kind == kFdSocket); + npassert(fd->kind == kFdSocket); if (__sys_bind_nt(fd->handle, addr, addrsize) != -1) { return 0; } else { diff --git a/libc/sock/connect-nt.c b/libc/sock/connect-nt.c index 63fa29a5d..3f81b727c 100644 --- a/libc/sock/connect-nt.c +++ b/libc/sock/connect-nt.c @@ -28,7 +28,7 @@ textwindows int sys_connect_nt(struct Fd *fd, const void *addr, uint32_t addrsize) { struct SockFd *sockfd; sockfd = (struct SockFd *)fd->extra; - _npassert(fd->kind == kFdSocket); + npassert(fd->kind == kFdSocket); return __winsockblock( fd->handle, _bsr(kNtFdConnect), WSAConnect(fd->handle, addr, addrsize, NULL, NULL, NULL, NULL), diff --git a/libc/sock/epoll.c b/libc/sock/epoll.c index 8ab72cc4d..d90db45ba 100644 --- a/libc/sock/epoll.c +++ b/libc/sock/epoll.c @@ -383,7 +383,7 @@ static textwindows int afd_poll(int64_t afd_device_handle, struct NtIoStatusBlock *io_status_block) { NtStatus status; /* Blocking operation is not supported.*/ - _npassert(io_status_block); + npassert(io_status_block); io_status_block->Status = kNtStatusPending; status = NtDeviceIoControlFile(afd_device_handle, 0, NULL, io_status_block, @@ -563,7 +563,7 @@ static textwindows int ts_tree_add(struct TsTree *ts_tree, } static textwindows void port__free(struct PortState *port) { - _npassert(port); + npassert(port); free(port); } @@ -591,7 +591,7 @@ err1: } static textwindows int sock__cancel_poll(struct SockState *sock_state) { - _npassert(sock_state->poll_status == kPollPending); + npassert(sock_state->poll_status == kPollPending); if (afd_cancel_poll(poll_group_get_afd_device_handle(sock_state->poll_group), &sock_state->io_status_block) < 0) { return -1; @@ -707,13 +707,13 @@ static textwindows void reflock__await_event(void *address) { static textwindows void reflock_ref(struct RefLock *reflock) { long state = InterlockedAdd(&reflock->state, REFLOCK__REF); /* Verify that the counter didn 't overflow and the lock isn' t destroyed.*/ - _npassert((state & REFLOCK__DESTROY_MASK) == 0); + npassert((state & REFLOCK__DESTROY_MASK) == 0); } static textwindows void reflock_unref(struct RefLock *reflock) { long state = InterlockedAdd(&reflock->state, -REFLOCK__REF); /* Verify that the lock was referenced and not already destroyed.*/ - _npassert((state & REFLOCK__DESTROY_MASK & ~REFLOCK__DESTROY) == 0); + npassert((state & REFLOCK__DESTROY_MASK & ~REFLOCK__DESTROY) == 0); if (state == REFLOCK__DESTROY) reflock__signal_event(reflock); } @@ -749,10 +749,10 @@ static textwindows void reflock_unref_and_destroy(struct RefLock *reflock) { state = InterlockedAdd(&reflock->state, REFLOCK__DESTROY - REFLOCK__REF); ref_count = state & REFLOCK__REF_MASK; /* Verify that the lock was referenced and not already destroyed. */ - _npassert((state & REFLOCK__DESTROY_MASK) == REFLOCK__DESTROY); + npassert((state & REFLOCK__DESTROY_MASK) == REFLOCK__DESTROY); if (ref_count != 0) reflock__await_event(reflock); state = InterlockedExchange(&reflock->state, REFLOCK__POISON); - _npassert(state == REFLOCK__DESTROY); + npassert(state == REFLOCK__DESTROY); } static textwindows void ts_tree_node_unref_and_destroy( @@ -780,13 +780,13 @@ static textwindows void poll_group_release(struct PollGroup *poll_group) { struct PortState *port_state = poll_group->port_state; struct Queue *poll_group_queue = port_get_poll_group_queue(port_state); poll_group->group_size--; - _npassert(poll_group->group_size < MAX_GROUP_SIZE); + npassert(poll_group->group_size < MAX_GROUP_SIZE); queue_move_to_end(poll_group_queue, &poll_group->queue_node); /* Poll groups are currently only freed when the epoll port is closed. */ } static textwindows void sock__free(struct SockState *sock_state) { - _npassert(sock_state != NULL); + npassert(sock_state != NULL); free(sock_state); } @@ -832,7 +832,7 @@ static textwindows void sock_force_delete(struct PortState *port_state, } static textwindows void poll_group_delete(struct PollGroup *poll_group) { - _npassert(poll_group->group_size == 0); + npassert(poll_group->group_size == 0); CloseHandle(poll_group->afd_device_handle); queue_remove(&poll_group->queue_node); free(poll_group); @@ -844,7 +844,7 @@ static textwindows int port_delete(struct PortState *port_state) { struct SockState *sock_state; struct PollGroup *poll_group; /* At this point the IOCP port should have been closed.*/ - _npassert(!port_state->iocp_handle); + npassert(!port_state->iocp_handle); while ((tree_node = tree_root(&port_state->sock_tree)) != NULL) { sock_state = sock_state_from_tree_node(tree_node); sock_force_delete(port_state, sock_state); @@ -857,14 +857,14 @@ static textwindows int port_delete(struct PortState *port_state) { poll_group = poll_group_from_queue_node(queue_node); poll_group_delete(poll_group); } - _npassert(queue_is_empty(&port_state->sock_update_queue)); + npassert(queue_is_empty(&port_state->sock_update_queue)); DeleteCriticalSection(&port_state->lock); port__free(port_state); return 0; } static textwindows int64_t port_get_iocp_handle(struct PortState *port_state) { - _npassert(port_state->iocp_handle); + npassert(port_state->iocp_handle); return port_state->iocp_handle; } @@ -938,7 +938,7 @@ static textwindows uint32_t sock__afd_events_to_epoll_events(uint32_t a) { static textwindows int sock_update(struct PortState *port_state, struct SockState *sock_state) { - _npassert(!sock_state->delete_pending); + npassert(!sock_state->delete_pending); if ((sock_state->poll_status == kPollPending) && !(sock_state->user_events & KNOWN_EVENTS & ~sock_state->pending_events)) { /* All the events the user is interested in are already being diff --git a/libc/sock/getsockopt-nt.c b/libc/sock/getsockopt-nt.c index d85115b04..caa43f98b 100644 --- a/libc/sock/getsockopt-nt.c +++ b/libc/sock/getsockopt-nt.c @@ -36,7 +36,7 @@ textwindows int sys_getsockopt_nt(struct Fd *fd, int level, int optname, uint32_t in_optlen; struct SockFd *sockfd; struct linger_nt linger; - _npassert(fd->kind == kFdSocket); + npassert(fd->kind == kFdSocket); sockfd = (struct SockFd *)fd->extra; if (out_opt_optval && inout_optlen) { diff --git a/libc/sock/kntwsadata.c b/libc/sock/kntwsadata.c index fce9b568f..aca43955d 100644 --- a/libc/sock/kntwsadata.c +++ b/libc/sock/kntwsadata.c @@ -30,7 +30,7 @@ /** * Information about underlying Windows Sockets implementation. * - * Cosmopolitan automatically calls YOINK() on this symbol when its + * Cosmopolitan automatically calls __yoink() on this symbol when its * Berkeley Socket wrappers are linked. The latest version of Winsock * was introduced alongside x64, so this should never fail. */ @@ -43,7 +43,7 @@ static textwindows void WinSockCleanup(void) { NTTRACE("WSACleanup() → %d% lm", rc); } -textwindows noasan void WinSockInit(void) { +textwindows dontasan void WinSockInit(void) { int rc; atexit(WinSockCleanup); NTTRACE("WSAStartup()"); diff --git a/libc/sock/listen-nt.c b/libc/sock/listen-nt.c index c899f97ef..38c9d3b23 100644 --- a/libc/sock/listen-nt.c +++ b/libc/sock/listen-nt.c @@ -22,7 +22,7 @@ #include "libc/sock/syscall_fd.internal.h" textwindows int sys_listen_nt(struct Fd *fd, int backlog) { - _npassert(fd->kind == kFdSocket); + npassert(fd->kind == kFdSocket); if (__sys_listen_nt(fd->handle, backlog) != -1) { return 0; } else { diff --git a/libc/sock/nointernet.c b/libc/sock/nointernet.c index ce9ac094d..887ac19ca 100644 --- a/libc/sock/nointernet.c +++ b/libc/sock/nointernet.c @@ -323,7 +323,7 @@ int nointernet(void) { sigprocmask(SIG_SETMASK, &old, 0); return eperm(); } - _npassert(WIFSTOPPED(ws)); + npassert(WIFSTOPPED(ws)); // parent process becomes monitor of subprocess tree. all signals // continue to be blocked since we assume they'll also be sent to diff --git a/libc/sock/recv-nt.c b/libc/sock/recv-nt.c index 619383335..86e8c8806 100644 --- a/libc/sock/recv-nt.c +++ b/libc/sock/recv-nt.c @@ -49,6 +49,6 @@ textwindows ssize_t sys_recv_nt(struct Fd *fd, const struct iovec *iov, sockfd = (struct SockFd *)fd->extra; rc = __wsablock(fd, &overlapped, &flags, true, sockfd->rcvtimeo); } - _unassert(WSACloseEvent(overlapped.hEvent)); + unassert(WSACloseEvent(overlapped.hEvent)); return rc; } diff --git a/libc/sock/sendfile.c b/libc/sock/sendfile.c index de45a3077..1edc8eede 100644 --- a/libc/sock/sendfile.c +++ b/libc/sock/sendfile.c @@ -110,9 +110,9 @@ static dontinline textwindows ssize_t sys_sendfile_nt( if (rc != -1) { if (opt_in_out_inoffset) { *opt_in_out_inoffset = offset + rc; - _npassert(SetFilePointerEx(ih, pos, 0, SEEK_SET)); + npassert(SetFilePointerEx(ih, pos, 0, SEEK_SET)); } else { - _npassert(SetFilePointerEx(ih, offset + rc, 0, SEEK_SET)); + npassert(SetFilePointerEx(ih, offset + rc, 0, SEEK_SET)); } } WSACloseEvent(ov.hEvent); @@ -141,7 +141,7 @@ static ssize_t sys_sendfile_bsd(int outfd, int infd, if (opt_in_out_inoffset) { *opt_in_out_inoffset += sbytes; } else { - _npassert(lseek(infd, offset + sbytes, SEEK_SET) == offset + sbytes); + npassert(lseek(infd, offset + sbytes, SEEK_SET) == offset + sbytes); } return sbytes; } else { diff --git a/libc/sock/socket-nt.c b/libc/sock/socket-nt.c index 5e9874b1a..977a37db8 100644 --- a/libc/sock/socket-nt.c +++ b/libc/sock/socket-nt.c @@ -35,9 +35,9 @@ * functions through weak reference. This ensure those symbols are not * stripped during final link. */ -STATIC_YOINK("GetAdaptersAddresses"); -STATIC_YOINK("tprecode16to8"); -STATIC_YOINK("_dupsockfd"); +__static_yoink("GetAdaptersAddresses"); +__static_yoink("tprecode16to8"); +__static_yoink("_dupsockfd"); textwindows int sys_socket_nt(int family, int type, int protocol) { int64_t h; diff --git a/libc/sock/wsablock.c b/libc/sock/wsablock.c index a60c79072..e343ff0f6 100644 --- a/libc/sock/wsablock.c +++ b/libc/sock/wsablock.c @@ -47,8 +47,8 @@ textwindows int __wsablock(struct Fd *fd, struct NtOverlapped *overlapped, } if (fd->flags & O_NONBLOCK) { e = errno; - _unassert(CancelIoEx(fd->handle, overlapped) || - WSAGetLastError() == kNtErrorNotFound); + unassert(CancelIoEx(fd->handle, overlapped) || + WSAGetLastError() == kNtErrorNotFound); errno = e; } else { if (_check_interrupts(restartable, g_fds.p)) { diff --git a/libc/sock/yoink.inc b/libc/sock/yoink.inc index 4a210880d..e80415948 100644 --- a/libc/sock/yoink.inc +++ b/libc/sock/yoink.inc @@ -1,5 +1,5 @@ -STATIC_YOINK("kNtWsaData"); // for winmain -STATIC_YOINK("WSAGetLastError"); // for kprintf -STATIC_YOINK("sys_closesocket_nt"); // for close -STATIC_YOINK("sys_recv_nt"); // for readv -STATIC_YOINK("sys_send_nt"); // for writev +__static_yoink("kNtWsaData"); // for winmain +__static_yoink("WSAGetLastError"); // for kprintf +__static_yoink("sys_closesocket_nt"); // for close +__static_yoink("sys_recv_nt"); // for readv +__static_yoink("sys_send_nt"); // for writev diff --git a/libc/stdio/appendd.c b/libc/stdio/appendd.c index 31cde43d5..219c9c447 100644 --- a/libc/stdio/appendd.c +++ b/libc/stdio/appendd.c @@ -53,7 +53,7 @@ ssize_t appendd(char **b, const void *s, size_t l) { z.n = ROUNDUP(z.n, W); if ((p = realloc(p, z.n))) { z.n = malloc_usable_size(p); - _unassert(!(z.n & (W - 1))); + unassert(!(z.n & (W - 1))); *b = p; } else { return -1; diff --git a/libc/stdio/appendr.c b/libc/stdio/appendr.c index 13128f920..5e5cf52a2 100644 --- a/libc/stdio/appendr.c +++ b/libc/stdio/appendr.c @@ -51,14 +51,14 @@ ssize_t appendr(char **b, size_t i) { char *p; size_t n; struct appendz z; - _unassert(b); + unassert(b); z = appendz((p = *b)); if (i != z.i || !p) { n = ROUNDUP(i + 1, 8) + W; if (n > z.n || _bsrl(n) < _bsrl(z.n)) { if ((p = realloc(p, n))) { z.n = malloc_usable_size(p); - _unassert(!(z.n & (W - 1))); + unassert(!(z.n & (W - 1))); *b = p; } else { return -1; diff --git a/libc/stdio/appendw.c b/libc/stdio/appendw.c index c13db27f8..3c765b772 100644 --- a/libc/stdio/appendw.c +++ b/libc/stdio/appendw.c @@ -67,7 +67,7 @@ ssize_t appendw(char **b, uint64_t w) { z.n = ROUNDUP(z.n, W); if ((p = realloc(p, z.n))) { z.n = malloc_usable_size(p); - _unassert(!(z.n & (W - 1))); + unassert(!(z.n & (W - 1))); *b = p; } else { return -1; diff --git a/libc/stdio/appendz.c b/libc/stdio/appendz.c index 936908a28..a71a6142f 100644 --- a/libc/stdio/appendz.c +++ b/libc/stdio/appendz.c @@ -34,7 +34,7 @@ struct appendz appendz(char *p) { struct appendz z; if (p) { z.n = malloc_usable_size(p); - _unassert(z.n >= W * 2 && !(z.n & (W - 1))); + unassert(z.n >= W * 2 && !(z.n & (W - 1))); z.i = *(size_t *)(p + z.n - W); if (!IsTiny() && W == 8) { /* @@ -43,10 +43,10 @@ struct appendz appendz(char *p) { * can be free()'d safely, but they need to be allocated by the * append library, because we write a special value to the end. */ - _unassert((z.i >> 48) == APPEND_COOKIE); + unassert((z.i >> 48) == APPEND_COOKIE); z.i &= 0x0000ffffffffffff; } - _unassert(z.n >= z.i); + unassert(z.n >= z.i); } else { z.i = 0; z.n = 0; diff --git a/libc/stdio/dirstream.c b/libc/stdio/dirstream.c index 397ef1692..9c3bd2388 100644 --- a/libc/stdio/dirstream.c +++ b/libc/stdio/dirstream.c @@ -347,8 +347,8 @@ static struct dirent *readdir_impl(DIR *dir) { ent = 0; zip = _weaken(__zipos_get)(); while (!ent && dir->tell < dir->zip.records) { - _npassert(ZIP_CFILE_MAGIC(zip->map + dir->zip.offset) == - kZipCfileHdrMagic); + npassert(ZIP_CFILE_MAGIC(zip->map + dir->zip.offset) == + kZipCfileHdrMagic); s = ZIP_CFILE_NAME(zip->map + dir->zip.offset); n = ZIP_CFILE_NAMESIZE(zip->map + dir->zip.offset); if (dir->zip.prefixlen < n && diff --git a/libc/stdio/fmt.c b/libc/stdio/fmt.c index d6a2e392d..a9697f05b 100644 --- a/libc/stdio/fmt.c +++ b/libc/stdio/fmt.c @@ -270,7 +270,7 @@ static int __fmt_ntoa2(int out(const char *, void *, size_t), void *arg, } buf[len++] = alphabet[digit]; } while (value); - _npassert(count <= BUFFER_SIZE); + npassert(count <= BUFFER_SIZE); } return __fmt_ntoa_format(out, arg, buf, len, neg, log2base, prec, width, flags, alphabet); diff --git a/libc/stdio/getrandom.c b/libc/stdio/getrandom.c index 2532d8aac..4e93be046 100644 --- a/libc/stdio/getrandom.c +++ b/libc/stdio/getrandom.c @@ -52,7 +52,7 @@ #include "libc/sysv/errfuns.h" #include "libc/thread/thread.h" -STATIC_YOINK("rdrand_init"); +__static_yoink("rdrand_init"); int sys_getentropy(void *, size_t) asm("sys_getrandom"); @@ -128,7 +128,7 @@ static ssize_t GetRandomMetal(char *p, size_t n, int f) { } static void GetRandomEntropy(char *p, size_t n) { - _unassert(n <= 256); + unassert(n <= 256); if (sys_getentropy(p, n)) notpossible; } @@ -137,7 +137,7 @@ static void GetRandomArnd(char *p, size_t n) { int cmd[2]; cmd[0] = 1; // CTL_KERN cmd[1] = IsFreebsd() ? 37 : 81; // KERN_ARND - _unassert((m = n) <= 256); + unassert((m = n) <= 256); if (sys_sysctl(cmd, 2, p, &n, 0, 0) == -1) notpossible; if (m != n) notpossible; } diff --git a/libc/stdio/kvappendf.c b/libc/stdio/kvappendf.c index b0fc5dce5..df265fd73 100644 --- a/libc/stdio/kvappendf.c +++ b/libc/stdio/kvappendf.c @@ -51,9 +51,9 @@ ssize_t kvappendf(char **b, const char *f, va_list v) { z.n = ROUNDUP(z.n, W); if ((p = realloc(p, z.n))) { z.n = malloc_usable_size(p); - _unassert(!(z.n & (W - 1))); + unassert(!(z.n & (W - 1))); s = kvsnprintf(p + z.i, z.n - W - z.i, f, w); - _unassert(s == r); + unassert(s == r); *b = p; } else { va_end(w); diff --git a/libc/stdio/mkostempsm.c b/libc/stdio/mkostempsm.c index 61c58f437..aed32cffe 100644 --- a/libc/stdio/mkostempsm.c +++ b/libc/stdio/mkostempsm.c @@ -38,7 +38,7 @@ int mkostempsmi(char *tpl, int slen, unsigned flags, uint64_t *rando, int mode, size_t wildlen = strlen(WILDCARD); if (len < wildlen || slen > len - wildlen) return einval(); char *ss = tpl + len - wildlen - slen; - _npassert(memcmp(ss, WILDCARD, wildlen) == 0); + npassert(memcmp(ss, WILDCARD, wildlen) == 0); flags = (flags & ~(flags & O_ACCMODE)) | O_RDWR | O_CREAT | O_EXCL; unsigned attempts = ATTEMPTS; do { diff --git a/libc/stdio/popen.c b/libc/stdio/popen.c index 6d86497fa..b848d3903 100644 --- a/libc/stdio/popen.c +++ b/libc/stdio/popen.c @@ -73,26 +73,26 @@ FILE *popen(const char *cmdline, const char *mode) { if ((f = fdopen(pipefds[dir], mode))) { switch ((pid = fork())) { case 0: - _unassert(dup2(pipefds[!dir], !dir) == !dir); + unassert(dup2(pipefds[!dir], !dir) == !dir); // we can't rely on cloexec because cocmd builtins don't execve - if (pipefds[0] != !dir) _unassert(!close(pipefds[0])); - if (pipefds[1] != !dir) _unassert(!close(pipefds[1])); + if (pipefds[0] != !dir) unassert(!close(pipefds[0])); + if (pipefds[1] != !dir) unassert(!close(pipefds[1])); _Exit(_cocmd(3, (char *[]){"popen", "-c", cmdline, 0}, environ)); default: f->pid = pid; - _unassert(!close(pipefds[!dir])); + unassert(!close(pipefds[!dir])); return f; case -1: e = errno; - _unassert(!fclose(f)); - _unassert(!close(pipefds[!dir])); + unassert(!fclose(f)); + unassert(!close(pipefds[!dir])); errno = e; return NULL; } } else { e = errno; - _unassert(!close(pipefds[0])); - _unassert(!close(pipefds[1])); + unassert(!close(pipefds[0])); + unassert(!close(pipefds[1])); errno = e; return NULL; } diff --git a/libc/stdio/posix_spawnattr.c b/libc/stdio/posix_spawnattr.c index 622c2f1ca..7b2763135 100644 --- a/libc/stdio/posix_spawnattr.c +++ b/libc/stdio/posix_spawnattr.c @@ -217,7 +217,7 @@ int posix_spawnattr_getsigmask(const posix_spawnattr_t *attr, sigset_t *sigmask) { struct _posix_spawna *a = *(/*unconst*/ posix_spawnattr_t *)attr; if (!a->sigmask_isset) { - _npassert(!sigprocmask(SIG_SETMASK, 0, &a->sigmask)); + npassert(!sigprocmask(SIG_SETMASK, 0, &a->sigmask)); a->sigmask_isset = true; } *sigmask = a->sigmask; diff --git a/libc/stdio/rdrand.c b/libc/stdio/rdrand.c index d55fa10fb..60079b8fb 100644 --- a/libc/stdio/rdrand.c +++ b/libc/stdio/rdrand.c @@ -22,7 +22,7 @@ #include "libc/stdio/rand.h" #include "libc/sysv/consts/grnd.h" -STATIC_YOINK("rdrand_init"); +__static_yoink("rdrand_init"); static dontinline uint64_t rdrand_failover(void) { int f; diff --git a/libc/stdio/rngset.c b/libc/stdio/rngset.c index b9317d20f..601a1d92e 100644 --- a/libc/stdio/rngset.c +++ b/libc/stdio/rngset.c @@ -41,7 +41,7 @@ * * @return original buf */ -noasan void *rngset(void *b, size_t n, uint64_t seed(void), size_t reseed) { +dontasan void *rngset(void *b, size_t n, uint64_t seed(void), size_t reseed) { size_t m; uint64_t i, x, t = 0; unsigned char *p = b; diff --git a/libc/stdio/vappendf.c b/libc/stdio/vappendf.c index a8ac2873b..492e0d676 100644 --- a/libc/stdio/vappendf.c +++ b/libc/stdio/vappendf.c @@ -44,9 +44,9 @@ ssize_t(vappendf)(char **b, const char *f, va_list v) { z.n = ROUNDUP(z.n, W); if ((p = realloc(p, z.n))) { z.n = malloc_usable_size(p); - _unassert(!(z.n & (W - 1))); + unassert(!(z.n & (W - 1))); s = (vsnprintf)(p + z.i, z.n - W - z.i, f, w); - _unassert(s == r); + unassert(s == r); *b = p; } else { va_end(w); diff --git a/libc/stdio/vasprintf.c b/libc/stdio/vasprintf.c index a4d5a9f0f..cba7ae3b7 100644 --- a/libc/stdio/vasprintf.c +++ b/libc/stdio/vasprintf.c @@ -43,7 +43,7 @@ int vasprintf(char **strp, const char *fmt, va_list va) { if ((p2 = realloc(p, size))) { p = p2; wrote = vsnprintf(p, size, fmt, vb); - _unassert(wrote == size - 1); + unassert(wrote == size - 1); rc = wrote; } } diff --git a/libc/str/blake2.c b/libc/str/blake2.c index 815c3691f..26285aad6 100644 --- a/libc/str/blake2.c +++ b/libc/str/blake2.c @@ -126,7 +126,7 @@ int BLAKE2B256_Update(struct Blake2b *b2b, const void *in_data, size_t len) { return 0; } // More input remains therefore we must have filled |b2b->block|. - _unassert(b2b->block_used == BLAKE2B_CBLOCK); + unassert(b2b->block_used == BLAKE2B_CBLOCK); Blake2bTransform(b2b, b2b->block.words, BLAKE2B_CBLOCK, /*is_final_block=*/0); b2b->block_used = 0; diff --git a/libc/str/getcachesize.c b/libc/str/getcachesize.c index 769f66a9a..96eda56e5 100644 --- a/libc/str/getcachesize.c +++ b/libc/str/getcachesize.c @@ -52,8 +52,8 @@ static unsigned _getcachesize_cpuid4(int type, int level) { * @return size in bytes, or 0 if unknown */ unsigned _getcachesize(int type, int level) { - _unassert(1 <= type && type <= 3); - _unassert(level >= 1); + unassert(1 <= type && type <= 3); + unassert(level >= 1); return _getcachesize_cpuid4(type, level); } diff --git a/libc/str/isutf8.c b/libc/str/isutf8.c index 3c18af493..28b84e58a 100644 --- a/libc/str/isutf8.c +++ b/libc/str/isutf8.c @@ -51,7 +51,7 @@ static const char kUtf8Dispatch[] = { * * @param size if -1 implies strlen */ -noasan bool _isutf8(const void *data, size_t size) { +dontasan bool _isutf8(const void *data, size_t size) { long c; unsigned m; const char *p, *e; diff --git a/libc/str/memmem.c b/libc/str/memmem.c index 97b993431..c597ef79c 100644 --- a/libc/str/memmem.c +++ b/libc/str/memmem.c @@ -32,8 +32,8 @@ typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16))); * @param needlelen is its character count * @return pointer to first result or NULL if not found */ -noasan void *memmem(const void *haystack, size_t haystacklen, - const void *needle, size_t needlelen) { +dontasan void *memmem(const void *haystack, size_t haystacklen, + const void *needle, size_t needlelen) { #ifdef __x86_64__ char c; xmm_t n, *v; diff --git a/libc/str/memrchr16.c b/libc/str/memrchr16.c index f62335d5d..4d52aff18 100644 --- a/libc/str/memrchr16.c +++ b/libc/str/memrchr16.c @@ -35,8 +35,8 @@ static inline const char16_t *memrchr16_pure(const char16_t *s, char16_t c, } #ifdef __x86_64__ -noasan static inline const char16_t *memrchr16_sse(const char16_t *s, - char16_t c, size_t n) { +dontasan static inline const char16_t *memrchr16_sse(const char16_t *s, + char16_t c, size_t n) { size_t i; unsigned k, m; xmm_t v, t = {c, c, c, c, c, c, c, c}; diff --git a/libc/str/rawmemchr.c b/libc/str/rawmemchr.c index 085c58802..271c355b8 100644 --- a/libc/str/rawmemchr.c +++ b/libc/str/rawmemchr.c @@ -33,7 +33,8 @@ static inline const unsigned char *rawmemchr_pure(const unsigned char *s, #ifdef __x86_64__ typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16))); -noasan static inline const char *rawmemchr_sse(const char *s, unsigned char c) { +dontasan static inline const char *rawmemchr_sse(const char *s, + unsigned char c) { unsigned k; unsigned m; xmm_t v, *p; @@ -53,7 +54,7 @@ noasan static inline const char *rawmemchr_sse(const char *s, unsigned char c) { } #endif -static inline noasan uint64_t UncheckedAlignedRead64(unsigned char *p) { +static inline dontasan uint64_t UncheckedAlignedRead64(unsigned char *p) { return (uint64_t)p[7] << 070 | (uint64_t)p[6] << 060 | (uint64_t)p[5] << 050 | (uint64_t)p[4] << 040 | (uint64_t)p[3] << 030 | (uint64_t)p[2] << 020 | (uint64_t)p[1] << 010 | (uint64_t)p[0] << 000; diff --git a/libc/str/strcasecmp.c b/libc/str/strcasecmp.c index 219f2c730..0878aed5c 100644 --- a/libc/str/strcasecmp.c +++ b/libc/str/strcasecmp.c @@ -29,7 +29,7 @@ * @return is <0, 0, or >0 based on tolower(uint8_t) comparison * @asyncsignalsafe */ -noasan int strcasecmp(const char *a, const char *b) { +dontasan int strcasecmp(const char *a, const char *b) { int x, y; size_t i = 0; uint64_t v, w, d; diff --git a/libc/str/strcasestr.c b/libc/str/strcasestr.c index ff8411f78..15b0666b2 100644 --- a/libc/str/strcasestr.c +++ b/libc/str/strcasestr.c @@ -35,7 +35,7 @@ typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16))); * @asyncsignalsafe * @see strstr() */ -noasan char *strcasestr(const char *haystack, const char *needle) { +dontasan char *strcasestr(const char *haystack, const char *needle) { #ifdef __x86_64__ char c; xmm_t *p; diff --git a/libc/str/strlen16.c b/libc/str/strlen16.c index 1ea52b8d0..2fb5ab89e 100644 --- a/libc/str/strlen16.c +++ b/libc/str/strlen16.c @@ -29,7 +29,7 @@ typedef char16_t xmm_t __attribute__((__vector_size__(16), __aligned__(16))); * @return number of shorts (excluding NUL) * @asyncsignalsafe */ -noasan size_t strlen16(const char16_t *s) { +dontasan size_t strlen16(const char16_t *s) { #ifdef __x86_64__ size_t n; xmm_t z = {0}; diff --git a/libc/str/strnlen16.c b/libc/str/strnlen16.c index 4e59b1c0c..19a2b4e33 100644 --- a/libc/str/strnlen16.c +++ b/libc/str/strnlen16.c @@ -27,11 +27,11 @@ * @return number of shorts * @asyncsignalsafe */ -noasan size_t strnlen16(const char16_t *s, size_t n) { +dontasan size_t strnlen16(const char16_t *s, size_t n) { size_t i; for (i = 0;; ++i) { if (i == n || !s[i]) break; } - _unassert(i == n || (i < n && !s[i])); + unassert(i == n || (i < n && !s[i])); return i; } diff --git a/libc/str/strnlen_s.c b/libc/str/strnlen_s.c index d04084ea9..92c5ed5a3 100644 --- a/libc/str/strnlen_s.c +++ b/libc/str/strnlen_s.c @@ -21,7 +21,7 @@ #include "libc/intrin/asan.internal.h" #include "libc/str/str.h" -static noasan size_t strnlen_s_x64(const char *s, size_t n, size_t i) { +static dontasan size_t strnlen_s_x64(const char *s, size_t n, size_t i) { uint64_t w; for (; i + 8 < n; i += 8) { w = *(uint64_t *)(s + i); @@ -45,7 +45,7 @@ static noasan size_t strnlen_s_x64(const char *s, size_t n, size_t i) { * @return byte length * @asyncsignalsafe */ -noasan size_t strnlen_s(const char *s, size_t n) { +dontasan size_t strnlen_s(const char *s, size_t n) { size_t i; if (!s) return 0; if (IsAsan()) __asan_verify(s, n); @@ -56,6 +56,6 @@ noasan size_t strnlen_s(const char *s, size_t n) { for (;; ++i) { if (i == n || !s[i]) break; } - _unassert(i == n || (i < n && !s[i])); + unassert(i == n || (i < n && !s[i])); return i; } diff --git a/libc/str/strstr.c b/libc/str/strstr.c index b0de4ea9e..19cb585a0 100644 --- a/libc/str/strstr.c +++ b/libc/str/strstr.c @@ -35,7 +35,7 @@ typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16))); * @see strcasestr() * @see memmem() */ -noasan char *strstr(const char *haystack, const char *needle) { +dontasan char *strstr(const char *haystack, const char *needle) { #ifdef __x86_64__ xmm_t *p; size_t i; diff --git a/libc/str/strxfrm.c b/libc/str/strxfrm.c index ff665250f..e50661fb9 100644 --- a/libc/str/strxfrm.c +++ b/libc/str/strxfrm.c @@ -42,7 +42,7 @@ * @note if dest is NULL, count has to be zero */ size_t strxfrm(char *dest, const char *src, size_t count) { - _unassert(dest == NULL ? count == 0 : 1); + unassert(dest == NULL ? count == 0 : 1); return strlcpy(dest, src, count); } diff --git a/libc/str/timingsafe_bcmp.c b/libc/str/timingsafe_bcmp.c index f64fda30d..82e54b5ea 100644 --- a/libc/str/timingsafe_bcmp.c +++ b/libc/str/timingsafe_bcmp.c @@ -24,8 +24,8 @@ typedef uint64_t xmm_t __attribute__((__vector_size__(16), __aligned__(1))); -noasan static unsigned timingsafe_bcmp_sse(const char *p, const char *q, - size_t n) { +dontasan static unsigned timingsafe_bcmp_sse(const char *p, const char *q, + size_t n) { uint64_t w; xmm_t a = {0}; while (n > 16 + 16) { @@ -41,9 +41,9 @@ noasan static unsigned timingsafe_bcmp_sse(const char *p, const char *q, } #ifdef __x86_64__ -noasan static _Microarchitecture("avx") int timingsafe_bcmp_avx(const char *p, - const char *q, - size_t n) { +dontasan static _Microarchitecture("avx") int timingsafe_bcmp_avx(const char *p, + const char *q, + size_t n) { uint64_t w; xmm_t a = {0}; if (n > 32) { diff --git a/libc/str/tprecode16to8.c b/libc/str/tprecode16to8.c index 6708788ec..424ff7212 100644 --- a/libc/str/tprecode16to8.c +++ b/libc/str/tprecode16to8.c @@ -27,8 +27,8 @@ static const int16_t kDel16[8] = {127, 127, 127, 127, 127, 127, 127, 127}; /* 10x speedup for ascii */ -static noasan axdx_t tprecode16to8_sse2(char *dst, size_t dstsize, - const char16_t *src, axdx_t r) { +static dontasan axdx_t tprecode16to8_sse2(char *dst, size_t dstsize, + const char16_t *src, axdx_t r) { int16_t v1[8], v2[8], v3[8], vz[8]; memset(vz, 0, 16); while (r.ax + 8 < dstsize) { diff --git a/libc/str/tprecode8to16.c b/libc/str/tprecode8to16.c index a4f6bc9c1..4dd15b28f 100644 --- a/libc/str/tprecode8to16.c +++ b/libc/str/tprecode8to16.c @@ -25,8 +25,8 @@ #include "libc/str/utf16.h" /* 34x speedup for ascii */ -static inline noasan axdx_t tprecode8to16_sse2(char16_t *dst, size_t dstsize, - const char *src, axdx_t r) { +static inline dontasan axdx_t tprecode8to16_sse2(char16_t *dst, size_t dstsize, + const char *src, axdx_t r) { uint8_t v1[16], v2[16], vz[16]; memset(vz, 0, 16); while (r.ax + 16 < dstsize) { diff --git a/libc/str/wcslen.c b/libc/str/wcslen.c index 1d4d17c0e..ecea304cf 100644 --- a/libc/str/wcslen.c +++ b/libc/str/wcslen.c @@ -29,7 +29,7 @@ typedef wchar_t xmm_t __attribute__((__vector_size__(16), __aligned__(16))); * @return number of wide characters (excluding NUL) * @asyncsignalsafe */ -noasan size_t wcslen(const wchar_t *s) { +dontasan size_t wcslen(const wchar_t *s) { #ifdef __x86_64__ size_t n; xmm_t z = {0}; diff --git a/libc/str/wmemrchr.c b/libc/str/wmemrchr.c index e9e0519a8..ab9805c6e 100644 --- a/libc/str/wmemrchr.c +++ b/libc/str/wmemrchr.c @@ -36,8 +36,8 @@ static inline const wchar_t *wmemrchr_pure(const wchar_t *s, wchar_t c, } #ifdef __x86_64__ -noasan static inline const wchar_t *wmemrchr_sse(const wchar_t *s, wchar_t c, - size_t n) { +dontasan static inline const wchar_t *wmemrchr_sse(const wchar_t *s, wchar_t c, + size_t n) { size_t i; unsigned k, m; xmm_t v, t = {c, c, c, c}; diff --git a/libc/sysv/consts.sh b/libc/sysv/consts.sh index e97fc36b3..e2d66a494 100755 --- a/libc/sysv/consts.sh +++ b/libc/sysv/consts.sh @@ -416,39 +416,31 @@ syscon utime UTIME_NOW 0x3fffffff 0x3fffffff -1 -1 -1 -2 0x3fffffff syscon utime UTIME_OMIT 0x3ffffffe 0x3ffffffe -2 -2 -2 -1 0x3ffffffe -1 # timespec::tv_nsec may be this; polyfilled xnu/nt # getauxval() keys -# -# Unsupported values are encoded as 0. +# libc/sysv/consts/auxv.h # # group name GNU/Systemd GNU/Systemd (Aarch64) XNU's Not UNIX! MacOS (Arm64) FreeBSD OpenBSD NetBSD The New Technology Commentary -syscon auxv AT_EXECFD 2 2 0 0 2 0 2 0 # file descriptor of program -syscon auxv AT_PHDR 3 3 3 3 3 0 3 0 # address of program headers of executable -syscon auxv AT_PHENT 4 4 4 4 4 0 4 0 -syscon auxv AT_PHNUM 5 5 5 5 5 0 5 0 -syscon auxv AT_PAGESZ 6 6 6 6 6 0 6 0 -syscon auxv AT_BASE 7 7 7 7 7 0 7 0 # address of program interpreter -syscon auxv AT_FLAGS 8 8 0 0 8 0 8 0 -syscon auxv AT_ENTRY 9 9 9 9 9 0 9 0 # entry address of executable -syscon auxv AT_NOTELF 10 10 0 0 10 0 0 0 +syscon auxv AT_EXECFN 31 31 31 31 15 31 2014 31 # address of string containing first argument passed to execve() used when running program; AT_EXECPATH on FreeBSD +syscon auxv AT_SECURE 23 23 23 23 0 23 0 23 +syscon auxv AT_RANDOM 25 25 25 25 16 25 0 25 # address of sixteen bytes of random data; AT_CANARY on FreeBSD whose AT_CANARYLEN should be 64 +syscon auxv AT_HWCAP 16 16 16 16 0 16 0 16 +syscon auxv AT_HWCAP2 26 26 26 26 0 26 0 26 +syscon auxv AT_UID 11 11 11 11 0 11 2001 11 +syscon auxv AT_EUID 12 12 12 12 0 12 2000 12 +syscon auxv AT_GID 13 13 13 13 0 13 2003 13 +syscon auxv AT_EGID 14 14 14 14 0 14 2002 14 +syscon auxv AT_EXECFD 2 2 0 0 2 2 2 2 # file descriptor of program +syscon auxv AT_NOTELF 10 10 0 0 10 10 0 10 syscon auxv AT_OSRELDATE 0 0 0 0 18 0 0 0 -syscon auxv AT_UID 11 11 11 11 0 0 2001 0 -syscon auxv AT_EUID 12 12 12 12 0 0 2000 0 -syscon auxv AT_GID 13 13 13 13 0 0 2003 0 -syscon auxv AT_EGID 14 14 14 14 0 0 2002 0 -syscon auxv AT_PLATFORM 15 15 0 0 0 0 0 0 # address of string with hardware platform for rpath interpretation -syscon auxv AT_HWCAP 16 16 16 16 0 0 0 0 -syscon auxv AT_CLKTCK 17 17 0 0 0 0 0 0 -syscon auxv AT_DCACHEBSIZE 19 19 0 0 0 0 0 0 -syscon auxv AT_ICACHEBSIZE 20 20 0 0 0 0 0 0 -syscon auxv AT_UCACHEBSIZE 21 21 0 0 0 0 0 0 -syscon auxv AT_SECURE 23 23 23 23 0 0 0 0 -syscon auxv AT_BASE_PLATFORM 24 24 0 0 0 0 0 0 -syscon auxv AT_RANDOM 25 25 25 25 16 0 0 0 # address of sixteen bytes of random data; AT_CANARY on FreeBSD whose AT_CANARYLEN should be 64 -syscon auxv AT_HWCAP2 26 26 26 26 0 0 0 0 -syscon auxv AT_EXECFN 31 31 31 31 15 999 2014 31 # address of string containing first argument passed to execve() used when running program; AT_EXECPATH on FreeBSD -syscon auxv AT_SYSINFO_EHDR 33 33 0 0 0 0 0 0 +syscon auxv AT_PLATFORM 15 15 0 0 0 15 0 15 # address of string with hardware platform for rpath interpretation +syscon auxv AT_CLKTCK 17 17 0 0 0 17 0 17 +syscon auxv AT_DCACHEBSIZE 19 19 0 0 0 19 0 19 +syscon auxv AT_ICACHEBSIZE 20 20 0 0 0 20 0 20 +syscon auxv AT_UCACHEBSIZE 21 21 0 0 0 21 0 21 +syscon auxv AT_BASE_PLATFORM 24 24 0 0 0 24 0 24 +syscon auxv AT_SYSINFO_EHDR 33 33 0 0 0 33 0 33 syscon auxv AT_STACKBASE 0 0 0 0 0 0 13 0 -syscon auxv AT_EXECPATH 31 31 31 31 15 999 2014 31 # FreeBSD name for AT_EXECFN -syscon auxv AT_MINSIGSTKSZ 51 51 0 0 0 0 0 0 # FreeBSD name for AT_EXECFN +syscon auxv AT_EXECPATH 31 31 31 31 15 31 2014 31 # FreeBSD name for AT_EXECFN +syscon auxv AT_MINSIGSTKSZ 51 51 0 0 0 51 0 51 # FreeBSD name for AT_EXECFN syscon auxv AT_CANARY 0 0 0 0 16 0 0 0 syscon auxv AT_CANARYLEN 0 0 0 0 17 0 0 0 syscon auxv AT_NCPUS 0 0 0 0 19 0 0 0 @@ -457,7 +449,7 @@ syscon auxv AT_PAGESIZESLEN 0 0 0 0 21 0 0 0 syscon auxv AT_TIMEKEEP 0 0 0 0 22 0 0 0 syscon auxv AT_STACKPROT 0 0 0 0 23 0 0 0 syscon auxv AT_EHDRFLAGS 0 0 0 0 24 0 0 0 -syscon auxv AT_NO_AUTOMOUNT 0x0800 0x0800 0 0 0 0 0 0 +syscon auxv AT_NO_AUTOMOUNT 0x0800 0x0800 0 0 0 0x0800 0 0x0800 # getrlimit() / setrlimit() resource parameter # diff --git a/libc/sysv/consts/AT_BASE.S b/libc/sysv/consts/AT_BASE.S deleted file mode 100644 index 175c15fc0..000000000 --- a/libc/sysv/consts/AT_BASE.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_BASE,7,7,7,7,7,0,7,0 diff --git a/libc/sysv/consts/AT_BASE_PLATFORM.S b/libc/sysv/consts/AT_BASE_PLATFORM.S index 37316e7c4..8ce402d57 100644 --- a/libc/sysv/consts/AT_BASE_PLATFORM.S +++ b/libc/sysv/consts/AT_BASE_PLATFORM.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_BASE_PLATFORM,24,24,0,0,0,0,0,0 +.syscon auxv,AT_BASE_PLATFORM,24,24,0,0,0,24,0,24 diff --git a/libc/sysv/consts/AT_CLKTCK.S b/libc/sysv/consts/AT_CLKTCK.S index 3ace4dea9..3a36be93b 100644 --- a/libc/sysv/consts/AT_CLKTCK.S +++ b/libc/sysv/consts/AT_CLKTCK.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_CLKTCK,17,17,0,0,0,0,0,0 +.syscon auxv,AT_CLKTCK,17,17,0,0,0,17,0,17 diff --git a/libc/sysv/consts/AT_DCACHEBSIZE.S b/libc/sysv/consts/AT_DCACHEBSIZE.S index a0ca36d47..2c150f40e 100644 --- a/libc/sysv/consts/AT_DCACHEBSIZE.S +++ b/libc/sysv/consts/AT_DCACHEBSIZE.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_DCACHEBSIZE,19,19,0,0,0,0,0,0 +.syscon auxv,AT_DCACHEBSIZE,19,19,0,0,0,19,0,19 diff --git a/libc/sysv/consts/AT_EGID.S b/libc/sysv/consts/AT_EGID.S index 89835346d..8800e4d1d 100644 --- a/libc/sysv/consts/AT_EGID.S +++ b/libc/sysv/consts/AT_EGID.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_EGID,14,14,14,14,0,0,2002,0 +.syscon auxv,AT_EGID,14,14,14,14,0,14,2002,14 diff --git a/libc/sysv/consts/AT_ENTRY.S b/libc/sysv/consts/AT_ENTRY.S deleted file mode 100644 index 843856b89..000000000 --- a/libc/sysv/consts/AT_ENTRY.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_ENTRY,9,9,9,9,9,0,9,0 diff --git a/libc/sysv/consts/AT_EUID.S b/libc/sysv/consts/AT_EUID.S index a332b0a0c..d41d9814d 100644 --- a/libc/sysv/consts/AT_EUID.S +++ b/libc/sysv/consts/AT_EUID.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_EUID,12,12,12,12,0,0,2000,0 +.syscon auxv,AT_EUID,12,12,12,12,0,12,2000,12 diff --git a/libc/sysv/consts/AT_EXECFD.S b/libc/sysv/consts/AT_EXECFD.S index 336f7abf7..015bffda2 100644 --- a/libc/sysv/consts/AT_EXECFD.S +++ b/libc/sysv/consts/AT_EXECFD.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_EXECFD,2,2,0,0,2,0,2,0 +.syscon auxv,AT_EXECFD,2,2,0,0,2,2,2,2 diff --git a/libc/sysv/consts/AT_EXECFN.S b/libc/sysv/consts/AT_EXECFN.S index bd6e4da73..363f4b7cd 100644 --- a/libc/sysv/consts/AT_EXECFN.S +++ b/libc/sysv/consts/AT_EXECFN.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_EXECFN,31,31,31,31,15,999,2014,31 +.syscon auxv,AT_EXECFN,31,31,31,31,15,31,2014,31 diff --git a/libc/sysv/consts/AT_EXECPATH.S b/libc/sysv/consts/AT_EXECPATH.S index 3c428940a..b301433f6 100644 --- a/libc/sysv/consts/AT_EXECPATH.S +++ b/libc/sysv/consts/AT_EXECPATH.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_EXECPATH,31,31,31,31,15,999,2014,31 +.syscon auxv,AT_EXECPATH,31,31,31,31,15,31,2014,31 diff --git a/libc/sysv/consts/AT_FLAGS.S b/libc/sysv/consts/AT_FLAGS.S deleted file mode 100644 index 0183d3433..000000000 --- a/libc/sysv/consts/AT_FLAGS.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_FLAGS,8,8,0,0,8,0,8,0 diff --git a/libc/sysv/consts/AT_GID.S b/libc/sysv/consts/AT_GID.S index 2b78a8828..87784f3f6 100644 --- a/libc/sysv/consts/AT_GID.S +++ b/libc/sysv/consts/AT_GID.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_GID,13,13,13,13,0,0,2003,0 +.syscon auxv,AT_GID,13,13,13,13,0,13,2003,13 diff --git a/libc/sysv/consts/AT_HWCAP.S b/libc/sysv/consts/AT_HWCAP.S index 122148719..0db036194 100644 --- a/libc/sysv/consts/AT_HWCAP.S +++ b/libc/sysv/consts/AT_HWCAP.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_HWCAP,16,16,16,16,0,0,0,0 +.syscon auxv,AT_HWCAP,16,16,16,16,0,16,0,16 diff --git a/libc/sysv/consts/AT_HWCAP2.S b/libc/sysv/consts/AT_HWCAP2.S index 655984437..824f587e0 100644 --- a/libc/sysv/consts/AT_HWCAP2.S +++ b/libc/sysv/consts/AT_HWCAP2.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_HWCAP2,26,26,26,26,0,0,0,0 +.syscon auxv,AT_HWCAP2,26,26,26,26,0,26,0,26 diff --git a/libc/sysv/consts/AT_ICACHEBSIZE.S b/libc/sysv/consts/AT_ICACHEBSIZE.S index e8163afed..4ee5b52cc 100644 --- a/libc/sysv/consts/AT_ICACHEBSIZE.S +++ b/libc/sysv/consts/AT_ICACHEBSIZE.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_ICACHEBSIZE,20,20,0,0,0,0,0,0 +.syscon auxv,AT_ICACHEBSIZE,20,20,0,0,0,20,0,20 diff --git a/libc/sysv/consts/AT_MINSIGSTKSZ.S b/libc/sysv/consts/AT_MINSIGSTKSZ.S index 05b310d3f..e9fd4aaf0 100644 --- a/libc/sysv/consts/AT_MINSIGSTKSZ.S +++ b/libc/sysv/consts/AT_MINSIGSTKSZ.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_MINSIGSTKSZ,51,51,0,0,0,0,0,0 +.syscon auxv,AT_MINSIGSTKSZ,51,51,0,0,0,51,0,51 diff --git a/libc/sysv/consts/AT_NOTELF.S b/libc/sysv/consts/AT_NOTELF.S index 1fabb1749..1abd92f1e 100644 --- a/libc/sysv/consts/AT_NOTELF.S +++ b/libc/sysv/consts/AT_NOTELF.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_NOTELF,10,10,0,0,10,0,0,0 +.syscon auxv,AT_NOTELF,10,10,0,0,10,10,0,10 diff --git a/libc/sysv/consts/AT_NO_AUTOMOUNT.S b/libc/sysv/consts/AT_NO_AUTOMOUNT.S index 8a579fcf2..9c701cef4 100644 --- a/libc/sysv/consts/AT_NO_AUTOMOUNT.S +++ b/libc/sysv/consts/AT_NO_AUTOMOUNT.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_NO_AUTOMOUNT,0x0800,0x0800,0,0,0,0,0,0 +.syscon auxv,AT_NO_AUTOMOUNT,0x0800,0x0800,0,0,0,0x0800,0,0x0800 diff --git a/libc/sysv/consts/AT_PAGESZ.S b/libc/sysv/consts/AT_PAGESZ.S deleted file mode 100644 index 5667dfe39..000000000 --- a/libc/sysv/consts/AT_PAGESZ.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_PAGESZ,6,6,6,6,6,0,6,0 diff --git a/libc/sysv/consts/AT_PHDR.S b/libc/sysv/consts/AT_PHDR.S deleted file mode 100644 index 90d38960f..000000000 --- a/libc/sysv/consts/AT_PHDR.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_PHDR,3,3,3,3,3,0,3,0 diff --git a/libc/sysv/consts/AT_PHENT.S b/libc/sysv/consts/AT_PHENT.S deleted file mode 100644 index d3ab1e34d..000000000 --- a/libc/sysv/consts/AT_PHENT.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_PHENT,4,4,4,4,4,0,4,0 diff --git a/libc/sysv/consts/AT_PHNUM.S b/libc/sysv/consts/AT_PHNUM.S deleted file mode 100644 index 0e62951ed..000000000 --- a/libc/sysv/consts/AT_PHNUM.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_PHNUM,5,5,5,5,5,0,5,0 diff --git a/libc/sysv/consts/AT_PLATFORM.S b/libc/sysv/consts/AT_PLATFORM.S index 29d4660df..e5f4bf031 100644 --- a/libc/sysv/consts/AT_PLATFORM.S +++ b/libc/sysv/consts/AT_PLATFORM.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_PLATFORM,15,15,0,0,0,0,0,0 +.syscon auxv,AT_PLATFORM,15,15,0,0,0,15,0,15 diff --git a/libc/sysv/consts/AT_RANDOM.S b/libc/sysv/consts/AT_RANDOM.S index b13b6ed17..2710efb4a 100644 --- a/libc/sysv/consts/AT_RANDOM.S +++ b/libc/sysv/consts/AT_RANDOM.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_RANDOM,25,25,25,25,16,0,0,0 +.syscon auxv,AT_RANDOM,25,25,25,25,16,25,0,25 diff --git a/libc/sysv/consts/AT_SECURE.S b/libc/sysv/consts/AT_SECURE.S index 44dc2ebff..d9f0f1218 100644 --- a/libc/sysv/consts/AT_SECURE.S +++ b/libc/sysv/consts/AT_SECURE.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_SECURE,23,23,23,23,0,0,0,0 +.syscon auxv,AT_SECURE,23,23,23,23,0,23,0,23 diff --git a/libc/sysv/consts/AT_SYSINFO_EHDR.S b/libc/sysv/consts/AT_SYSINFO_EHDR.S index 3796556bc..fd5dda35b 100644 --- a/libc/sysv/consts/AT_SYSINFO_EHDR.S +++ b/libc/sysv/consts/AT_SYSINFO_EHDR.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_SYSINFO_EHDR,33,33,0,0,0,0,0,0 +.syscon auxv,AT_SYSINFO_EHDR,33,33,0,0,0,33,0,33 diff --git a/libc/sysv/consts/AT_UCACHEBSIZE.S b/libc/sysv/consts/AT_UCACHEBSIZE.S index 3d1a2020e..4d949b6e7 100644 --- a/libc/sysv/consts/AT_UCACHEBSIZE.S +++ b/libc/sysv/consts/AT_UCACHEBSIZE.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_UCACHEBSIZE,21,21,0,0,0,0,0,0 +.syscon auxv,AT_UCACHEBSIZE,21,21,0,0,0,21,0,21 diff --git a/libc/sysv/consts/AT_UID.S b/libc/sysv/consts/AT_UID.S index 32ea21f60..b56d63cab 100644 --- a/libc/sysv/consts/AT_UID.S +++ b/libc/sysv/consts/AT_UID.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon auxv,AT_UID,11,11,11,11,0,0,2001,0 +.syscon auxv,AT_UID,11,11,11,11,0,11,2001,11 diff --git a/libc/sysv/consts/auxv.h b/libc/sysv/consts/auxv.h index 8972acf38..0bbb02176 100644 --- a/libc/sysv/consts/auxv.h +++ b/libc/sysv/consts/auxv.h @@ -1,25 +1,53 @@ #ifndef COSMOPOLITAN_LIBC_CALLS_AUXV_H_ #define COSMOPOLITAN_LIBC_CALLS_AUXV_H_ + +/* + * integral getauxval() keys + */ +#define AT_PHDR 3 +#define AT_PHENT 4 +#define AT_PHNUM 5 +#define AT_PAGESZ 6 +#define AT_BASE 7 +#define AT_FLAGS 8 +#define AT_ENTRY 9 + #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -extern const unsigned long AT_BASE; +/* + * portable getauxval() keys + */ +extern const unsigned long AT_EXECFN; +extern const unsigned long AT_SECURE; +extern const unsigned long AT_RANDOM; +extern const unsigned long AT_HWCAP; +extern const unsigned long AT_HWCAP2; +extern const unsigned long AT_UID; +extern const unsigned long AT_EUID; +extern const unsigned long AT_GID; +extern const unsigned long AT_EGID; +#define AT_EXECFN AT_EXECFN +#define AT_SECURE AT_SECURE +#define AT_RANDOM AT_RANDOM +#define AT_HWCAP AT_HWCAP +#define AT_HWCAP2 AT_HWCAP2 +#define AT_UID AT_UID +#define AT_EUID AT_EUID +#define AT_GID AT_GID +#define AT_EGID AT_EGID + +/* + * platform-specific getauxval() keys + */ extern const unsigned long AT_BASE_PLATFORM; extern const unsigned long AT_CANARY; extern const unsigned long AT_CANARYLEN; extern const unsigned long AT_CLKTCK; extern const unsigned long AT_DCACHEBSIZE; -extern const unsigned long AT_EGID; extern const unsigned long AT_EHDRFLAGS; -extern const unsigned long AT_ENTRY; -extern const unsigned long AT_EUID; extern const unsigned long AT_EXECFD; -extern const unsigned long AT_EXECFN; extern const unsigned long AT_EXECPATH; -extern const unsigned long AT_FLAGS; -extern const unsigned long AT_GID; -extern const unsigned long AT_HWCAP2; -extern const unsigned long AT_HWCAP; extern const unsigned long AT_ICACHEBSIZE; extern const unsigned long AT_MINSIGSTKSZ; extern const unsigned long AT_NCPUS; @@ -28,61 +56,13 @@ extern const unsigned long AT_NO_AUTOMOUNT; extern const unsigned long AT_OSRELDATE; extern const unsigned long AT_PAGESIZES; extern const unsigned long AT_PAGESIZESLEN; -extern const unsigned long AT_PAGESZ; -extern const unsigned long AT_PHDR; -extern const unsigned long AT_PHENT; -extern const unsigned long AT_PHNUM; extern const unsigned long AT_PLATFORM; -extern const unsigned long AT_RANDOM; -extern const unsigned long AT_SECURE; extern const unsigned long AT_STACKBASE; extern const unsigned long AT_STACKPROT; extern const unsigned long AT_SYSINFO_EHDR; extern const unsigned long AT_TIMEKEEP; extern const unsigned long AT_UCACHEBSIZE; -extern const unsigned long AT_UID; COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ - -#define AT_BASE AT_BASE -#define AT_BASE_PLATFORM AT_BASE_PLATFORM -#define AT_CANARY AT_CANARY -#define AT_CANARYLEN AT_CANARYLEN -#define AT_CLKTCK AT_CLKTCK -#define AT_DCACHEBSIZE AT_DCACHEBSIZE -#define AT_EGID AT_EGID -#define AT_EHDRFLAGS AT_EHDRFLAGS -#define AT_ENTRY AT_ENTRY -#define AT_EUID AT_EUID -#define AT_EXECFD AT_EXECFD -#define AT_EXECFN AT_EXECFN -#define AT_EXECPATH AT_EXECPATH -#define AT_FLAGS AT_FLAGS -#define AT_GID AT_GID -#define AT_HWCAP AT_HWCAP -#define AT_HWCAP2 AT_HWCAP2 -#define AT_ICACHEBSIZE AT_ICACHEBSIZE -#define AT_MINSIGSTKSZ AT_MINSIGSTKSZ -#define AT_NCPUS AT_NCPUS -#define AT_NOTELF AT_NOTELF -#define AT_NO_AUTOMOUNT AT_NO_AUTOMOUNT -#define AT_OSRELDATE AT_OSRELDATE -#define AT_PAGESIZES AT_PAGESIZES -#define AT_PAGESIZESLEN AT_PAGESIZESLEN -#define AT_PAGESZ AT_PAGESZ -#define AT_PHDR AT_PHDR -#define AT_PHENT AT_PHENT -#define AT_PHNUM AT_PHNUM -#define AT_PLATFORM AT_PLATFORM -#define AT_RANDOM AT_RANDOM -#define AT_SECURE AT_SECURE -#define AT_STACKBASE AT_STACKBASE -#define AT_STACKPROT AT_STACKPROT -#define AT_SYSINFO_EHDR AT_SYSINFO_EHDR -#define AT_TIMEKEEP AT_TIMEKEEP -#define AT_UCACHEBSIZE AT_UCACHEBSIZE -#define AT_UID AT_UID - - #endif /* COSMOPOLITAN_LIBC_CALLS_AUXV_H_ */ diff --git a/libc/testlib/extract.c b/libc/testlib/extract.c index a0da629d3..4d6bcf194 100644 --- a/libc/testlib/extract.c +++ b/libc/testlib/extract.c @@ -20,7 +20,7 @@ #include "libc/sysv/consts/o.h" #include "libc/testlib/testlib.h" -STATIC_YOINK("zipos"); +__static_yoink("zipos"); /** * Extracts zip asset to filesystem. diff --git a/libc/testlib/ezbenchreport.c b/libc/testlib/ezbenchreport.c index 53b6cfaaa..bd9fe7ce3 100644 --- a/libc/testlib/ezbenchreport.c +++ b/libc/testlib/ezbenchreport.c @@ -24,7 +24,7 @@ #include "libc/time/time.h" #include "libc/x/x.h" -STATIC_YOINK("strnwidth"); +__static_yoink("strnwidth"); void __testlib_ezbenchreport(const char *form, double c1, double c2) { long ns1, ns2; @@ -32,7 +32,7 @@ void __testlib_ezbenchreport(const char *form, double c1, double c2) { ns1 = lrintl(ConvertTicksToNanos(c1)); ns2 = lrintl(ConvertTicksToNanos(c2)); (fprintf)(stderr, - VEIL("r", " * %-19s l: %,9luc %,9luns m: %,9luc %,9luns\n"), + __veil("r", " * %-19s l: %,9luc %,9luns m: %,9luc %,9luns\n"), form, lrint(c1), ns1, lrint(c2), ns2); } @@ -47,40 +47,41 @@ void __testlib_ezbenchreport_n(const char *form, char z, size_t n, double c) { (fprintf)(stderr, "\n"); (fprintf)(stderr, " * %-28s", msg); if (cn < 1) { - (fprintf)(stderr, VEIL("r", " %,9lu %-12s"), (int64_t)(cn * 1024), + (fprintf)(stderr, __veil("r", " %,9lu %-12s"), (int64_t)(cn * 1024), "picoseconds"); } else if (cn > 1024) { - (fprintf)(stderr, VEIL("r", " %,9lu %-12s"), (int64_t)(cn / 1024), + (fprintf)(stderr, __veil("r", " %,9lu %-12s"), (int64_t)(cn / 1024), "microseconds"); } else { - (fprintf)(stderr, VEIL("r", " %,9lu %-12s"), (int64_t)cn, "nanoseconds"); + (fprintf)(stderr, __veil("r", " %,9lu %-12s"), (int64_t)cn, + "nanoseconds"); } } else { (fprintf)(stderr, " * %-28s", msg); bps = n / cn * 1e9; lat = cn / n; if (lat < 1e-3) { - (fprintf)(stderr, VEIL("r", " %,9lu %-12s"), (int64_t)(lat * 1024 * 1024), - "fs/byte"); + (fprintf)(stderr, __veil("r", " %,9lu %-12s"), + (int64_t)(lat * 1024 * 1024), "fs/byte"); } else if (lat < 1) { - (fprintf)(stderr, VEIL("r", " %,9lu %-12s"), (int64_t)(lat * 1024), + (fprintf)(stderr, __veil("r", " %,9lu %-12s"), (int64_t)(lat * 1024), "ps/byte"); } else if (lat > 1024) { - (fprintf)(stderr, VEIL("r", " %,9lu %-12s"), (int64_t)(lat / 1024), + (fprintf)(stderr, __veil("r", " %,9lu %-12s"), (int64_t)(lat / 1024), "µs/byte"); } else { - (fprintf)(stderr, VEIL("r", " %,9lu %-12s"), (int64_t)lat, "ns/byte"); + (fprintf)(stderr, __veil("r", " %,9lu %-12s"), (int64_t)lat, "ns/byte"); } if (bps < 10 * 1000) { - (fprintf)(stderr, VEIL("r", " %,9lu b/s"), bps); + (fprintf)(stderr, __veil("r", " %,9lu b/s"), bps); } else if (bps < 10 * 1000 * 1024) { - (fprintf)(stderr, VEIL("r", " %,9lu kb/s"), bps / 1024); + (fprintf)(stderr, __veil("r", " %,9lu kb/s"), bps / 1024); } else if (bps < 10ul * 1000 * 1024 * 1024) { - (fprintf)(stderr, VEIL("r", " %,9lu mb/s"), bps / (1024 * 1024)); + (fprintf)(stderr, __veil("r", " %,9lu mb/s"), bps / (1024 * 1024)); } else if (bps < 10ul * 1000 * 1024 * 1024 * 1024) { - (fprintf)(stderr, VEIL("r", " %,9lu GB/s"), bps / (1024 * 1024 * 1024)); + (fprintf)(stderr, __veil("r", " %,9lu GB/s"), bps / (1024 * 1024 * 1024)); } else { - (fprintf)(stderr, VEIL("r", " %,9lu TB/s"), + (fprintf)(stderr, __veil("r", " %,9lu TB/s"), bps / (1024ul * 1024 * 1024 * 1024)); } } diff --git a/libc/testlib/memoryexists.c b/libc/testlib/memoryexists.c index 0db928464..718449e87 100644 --- a/libc/testlib/memoryexists.c +++ b/libc/testlib/memoryexists.c @@ -51,7 +51,7 @@ static void ContinueOnError(int sig, siginfo_t *si, void *vctx) { * on error. It then attempts a volatile read and if it faults, then * this function shall return false. The value at `p` isn't considered. */ -noasan bool testlib_memoryexists(const void *p) { +dontasan bool testlib_memoryexists(const void *p) { volatile char c; const atomic_char *mem = p; struct sigaction old[2]; @@ -60,11 +60,11 @@ noasan bool testlib_memoryexists(const void *p) { .sa_flags = SA_SIGINFO, }; gotsignal = 0; - _npassert(!sigaction(SIGSEGV, &sa, old + 0)); - _npassert(!sigaction(SIGBUS, &sa, old + 1)); + npassert(!sigaction(SIGSEGV, &sa, old + 0)); + npassert(!sigaction(SIGBUS, &sa, old + 1)); c = atomic_load(mem); (void)c; - _npassert(!sigaction(SIGBUS, old + 1, 0)); - _npassert(!sigaction(SIGSEGV, old + 0, 0)); + npassert(!sigaction(SIGBUS, old + 1, 0)); + npassert(!sigaction(SIGSEGV, old + 0, 0)); return !gotsignal; } diff --git a/libc/testlib/quota.c b/libc/testlib/quota.c index 2f5c66576..ea4bf84ef 100644 --- a/libc/testlib/quota.c +++ b/libc/testlib/quota.c @@ -34,7 +34,7 @@ #include "libc/testlib/testlib.h" #include "third_party/dlmalloc/dlmalloc.h" -static noasan noubsan relegated uint64_t CountMappedBytes(void) { +static dontasan dontubsan relegated uint64_t CountMappedBytes(void) { size_t i; uint64_t x, y; for (x = i = 0; i < _mmi.i; ++i) { diff --git a/libc/testlib/testlib.h b/libc/testlib/testlib.h index 371383704..606da71bb 100644 --- a/libc/testlib/testlib.h +++ b/libc/testlib/testlib.h @@ -13,7 +13,7 @@ COSMOPOLITAN_C_START_ * the (SUITE, NAME) tuple passed here. */ #define TEST(SUITE, NAME) \ - STATIC_YOINK("__testcase_start"); \ + __static_yoink("__testcase_start"); \ __TEST_PROTOTYPE(SUITE, NAME, __TEST_ARRAY, ) /** @@ -26,7 +26,7 @@ COSMOPOLITAN_C_START_ * are also guaranteed by the linker to be run in sorted order. */ #define FIXTURE(SUITE, NAME) \ - STATIC_YOINK("__fixture_start"); \ + __static_yoink("__fixture_start"); \ __FIXTURE("fixture", SUITE, NAME) /** @@ -37,7 +37,7 @@ COSMOPOLITAN_C_START_ * more appropriate for testing pure code (i.e. no syscalls) like math. */ #define COMBO(GROUP, ENTRY) \ - STATIC_YOINK("__combo_start"); \ + __static_yoink("__combo_start"); \ __FIXTURE("combo", GROUP, ENTRY) /** @@ -50,7 +50,7 @@ COSMOPOLITAN_C_START_ * @see EZBENCH() */ #define BENCH(SUITE, NAME) \ - STATIC_YOINK("__bench_start"); \ + __static_yoink("__bench_start"); \ __TEST_PROTOTYPE(SUITE, NAME, __BENCH_ARRAY, optimizespeed) #define ASSERT_GE(C, X) _TEST2("ASSERT_GE", C, >=, (X), #C, " ≥ ", #X, 1) diff --git a/libc/testlib/testmain.c b/libc/testlib/testmain.c index 538b7f267..7172e12fe 100644 --- a/libc/testlib/testmain.c +++ b/libc/testlib/testmain.c @@ -67,10 +67,10 @@ Flags:\n\ -h show this information\n\ \n" -STATIC_YOINK("__die"); -STATIC_YOINK("GetSymbolByAddr"); -STATIC_YOINK("testlib_quota_handlers"); -STATIC_YOINK("stack_usage_logging"); +__static_yoink("__die"); +__static_yoink("GetSymbolByAddr"); +__static_yoink("testlib_quota_handlers"); +__static_yoink("stack_usage_logging"); static bool runbenchmarks_; @@ -163,7 +163,7 @@ static void SetLimit(int resource, uint64_t soft, uint64_t hard) { /** * Generic test program main function. */ -noasan int main(int argc, char *argv[]) { +dontasan int main(int argc, char *argv[]) { unsigned cpus; const char *comdbg; __log_level = kLogInfo; diff --git a/libc/testlib/testrunner.c b/libc/testlib/testrunner.c index ad9cbee2d..2fd264bf7 100644 --- a/libc/testlib/testrunner.c +++ b/libc/testlib/testrunner.c @@ -120,7 +120,7 @@ static void CheckSignalHandler(int sig) { #if 0 int i; struct sigaction sa = {0}; - _unassert(0 <= sig - 1 && sig - 1 < ARRAYLEN(wanthandlers)); + unassert(0 <= sig - 1 && sig - 1 < ARRAYLEN(wanthandlers)); CHECK_EQ(0, sigaction(sig, 0, &sa)); CHECK_EQ(0, memcmp(wanthandlers + sig - 1, &sa, sizeof(sa)), "signal handler for %s was %p/%#x/%#x:%x " diff --git a/libc/testlib/waitforexit.c b/libc/testlib/waitforexit.c index 79b8beba8..a1218fbf5 100644 --- a/libc/testlib/waitforexit.c +++ b/libc/testlib/waitforexit.c @@ -22,7 +22,7 @@ #include "libc/str/str.h" #include "libc/testlib/testlib.h" -STATIC_YOINK("strsignal"); +__static_yoink("strsignal"); void testlib_waitforexit(const char *file, int line, const char *code, int rc, int pid) { diff --git a/libc/testlib/waitforterm.c b/libc/testlib/waitforterm.c index cf3b0512c..75eb80765 100644 --- a/libc/testlib/waitforterm.c +++ b/libc/testlib/waitforterm.c @@ -22,7 +22,7 @@ #include "libc/str/str.h" #include "libc/testlib/testlib.h" -STATIC_YOINK("strsignal"); +__static_yoink("strsignal"); void testlib_waitforterm(const char *file, int line, const char *code, int sig, int pid) { diff --git a/libc/thread/pthread_atfork.c b/libc/thread/pthread_atfork.c index fa8d0d1e8..2aaf7b31d 100644 --- a/libc/thread/pthread_atfork.c +++ b/libc/thread/pthread_atfork.c @@ -48,7 +48,7 @@ static void _pthread_purge(void) { static void _pthread_onfork(int i) { struct AtFork *a; struct PosixThread *pt; - _unassert(0 <= i && i <= 2); + unassert(0 <= i && i <= 2); if (!i) pthread_spin_lock(&_atforks.lock); for (a = _atforks.list; a; a = a->p[!i]) { if (a->f[i]) a->f[i](); diff --git a/libc/thread/pthread_attr_init.c b/libc/thread/pthread_attr_init.c index 87b7f7441..231d7db1d 100644 --- a/libc/thread/pthread_attr_init.c +++ b/libc/thread/pthread_attr_init.c @@ -16,7 +16,9 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/runtime/runtime.h" #include "libc/runtime/stack.h" +#include "libc/sysv/consts/auxv.h" #include "libc/thread/thread.h" /** @@ -36,7 +38,7 @@ errno_t pthread_attr_init(pthread_attr_t *attr) { *attr = (pthread_attr_t){ .__stacksize = GetStackSize(), - .__guardsize = APE_GUARDSIZE, + .__guardsize = getauxval(AT_PAGESZ), }; return 0; } diff --git a/libc/thread/pthread_cancel.c b/libc/thread/pthread_cancel.c index 0a0124fed..882cab2a9 100644 --- a/libc/thread/pthread_cancel.c +++ b/libc/thread/pthread_cancel.c @@ -75,7 +75,7 @@ static void ListenForSigThr(void) { sa.sa_sigaction = OnSigThr; sa.sa_flags = SA_SIGINFO | SA_RESTART | SA_ONSTACK; memset(&sa.sa_mask, -1, sizeof(sa.sa_mask)); - _npassert(!sigaction(SIGTHR, &sa, 0)); + npassert(!sigaction(SIGTHR, &sa, 0)); } /** diff --git a/libc/thread/pthread_create.c b/libc/thread/pthread_create.c index 4c65ed264..8ac005e80 100644 --- a/libc/thread/pthread_create.c +++ b/libc/thread/pthread_create.c @@ -27,12 +27,14 @@ #include "libc/intrin/atomic.h" #include "libc/intrin/bits.h" #include "libc/intrin/dll.h" +#include "libc/intrin/kprintf.h" #include "libc/log/internal.h" #include "libc/macros.internal.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/runtime/stack.h" #include "libc/str/str.h" +#include "libc/sysv/consts/auxv.h" #include "libc/sysv/consts/clone.h" #include "libc/sysv/consts/map.h" #include "libc/sysv/consts/prot.h" @@ -44,9 +46,9 @@ #include "libc/thread/tls.h" #include "libc/thread/wait0.internal.h" -STATIC_YOINK("nsync_mu_lock"); -STATIC_YOINK("nsync_mu_unlock"); -STATIC_YOINK("_pthread_atfork"); +__static_yoink("nsync_mu_lock"); +__static_yoink("nsync_mu_unlock"); +__static_yoink("_pthread_atfork"); #define MAP_ANON_OPENBSD 0x1000 #define MAP_STACK_OPENBSD 0x4000 @@ -57,7 +59,7 @@ void _pthread_free(struct PosixThread *pt) { if ((pt->flags & PT_OWNSTACK) && // pt->attr.__stackaddr && // pt->attr.__stackaddr != MAP_FAILED) { - _npassert(!munmap(pt->attr.__stackaddr, pt->attr.__stacksize)); + npassert(!munmap(pt->attr.__stackaddr, pt->attr.__stacksize)); } if (pt->altstack) { free(pt->altstack); @@ -70,7 +72,7 @@ static int PosixThread(void *arg, int tid) { struct sigaltstack ss; struct PosixThread *pt = arg; enum PosixThreadStatus status; - _unassert(__get_tls()->tib_tid > 0); + unassert(__get_tls()->tib_tid > 0); if (pt->altstack) { ss.ss_flags = 0; ss.ss_size = SIGSTKSZ; @@ -85,10 +87,10 @@ static int PosixThread(void *arg, int tid) { // set long jump handler so pthread_exit can bring control back here if (!setjmp(pt->exiter)) { __get_tls()->tib_pthread = (pthread_t)pt; - _npassert(!sigprocmask(SIG_SETMASK, (sigset_t *)pt->attr.__sigmask, 0)); + npassert(!sigprocmask(SIG_SETMASK, (sigset_t *)pt->attr.__sigmask, 0)); rc = pt->start(pt->arg); // ensure pthread_cleanup_pop(), and pthread_exit() popped cleanup - _npassert(!pt->cleanup); + npassert(!pt->cleanup); // calling pthread_exit() will either jump back here, or call exit pthread_exit(rc); } @@ -170,15 +172,17 @@ static errno_t pthread_create_impl(pthread_t *thread, // cosmo is managing the stack // 1. in mono repo optimize for tiniest stack possible // 2. in public world optimize to *work* regardless of memory + unsigned long default_guardsize; + default_guardsize = getauxval(AT_PAGESZ); pt->flags = PT_OWNSTACK; pt->attr.__stacksize = MAX(pt->attr.__stacksize, GetStackSize()); pt->attr.__stacksize = _roundup2pow(pt->attr.__stacksize); - pt->attr.__guardsize = ROUNDUP(pt->attr.__guardsize, APE_GUARDSIZE); - if (pt->attr.__guardsize + APE_GUARDSIZE >= pt->attr.__stacksize) { + pt->attr.__guardsize = ROUNDUP(pt->attr.__guardsize, default_guardsize); + if (pt->attr.__guardsize + default_guardsize >= pt->attr.__stacksize) { _pthread_free(pt); return EINVAL; } - if (pt->attr.__guardsize == APE_GUARDSIZE) { + if (pt->attr.__guardsize == default_guardsize) { // user is wisely using smaller stacks with default guard size pt->attr.__stackaddr = mmap(0, pt->attr.__stacksize, PROT_READ | PROT_WRITE, diff --git a/libc/thread/pthread_exit.c b/libc/thread/pthread_exit.c index aae41e711..af44019a4 100644 --- a/libc/thread/pthread_exit.c +++ b/libc/thread/pthread_exit.c @@ -103,7 +103,7 @@ wontreturn void pthread_exit(void *rc) { tib = __get_tls(); pt = (struct PosixThread *)tib->tib_pthread; - _unassert(~pt->flags & PT_EXITING); + unassert(~pt->flags & PT_EXITING); pt->flags |= PT_EXITING; pt->rc = rc; diff --git a/libc/thread/pthread_self.c b/libc/thread/pthread_self.c index 250cc0391..0be3110c2 100644 --- a/libc/thread/pthread_self.c +++ b/libc/thread/pthread_self.c @@ -27,6 +27,6 @@ pthread_t pthread_self(void) { pthread_t t; t = __get_tls()->tib_pthread; - _unassert(t); + unassert(t); return t; } diff --git a/libc/thread/pthread_timedjoin_np.c b/libc/thread/pthread_timedjoin_np.c index 1d6e37573..a31ef32c8 100644 --- a/libc/thread/pthread_timedjoin_np.c +++ b/libc/thread/pthread_timedjoin_np.c @@ -58,7 +58,7 @@ errno_t pthread_timedjoin_np(pthread_t thread, void **value_ptr, // "The behavior is undefined if the value specified by the thread // argument to pthread_join() does not refer to a joinable thread." // ──Quoth POSIX.1-2017 - _unassert(status == kPosixThreadJoinable || status == kPosixThreadTerminated); + unassert(status == kPosixThreadJoinable || status == kPosixThreadTerminated); if (!(rc = _wait0(&pt->tib->tib_tid, abstime))) { pthread_spin_lock(&_pthread_lock); dll_remove(&_pthread_list, &pt->list); diff --git a/libc/thread/sem_destroy.c b/libc/thread/sem_destroy.c index 3f2869814..7cf156724 100644 --- a/libc/thread/sem_destroy.c +++ b/libc/thread/sem_destroy.c @@ -41,10 +41,10 @@ */ int sem_destroy(sem_t *sem) { int waiters; - _npassert(sem->sem_magic != SEM_MAGIC_NAMED); + npassert(sem->sem_magic != SEM_MAGIC_NAMED); if (sem->sem_magic != SEM_MAGIC_UNNAMED) return einval(); waiters = atomic_load_explicit(&sem->sem_waiters, memory_order_relaxed); - _unassert(waiters >= 0); + unassert(waiters >= 0); if (waiters) return ebusy(); atomic_store_explicit(&sem->sem_value, INT_MIN, memory_order_relaxed); return 0; diff --git a/libc/thread/sem_open.c b/libc/thread/sem_open.c index efd32c5f0..5c8a48762 100644 --- a/libc/thread/sem_open.c +++ b/libc/thread/sem_open.c @@ -85,9 +85,9 @@ static sem_t *sem_open_impl(const char *path, int oflag, unsigned mode, if ((fd = openat(AT_FDCWD, path, oflag, mode)) == -1) { return SEM_FAILED; } - _npassert(!fstat(fd, &st)); + npassert(!fstat(fd, &st)); if (st.st_size < PAGESIZE && ftruncate(fd, PAGESIZE) == -1) { - _npassert(!close(fd)); + npassert(!close(fd)); return SEM_FAILED; } sem = mmap(0, PAGESIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); @@ -100,7 +100,7 @@ static sem_t *sem_open_impl(const char *path, int oflag, unsigned mode, } else { sem = SEM_FAILED; } - _npassert(!close(fd)); + npassert(!close(fd)); return sem; } @@ -256,23 +256,23 @@ int sem_close(sem_t *sem) { int prefs; bool unmap, delete; struct Semaphore *s, **p; - _npassert(sem->sem_magic == SEM_MAGIC_NAMED); + npassert(sem->sem_magic == SEM_MAGIC_NAMED); sem_open_init(); sem_open_lock(); - _npassert((s = sem_open_get(sem, &p))); + npassert((s = sem_open_get(sem, &p))); prefs = atomic_fetch_add_explicit(&sem->sem_prefs, -1, memory_order_acq_rel); - _npassert(s->refs > 0); + npassert(s->refs > 0); if ((unmap = !--s->refs)) { - _npassert(prefs > 0); + npassert(prefs > 0); delete = sem->sem_lazydelete && prefs == 1; *p = s->next; } else { - _npassert(prefs > 1); + npassert(prefs > 1); delete = false; } sem_open_unlock(); if (unmap) { - _npassert(!munmap(sem, PAGESIZE)); + npassert(!munmap(sem, PAGESIZE)); } if (delete) { unlink(s->path); diff --git a/libc/thread/sem_post.c b/libc/thread/sem_post.c index 37c5f3f43..4ed66ec45 100644 --- a/libc/thread/sem_post.c +++ b/libc/thread/sem_post.c @@ -34,10 +34,10 @@ int sem_post(sem_t *sem) { int rc, old, wakeups; old = atomic_fetch_add_explicit(&sem->sem_value, 1, memory_order_acq_rel); - _unassert(old > INT_MIN); + unassert(old > INT_MIN); if (old >= 0) { wakeups = nsync_futex_wake_(&sem->sem_value, 1, true); - _npassert(wakeups >= 0); + npassert(wakeups >= 0); rc = 0; } else { wakeups = 0; diff --git a/libc/thread/sem_timedwait.c b/libc/thread/sem_timedwait.c index 9419fab74..33e7e7320 100644 --- a/libc/thread/sem_timedwait.c +++ b/libc/thread/sem_timedwait.c @@ -35,8 +35,8 @@ static void sem_delay(int n) { static void sem_timedwait_cleanup(void *arg) { sem_t *sem = arg; - _unassert(atomic_fetch_add_explicit(&sem->sem_waiters, -1, - memory_order_acq_rel) > 0); + unassert(atomic_fetch_add_explicit(&sem->sem_waiters, -1, + memory_order_acq_rel) > 0); } /** @@ -69,8 +69,8 @@ int sem_timedwait(sem_t *sem, const struct timespec *abstime) { } BEGIN_CANCELLATION_POINT; - _unassert(atomic_fetch_add_explicit(&sem->sem_waiters, +1, - memory_order_acq_rel) >= 0); + unassert(atomic_fetch_add_explicit(&sem->sem_waiters, +1, + memory_order_acq_rel) >= 0); pthread_cleanup_push(sem_timedwait_cleanup, sem); do { @@ -82,20 +82,20 @@ int sem_timedwait(sem_t *sem, const struct timespec *abstime) { } else if (rc == -EAGAIN || rc == -EWOULDBLOCK) { rc = 0; } else if (rc == -ETIMEDOUT) { - _npassert(abstime); + npassert(abstime); if (timespec_cmp(*abstime, timespec_real()) <= 0) { rc = etimedout(); } else { rc = 0; } } else { - _npassert(!rc); + npassert(!rc); rc = 0; } } else if (v > 0) { rc = 0; } else { - _unassert(v > INT_MIN); + unassert(v > INT_MIN); rc = einval(); } } while (!rc && (!v || !atomic_compare_exchange_weak_explicit( diff --git a/libc/thread/sem_trywait.c b/libc/thread/sem_trywait.c index 0fa730554..d76a6402a 100644 --- a/libc/thread/sem_trywait.c +++ b/libc/thread/sem_trywait.c @@ -36,7 +36,7 @@ int sem_trywait(sem_t *sem) { int v; v = atomic_load_explicit(&sem->sem_value, memory_order_relaxed); do { - _unassert(v > INT_MIN); + unassert(v > INT_MIN); if (!v) return eagain(); if (v < 0) return einval(); } while (!atomic_compare_exchange_weak_explicit( diff --git a/libc/thread/spawn.c b/libc/thread/spawn.c index dc813776d..b83554841 100644 --- a/libc/thread/spawn.c +++ b/libc/thread/spawn.c @@ -153,7 +153,7 @@ int _join(struct spawn *th) { int rc; if (th->tib) { // wait for ctid to become zero - _npassert(!_wait0(&th->tib->tib_tid, 0)); + npassert(!_wait0(&th->tib->tib_tid, 0)); // free thread memory free(th->tls); rc = munmap(th->stk, GetStackSize()); diff --git a/libc/thread/tls2.h b/libc/thread/tls2.h index d16c49685..49cae06c7 100644 --- a/libc/thread/tls2.h +++ b/libc/thread/tls2.h @@ -12,7 +12,7 @@ COSMOPOLITAN_C_START_ * This should be favored over __get_tls() for .privileged code that * can't be self-modified by __enable_tls(). */ -privileged static inline noasan struct CosmoTib *__get_tls_privileged(void) { +privileged static inline struct CosmoTib *__get_tls_privileged(void) { char *tib, *lin = (char *)0x30; if (IsLinux() || IsFreebsd() || IsNetbsd() || IsOpenbsd() || IsMetal()) { asm("mov\t%%fs:(%1),%0" : "=a"(tib) : "r"(lin) : "memory"); @@ -25,14 +25,14 @@ privileged static inline noasan struct CosmoTib *__get_tls_privileged(void) { return (struct CosmoTib *)tib; } -static noasan inline struct CosmoTib *__get_tls_win32(void) { +static dontasan inline struct CosmoTib *__get_tls_win32(void) { char *tib, *lin = (char *)0x30; asm("mov\t%%gs:(%1),%0" : "=a"(tib) : "r"(lin) : "memory"); tib = *(char **)(tib + 0x1480 + __tls_index * 8); return (struct CosmoTib *)tib; } -static noasan inline void __set_tls_win32(void *tls) { +static dontasan inline void __set_tls_win32(void *tls) { asm("mov\t%1,%%gs:%0" : "=m"(*((long *)0x1480 + __tls_index)) : "r"(tls)); } diff --git a/libc/thread/wait0.c b/libc/thread/wait0.c index c77fb17c8..5972b5290 100644 --- a/libc/thread/wait0.c +++ b/libc/thread/wait0.c @@ -46,7 +46,7 @@ errno_t _wait0(const atomic_int *ctid, struct timespec *abstime) { // "The behavior is undefined if the value specified by the thread // argument to pthread_join() refers to the calling thread." // ──Quoth POSIX.1-2017 - _unassert(ctid != &__get_tls()->tib_tid); + unassert(ctid != &__get_tls()->tib_tid); // "If the thread calling pthread_join() is canceled, then the target // thread shall not be detached." ──Quoth POSIX.1-2017 if (!(rc = pthread_testcancel_np())) { diff --git a/libc/time/iso8601.c b/libc/time/iso8601.c index ad1113a95..a131124ea 100644 --- a/libc/time/iso8601.c +++ b/libc/time/iso8601.c @@ -60,34 +60,34 @@ char *iso8601(char p[hasatleast 20], struct tm *tm) { int x; x = tm->tm_year + 1900; - _unassert(0 <= x && x <= 9999); + unassert(0 <= x && x <= 9999); *p++ = '0' + x / 1000; *p++ = '0' + x / 100 % 10; *p++ = '0' + x / 10 % 10; *p++ = '0' + x % 10; *p++ = '-'; x = tm->tm_mon + 1; - _unassert(1 <= x && x <= 12); + unassert(1 <= x && x <= 12); *p++ = '0' + x / 10; *p++ = '0' + x % 10; *p++ = '-'; x = tm->tm_mday; - _unassert(1 <= x && x <= 31); + unassert(1 <= x && x <= 31); *p++ = '0' + x / 10; *p++ = '0' + x % 10; *p++ = 'T'; x = tm->tm_hour; - _unassert(0 <= x && x <= 23); + unassert(0 <= x && x <= 23); *p++ = '0' + x / 10; *p++ = '0' + x % 10; *p++ = ':'; x = tm->tm_min; - _unassert(0 <= x && x <= 59); + unassert(0 <= x && x <= 59); *p++ = '0' + x / 10; *p++ = '0' + x % 10; *p++ = ':'; x = tm->tm_sec; - _unassert(0 <= x && x <= 60); + unassert(0 <= x && x <= 60); *p++ = '0' + x / 10; *p++ = '0' + x % 10; *p = 0; diff --git a/libc/time/iso8601us.c b/libc/time/iso8601us.c index 77aff570c..1fb24f501 100644 --- a/libc/time/iso8601us.c +++ b/libc/time/iso8601us.c @@ -66,7 +66,7 @@ */ char *iso8601us(char p[hasatleast 27], struct tm *tm, long ns) { p = iso8601(p, tm); - _unassert(0 <= ns && ns < 1000000000); + unassert(0 <= ns && ns < 1000000000); *p++ = '.'; *p++ = '0' + ns / 100000000; *p++ = '0' + ns / 10000000 % 10; diff --git a/libc/time/localtime.c b/libc/time/localtime.c index 8d6709afc..0878136df 100644 --- a/libc/time/localtime.c +++ b/libc/time/localtime.c @@ -17,22 +17,22 @@ #include "libc/time/tz.internal.h" #include "libc/time/tzfile.internal.h" -STATIC_YOINK("zipos"); -STATIC_YOINK("usr/share/zoneinfo/"); -STATIC_YOINK("usr/share/zoneinfo/Anchorage"); -STATIC_YOINK("usr/share/zoneinfo/Beijing"); -STATIC_YOINK("usr/share/zoneinfo/Berlin"); -STATIC_YOINK("usr/share/zoneinfo/Boulder"); -STATIC_YOINK("usr/share/zoneinfo/Chicago"); -STATIC_YOINK("usr/share/zoneinfo/GMT"); -STATIC_YOINK("usr/share/zoneinfo/GST"); -STATIC_YOINK("usr/share/zoneinfo/Honolulu"); -STATIC_YOINK("usr/share/zoneinfo/Israel"); -STATIC_YOINK("usr/share/zoneinfo/Japan"); -STATIC_YOINK("usr/share/zoneinfo/London"); -STATIC_YOINK("usr/share/zoneinfo/Melbourne"); -STATIC_YOINK("usr/share/zoneinfo/New_York"); -STATIC_YOINK("usr/share/zoneinfo/UTC"); +__static_yoink("zipos"); +__static_yoink("usr/share/zoneinfo/"); +__static_yoink("usr/share/zoneinfo/Anchorage"); +__static_yoink("usr/share/zoneinfo/Beijing"); +__static_yoink("usr/share/zoneinfo/Berlin"); +__static_yoink("usr/share/zoneinfo/Boulder"); +__static_yoink("usr/share/zoneinfo/Chicago"); +__static_yoink("usr/share/zoneinfo/GMT"); +__static_yoink("usr/share/zoneinfo/GST"); +__static_yoink("usr/share/zoneinfo/Honolulu"); +__static_yoink("usr/share/zoneinfo/Israel"); +__static_yoink("usr/share/zoneinfo/Japan"); +__static_yoink("usr/share/zoneinfo/London"); +__static_yoink("usr/share/zoneinfo/Melbourne"); +__static_yoink("usr/share/zoneinfo/New_York"); +__static_yoink("usr/share/zoneinfo/UTC"); // clang-format off /* Convert timestamp from time_t to struct tm. */ diff --git a/libc/tinymath/magicu.c b/libc/tinymath/magicu.c index e54a99a57..802d16370 100644 --- a/libc/tinymath/magicu.c +++ b/libc/tinymath/magicu.c @@ -36,7 +36,7 @@ struct magicu __magicu_get(uint32_t d) { int a, p; struct magicu magu; uint32_t p32, q, r, delta; - _npassert(d); // Can't divide by zero. + npassert(d); // Can't divide by zero. p32 = 0; // Avoid compiler warning. a = 0; // Initialize "add" indicator. p = 31; // Initialize p. @@ -60,9 +60,9 @@ struct magicu __magicu_get(uint32_t d) { } delta = d - 1 - r; } while (p < 64 && p32 < delta); - magu.M = q + 1; // Magic number and - magu.s = p - 32; // Shift amount to return - if (a) magu.s |= 64; // Sets "add" indicator - _npassert(magu.M || magu.s); // Never returns zero. + magu.M = q + 1; // Magic number and + magu.s = p - 32; // Shift amount to return + if (a) magu.s |= 64; // Sets "add" indicator + npassert(magu.M || magu.s); // Never returns zero. return magu; } diff --git a/libc/zip.internal.h b/libc/zip.internal.h index a784ff9c2..b02523000 100644 --- a/libc/zip.internal.h +++ b/libc/zip.internal.h @@ -12,7 +12,7 @@ #ifdef __ASSEMBLER__ #define ZM_(x) x #else -#define ZM_(x) ~VEIL("r", ~x) /* prevent magic from appearing in binary */ +#define ZM_(x) ~__veil("r", ~x) /* prevent magic from appearing in binary */ #endif #ifdef TINY diff --git a/libc/zipos/find.c b/libc/zipos/find.c index 1c81d31c9..734cf9e0e 100644 --- a/libc/zipos/find.c +++ b/libc/zipos/find.c @@ -34,7 +34,7 @@ ssize_t __zipos_find(struct Zipos *zipos, const struct ZiposUri *name) { c = GetZipCdirOffset(zipos->cdir); n = GetZipCdirRecords(zipos->cdir); for (i = 0; i < n; ++i, c += ZIP_CFILE_HDRSIZE(zipos->map + c)) { - _npassert(ZIP_CFILE_MAGIC(zipos->map + c) == kZipCfileHdrMagic); + npassert(ZIP_CFILE_MAGIC(zipos->map + c) == kZipCfileHdrMagic); zname = ZIP_CFILE_NAME(zipos->map + c); znamesize = ZIP_CFILE_NAMESIZE(zipos->map + c); if ((name->len == znamesize && !memcmp(name->path, zname, name->len)) || diff --git a/libc/zipos/get.c b/libc/zipos/get.c index e3242bd31..a0fc5fbd2 100644 --- a/libc/zipos/get.c +++ b/libc/zipos/get.c @@ -32,7 +32,7 @@ #include "libc/zipos/zipos.internal.h" #ifdef __x86_64__ -STATIC_YOINK(APE_COM_NAME); +__static_yoink(APE_COM_NAME); #endif static uint64_t __zipos_get_min_offset(const uint8_t *base, diff --git a/libc/zipos/mmap.c b/libc/zipos/mmap.c index 898c55bb9..5e31a7986 100644 --- a/libc/zipos/mmap.c +++ b/libc/zipos/mmap.c @@ -47,8 +47,8 @@ * it does not need to be 64kb aligned. * @return virtual base address of new mapping, or MAP_FAILED w/ errno */ -noasan void *__zipos_Mmap(void *addr, size_t size, int prot, int flags, - struct ZiposHandle *h, int64_t off) { +dontasan void *__zipos_Mmap(void *addr, size_t size, int prot, int flags, + struct ZiposHandle *h, int64_t off) { if (!(flags & MAP_PRIVATE) || (flags & ~(MAP_PRIVATE | MAP_FILE | MAP_FIXED | MAP_FIXED_NOREPLACE)) || (!!(flags & MAP_FIXED) ^ !!(flags & MAP_FIXED_NOREPLACE))) { diff --git a/libc/zipos/open.c b/libc/zipos/open.c index d632c049f..1ecbea579 100644 --- a/libc/zipos/open.c +++ b/libc/zipos/open.c @@ -50,7 +50,7 @@ static size_t maptotal; static void *__zipos_mmap_space(size_t mapsize) { char *start; size_t offset; - _unassert(mapsize); + unassert(mapsize); offset = maptotal; maptotal += mapsize; start = (char *)kMemtrackZiposStart; @@ -135,7 +135,7 @@ static int __zipos_load(struct Zipos *zipos, size_t cf, unsigned flags, int rc, fd, minfd; struct ZiposHandle *h; lf = GetZipCfileOffset(zipos->map + cf); - _npassert((ZIP_LFILE_MAGIC(zipos->map + lf) == kZipLfileHdrMagic)); + npassert((ZIP_LFILE_MAGIC(zipos->map + lf) == kZipLfileHdrMagic)); size = GetZipLfileUncompressedSize(zipos->map + lf); switch (ZIP_LFILE_COMPRESSIONMETHOD(zipos->map + lf)) { case kZipCompressionNone: diff --git a/libc/zipos/zipos.S b/libc/zipos/zipos.S index fe8ab77e7..d45b82394 100644 --- a/libc/zipos/zipos.S +++ b/libc/zipos/zipos.S @@ -37,6 +37,6 @@ // TODO(jart): why does corruption happen when zip has no assets? .yoink .cosmo -// deprecated: use STATIC_YOINK("zipos") +// deprecated: use __static_yoink("zipos") zip_uri_support = 0 .globl zip_uri_support diff --git a/libc/zipos/zipos.internal.h b/libc/zipos/zipos.internal.h index 1a095c46e..77e9eba38 100644 --- a/libc/zipos/zipos.internal.h +++ b/libc/zipos/zipos.internal.h @@ -50,8 +50,8 @@ ssize_t __zipos_write(struct ZiposHandle *, const struct iovec *, size_t, int64_t __zipos_lseek(struct ZiposHandle *, int64_t, unsigned); int __zipos_fcntl(int, int, uintptr_t); int __zipos_notat(int, const char *); -noasan void *__zipos_Mmap(void *, uint64_t, int32_t, int32_t, - struct ZiposHandle *, int64_t); +void *__zipos_Mmap(void *, uint64_t, int32_t, int32_t, struct ZiposHandle *, + int64_t) dontasan; #ifdef _NOPL0 #define __zipos_lock() _NOPL0("__threadcalls", __zipos_lock) diff --git a/net/http/headerhassubstring.c b/net/http/headerhassubstring.c index a07010b92..e984075c2 100644 --- a/net/http/headerhassubstring.c +++ b/net/http/headerhassubstring.c @@ -33,7 +33,7 @@ bool HeaderHas(struct HttpMessage *m, const char *b, int h, const char *s, size_t n) { size_t i; - _unassert(0 <= h && h < kHttpHeadersMax); + unassert(0 <= h && h < kHttpHeadersMax); if (n == -1) n = s ? strlen(s) : 0; if (m->headers[h].a) { if (memmem(b + m->headers[h].a, m->headers[h].b - m->headers[h].a, s, n)) { diff --git a/net/http/parsehttpmessage.c b/net/http/parsehttpmessage.c index f00caf713..fd7490bee 100644 --- a/net/http/parsehttpmessage.c +++ b/net/http/parsehttpmessage.c @@ -35,7 +35,7 @@ * Initializes HTTP message parser. */ void InitHttpMessage(struct HttpMessage *r, int type) { - _unassert(type == kHttpRequest || type == kHttpResponse); + unassert(type == kHttpRequest || type == kHttpResponse); bzero(r, sizeof(*r)); r->type = type; } diff --git a/net/https/generatehardrandom.c b/net/https/generatehardrandom.c index 0f2c2fcb6..7c1c42d33 100644 --- a/net/https/generatehardrandom.c +++ b/net/https/generatehardrandom.c @@ -24,7 +24,7 @@ int GenerateHardRandom(void *ctx, unsigned char *p, size_t n) { size_t i; ssize_t rc; for (i = 0; i < n; i += (size_t)rc) { - _npassert((rc = getrandom(p + i, n - i, 0)) != -1); + npassert((rc = getrandom(p + i, n - i, 0)) != -1); } return 0; } diff --git a/net/https/getsslroots.c b/net/https/getsslroots.c index 8ac1bbfb0..8c78bffb0 100644 --- a/net/https/getsslroots.c +++ b/net/https/getsslroots.c @@ -25,7 +25,7 @@ #include "libc/thread/thread.h" #include "third_party/mbedtls/x509_crt.h" -STATIC_YOINK("ssl_root_support"); +__static_yoink("ssl_root_support"); #define SSL_ROOT_DIR "/zip/usr/share/ssl/root" diff --git a/net/https/sslroots.c b/net/https/sslroots.c index 2d98ae616..98b28350b 100644 --- a/net/https/sslroots.c +++ b/net/https/sslroots.c @@ -18,20 +18,20 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "net/https/https.h" -STATIC_YOINK("zipos"); -STATIC_YOINK("usr/share/ssl/root/"); -STATIC_YOINK("usr/share/ssl/root/amazon.pem"); -STATIC_YOINK("usr/share/ssl/root/certum.pem"); -STATIC_YOINK("usr/share/ssl/root/comodo.pem"); -STATIC_YOINK("usr/share/ssl/root/digicert.pem"); -STATIC_YOINK("usr/share/ssl/root/geotrust.pem"); -STATIC_YOINK("usr/share/ssl/root/globalsign.pem"); -STATIC_YOINK("usr/share/ssl/root/godaddy.pem"); -STATIC_YOINK("usr/share/ssl/root/google.pem"); -STATIC_YOINK("usr/share/ssl/root/isrg.pem"); -STATIC_YOINK("usr/share/ssl/root/quovadis.pem"); -STATIC_YOINK("usr/share/ssl/root/redbean.pem"); -STATIC_YOINK("usr/share/ssl/root/starfield.pem"); -STATIC_YOINK("usr/share/ssl/root/verisign.pem"); +__static_yoink("zipos"); +__static_yoink("usr/share/ssl/root/"); +__static_yoink("usr/share/ssl/root/amazon.pem"); +__static_yoink("usr/share/ssl/root/certum.pem"); +__static_yoink("usr/share/ssl/root/comodo.pem"); +__static_yoink("usr/share/ssl/root/digicert.pem"); +__static_yoink("usr/share/ssl/root/geotrust.pem"); +__static_yoink("usr/share/ssl/root/globalsign.pem"); +__static_yoink("usr/share/ssl/root/godaddy.pem"); +__static_yoink("usr/share/ssl/root/google.pem"); +__static_yoink("usr/share/ssl/root/isrg.pem"); +__static_yoink("usr/share/ssl/root/quovadis.pem"); +__static_yoink("usr/share/ssl/root/redbean.pem"); +__static_yoink("usr/share/ssl/root/starfield.pem"); +__static_yoink("usr/share/ssl/root/verisign.pem"); char ssl_root_support; diff --git a/net/turfwar/blackholed.c b/net/turfwar/blackholed.c index 7544ac25c..d4ede885e 100644 --- a/net/turfwar/blackholed.c +++ b/net/turfwar/blackholed.c @@ -263,14 +263,14 @@ void RequireRoot(void) { void ListenForTerm(void) { struct sigaction sa = {.sa_handler = OnTerm}; - _npassert(!sigaction(SIGTERM, &sa, 0)); - _npassert(!sigaction(SIGHUP, &sa, 0)); - _npassert(!sigaction(SIGINT, &sa, 0)); + npassert(!sigaction(SIGTERM, &sa, 0)); + npassert(!sigaction(SIGHUP, &sa, 0)); + npassert(!sigaction(SIGINT, &sa, 0)); } void AutomaticallyHarvestZombies(void) { struct sigaction sa = {.sa_handler = SIG_IGN, .sa_flags = SA_NOCLDWAIT}; - _npassert(!sigaction(SIGCHLD, &sa, 0)); + npassert(!sigaction(SIGCHLD, &sa, 0)); } void FindFirewall(void) { @@ -305,9 +305,9 @@ void Daemonize(void) { void UseLog(void) { if (g_logfd > 0) { - _npassert(dup2(g_logfd, 2) == 2); + npassert(dup2(g_logfd, 2) == 2); if (g_logfd != 2) { - _npassert(!close(g_logfd)); + npassert(!close(g_logfd)); } } } @@ -338,7 +338,7 @@ void WritePid(void) { LOG("error: open(%#s) failed: %s", g_pidname, strerror(errno)); _Exit(4); } - _npassert((rc = pread(fd, buf, 11, 0)) != -1); + npassert((rc = pread(fd, buf, 11, 0)) != -1); if (rc) { pid = atoi(buf); LOG("killing old blackholed process %d", pid); @@ -358,9 +358,9 @@ void WritePid(void) { } } FormatInt32(buf, getpid()); - _npassert(!ftruncate(fd, 0)); - _npassert((rc = pwrite(fd, buf, strlen(buf), 0)) == strlen(buf)); - _npassert(!close(fd)); + npassert(!ftruncate(fd, 0)); + npassert((rc = pwrite(fd, buf, strlen(buf), 0)) == strlen(buf)); + npassert(!close(fd)); } bool IsMyIp(uint32_t ip) { diff --git a/net/turfwar/turfwar.c b/net/turfwar/turfwar.c index cff1d133d..6a75c83a5 100644 --- a/net/turfwar/turfwar.c +++ b/net/turfwar/turfwar.c @@ -656,8 +656,8 @@ void *NewSafeBuffer(size_t n) { char *p; long pagesize = sysconf(_SC_PAGESIZE); size_t m = ROUNDUP(n, pagesize); - _npassert((p = valloc(m + pagesize))); - _npassert(!mprotect(p + m, pagesize, PROT_NONE)); + npassert((p = valloc(m + pagesize))); + npassert(!mprotect(p + m, pagesize, PROT_NONE)); return p; } @@ -666,7 +666,7 @@ void FreeSafeBuffer(void *p) { long pagesize = sysconf(_SC_PAGESIZE); size_t n = malloc_usable_size(p); size_t m = ROUNDDOWN(n, pagesize); - _npassert(!mprotect(p, m, PROT_READ | PROT_WRITE)); + npassert(!mprotect(p, m, PROT_READ | PROT_WRITE)); free(p); } @@ -1947,9 +1947,9 @@ int main(int argc, char *argv[]) { if (closefrom(0)) for (int i = 0; i < 256; ++i) // close(i); - _npassert(0 == open(_PATH_DEVNULL, O_RDWR)); - _npassert(1 == dup(0)); - _npassert(2 == open("turfwar.log", O_CREAT | O_WRONLY | O_APPEND, 0644)); + npassert(0 == open(_PATH_DEVNULL, O_RDWR)); + npassert(1 == dup(0)); + npassert(2 == open("turfwar.log", O_CREAT | O_WRONLY | O_APPEND, 0644)); } LOG("Generating Hilbert Curve...\n"); diff --git a/test/dsp/core/inv3_test.c b/test/dsp/core/inv3_test.c index 8ae025db5..09d27e96a 100644 --- a/test/dsp/core/inv3_test.c +++ b/test/dsp/core/inv3_test.c @@ -34,6 +34,6 @@ TEST(inv3, test) { BENCH(inv3, bench) { double M[3][3], d; - EZBENCH2("det3", donothing, EXPROPRIATE((d = det3(kBradford)))); - EZBENCH2("inv3", donothing, EXPROPRIATE(inv3(M, kBradford, d))); + EZBENCH2("det3", donothing, __expropriate((d = det3(kBradford)))); + EZBENCH2("inv3", donothing, __expropriate(inv3(M, kBradford, d))); } diff --git a/test/libc/calls/fexecve_test.c b/test/libc/calls/fexecve_test.c index 065c38fad..99141afef 100644 --- a/test/libc/calls/fexecve_test.c +++ b/test/libc/calls/fexecve_test.c @@ -29,7 +29,7 @@ #include "libc/testlib/testlib.h" // clang-format off -STATIC_YOINK("zipos"); +__static_yoink("zipos"); int fds[2]; char buf[8]; diff --git a/test/libc/calls/pipe_test.c b/test/libc/calls/pipe_test.c index 0a4e4d9ac..8aab9aef4 100644 --- a/test/libc/calls/pipe_test.c +++ b/test/libc/calls/pipe_test.c @@ -30,7 +30,7 @@ char buf[6] = {0}; struct rlimit rlim = {0, 10}; TEST(pipe, efault) { - EXPECT_SYS(EFAULT, -1, pipe(VEIL("r", (void *)0))); + EXPECT_SYS(EFAULT, -1, pipe(__veil("r", (void *)0))); } TEST(pipe, einval) { diff --git a/test/libc/calls/reservefd_test.c b/test/libc/calls/reservefd_test.c index 8a9127235..7d247c941 100644 --- a/test/libc/calls/reservefd_test.c +++ b/test/libc/calls/reservefd_test.c @@ -44,8 +44,8 @@ #include "libc/time/struct/tm.h" #include "libc/time/time.h" -STATIC_YOINK("zipos"); -STATIC_YOINK("libc/testlib/hyperion.txt"); +__static_yoink("zipos"); +__static_yoink("libc/testlib/hyperion.txt"); #define THREADS 8 diff --git a/test/libc/calls/setrlimit_test.c b/test/libc/calls/setrlimit_test.c index 75eedfb86..f135ed884 100644 --- a/test/libc/calls/setrlimit_test.c +++ b/test/libc/calls/setrlimit_test.c @@ -26,6 +26,7 @@ #include "libc/intrin/safemacros.internal.h" #include "libc/runtime/runtime.h" #include "libc/stdio/rand.h" +#include "libc/sysv/consts/auxv.h" #include "libc/sysv/consts/map.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/prot.h" @@ -128,8 +129,8 @@ TEST(setrlimit, testMemoryLimit) { ASSERT_NE(-1, (wstatus = xspawn(0))); if (wstatus == -2) { ASSERT_EQ(0, SetKernelEnforcedMemoryLimit(MEM)); - for (gotsome = i = 0; i < (MEM * 2) / APE_GUARDSIZE; ++i) { - p = mmap(0, APE_GUARDSIZE, PROT_READ | PROT_WRITE, + for (gotsome = i = 0; i < (MEM * 2) / getauxval(AT_PAGESZ); ++i) { + p = mmap(0, getauxval(AT_PAGESZ), PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE | MAP_POPULATE, -1, 0); if (p != MAP_FAILED) { gotsome = true; @@ -141,7 +142,7 @@ TEST(setrlimit, testMemoryLimit) { ASSERT_EQ(ENOMEM, errno); _Exit(0); } - rngset(p, APE_GUARDSIZE, _rand64, -1); + rngset(p, getauxval(AT_PAGESZ), _rand64, -1); } _Exit(1); } @@ -161,15 +162,15 @@ TEST(setrlimit, testVirtualMemoryLimit) { ASSERT_NE(-1, (wstatus = xspawn(0))); if (wstatus == -2) { ASSERT_EQ(0, setrlimit(RLIMIT_AS, &(struct rlimit){MEM, MEM})); - for (i = 0; i < (MEM * 2) / APE_GUARDSIZE; ++i) { - p = sys_mmap(0, APE_GUARDSIZE, PROT_READ | PROT_WRITE, + for (i = 0; i < (MEM * 2) / getauxval(AT_PAGESZ); ++i) { + p = sys_mmap(0, getauxval(AT_PAGESZ), PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE | MAP_POPULATE, -1, 0) .addr; if (p == MAP_FAILED) { ASSERT_EQ(ENOMEM, errno); _Exit(0); } - rngset(p, APE_GUARDSIZE, _rand64, -1); + rngset(p, getauxval(AT_PAGESZ), _rand64, -1); } _Exit(1); } @@ -191,15 +192,15 @@ TEST(setrlimit, testDataMemoryLimit) { ASSERT_NE(-1, (wstatus = xspawn(0))); if (wstatus == -2) { ASSERT_EQ(0, setrlimit(RLIMIT_DATA, &(struct rlimit){MEM, MEM})); - for (i = 0; i < (MEM * 2) / APE_GUARDSIZE; ++i) { - p = sys_mmap(0, APE_GUARDSIZE, PROT_READ | PROT_WRITE, + for (i = 0; i < (MEM * 2) / getauxval(AT_PAGESZ); ++i) { + p = sys_mmap(0, getauxval(AT_PAGESZ), PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE | MAP_POPULATE, -1, 0) .addr; if (p == MAP_FAILED) { ASSERT_EQ(ENOMEM, errno); _Exit(0); } - rngset(p, APE_GUARDSIZE, _rand64, -1); + rngset(p, getauxval(AT_PAGESZ), _rand64, -1); } _Exit(1); } diff --git a/test/libc/calls/sigaction_test.c b/test/libc/calls/sigaction_test.c index 90ff6583e..c41e3818e 100644 --- a/test/libc/calls/sigaction_test.c +++ b/test/libc/calls/sigaction_test.c @@ -155,7 +155,7 @@ void OnFpe(int sig, struct siginfo *si, void *vctx) { ctx->uc_mcontext.rdx = 0; } -noubsan void ubsanTrumpsSystemsEngineering(void) { +dontubsan void ubsanTrumpsSystemsEngineering(void) { struct sigaction saint = {.sa_sigaction = OnFpe, .sa_flags = SA_SIGINFO}; EXPECT_SYS(0, 0, sigaction(SIGFPE, &saint, &oldsa)); volatile long x = 0; diff --git a/test/libc/calls/stat_test.c b/test/libc/calls/stat_test.c index df5f8c933..66239ca9b 100644 --- a/test/libc/calls/stat_test.c +++ b/test/libc/calls/stat_test.c @@ -34,7 +34,7 @@ #include "libc/testlib/testlib.h" #include "libc/x/x.h" -STATIC_YOINK("zipos"); +__static_yoink("zipos"); char testlib_enable_tmp_setup_teardown; diff --git a/test/libc/calls/zipread.c b/test/libc/calls/zipread.c index 7bc09bfe6..a9bc1a3f8 100644 --- a/test/libc/calls/zipread.c +++ b/test/libc/calls/zipread.c @@ -20,7 +20,7 @@ #include "libc/str/str.h" #include "libc/sysv/consts/o.h" -STATIC_YOINK("zipos"); +__static_yoink("zipos"); int main(int argc, char *argv[]) { int fd = open("/zip/life.elf", O_RDONLY); diff --git a/test/libc/fmt/atoi_test.c b/test/libc/fmt/atoi_test.c index 7afed03f2..a7d2c0780 100644 --- a/test/libc/fmt/atoi_test.c +++ b/test/libc/fmt/atoi_test.c @@ -573,29 +573,30 @@ TEST(strtol, invalidHex_consistentWithBsd2) { } BENCH(atoi, bench) { - EZBENCH2("atoi 10⁸", donothing, EXPROPRIATE(atoi(VEIL("r", "100000000")))); + EZBENCH2("atoi 10⁸", donothing, + __expropriate(atoi(__veil("r", "100000000")))); EZBENCH2("strtol 10⁸", donothing, - EXPROPRIATE(strtol(VEIL("r", "100000000"), 0, 10))); + __expropriate(strtol(__veil("r", "100000000"), 0, 10))); EZBENCH2("strtoul 10⁸", donothing, - EXPROPRIATE(strtol(VEIL("r", "100000000"), 0, 10))); + __expropriate(strtol(__veil("r", "100000000"), 0, 10))); EZBENCH2("wcstol 10⁸", donothing, - EXPROPRIATE(wcstol(VEIL("r", L"100000000"), 0, 10))); + __expropriate(wcstol(__veil("r", L"100000000"), 0, 10))); EZBENCH2("wcstoul 10⁸", donothing, - EXPROPRIATE(wcstol(VEIL("r", L"100000000"), 0, 10))); + __expropriate(wcstol(__veil("r", L"100000000"), 0, 10))); EZBENCH2("strtoimax 10⁸", donothing, - EXPROPRIATE(strtoimax(VEIL("r", "100000000"), 0, 10))); + __expropriate(strtoimax(__veil("r", "100000000"), 0, 10))); EZBENCH2("strtoumax 10⁸", donothing, - EXPROPRIATE(strtoimax(VEIL("r", "100000000"), 0, 10))); + __expropriate(strtoimax(__veil("r", "100000000"), 0, 10))); EZBENCH2("wcstoimax 10⁸", donothing, - EXPROPRIATE(wcstoimax(VEIL("r", L"100000000"), 0, 10))); + __expropriate(wcstoimax(__veil("r", L"100000000"), 0, 10))); EZBENCH2("wcstoumax 10⁸", donothing, - EXPROPRIATE(wcstoimax(VEIL("r", L"100000000"), 0, 10))); + __expropriate(wcstoimax(__veil("r", L"100000000"), 0, 10))); EZBENCH2("strtoi128 10⁸", donothing, - EXPROPRIATE(strtoi128(VEIL("r", "100000000"), 0, 10))); + __expropriate(strtoi128(__veil("r", "100000000"), 0, 10))); EZBENCH2("strtou128 10⁸", donothing, - EXPROPRIATE(strtoi128(VEIL("r", "100000000"), 0, 10))); + __expropriate(strtoi128(__veil("r", "100000000"), 0, 10))); EZBENCH2("wcstoi128 10⁸", donothing, - EXPROPRIATE(wcstoi128(VEIL("r", L"100000000"), 0, 10))); + __expropriate(wcstoi128(__veil("r", L"100000000"), 0, 10))); EZBENCH2("wcstou128 10⁸", donothing, - EXPROPRIATE(wcstoi128(VEIL("r", L"100000000"), 0, 10))); + __expropriate(wcstoi128(__veil("r", L"100000000"), 0, 10))); } diff --git a/test/libc/intrin/bitreverse_test.c b/test/libc/intrin/bitreverse_test.c index 4e0af4889..bee323e7e 100644 --- a/test/libc/intrin/bitreverse_test.c +++ b/test/libc/intrin/bitreverse_test.c @@ -35,9 +35,9 @@ TEST(_bitreverse, test) { BENCH(_bitreverse, bench) { EZBENCH2("_bitreverse8", donothing, - EXPROPRIATE(_bitreverse8(CONCEAL("r", 123)))); + __expropriate(_bitreverse8(__conceal("r", 123)))); EZBENCH2("_bitreverse32", donothing, - EXPROPRIATE(_bitreverse32(CONCEAL("r", 123)))); + __expropriate(_bitreverse32(__conceal("r", 123)))); EZBENCH2("_bitreverse64", donothing, - EXPROPRIATE(_bitreverse64(CONCEAL("r", 123)))); + __expropriate(_bitreverse64(__conceal("r", 123)))); } diff --git a/test/libc/intrin/kprintf_test.c b/test/libc/intrin/kprintf_test.c index 26aa2b0f7..0a2197067 100644 --- a/test/libc/intrin/kprintf_test.c +++ b/test/libc/intrin/kprintf_test.c @@ -227,7 +227,7 @@ TEST(ksnprintf, fuzzTheUnbreakable) { uint64_t x; char *f, b[32]; _Alignas(FRAMESIZE) static const char weasel[FRAMESIZE]; - f = VEIL("r", weasel); + f = __veil("r", weasel); EXPECT_SYS(0, 0, mprotect(f, FRAMESIZE, PROT_READ | PROT_WRITE)); strcpy(f, "hello %s\n"); EXPECT_EQ(12, ksnprintf(b, sizeof(b), f, "world")); diff --git a/test/libc/intrin/memset_test.c b/test/libc/intrin/memset_test.c index d95e0c413..16fe462e5 100644 --- a/test/libc/intrin/memset_test.c +++ b/test/libc/intrin/memset_test.c @@ -18,14 +18,14 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/dce.h" #include "libc/intrin/asan.internal.h" -#include "libc/mem/mem.h" #include "libc/mem/gc.internal.h" +#include "libc/mem/mem.h" #include "libc/stdio/rand.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" -static noasan void *golden(void *p, int c, size_t n) { +static dontasan void *golden(void *p, int c, size_t n) { size_t i; if (IsAsan()) __asan_verify(p, n); for (i = 0; i < n; ++i) ((char *)p)[i] = c; diff --git a/test/libc/intrin/morton_test.c b/test/libc/intrin/morton_test.c index 571cc6705..1280dae74 100644 --- a/test/libc/intrin/morton_test.c +++ b/test/libc/intrin/morton_test.c @@ -60,6 +60,6 @@ TEST(unmorton, test) { BENCH(morton, bench) { EZBENCH2("morton", donothing, - EXPROPRIATE(morton(CONCEAL("r", 123), CONCEAL("r", 123)))); - EZBENCH2("unmorton", donothing, EXPROPRIATE(unmorton(CONCEAL("r", 123)))); + __expropriate(morton(__conceal("r", 123), __conceal("r", 123)))); + EZBENCH2("unmorton", donothing, __expropriate(unmorton(__conceal("r", 123)))); } diff --git a/test/libc/intrin/popcnt_test.c b/test/libc/intrin/popcnt_test.c index b8ff51617..e2f291a4f 100644 --- a/test/libc/intrin/popcnt_test.c +++ b/test/libc/intrin/popcnt_test.c @@ -16,8 +16,8 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/calls.h" #include "libc/intrin/popcnt.h" +#include "libc/calls/calls.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" #include "libc/testlib/testlib.h" @@ -28,14 +28,14 @@ void SetUpOnce(void) { TEST(popcnt, test) { EXPECT_EQ(32, popcnt(0x5555555555555555)); - EXPECT_EQ(32, popcnt(VEIL("r", 0x5555555555555555))); - EXPECT_EQ(32, (popcnt)(VEIL("r", 0x5555555555555555))); + EXPECT_EQ(32, popcnt(__veil("r", 0x5555555555555555))); + EXPECT_EQ(32, (popcnt)(__veil("r", 0x5555555555555555))); } BENCH(popcnt, bench) { EZBENCH2("popcnt", donothing, - EXPROPRIATE(popcnt(VEIL("r", 0x5555555555555555)))); + __expropriate(popcnt(__veil("r", 0x5555555555555555)))); EZBENCH2("(popcnt)", donothing, - EXPROPRIATE((popcnt)(VEIL("r", 0x5555555555555555)))); + __expropriate((popcnt)(__veil("r", 0x5555555555555555)))); EZBENCH_N("_countbits", kHyperionSize, _countbits(kHyperion, kHyperionSize)); } diff --git a/test/libc/intrin/strchr_test.c b/test/libc/intrin/strchr_test.c index 442ffbb61..98d1e4cba 100644 --- a/test/libc/intrin/strchr_test.c +++ b/test/libc/intrin/strchr_test.c @@ -93,15 +93,16 @@ TEST(strchr, fuzz) { } BENCH(strchr, bench) { - EZBENCH2("strchr 0", donothing, EXPROPRIATE(strchr(VEIL("r", ""), 0))); - EZBENCH2("strchr 5", donothing, EXPROPRIATE(strchr(VEIL("r", "hello"), 'o'))); + EZBENCH2("strchr 0", donothing, __expropriate(strchr(__veil("r", ""), 0))); + EZBENCH2("strchr 5", donothing, + __expropriate(strchr(__veil("r", "hello"), 'o'))); EZBENCH2("strchr 8", donothing, - EXPROPRIATE(strchr(VEIL("r", "hellzzzo"), 'o'))); + __expropriate(strchr(__veil("r", "hellzzzo"), 'o'))); EZBENCH2("strchr 17", donothing, - EXPROPRIATE(strchr(VEIL("r", "hellzzzhellzzzeeo"), 'o'))); + __expropriate(strchr(__veil("r", "hellzzzhellzzzeeo"), 'o'))); EZBENCH2("strchr 34", donothing, - EXPROPRIATE( - strchr(VEIL("r", "hellzzzhellzzzeeAhellzzzhellzzzeeo"), 'o'))); + __expropriate( + strchr(__veil("r", "hellzzzhellzzzeeAhellzzzhellzzzeeo"), 'o'))); } char *memchr_pure(const char *m, int c, size_t n) { diff --git a/test/libc/intrin/strcmp_test.c b/test/libc/intrin/strcmp_test.c index 49349a05c..c7d9a1bab 100644 --- a/test/libc/intrin/strcmp_test.c +++ b/test/libc/intrin/strcmp_test.c @@ -543,37 +543,37 @@ BENCH(bench_00_strcmp, bench) { dupe = gc(malloc(size)); EZBENCH2("strcmp [identity]", longstringislong(size, data), - EXPROPRIATE(strcmp(VEIL("r", data), data))); + __expropriate(strcmp(__veil("r", data), data))); EZBENCH2("strcmp [2 diff]", donothing, - EXPROPRIATE(strcmp(VEIL("r", "hi"), VEIL("r", "there")))); + __expropriate(strcmp(__veil("r", "hi"), __veil("r", "there")))); EZBENCH2("scmppure [2 diff]", donothing, - EXPROPRIATE(strcmp_pure(VEIL("r", "hi"), VEIL("r", "there")))); + __expropriate(strcmp_pure(__veil("r", "hi"), __veil("r", "there")))); EZBENCH2("strcmp [2 dupe]", randomize_buf2str_dupe(2, data, dupe), - EXPROPRIATE(strcmp(VEIL("r", data), VEIL("r", dupe)))); + __expropriate(strcmp(__veil("r", data), __veil("r", dupe)))); EZBENCH2("scmp_pure [2 dupe]", randomize_buf2str_dupe(2, data, dupe), - EXPROPRIATE(strcmp_pure(VEIL("r", data), VEIL("r", dupe)))); + __expropriate(strcmp_pure(__veil("r", data), __veil("r", dupe)))); EZBENCH2("strcmp [4 dupe]", randomize_buf2str_dupe(4, data, dupe), - EXPROPRIATE(strcmp(VEIL("r", data), VEIL("r", dupe)))); + __expropriate(strcmp(__veil("r", data), __veil("r", dupe)))); EZBENCH2("scmp_pure [4 dupe]", randomize_buf2str_dupe(4, data, dupe), - EXPROPRIATE(strcmp_pure(VEIL("r", data), VEIL("r", dupe)))); + __expropriate(strcmp_pure(__veil("r", data), __veil("r", dupe)))); EZBENCH2("strcmp [8 dupe]", randomize_buf2str_dupe(8, data, dupe), - EXPROPRIATE(strcmp(VEIL("r", data), VEIL("r", dupe)))); + __expropriate(strcmp(__veil("r", data), __veil("r", dupe)))); EZBENCH2("scmp_pure [8 dupe]", randomize_buf2str_dupe(8, data, dupe), - EXPROPRIATE(strcmp_pure(VEIL("r", data), VEIL("r", dupe)))); + __expropriate(strcmp_pure(__veil("r", data), __veil("r", dupe)))); EZBENCH2("strcmp [sdupe]", randomize_buf2str_dupe(size, data, dupe), - EXPROPRIATE(strcmp(VEIL("r", data), VEIL("r", dupe)))); + __expropriate(strcmp(__veil("r", data), __veil("r", dupe)))); EZBENCH2("scmp_pure [sdupe]", randomize_buf2str_dupe(size, data, dupe), - EXPROPRIATE(strcmp_pure(VEIL("r", data), VEIL("r", dupe)))); + __expropriate(strcmp_pure(__veil("r", data), __veil("r", dupe)))); EZBENCH2("strcmp [ldupe]", longstringislong_dupe(size, data, dupe), - EXPROPRIATE(strcmp(VEIL("r", data), VEIL("r", dupe)))); + __expropriate(strcmp(__veil("r", data), __veil("r", dupe)))); EZBENCH2("scmp_pure [ldupe]", longstringislong_dupe(size, data, dupe), - EXPROPRIATE(strcmp_pure(VEIL("r", data), VEIL("r", dupe)))); + __expropriate(strcmp_pure(__veil("r", data), __veil("r", dupe)))); } BENCH(bench_01_strcasecmp, bench) { @@ -584,26 +584,28 @@ BENCH(bench_01_strcasecmp, bench) { dupe = gc(malloc(size)); EZBENCH2("strcasecmp [iden]", longstringislong(size, data), - EXPROPRIATE(strcasecmp(VEIL("r", data), data))); + __expropriate(strcasecmp(__veil("r", data), data))); EZBENCH2("strcasecmp [sdupe]", randomize_buf2str_dupe(size, data, dupe), - EXPROPRIATE(strcasecmp(VEIL("r", data), VEIL("r", dupe)))); - EZBENCH2("sccmp_pure [sdupe]", randomize_buf2str_dupe(size, data, dupe), - EXPROPRIATE(strcasecmp_pure(VEIL("r", data), VEIL("r", dupe)))); + __expropriate(strcasecmp(__veil("r", data), __veil("r", dupe)))); + EZBENCH2( + "sccmp_pure [sdupe]", randomize_buf2str_dupe(size, data, dupe), + __expropriate(strcasecmp_pure(__veil("r", data), __veil("r", dupe)))); EZBENCH2("strcasecmp [ldupe]", longstringislong_dupe(size, data, dupe), - EXPROPRIATE(strcasecmp(VEIL("r", data), VEIL("r", dupe)))); - EZBENCH2("sccmp_pure [ldupe]", longstringislong_dupe(size, data, dupe), - EXPROPRIATE(strcasecmp_pure(VEIL("r", data), VEIL("r", dupe)))); + __expropriate(strcasecmp(__veil("r", data), __veil("r", dupe)))); + EZBENCH2( + "sccmp_pure [ldupe]", longstringislong_dupe(size, data, dupe), + __expropriate(strcasecmp_pure(__veil("r", data), __veil("r", dupe)))); } BENCH(memcmp, bench) { volatile char *copy = gc(strdup(kHyperion)); EZBENCH2("memcmp big", donothing, - EXPROPRIATE(memcmp(kHyperion, copy, kHyperionSize))); + __expropriate(memcmp(kHyperion, copy, kHyperionSize))); copy = gc(strdup("tough little ship")); EZBENCH2("memcmp 18", donothing, - EXPROPRIATE(memcmp("tough little ship", copy, 18))); + __expropriate(memcmp("tough little ship", copy, 18))); } /* jart diff --git a/test/libc/log/backtrace_test.c b/test/libc/log/backtrace_test.c index adf9cfea8..5ffb88f82 100644 --- a/test/libc/log/backtrace_test.c +++ b/test/libc/log/backtrace_test.c @@ -41,8 +41,8 @@ #include "net/http/escape.h" #ifdef __x86_64__ -STATIC_YOINK("backtrace.com"); -STATIC_YOINK("backtrace.com.dbg"); +__static_yoink("backtrace.com"); +__static_yoink("backtrace.com.dbg"); char testlib_enable_tmp_setup_teardown_once; diff --git a/test/libc/nexgen32e/memrchr_test.c b/test/libc/nexgen32e/memrchr_test.c index 4d4c4634d..f218d3028 100644 --- a/test/libc/nexgen32e/memrchr_test.c +++ b/test/libc/nexgen32e/memrchr_test.c @@ -26,5 +26,6 @@ TEST(memrchr, test) { } BENCH(memrchr, bench) { - EZBENCH2("memrchr", donothing, EXPROPRIATE(memrchr("yo.hi.there", '.', 11))); + EZBENCH2("memrchr", donothing, + __expropriate(memrchr("yo.hi.there", '.', 11))); } diff --git a/test/libc/nexgen32e/strcspn_test.c b/test/libc/nexgen32e/strcspn_test.c index 9c439c151..51fc2762c 100644 --- a/test/libc/nexgen32e/strcspn_test.c +++ b/test/libc/nexgen32e/strcspn_test.c @@ -36,14 +36,14 @@ TEST(strcspn, test) { BENCH(strcspn, bench) { EZBENCH2("strcspn", donothing, - EXPROPRIATE( + __expropriate( strcspn("pABCDEFGHIJKLMNOPABCDEFGHIJKLMNO", "abcdefghijklmnp"))); EZBENCH2("strcspn", donothing, - EXPROPRIATE( + __expropriate( strcspn("ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOp", "abcdefghijklmnp"))); EZBENCH2( "strcspn", donothing, - EXPROPRIATE(strcspn( + __expropriate(strcspn( "ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOABCDEFGHIJKLMNOPABCDEFGHIJKLMNOp", "abcdefghijklmnp"))); } diff --git a/test/libc/runtime/grow_test.c b/test/libc/runtime/grow_test.c index a3a2338bc..0564b7c52 100644 --- a/test/libc/runtime/grow_test.c +++ b/test/libc/runtime/grow_test.c @@ -27,7 +27,7 @@ #include "libc/str/str.h" #include "libc/testlib/testlib.h" -STATIC_YOINK("realloc"); +__static_yoink("realloc"); TEST(grow, testNull_hasAllocatingBehavior) { void *p = NULL; diff --git a/test/libc/runtime/itsatrap_test.c b/test/libc/runtime/itsatrap_test.c index 2946ef585..12defd58e 100644 --- a/test/libc/runtime/itsatrap_test.c +++ b/test/libc/runtime/itsatrap_test.c @@ -50,128 +50,128 @@ void SetUp(void) { /* 32-BIT SIGNED NEGATION */ TEST(__negvsi2, testMax) { - EXPECT_EQ(-INT_MAX, -VEIL("r", INT_MAX)); + EXPECT_EQ(-INT_MAX, -__veil("r", INT_MAX)); EXPECT_FALSE(overflowed_); } TEST(__negvsi2, testMin0) { - EXPROPRIATE(-VEIL("r", INT_MIN)); + __expropriate(-__veil("r", INT_MIN)); EXPECT_TRUE(overflowed_); } /* 64-BIT SIGNED NEGATION */ TEST(__negvdi2, testMax) { - EXPECT_EQ(-LONG_MAX, -VEIL("r", LONG_MAX)); + EXPECT_EQ(-LONG_MAX, -__veil("r", LONG_MAX)); EXPECT_FALSE(overflowed_); } TEST(__negvdi2, testMin0) { - EXPROPRIATE(-VEIL("r", LONG_MIN)); + __expropriate(-__veil("r", LONG_MIN)); EXPECT_TRUE(overflowed_); } /* 32-BIT SIGNED MULTIPLICATION */ TEST(__mulvsi3, testMin0) { - EXPECT_EQ(0, 0 * VEIL("r", INT_MIN)); + EXPECT_EQ(0, 0 * __veil("r", INT_MIN)); EXPECT_FALSE(overflowed_); } TEST(__mulvsi3, testMin1) { - EXPECT_EQ(INT_MIN, 1 * VEIL("r", INT_MIN)); + EXPECT_EQ(INT_MIN, 1 * __veil("r", INT_MIN)); EXPECT_FALSE(overflowed_); } TEST(__mulvsi3, testMin2) { - EXPROPRIATE(2 * VEIL("r", INT_MIN)); + __expropriate(2 * __veil("r", INT_MIN)); EXPECT_TRUE(overflowed_); } TEST(__mulvsi3, testMax0) { - EXPECT_EQ(0, 0 * VEIL("r", INT_MAX)); + EXPECT_EQ(0, 0 * __veil("r", INT_MAX)); EXPECT_FALSE(overflowed_); } TEST(__mulvsi3, testMax1) { - EXPECT_EQ(INT_MAX, 1 * VEIL("r", INT_MAX)); + EXPECT_EQ(INT_MAX, 1 * __veil("r", INT_MAX)); EXPECT_FALSE(overflowed_); } TEST(__mulvsi3, testMax2) { - EXPROPRIATE(2 * VEIL("r", INT_MAX)); + __expropriate(2 * __veil("r", INT_MAX)); EXPECT_TRUE(overflowed_); } TEST(__mulvsi3, test7) { - EXPECT_EQ(0x70000000, 7 * VEIL("r", 0x10000000)); + EXPECT_EQ(0x70000000, 7 * __veil("r", 0x10000000)); EXPECT_FALSE(overflowed_); } TEST(__mulvsi3, test8) { - EXPROPRIATE(8 * VEIL("r", 0x10000000)); + __expropriate(8 * __veil("r", 0x10000000)); EXPECT_TRUE(overflowed_); } TEST(__mulvsi3, test31337) { - EXPROPRIATE(0x31337 * VEIL("r", 0x31337)); + __expropriate(0x31337 * __veil("r", 0x31337)); EXPECT_TRUE(overflowed_); } TEST(__mulvsi3, standAndDeliver_aNegativeTimesANegativeEqualsAPositive) { - EXPECT_EQ(25, -5 * VEIL("r", -5)); + EXPECT_EQ(25, -5 * __veil("r", -5)); EXPECT_FALSE(overflowed_); } /* 64-BIT SIGNED MULTIPLICATION */ TEST(__mulvdi3, testMin0) { - EXPECT_EQ(0, 0 * VEIL("r", LONG_MIN)); + EXPECT_EQ(0, 0 * __veil("r", LONG_MIN)); EXPECT_FALSE(overflowed_); } TEST(__mulvdi3, testMin1) { - EXPECT_EQ(LONG_MIN, 1 * VEIL("r", LONG_MIN)); + EXPECT_EQ(LONG_MIN, 1 * __veil("r", LONG_MIN)); EXPECT_FALSE(overflowed_); } TEST(__mulvdi3, testMin2) { - EXPROPRIATE(2 * VEIL("r", LONG_MIN)); + __expropriate(2 * __veil("r", LONG_MIN)); EXPECT_TRUE(overflowed_); } TEST(__mulvdi3, testMax0) { - EXPECT_EQ(0, 0 * VEIL("r", LONG_MAX)); + EXPECT_EQ(0, 0 * __veil("r", LONG_MAX)); EXPECT_FALSE(overflowed_); } TEST(__mulvdi3, testMax1) { - EXPECT_EQ(LONG_MAX, 1 * VEIL("r", LONG_MAX)); + EXPECT_EQ(LONG_MAX, 1 * __veil("r", LONG_MAX)); EXPECT_FALSE(overflowed_); } TEST(__mulvdi3, testMax2) { - EXPROPRIATE(2 * VEIL("r", LONG_MAX)); + __expropriate(2 * __veil("r", LONG_MAX)); EXPECT_TRUE(overflowed_); } TEST(__mulvdi3, test7) { - EXPECT_EQ(0x7000000000000000l, 7 * VEIL("r", 0x1000000000000000l)); + EXPECT_EQ(0x7000000000000000l, 7 * __veil("r", 0x1000000000000000l)); EXPECT_FALSE(overflowed_); } TEST(__mulvdi3, test8) { - EXPROPRIATE(8 * VEIL("r", 0x1000000000000000l)); + __expropriate(8 * __veil("r", 0x1000000000000000l)); EXPECT_TRUE(overflowed_); } TEST(__mulvdi3, test31337) { - EXPROPRIATE(0x3133700000000l * VEIL("r", 0x3133700000000l)); + __expropriate(0x3133700000000l * __veil("r", 0x3133700000000l)); EXPECT_TRUE(overflowed_); } TEST(__mulvdi3, standAndDeliver_aNegativeTimesANegativeEqualsAPositive) { - EXPECT_EQ(25l, -5l * VEIL("r", -5l)); + EXPECT_EQ(25l, -5l * __veil("r", -5l)); EXPECT_FALSE(overflowed_); } @@ -188,73 +188,73 @@ TEST(__mulvdi3, testOverflow) { /* 32-BIT SIGNED ADDITION */ TEST(__addvsi3, testMin1) { - EXPECT_EQ(INT_MIN + 1, 1 + VEIL("r", INT_MIN)); + EXPECT_EQ(INT_MIN + 1, 1 + __veil("r", INT_MIN)); EXPECT_FALSE(overflowed_); } TEST(__addvsi3, testMax1) { - EXPROPRIATE(1 + VEIL("r", INT_MAX)); + __expropriate(1 + __veil("r", INT_MAX)); EXPECT_TRUE(overflowed_); } TEST(__addvsi3, testNegPos) { - EXPECT_EQ(2, -2 + VEIL("r", 4)); + EXPECT_EQ(2, -2 + __veil("r", 4)); EXPECT_FALSE(overflowed_); } TEST(__addvsi3, testPosNeg) { - EXPECT_EQ(-2, 2 + VEIL("r", -4)); + EXPECT_EQ(-2, 2 + __veil("r", -4)); EXPECT_FALSE(overflowed_); } /* 64-BIT SIGNED ADDITION */ TEST(__addvdi3, testMin1) { - EXPECT_EQ(LONG_MIN + 1, 1 + VEIL("r", LONG_MIN)); + EXPECT_EQ(LONG_MIN + 1, 1 + __veil("r", LONG_MIN)); EXPECT_FALSE(overflowed_); } TEST(__addvdi3, testMax1) { - EXPROPRIATE(1 + VEIL("r", LONG_MAX)); + __expropriate(1 + __veil("r", LONG_MAX)); EXPECT_TRUE(overflowed_); } TEST(__addvdi3, testNegPos) { - EXPECT_EQ(2l, -2l + VEIL("r", 4l)); + EXPECT_EQ(2l, -2l + __veil("r", 4l)); EXPECT_FALSE(overflowed_); } TEST(__addvdi3, testPosNeg) { - EXPECT_EQ(-2l, 2l + VEIL("r", -4l)); + EXPECT_EQ(-2l, 2l + __veil("r", -4l)); EXPECT_FALSE(overflowed_); } /* 32-BIT SIGNED SUBTRACTION */ TEST(__subvsi3, testMin1) { - EXPROPRIATE(VEIL("r", INT_MIN) - 1); + __expropriate(__veil("r", INT_MIN) - 1); EXPECT_TRUE(overflowed_); } TEST(__subvsi3, testMax1) { - EXPECT_EQ(INT_MAX - 1, VEIL("r", INT_MAX) - 1); + EXPECT_EQ(INT_MAX - 1, __veil("r", INT_MAX) - 1); EXPECT_FALSE(overflowed_); } TEST(__subvsi3, testPosNeg) { - EXPECT_EQ(-2, 2 - VEIL("r", 4)); + EXPECT_EQ(-2, 2 - __veil("r", 4)); EXPECT_FALSE(overflowed_); } /* 64-BIT SIGNED SUBTRACTION */ TEST(__subvdi3, testMin1) { - EXPROPRIATE(VEIL("r", LONG_MIN) - 1); + __expropriate(__veil("r", LONG_MIN) - 1); EXPECT_TRUE(overflowed_); } TEST(__subvdi3, testMax1) { - EXPECT_EQ(LONG_MAX - 1, VEIL("r", LONG_MAX) - 1); + EXPECT_EQ(LONG_MAX - 1, __veil("r", LONG_MAX) - 1); EXPECT_FALSE(overflowed_); } diff --git a/test/libc/runtime/mmap_test.c b/test/libc/runtime/mmap_test.c index 5160e84fb..453305575 100644 --- a/test/libc/runtime/mmap_test.c +++ b/test/libc/runtime/mmap_test.c @@ -48,7 +48,7 @@ #include "libc/x/xspawn.h" #include "third_party/xed/x86.h" -STATIC_YOINK("zipos"); +__static_yoink("zipos"); char testlib_enable_tmp_setup_teardown; diff --git a/test/libc/runtime/mprotect_test.c b/test/libc/runtime/mprotect_test.c index 7a662097a..48f36af10 100644 --- a/test/libc/runtime/mprotect_test.c +++ b/test/libc/runtime/mprotect_test.c @@ -28,6 +28,7 @@ #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" +#include "libc/sysv/consts/auxv.h" #include "libc/sysv/consts/map.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/prot.h" @@ -116,9 +117,9 @@ void TearDown(void) { } TEST(mprotect, testOkMemory) { - char *p = gc(memalign(APE_GUARDSIZE, APE_GUARDSIZE)); + char *p = gc(memalign(getauxval(AT_PAGESZ), getauxval(AT_PAGESZ))); p[0] = 0; - ASSERT_NE(-1, mprotect(p, APE_GUARDSIZE, PROT_READ | PROT_WRITE)); + ASSERT_NE(-1, mprotect(p, getauxval(AT_PAGESZ), PROT_READ | PROT_WRITE)); p[0] = 1; EXPECT_EQ(1, p[0]); EXPECT_FALSE(gotsegv); @@ -127,19 +128,19 @@ TEST(mprotect, testOkMemory) { TEST(mprotect, testSegfault_writeToReadOnlyAnonymous) { volatile char *p; - p = gc(memalign(APE_GUARDSIZE, APE_GUARDSIZE)); + p = gc(memalign(getauxval(AT_PAGESZ), getauxval(AT_PAGESZ))); EXPECT_FALSE(gotsegv); p[0] = 1; EXPECT_FALSE(gotsegv); EXPECT_FALSE(gotbusted); - EXPECT_NE(-1, mprotect(p, APE_GUARDSIZE, PROT_READ)); + EXPECT_NE(-1, mprotect(p, getauxval(AT_PAGESZ), PROT_READ)); _missingno(p[0]); EXPECT_FALSE(gotsegv); EXPECT_FALSE(gotbusted); p[0] = 2; EXPECT_TRUE(gotsegv | gotbusted); EXPECT_EQ(1, p[0]); - EXPECT_NE(-1, mprotect(p, APE_GUARDSIZE, PROT_READ | PROT_WRITE)); + EXPECT_NE(-1, mprotect(p, getauxval(AT_PAGESZ), PROT_READ | PROT_WRITE)); } TEST(mprotect, testExecOnly_canExecute) { @@ -159,33 +160,34 @@ TEST(mprotect, testExecOnly_canExecute) { TEST(mprotect, testProtNone_cantEvenRead) { volatile char *p; - p = gc(memalign(APE_GUARDSIZE, APE_GUARDSIZE)); - EXPECT_NE(-1, mprotect(p, APE_GUARDSIZE, PROT_NONE)); + p = gc(memalign(getauxval(AT_PAGESZ), getauxval(AT_PAGESZ))); + EXPECT_NE(-1, mprotect(p, getauxval(AT_PAGESZ), PROT_NONE)); _missingno(p[0]); EXPECT_TRUE(gotsegv | gotbusted); - EXPECT_NE(-1, mprotect(p, APE_GUARDSIZE, PROT_READ | PROT_WRITE)); + EXPECT_NE(-1, mprotect(p, getauxval(AT_PAGESZ), PROT_READ | PROT_WRITE)); } TEST(mprotect, testExecJit_actuallyWorks) { - int (*p)(void) = gc(memalign(APE_GUARDSIZE, APE_GUARDSIZE)); + int (*p)(void) = gc(memalign(getauxval(AT_PAGESZ), getauxval(AT_PAGESZ))); memcpy(p, kRet31337, sizeof(kRet31337)); - EXPECT_NE(-1, mprotect(p, APE_GUARDSIZE, PROT_EXEC)); + EXPECT_NE(-1, mprotect(p, getauxval(AT_PAGESZ), PROT_EXEC)); EXPECT_EQ(31337, p()); EXPECT_FALSE(gotsegv); EXPECT_FALSE(gotbusted); - EXPECT_NE(-1, mprotect(p, APE_GUARDSIZE, PROT_READ | PROT_WRITE)); + EXPECT_NE(-1, mprotect(p, getauxval(AT_PAGESZ), PROT_READ | PROT_WRITE)); } TEST(mprotect, testRwxMap_vonNeumannRules) { if (IsOpenbsd()) return; // boo if (IsXnuSilicon()) return; // boo - int (*p)(void) = gc(memalign(APE_GUARDSIZE, APE_GUARDSIZE)); + int (*p)(void) = gc(memalign(getauxval(AT_PAGESZ), getauxval(AT_PAGESZ))); memcpy(p, kRet31337, sizeof(kRet31337)); - EXPECT_NE(-1, mprotect(p, APE_GUARDSIZE, PROT_READ | PROT_WRITE | PROT_EXEC)); + EXPECT_NE(-1, mprotect(p, getauxval(AT_PAGESZ), + PROT_READ | PROT_WRITE | PROT_EXEC)); EXPECT_EQ(31337, p()); EXPECT_FALSE(gotsegv); EXPECT_FALSE(gotbusted); - EXPECT_NE(-1, mprotect(p, APE_GUARDSIZE, PROT_READ | PROT_WRITE)); + EXPECT_NE(-1, mprotect(p, getauxval(AT_PAGESZ), PROT_READ | PROT_WRITE)); } TEST(mprotect, testExecuteFlatFileMapOpenedAsReadonly) { @@ -220,13 +222,13 @@ TEST(mprotect, testFileMap_canChangeToExecWhileOpenInRdwrMode) { } TEST(mprotect, testBadProt_failsEinval) { - volatile char *p = gc(memalign(APE_GUARDSIZE, APE_GUARDSIZE)); + volatile char *p = gc(memalign(getauxval(AT_PAGESZ), getauxval(AT_PAGESZ))); EXPECT_EQ(-1, mprotect(p, 9999, -1)); EXPECT_EQ(EINVAL, errno); } TEST(mprotect, testZeroSize_doesNothing) { - volatile char *p = gc(memalign(APE_GUARDSIZE, APE_GUARDSIZE)); + volatile char *p = gc(memalign(getauxval(AT_PAGESZ), getauxval(AT_PAGESZ))); EXPECT_NE(-1, mprotect(p, 0, PROT_READ)); p[0] = 1; EXPECT_FALSE(gotsegv); diff --git a/test/libc/runtime/test.mk b/test/libc/runtime/test.mk index 5a462cc9c..fa4d9e295 100644 --- a/test/libc/runtime/test.mk +++ b/test/libc/runtime/test.mk @@ -82,10 +82,15 @@ o/$(MODE)/test/libc/runtime/itsatrap_test.o: private \ -fno-sanitize=all \ -ftrapv +ifeq ($(ARCH), aarch64) +FTRACEASM_LDSCRIPT = o/$(MODE)/ape/aarch64.lds +endif + o/$(MODE)/test/libc/runtime/prog/ftraceasm.elf: \ $(TEST_LIBC_RUNTIME_DEPS) \ o/$(MODE)/test/libc/runtime/prog/ftraceasm.o \ - o/$(MODE)/test/libc/runtime/runtime.pkg + o/$(MODE)/test/libc/runtime/runtime.pkg \ + $(FTRACEASM_LDSCRIPT) @$(ELFLINK) o/$(MODE)/test/libc/runtime/prog/ftraceasm.txt: \ o/$(MODE)/test/libc/runtime/prog/ftraceasm.elf diff --git a/test/libc/runtime/tls_test.c b/test/libc/runtime/tls_test.c index 220f77524..6624cb55b 100644 --- a/test/libc/runtime/tls_test.c +++ b/test/libc/runtime/tls_test.c @@ -30,7 +30,7 @@ _Thread_local long x; _Thread_local long y[1] = {40}; _Alignas(A) _Thread_local long a; -noubsan void *Worker(void *arg) { +dontubsan void *Worker(void *arg) { ASSERT_EQ(42, x + y[0] + z); ASSERT_EQ(0, (intptr_t)&a & (A - 1)); if (IsAsan()) { diff --git a/test/libc/stdio/dirstream_test.c b/test/libc/stdio/dirstream_test.c index cb0b345cc..8d7d672d2 100644 --- a/test/libc/stdio/dirstream_test.c +++ b/test/libc/stdio/dirstream_test.c @@ -29,8 +29,8 @@ #include "libc/x/xasprintf.h" #include "libc/x/xiso8601.h" -STATIC_YOINK("zipos"); -STATIC_YOINK("usr/share/zoneinfo/New_York"); +__static_yoink("zipos"); +__static_yoink("usr/share/zoneinfo/New_York"); char testlib_enable_tmp_setup_teardown; diff --git a/test/libc/stdio/palandprintf_test.c b/test/libc/stdio/palandprintf_test.c index 5e6a3349c..6ca7e26e5 100644 --- a/test/libc/stdio/palandprintf_test.c +++ b/test/libc/stdio/palandprintf_test.c @@ -633,33 +633,36 @@ TEST(vsnprintf, issue785) { } BENCH(palandprintf, bench) { - EZBENCH2("ascii", donothing, Format(VEIL("r", "hiuhcreohucreo"))); - EZBENCH2("ascii %s", donothing, Format("%s", VEIL("r", "hiuhcreohucreo"))); - EZBENCH2("ascii %`'s", donothing, Format("%`'s", VEIL("r", "hiuhcreohucre"))); - EZBENCH2("utf8 %s", donothing, Format("%s", VEIL("r", "hi (╯°□°)╯"))); - EZBENCH2("snprintf %hs", donothing, Format("%hs", VEIL("r", u"hi (╯°□°)╯"))); - EZBENCH2("snprintf %ls", donothing, Format("%ls", VEIL("r", L"hi (╯°□°)╯"))); - EZBENCH2("23 %x", donothing, Format("%x", VEIL("r", 23))); - EZBENCH2("23 %d", donothing, Format("%d", VEIL("r", 23))); - EZBENCH2("%f M_PI", donothing, Format("%f", VEIL("x", M_PI))); - EZBENCH2("%g M_PI", donothing, Format("%g", VEIL("x", M_PI))); - EZBENCH2("%a M_PI", donothing, Format("%a", VEIL("x", M_PI))); - EZBENCH2("%e M_PI", donothing, Format("%e", VEIL("x", M_PI))); - EZBENCH2("ULONG_MAX %lo", donothing, Format("%lo", VEIL("r", ULONG_MAX))); - EZBENCH2("INT_MIN %x", donothing, Format("%x", VEIL("r", INT_MIN))); - EZBENCH2("INT_MIN %d", donothing, Format("%d", VEIL("r", INT_MIN))); - EZBENCH2("INT_MIN %,d", donothing, Format("%,d", VEIL("r", INT_MIN))); - EZBENCH2("INT_MIN %ld", donothing, Format("%ld", (long)VEIL("r", INT_MIN))); - EZBENCH2("LONG_MIN %lx", donothing, Format("%lx", VEIL("r", LONG_MIN))); - EZBENCH2("LONG_MIN %ld", donothing, Format("%ld", VEIL("r", LONG_MIN))); + EZBENCH2("ascii", donothing, Format(__veil("r", "hiuhcreohucreo"))); + EZBENCH2("ascii %s", donothing, Format("%s", __veil("r", "hiuhcreohucreo"))); + EZBENCH2("ascii %`'s", donothing, + Format("%`'s", __veil("r", "hiuhcreohucre"))); + EZBENCH2("utf8 %s", donothing, Format("%s", __veil("r", "hi (╯°□°)╯"))); + EZBENCH2("snprintf %hs", donothing, + Format("%hs", __veil("r", u"hi (╯°□°)╯"))); + EZBENCH2("snprintf %ls", donothing, + Format("%ls", __veil("r", L"hi (╯°□°)╯"))); + EZBENCH2("23 %x", donothing, Format("%x", __veil("r", 23))); + EZBENCH2("23 %d", donothing, Format("%d", __veil("r", 23))); + EZBENCH2("%f M_PI", donothing, Format("%f", __veil("x", M_PI))); + EZBENCH2("%g M_PI", donothing, Format("%g", __veil("x", M_PI))); + EZBENCH2("%a M_PI", donothing, Format("%a", __veil("x", M_PI))); + EZBENCH2("%e M_PI", donothing, Format("%e", __veil("x", M_PI))); + EZBENCH2("ULONG_MAX %lo", donothing, Format("%lo", __veil("r", ULONG_MAX))); + EZBENCH2("INT_MIN %x", donothing, Format("%x", __veil("r", INT_MIN))); + EZBENCH2("INT_MIN %d", donothing, Format("%d", __veil("r", INT_MIN))); + EZBENCH2("INT_MIN %,d", donothing, Format("%,d", __veil("r", INT_MIN))); + EZBENCH2("INT_MIN %ld", donothing, Format("%ld", (long)__veil("r", INT_MIN))); + EZBENCH2("LONG_MIN %lx", donothing, Format("%lx", __veil("r", LONG_MIN))); + EZBENCH2("LONG_MIN %ld", donothing, Format("%ld", __veil("r", LONG_MIN))); EZBENCH2("INT128_MIN %jjd", donothing, Format("%jjd", INT128_MIN)); EZBENCH2("INT128_MIN %jjx", donothing, Format("%jjx", INT128_MIN)); EZBENCH2("int64toarray 23", donothing, FormatInt64(buffer, 23)); EZBENCH2("int64toarray min", donothing, FormatInt64(buffer, INT_MIN)); #ifdef __x86__ - EZBENCH2("%Lf M_PI", donothing, Format("%Lf", VEIL("t", M_PI))); - EZBENCH2("%Lg M_PI", donothing, Format("%Lg", VEIL("t", M_PI))); - EZBENCH2("%La M_PI", donothing, Format("%La", VEIL("t", M_PI))); - EZBENCH2("%Le M_PI", donothing, Format("%Le", VEIL("t", M_PI))); + EZBENCH2("%Lf M_PI", donothing, Format("%Lf", __veil("t", M_PI))); + EZBENCH2("%Lg M_PI", donothing, Format("%Lg", __veil("t", M_PI))); + EZBENCH2("%La M_PI", donothing, Format("%La", __veil("t", M_PI))); + EZBENCH2("%Le M_PI", donothing, Format("%Le", __veil("t", M_PI))); #endif } diff --git a/test/libc/stdio/sprintf_s.inc b/test/libc/stdio/sprintf_s.inc index 497892e77..34529810c 100644 --- a/test/libc/stdio/sprintf_s.inc +++ b/test/libc/stdio/sprintf_s.inc @@ -18,9 +18,9 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ /* MODE=tiny makes these dependencies optional */ -STATIC_YOINK("strnwidth"); -STATIC_YOINK("strnwidth16"); -STATIC_YOINK("wcsnwidth"); +__static_yoink("strnwidth"); +__static_yoink("strnwidth16"); +__static_yoink("wcsnwidth"); TEST(SUITE(sprintf), testStringLength) { ASSERT_STREQ("This", Format(FORMAT("%.4"), STRING("This is a test"))); diff --git a/test/libc/stdio/system_test.c b/test/libc/stdio/system_test.c index 181093689..5ddb15010 100644 --- a/test/libc/stdio/system_test.c +++ b/test/libc/stdio/system_test.c @@ -30,8 +30,8 @@ #include "libc/x/x.h" #ifdef __x86_64__ -STATIC_YOINK("_tr"); -STATIC_YOINK("glob"); +__static_yoink("_tr"); +__static_yoink("glob"); char testlib_enable_tmp_setup_teardown; diff --git a/test/libc/str/crc32c_test.c b/test/libc/str/crc32c_test.c index dc3cd9d1c..00f50ce92 100644 --- a/test/libc/str/crc32c_test.c +++ b/test/libc/str/crc32c_test.c @@ -74,15 +74,17 @@ BENCH(crc32c, bench) { EZBENCH_N("crc32c", i, crc32c(0, kHyperion, i)); EZBENCH_N("crc32_z", i, crc32_z(0, kHyperion, i)); EZBENCH_N("fnv_hash", i, - EXPROPRIATE(fnv_hash(VEIL("r", kHyperion), VEIL("r", i)))); - EZBENCH_N("KMH", i, EXPROPRIATE(KMH(VEIL("r", kHyperion), VEIL("r", i)))); + __expropriate(fnv_hash(__veil("r", kHyperion), __veil("r", i)))); + EZBENCH_N("KMH", i, + __expropriate(KMH(__veil("r", kHyperion), __veil("r", i)))); fprintf(stderr, "\n"); } EZBENCH_N("crc32c", kHyperionSize, crc32c(0, kHyperion, kHyperionSize)); EZBENCH_N("crc32_z", kHyperionSize, crc32_z(0, kHyperion, kHyperionSize)); + EZBENCH_N("fnv_hash", kHyperionSize, + __expropriate( + fnv_hash(__veil("r", kHyperion), __veil("r", kHyperionSize)))); EZBENCH_N( - "fnv_hash", kHyperionSize, - EXPROPRIATE(fnv_hash(VEIL("r", kHyperion), VEIL("r", kHyperionSize)))); - EZBENCH_N("KMH", kHyperionSize, - EXPROPRIATE(KMH(VEIL("r", kHyperion), VEIL("r", kHyperionSize)))); + "KMH", kHyperionSize, + __expropriate(KMH(__veil("r", kHyperion), __veil("r", kHyperionSize)))); } diff --git a/test/libc/str/highwayhash64_test.c b/test/libc/str/highwayhash64_test.c index 201bbbe8d..30cbb88c7 100644 --- a/test/libc/str/highwayhash64_test.c +++ b/test/libc/str/highwayhash64_test.c @@ -113,10 +113,10 @@ BENCH(highwayhash64, newbench) { BENCH(highwayhash64, bench) { EZBENCH2("knuth small", donothing, - EXPROPRIATE(KnuthMultiplicativeHash32(VEIL("r", "hello"), 5))); + __expropriate(KnuthMultiplicativeHash32(__veil("r", "hello"), 5))); EZBENCH2("crc32c small", donothing, crc32c(0, "hello", 5)); EZBENCH2("crc32 small", donothing, - EXPROPRIATE(crc32_z(0, VEIL("r", "hello"), 5))); + __expropriate(crc32_z(0, __veil("r", "hello"), 5))); EZBENCH2("highwayhash64 small", donothing, HighwayHash64((void *)"hello", 5, kTestKey1)); EZBENCH2("crc32 big", donothing, crc32_z(0, kHyperion, kHyperionSize)); @@ -124,6 +124,6 @@ BENCH(highwayhash64, bench) { EZBENCH2("highwayhash64 big", donothing, HighwayHash64((void *)kHyperion, kHyperionSize, kTestKey1)); EZBENCH2("knuth big", donothing, - EXPROPRIATE( - KnuthMultiplicativeHash32(VEIL("r", kHyperion), kHyperionSize))); + __expropriate(KnuthMultiplicativeHash32(__veil("r", kHyperion), + kHyperionSize))); } diff --git a/test/libc/str/memcasecmp_test.c b/test/libc/str/memcasecmp_test.c index baf0fea6f..f98337527 100644 --- a/test/libc/str/memcasecmp_test.c +++ b/test/libc/str/memcasecmp_test.c @@ -16,8 +16,8 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/mem/mem.h" #include "libc/mem/gc.internal.h" +#include "libc/mem/mem.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" @@ -35,5 +35,5 @@ TEST(memcasecmp, test) { BENCH(memcasecmp, bench) { volatile char *copy = gc(strdup(kHyperion)); EZBENCH2("memcasecmp", donothing, - EXPROPRIATE(memcasecmp(kHyperion, copy, kHyperionSize))); + __expropriate(memcasecmp(kHyperion, copy, kHyperionSize))); } diff --git a/test/libc/str/memcpy_test.c b/test/libc/str/memcpy_test.c index 25eee7ec6..11bf35d83 100644 --- a/test/libc/str/memcpy_test.c +++ b/test/libc/str/memcpy_test.c @@ -154,20 +154,20 @@ TEST(memcpy, testBackwardsOverlap3) { volatile char *c; c = malloc(3); memcpy(c, "\e[C", 3); - memcpy(c, c + 1, VEIL("r", 3) - 1); + memcpy(c, c + 1, __veil("r", 3) - 1); EXPECT_EQ('[', c[0]); EXPECT_EQ('C', c[1]); free(c); } -#define B(F, N) \ - do { \ - char *d = rngset(malloc(N), N, _rand64, -1); \ - char *s = rngset(malloc(N), N, _rand64, -1); \ - EZBENCH2(#F " " #N, donothing, \ - EXPROPRIATE(F(VEIL("r", d), VEIL("r", s), N))); \ - free(d); \ - free(s); \ +#define B(F, N) \ + do { \ + char *d = rngset(malloc(N), N, _rand64, -1); \ + char *s = rngset(malloc(N), N, _rand64, -1); \ + EZBENCH2(#F " " #N, donothing, \ + __expropriate(F(__veil("r", d), __veil("r", s), N))); \ + free(d); \ + free(s); \ } while (0) void BB(size_t N) { diff --git a/test/libc/str/memmem_test.c b/test/libc/str/memmem_test.c index f8b7ba222..75fc028a8 100644 --- a/test/libc/str/memmem_test.c +++ b/test/libc/str/memmem_test.c @@ -193,11 +193,11 @@ TEST(memmem, fuzz) { */ BENCH(memmem, bench) { EZBENCH2("memmem naive", donothing, - EXPROPRIATE(memmem_naive(kHyperion, kHyperionSize, "THE END", 7))); + __expropriate(memmem_naive(kHyperion, kHyperionSize, "THE END", 7))); EZBENCH2("memmem", donothing, - EXPROPRIATE(memmem(kHyperion, kHyperionSize, "THE END", 7))); + __expropriate(memmem(kHyperion, kHyperionSize, "THE END", 7))); EZBENCH2("memmem", donothing, - EXPROPRIATE(memmem( + __expropriate(memmem( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", 62, "aaaaaab", 7))); } diff --git a/test/libc/str/memrchr16_test.c b/test/libc/str/memrchr16_test.c index f18b8873f..32c909aa1 100644 --- a/test/libc/str/memrchr16_test.c +++ b/test/libc/str/memrchr16_test.c @@ -31,7 +31,7 @@ TEST(memrchr16, test) { BENCH(memrchr16, bench) { EZBENCH2("memrchr16", donothing, - EXPROPRIATE(memrchr16(u"yo.hi.there", '.', 11))); + __expropriate(memrchr16(u"yo.hi.there", '.', 11))); EZBENCH2("memrchr16 hyperion", donothing, - EXPROPRIATE(memrchr16(kHyperion, '.', kHyperionSize / 2))); + __expropriate(memrchr16(kHyperion, '.', kHyperionSize / 2))); } diff --git a/test/libc/str/strcasecmp_test.c b/test/libc/str/strcasecmp_test.c index 32aa33406..46bd82982 100644 --- a/test/libc/str/strcasecmp_test.c +++ b/test/libc/str/strcasecmp_test.c @@ -32,9 +32,9 @@ TEST(strcasecmp, test) { BENCH(strcasecmp, bench) { EZBENCH2("strcasecmp 16 eq (same)", donothing, - EXPROPRIATE( - strcasecmp(VEIL("r", "abcdefghijklmnop"), "abcdefghijklmnop"))); + __expropriate(strcasecmp(__veil("r", "abcdefghijklmnop"), + "abcdefghijklmnop"))); EZBENCH2("strcasecmp 16 eq (evil)", donothing, - EXPROPRIATE( - strcasecmp(VEIL("r", "abcdefghijklmnop"), "ABCDEFGHIJKLMNOP"))); + __expropriate(strcasecmp(__veil("r", "abcdefghijklmnop"), + "ABCDEFGHIJKLMNOP"))); } diff --git a/test/libc/str/strcasestr_test.c b/test/libc/str/strcasestr_test.c index 518e5bb67..8452356c6 100644 --- a/test/libc/str/strcasestr_test.c +++ b/test/libc/str/strcasestr_test.c @@ -122,41 +122,41 @@ TEST(strcasestr, test) { */ BENCH(strcasestr, bench) { EZBENCH2("strcasestr naive", donothing, - EXPROPRIATE(strcasestr_naive(kHyperion, "THE END"))); + __expropriate(strcasestr_naive(kHyperion, "THE END"))); EZBENCH2("strcasestr", donothing, - EXPROPRIATE(strcasestr(kHyperion, "THE END"))); + __expropriate(strcasestr(kHyperion, "THE END"))); EZBENCH2("strcasestr tort 1", donothing, - EXPROPRIATE(strcasestr( + __expropriate(strcasestr( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", "B"))); EZBENCH2("strcasestr tort 2", donothing, - EXPROPRIATE(strcasestr( + __expropriate(strcasestr( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", "ab"))); EZBENCH2("strcasestr tort 4", donothing, - EXPROPRIATE(strcasestr( + __expropriate(strcasestr( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", "aaab"))); EZBENCH2("strcasestr tort 8", donothing, - EXPROPRIATE(strcasestr( + __expropriate(strcasestr( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", "aaaaaaab"))); EZBENCH2("strcasestr tort 16", donothing, - EXPROPRIATE(strcasestr( + __expropriate(strcasestr( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", "aaaaaaaaaaaaaaab"))); EZBENCH2("strcasestr tort 32", donothing, - EXPROPRIATE(strcasestr( + __expropriate(strcasestr( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", diff --git a/test/libc/str/strlcpy_test.c b/test/libc/str/strlcpy_test.c index 5cf8a2864..3e79667c8 100644 --- a/test/libc/str/strlcpy_test.c +++ b/test/libc/str/strlcpy_test.c @@ -40,8 +40,10 @@ TEST(strlcpy, testShortBuffer_copies) { BENCH(strlcpy, bench) { char buf[256]; - EZBENCH2("strlcpy", donothing, - EXPROPRIATE(strlcpy(VEIL("r", buf), "hello there", sizeof(buf)))); - EZBENCH2("strncpy", donothing, - EXPROPRIATE(strncpy(VEIL("r", buf), "hello there", sizeof(buf)))); + EZBENCH2( + "strlcpy", donothing, + __expropriate(strlcpy(__veil("r", buf), "hello there", sizeof(buf)))); + EZBENCH2( + "strncpy", donothing, + __expropriate(strncpy(__veil("r", buf), "hello there", sizeof(buf)))); } diff --git a/test/libc/str/strnwidth_test.c b/test/libc/str/strnwidth_test.c index 75d77a2a5..61447592b 100644 --- a/test/libc/str/strnwidth_test.c +++ b/test/libc/str/strnwidth_test.c @@ -53,5 +53,5 @@ TEST(strwidth, cjk) { } BENCH(strnwidth, bench) { - EZBENCH2("strnwidth", donothing, EXPROPRIATE(strnwidth(kHyperion, -1, 0))); + EZBENCH2("strnwidth", donothing, __expropriate(strnwidth(kHyperion, -1, 0))); } diff --git a/test/libc/str/strstr_test.c b/test/libc/str/strstr_test.c index 99fb6b589..aaa772107 100644 --- a/test/libc/str/strstr_test.c +++ b/test/libc/str/strstr_test.c @@ -129,40 +129,40 @@ TEST(strstr, breakit) { */ BENCH(strstr, bench) { EZBENCH2("strstr naive", donothing, - EXPROPRIATE(strstr_naive(kHyperion, "THE END"))); - EZBENCH2("strstr", donothing, EXPROPRIATE(strstr(kHyperion, "THE END"))); + __expropriate(strstr_naive(kHyperion, "THE END"))); + EZBENCH2("strstr", donothing, __expropriate(strstr(kHyperion, "THE END"))); EZBENCH2("strstr torture 1", donothing, - EXPROPRIATE(strstr( + __expropriate(strstr( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", "b"))); EZBENCH2("strstr torture 2", donothing, - EXPROPRIATE(strstr( + __expropriate(strstr( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", "ab"))); EZBENCH2("strstr torture 4", donothing, - EXPROPRIATE(strstr( + __expropriate(strstr( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", "aaab"))); EZBENCH2("strstr torture 8", donothing, - EXPROPRIATE(strstr( + __expropriate(strstr( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", "aaaaaaab"))); EZBENCH2("strstr torture 16", donothing, - EXPROPRIATE(strstr( + __expropriate(strstr( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", "aaaaaaaaaaaaaaab"))); EZBENCH2("strstr torture 32", donothing, - EXPROPRIATE(strstr( + __expropriate(strstr( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab", diff --git a/test/libc/str/towupper_test.c b/test/libc/str/towupper_test.c index 48907900a..58bbb0328 100644 --- a/test/libc/str/towupper_test.c +++ b/test/libc/str/towupper_test.c @@ -44,39 +44,45 @@ TEST(towlower, test) { } BENCH(towupper, bench) { - EZBENCH2("towupper ascii", donothing, EXPROPRIATE(towupper(VEIL("r", L'a')))); + EZBENCH2("towupper ascii", donothing, + __expropriate(towupper(__veil("r", L'a')))); EZBENCH2("towupper latin1", donothing, - EXPROPRIATE(towupper(VEIL("r", u'A')))); + __expropriate(towupper(__veil("r", u'A')))); EZBENCH2("towupper watinc", donothing, - EXPROPRIATE(towupper(VEIL("r", u'Ỿ')))); - EZBENCH2("towupper greek", donothing, EXPROPRIATE(towupper(VEIL("r", u'α')))); + __expropriate(towupper(__veil("r", u'Ỿ')))); + EZBENCH2("towupper greek", donothing, + __expropriate(towupper(__veil("r", u'α')))); EZBENCH2("towupper astral", donothing, - EXPROPRIATE(towupper(VEIL("r", L'𝛿')))); + __expropriate(towupper(__veil("r", L'𝛿')))); } BENCH(towlower, bench) { - EZBENCH2("towlower ascii", donothing, EXPROPRIATE(towlower(VEIL("r", L'a')))); + EZBENCH2("towlower ascii", donothing, + __expropriate(towlower(__veil("r", L'a')))); EZBENCH2("towlower latin1", donothing, - EXPROPRIATE(towlower(VEIL("r", u'A')))); + __expropriate(towlower(__veil("r", u'A')))); EZBENCH2("towlower watinc", donothing, - EXPROPRIATE(towlower(VEIL("r", u'Ỿ')))); - EZBENCH2("towlower greek", donothing, EXPROPRIATE(towupper(VEIL("r", u'α')))); + __expropriate(towlower(__veil("r", u'Ỿ')))); + EZBENCH2("towlower greek", donothing, + __expropriate(towupper(__veil("r", u'α')))); EZBENCH2("towlower astral", donothing, - EXPROPRIATE(towlower(VEIL("r", L'𝛿')))); + __expropriate(towlower(__veil("r", L'𝛿')))); } BENCH(iswupper, bench) { - EZBENCH2("iswupper ascii", donothing, EXPROPRIATE(iswupper(VEIL("r", L'A')))); + EZBENCH2("iswupper ascii", donothing, + __expropriate(iswupper(__veil("r", L'A')))); EZBENCH2("iswupper latin1", donothing, - EXPROPRIATE(iswupper(VEIL("r", u'A')))); + __expropriate(iswupper(__veil("r", u'A')))); EZBENCH2("iswupper astral", donothing, - EXPROPRIATE(iswupper(VEIL("r", L'𝛿')))); + __expropriate(iswupper(__veil("r", L'𝛿')))); } BENCH(iswlower, bench) { - EZBENCH2("iswlower ascii", donothing, EXPROPRIATE(iswlower(VEIL("r", L'a')))); + EZBENCH2("iswlower ascii", donothing, + __expropriate(iswlower(__veil("r", L'a')))); EZBENCH2("iswlower latin1", donothing, - EXPROPRIATE(iswlower(VEIL("r", u'A')))); + __expropriate(iswlower(__veil("r", u'A')))); EZBENCH2("iswlower astral", donothing, - EXPROPRIATE(iswlower(VEIL("r", L'𝛿')))); + __expropriate(iswlower(__veil("r", L'𝛿')))); } diff --git a/test/libc/str/tpenc_test.c b/test/libc/str/tpenc_test.c index f70abb5d9..48455ad5e 100644 --- a/test/libc/str/tpenc_test.c +++ b/test/libc/str/tpenc_test.c @@ -23,7 +23,7 @@ #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" -STATIC_YOINK("strwidth"); +__static_yoink("strwidth"); volatile uint64_t v; @@ -45,7 +45,7 @@ TEST(_tpenc, testBeyondTheStandard) { } uint64_t _Tpenc(int x) { - return (v = EXPROPRIATE(_tpenc(VEIL("r", x)))); + return (v = __expropriate(_tpenc(__veil("r", x)))); } BENCH(_tpenc, bench) { diff --git a/test/libc/str/wcwidth_test.c b/test/libc/str/wcwidth_test.c index c463952a7..11b1d374f 100644 --- a/test/libc/str/wcwidth_test.c +++ b/test/libc/str/wcwidth_test.c @@ -77,5 +77,5 @@ TEST(strwidth, testTextDelimitingControlCodes_dontHaveSubstance) { BENCH(wcwidth, bench) { volatile int x; - EZBENCH2("wcwidth", donothing, x = wcwidth(VEIL("r", u'→'))); + EZBENCH2("wcwidth", donothing, x = wcwidth(__veil("r", u'→'))); } diff --git a/test/libc/str/wmemrchr_test.c b/test/libc/str/wmemrchr_test.c index 9e39ae657..e13fff34f 100644 --- a/test/libc/str/wmemrchr_test.c +++ b/test/libc/str/wmemrchr_test.c @@ -30,5 +30,5 @@ TEST(wmemrchr, test) { BENCH(wmemrchr, bench) { EZBENCH2("wmemrchr", donothing, - EXPROPRIATE(wmemrchr(L"yo.hi.there", '.', 11))); + __expropriate(wmemrchr(L"yo.hi.there", '.', 11))); } diff --git a/test/libc/thread/makecontext_test.c b/test/libc/thread/makecontext_test.c index 206e121c6..30e7cfcce 100644 --- a/test/libc/thread/makecontext_test.c +++ b/test/libc/thread/makecontext_test.c @@ -66,7 +66,7 @@ TEST(makecontext, args) { EXPECT_TRUE(gotsome); } -noasan noubsan void itsatrap(int x, int y) { +dontasan dontubsan void itsatrap(int x, int y) { *(int *)(intptr_t)x = scalbn(x, y); } diff --git a/test/libc/tinymath/atanh_test.c b/test/libc/tinymath/atanh_test.c index f2fe695be..8d258bf8b 100644 --- a/test/libc/tinymath/atanh_test.c +++ b/test/libc/tinymath/atanh_test.c @@ -64,7 +64,7 @@ TEST(atanhf, test) { BENCH(_atanh, bench) { volatile double a = .5; - EZBENCH2("atanhf", donothing, EXPROPRIATE(_atanhf(a))); - EZBENCH2("atanh", donothing, EXPROPRIATE(_atanh(a))); - EZBENCH2("atanhl", donothing, EXPROPRIATE(_atanhl(a))); + EZBENCH2("atanhf", donothing, __expropriate(_atanhf(a))); + EZBENCH2("atanh", donothing, __expropriate(_atanh(a))); + EZBENCH2("atanhl", donothing, __expropriate(_atanhl(a))); } diff --git a/test/libc/tinymath/hypot_test.c b/test/libc/tinymath/hypot_test.c index 360a8a2fb..63ca8afbf 100644 --- a/test/libc/tinymath/hypot_test.c +++ b/test/libc/tinymath/hypot_test.c @@ -121,7 +121,7 @@ _hypotl l: 43𝑐 14𝑛𝑠 m: 74 BENCH(_hypot, bench) { volatile double a = 2; volatile double b = 3; - EZBENCH2("hypotf", donothing, EXPROPRIATE(_hypotf(a, b))); - EZBENCH2("hypot", donothing, EXPROPRIATE(_hypot(a, b))); - EZBENCH2("hypotl", donothing, EXPROPRIATE(_hypotl(a, b))); + EZBENCH2("hypotf", donothing, __expropriate(_hypotf(a, b))); + EZBENCH2("hypot", donothing, __expropriate(_hypot(a, b))); + EZBENCH2("hypotl", donothing, __expropriate(_hypotl(a, b))); } diff --git a/test/libc/tinymath/magicu_test.c b/test/libc/tinymath/magicu_test.c index 2c19bc0ef..3502b3a09 100644 --- a/test/libc/tinymath/magicu_test.c +++ b/test/libc/tinymath/magicu_test.c @@ -49,8 +49,9 @@ TEST(magicu, test) { BENCH(magicu, bench) { struct magicu d = __magicu_get(UINT32_MAX); - EZBENCH2("__magicu_get", donothing, __magicu_get(VEIL("r", UINT32_MAX))); + EZBENCH2("__magicu_get", donothing, __magicu_get(__veil("r", UINT32_MAX))); EZBENCH2("__magicu_div", donothing, - EXPROPRIATE(__magicu_div(VEIL("r", 77u), d))); - EZBENCH2("/", donothing, EXPROPRIATE(VEIL("r", 77u) / VEIL("r", UINT32_MAX))); + __expropriate(__magicu_div(__veil("r", 77u), d))); + EZBENCH2("/", donothing, + __expropriate(__veil("r", 77u) / __veil("r", UINT32_MAX))); } diff --git a/test/libc/tinymath/round_test.c b/test/libc/tinymath/round_test.c index 477b2bb35..efcd105bc 100644 --- a/test/libc/tinymath/round_test.c +++ b/test/libc/tinymath/round_test.c @@ -215,10 +215,12 @@ TEST(lroundl, test) { BENCH(round, bench) { #ifdef __x86_64__ - EZBENCH2("double+.5", donothing, EXPROPRIATE(VEIL("x", (double)(-3.5)) + .5)); - EZBENCH2("float+.5f", donothing, EXPROPRIATE(VEIL("x", (float)(-3.5)) + .5)); + EZBENCH2("double+.5", donothing, + __expropriate(__veil("x", (double)(-3.5)) + .5)); + EZBENCH2("float+.5f", donothing, + __expropriate(__veil("x", (float)(-3.5)) + .5)); EZBENCH2("ldbl+.5l", donothing, - EXPROPRIATE(VEIL("t", (long double)(-3.5)) + .5)); + __expropriate(__veil("t", (long double)(-3.5)) + .5)); #endif EZBENCH2("round", donothing, _round(.7)); /* ~4ns */ EZBENCH2("roundf", donothing, _roundf(.7)); /* ~3ns */ diff --git a/test/libc/x/xstrcat_test.c b/test/libc/x/xstrcat_test.c index a47e45d11..7c1eb1225 100644 --- a/test/libc/x/xstrcat_test.c +++ b/test/libc/x/xstrcat_test.c @@ -48,16 +48,16 @@ int hard_static(void) { int hard_dynamic(void) { char *b, *p; p = b = malloc(16); - p = stpcpy(p, VEIL("r", "eins")); - p = stpcpy(p, VEIL("r", "zwei")); - p = stpcpy(p, VEIL("r", "drei")); + p = stpcpy(p, __veil("r", "eins")); + p = stpcpy(p, __veil("r", "zwei")); + p = stpcpy(p, __veil("r", "drei")); free(b); return (intptr_t)b; } BENCH(xstrcat, bench) { - EZBENCH2("hard_static", donothing, EXPROPRIATE(hard_static())); - EZBENCH2("hard_dynamic", donothing, EXPROPRIATE(hard_dynamic())); + EZBENCH2("hard_static", donothing, __expropriate(hard_static())); + EZBENCH2("hard_dynamic", donothing, __expropriate(hard_dynamic())); EZBENCH2("xstrcat", donothing, free(xstrcat("eins", "zwei", "drei"))); EZBENCH2("xasprintf", donothing, free(xasprintf("%s%s%s", "eins", "zwei", "drei"))); diff --git a/test/libc/zipos/open_test.c b/test/libc/zipos/open_test.c index 13c4e0c8d..e8d49e873 100644 --- a/test/libc/zipos/open_test.c +++ b/test/libc/zipos/open_test.c @@ -26,11 +26,11 @@ #include "libc/testlib/testlib.h" #include "libc/thread/spawn.h" -STATIC_YOINK("zipos"); -STATIC_YOINK("libc/testlib/hyperion.txt"); -STATIC_YOINK("inflate"); -STATIC_YOINK("inflateInit2"); -STATIC_YOINK("inflateEnd"); +__static_yoink("zipos"); +__static_yoink("libc/testlib/hyperion.txt"); +__static_yoink("inflate"); +__static_yoink("inflateInit2"); +__static_yoink("inflateEnd"); int Worker(void *arg, int tid) { int i, fd; diff --git a/test/tool/net/redbean_test.c b/test/tool/net/redbean_test.c index c0d6f44b9..afc40c65a 100644 --- a/test/tool/net/redbean_test.c +++ b/test/tool/net/redbean_test.c @@ -41,8 +41,8 @@ #include "third_party/regex/regex.h" #ifdef __x86_64__ -STATIC_YOINK("zipos"); -STATIC_YOINK("o/" MODE "/test/tool/net/redbean-tester.com"); +__static_yoink("zipos"); +__static_yoink("o/" MODE "/test/tool/net/redbean-tester.com"); char testlib_enable_tmp_setup_teardown_once; int port; diff --git a/test/tool/plinko/plinko_test.c b/test/tool/plinko/plinko_test.c index 2d63eb5fd..1d9df1513 100644 --- a/test/tool/plinko/plinko_test.c +++ b/test/tool/plinko/plinko_test.c @@ -29,15 +29,15 @@ #include "libc/sysv/consts/sig.h" #include "libc/testlib/testlib.h" -STATIC_YOINK("zipos"); -STATIC_YOINK("plinko.com"); -STATIC_YOINK("library.lisp"); -STATIC_YOINK("library_test.lisp"); -STATIC_YOINK("binarytrees.lisp"); -STATIC_YOINK("algebra.lisp"); -STATIC_YOINK("algebra_test.lisp"); -STATIC_YOINK("infix.lisp"); -STATIC_YOINK("ok.lisp"); +__static_yoink("zipos"); +__static_yoink("plinko.com"); +__static_yoink("library.lisp"); +__static_yoink("library_test.lisp"); +__static_yoink("binarytrees.lisp"); +__static_yoink("algebra.lisp"); +__static_yoink("algebra_test.lisp"); +__static_yoink("infix.lisp"); +__static_yoink("ok.lisp"); static const char *const kSauces[] = { "/zip/library.lisp", // diff --git a/third_party/chibicc/test/test.h b/third_party/chibicc/test/test.h index e6a6e4c7c..0bd6bb061 100644 --- a/third_party/chibicc/test/test.h +++ b/third_party/chibicc/test/test.h @@ -3,8 +3,8 @@ #include "libc/stdio/stdio.h" #include "libc/str/str.h" -STATIC_YOINK("sys_mmap"); /* asan needs it */ -STATIC_YOINK("TrackMemoryInterval"); /* asan needs it */ +__static_yoink("sys_mmap"); /* asan needs it */ +__static_yoink("TrackMemoryInterval"); /* asan needs it */ #define ASSERT(x, y) Assert2(x, y, #y, __FILE__, __LINE__) #define ASSERT128(x, y) Assert128(x, y, #y, __FILE__, __LINE__) diff --git a/third_party/compiler_rt/absvdi2.c b/third_party/compiler_rt/absvdi2.c index bf9077ca2..0628ee38a 100644 --- a/third_party/compiler_rt/absvdi2.c +++ b/third_party/compiler_rt/absvdi2.c @@ -13,7 +13,7 @@ *===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/absvsi2.c b/third_party/compiler_rt/absvsi2.c index cf60b6207..b60c5281e 100644 --- a/third_party/compiler_rt/absvsi2.c +++ b/third_party/compiler_rt/absvsi2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/absvti2.c b/third_party/compiler_rt/absvti2.c index 86f1a0b89..db7d23294 100644 --- a/third_party/compiler_rt/absvti2.c +++ b/third_party/compiler_rt/absvti2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/adddf3.c b/third_party/compiler_rt/adddf3.c index 8dfba8840..c3fcaaa40 100644 --- a/third_party/compiler_rt/adddf3.c +++ b/third_party/compiler_rt/adddf3.c @@ -13,7 +13,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define DOUBLE_PRECISION #include "third_party/compiler_rt/fp_add_impl.inc" diff --git a/third_party/compiler_rt/addsf3.c b/third_party/compiler_rt/addsf3.c index 909eabeab..2fe1bd990 100644 --- a/third_party/compiler_rt/addsf3.c +++ b/third_party/compiler_rt/addsf3.c @@ -13,7 +13,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define SINGLE_PRECISION #include "third_party/compiler_rt/fp_add_impl.inc" diff --git a/third_party/compiler_rt/addtf3.c b/third_party/compiler_rt/addtf3.c index 535256e80..902c9b374 100644 --- a/third_party/compiler_rt/addtf3.c +++ b/third_party/compiler_rt/addtf3.c @@ -15,7 +15,7 @@ #include "libc/math.h" #if !(LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024) -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define QUAD_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/ashldi3.c b/third_party/compiler_rt/ashldi3.c index edb6a650e..112e5e2ca 100644 --- a/third_party/compiler_rt/ashldi3.c +++ b/third_party/compiler_rt/ashldi3.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/ashrdi3.c b/third_party/compiler_rt/ashrdi3.c index 844227144..c00c2eea6 100644 --- a/third_party/compiler_rt/ashrdi3.c +++ b/third_party/compiler_rt/ashrdi3.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/ashrti3.c b/third_party/compiler_rt/ashrti3.c index 4c3cc3d50..8f5f79bac 100644 --- a/third_party/compiler_rt/ashrti3.c +++ b/third_party/compiler_rt/ashrti3.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/bswapdi2.c b/third_party/compiler_rt/bswapdi2.c index e3e61e90e..3b1aec649 100644 --- a/third_party/compiler_rt/bswapdi2.c +++ b/third_party/compiler_rt/bswapdi2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/bswapsi2.c b/third_party/compiler_rt/bswapsi2.c index 01c34c475..3e8155f95 100644 --- a/third_party/compiler_rt/bswapsi2.c +++ b/third_party/compiler_rt/bswapsi2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/clzdi2.c b/third_party/compiler_rt/clzdi2.c index b2e4e222b..8d7155ef3 100644 --- a/third_party/compiler_rt/clzdi2.c +++ b/third_party/compiler_rt/clzdi2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/clzsi2.c b/third_party/compiler_rt/clzsi2.c index 32d52e74f..24df9b209 100644 --- a/third_party/compiler_rt/clzsi2.c +++ b/third_party/compiler_rt/clzsi2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/clzti2.c b/third_party/compiler_rt/clzti2.c index 4894b43dc..b1a673a22 100644 --- a/third_party/compiler_rt/clzti2.c +++ b/third_party/compiler_rt/clzti2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/cmpdi2.c b/third_party/compiler_rt/cmpdi2.c index 5aabf4fe9..578cef946 100644 --- a/third_party/compiler_rt/cmpdi2.c +++ b/third_party/compiler_rt/cmpdi2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/cmpti2.c b/third_party/compiler_rt/cmpti2.c index 0e4d86c6e..d4b3ae6e4 100644 --- a/third_party/compiler_rt/cmpti2.c +++ b/third_party/compiler_rt/cmpti2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/comparedf2.c b/third_party/compiler_rt/comparedf2.c index 6e36614f3..45a9b1e03 100644 --- a/third_party/compiler_rt/comparedf2.c +++ b/third_party/compiler_rt/comparedf2.c @@ -38,7 +38,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define DOUBLE_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/comparesf2.c b/third_party/compiler_rt/comparesf2.c index 008da5455..8e785039e 100644 --- a/third_party/compiler_rt/comparesf2.c +++ b/third_party/compiler_rt/comparesf2.c @@ -38,7 +38,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define SINGLE_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/ctzdi2.c b/third_party/compiler_rt/ctzdi2.c index 6fae24001..31c058729 100644 --- a/third_party/compiler_rt/ctzdi2.c +++ b/third_party/compiler_rt/ctzdi2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/ctzsi2.c b/third_party/compiler_rt/ctzsi2.c index 42f57be5d..3feb60d28 100644 --- a/third_party/compiler_rt/ctzsi2.c +++ b/third_party/compiler_rt/ctzsi2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/ctzti2.c b/third_party/compiler_rt/ctzti2.c index 981b1089d..e5782d699 100644 --- a/third_party/compiler_rt/ctzti2.c +++ b/third_party/compiler_rt/ctzti2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/divdc3.c b/third_party/compiler_rt/divdc3.c index ac2320c0f..e36bc8b12 100644 --- a/third_party/compiler_rt/divdc3.c +++ b/third_party/compiler_rt/divdc3.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define DOUBLE_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/divdf3.c b/third_party/compiler_rt/divdf3.c index 42078c61f..066ce3ed3 100644 --- a/third_party/compiler_rt/divdf3.c +++ b/third_party/compiler_rt/divdf3.c @@ -17,7 +17,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define DOUBLE_PRECISION #include "libc/literal.h" diff --git a/third_party/compiler_rt/divdi3.c b/third_party/compiler_rt/divdi3.c index 1c8b2cf23..1c1048b13 100644 --- a/third_party/compiler_rt/divdi3.c +++ b/third_party/compiler_rt/divdi3.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/divmoddi4.c b/third_party/compiler_rt/divmoddi4.c index 0080c6394..a69264ecf 100644 --- a/third_party/compiler_rt/divmoddi4.c +++ b/third_party/compiler_rt/divmoddi4.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/divmodsi4.c b/third_party/compiler_rt/divmodsi4.c index 20ed8359e..ac6498f0e 100644 --- a/third_party/compiler_rt/divmodsi4.c +++ b/third_party/compiler_rt/divmodsi4.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/divsc3.c b/third_party/compiler_rt/divsc3.c index d651b9484..bd7fae559 100644 --- a/third_party/compiler_rt/divsc3.c +++ b/third_party/compiler_rt/divsc3.c @@ -13,7 +13,7 @@ *===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define SINGLE_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/divsf3.c b/third_party/compiler_rt/divsf3.c index d93e977a9..308ac30aa 100644 --- a/third_party/compiler_rt/divsf3.c +++ b/third_party/compiler_rt/divsf3.c @@ -17,7 +17,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define SINGLE_PRECISION #include "libc/literal.h" diff --git a/third_party/compiler_rt/divsi3.c b/third_party/compiler_rt/divsi3.c index 0737b05b0..e45934c2f 100644 --- a/third_party/compiler_rt/divsi3.c +++ b/third_party/compiler_rt/divsi3.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/divtc3.c b/third_party/compiler_rt/divtc3.c index 28e20f501..85353651c 100644 --- a/third_party/compiler_rt/divtc3.c +++ b/third_party/compiler_rt/divtc3.c @@ -15,7 +15,7 @@ #include "libc/math.h" #if !(LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024) -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define QUAD_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/divtf3.c b/third_party/compiler_rt/divtf3.c index 3d5f26258..bbfd12c09 100644 --- a/third_party/compiler_rt/divtf3.c +++ b/third_party/compiler_rt/divtf3.c @@ -17,7 +17,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define QUAD_PRECISION #include "libc/literal.h" diff --git a/third_party/compiler_rt/divxc3.c b/third_party/compiler_rt/divxc3.c index 7e8216802..b2bbea46a 100644 --- a/third_party/compiler_rt/divxc3.c +++ b/third_party/compiler_rt/divxc3.c @@ -14,7 +14,7 @@ #include "libc/math.h" #if !(LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024) -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #if !_ARCH_PPC diff --git a/third_party/compiler_rt/extenddftf2.c b/third_party/compiler_rt/extenddftf2.c index f4ad3ed91..1a836b0c1 100644 --- a/third_party/compiler_rt/extenddftf2.c +++ b/third_party/compiler_rt/extenddftf2.c @@ -9,7 +9,7 @@ //===----------------------------------------------------------------------===// // -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define QUAD_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/extendhfsf2.c b/third_party/compiler_rt/extendhfsf2.c index 8d5361dc0..709f031a3 100644 --- a/third_party/compiler_rt/extendhfsf2.c +++ b/third_party/compiler_rt/extendhfsf2.c @@ -9,7 +9,7 @@ //===----------------------------------------------------------------------===// // -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define SRC_HALF #define DST_SINGLE diff --git a/third_party/compiler_rt/extendsfdf2.c b/third_party/compiler_rt/extendsfdf2.c index 528b162f9..4db018864 100644 --- a/third_party/compiler_rt/extendsfdf2.c +++ b/third_party/compiler_rt/extendsfdf2.c @@ -9,7 +9,7 @@ //===----------------------------------------------------------------------===// // -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define SRC_SINGLE #define DST_DOUBLE diff --git a/third_party/compiler_rt/extendsftf2.c b/third_party/compiler_rt/extendsftf2.c index 6997ba73e..65fd1e49f 100644 --- a/third_party/compiler_rt/extendsftf2.c +++ b/third_party/compiler_rt/extendsftf2.c @@ -9,7 +9,7 @@ //===----------------------------------------------------------------------===// // -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define QUAD_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/ffsdi2.c b/third_party/compiler_rt/ffsdi2.c index 698520503..0b4406360 100644 --- a/third_party/compiler_rt/ffsdi2.c +++ b/third_party/compiler_rt/ffsdi2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/ffssi2.c b/third_party/compiler_rt/ffssi2.c index e5140c49d..663cfe8ab 100644 --- a/third_party/compiler_rt/ffssi2.c +++ b/third_party/compiler_rt/ffssi2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/ffsti2.c b/third_party/compiler_rt/ffsti2.c index a004168be..19fada7dd 100644 --- a/third_party/compiler_rt/ffsti2.c +++ b/third_party/compiler_rt/ffsti2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/fixdfdi.c b/third_party/compiler_rt/fixdfdi.c index 5af27de32..90330d838 100644 --- a/third_party/compiler_rt/fixdfdi.c +++ b/third_party/compiler_rt/fixdfdi.c @@ -9,7 +9,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define DOUBLE_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/fixdfsi.c b/third_party/compiler_rt/fixdfsi.c index 6d8b176c6..d47ddbcae 100644 --- a/third_party/compiler_rt/fixdfsi.c +++ b/third_party/compiler_rt/fixdfsi.c @@ -9,7 +9,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define DOUBLE_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/fixdfti.c b/third_party/compiler_rt/fixdfti.c index a3cd50132..b2a980695 100644 --- a/third_party/compiler_rt/fixdfti.c +++ b/third_party/compiler_rt/fixdfti.c @@ -9,7 +9,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/fixsfdi.c b/third_party/compiler_rt/fixsfdi.c index f774a5b72..8f6c88d82 100644 --- a/third_party/compiler_rt/fixsfdi.c +++ b/third_party/compiler_rt/fixsfdi.c @@ -9,7 +9,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define SINGLE_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/fixsfsi.c b/third_party/compiler_rt/fixsfsi.c index 9104d21d4..40d3b8424 100644 --- a/third_party/compiler_rt/fixsfsi.c +++ b/third_party/compiler_rt/fixsfsi.c @@ -9,7 +9,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define SINGLE_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/fixsfti.c b/third_party/compiler_rt/fixsfti.c index 3d080e9d5..f9dcadf62 100644 --- a/third_party/compiler_rt/fixsfti.c +++ b/third_party/compiler_rt/fixsfti.c @@ -9,7 +9,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/fixtfdi.c b/third_party/compiler_rt/fixtfdi.c index d7c280a1e..fce9af86f 100644 --- a/third_party/compiler_rt/fixtfdi.c +++ b/third_party/compiler_rt/fixtfdi.c @@ -9,7 +9,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define QUAD_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/fixtfsi.c b/third_party/compiler_rt/fixtfsi.c index 25341cf70..04a298fdb 100644 --- a/third_party/compiler_rt/fixtfsi.c +++ b/third_party/compiler_rt/fixtfsi.c @@ -9,7 +9,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define QUAD_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/fixtfti.c b/third_party/compiler_rt/fixtfti.c index 0d7c7d064..0c74e222f 100644 --- a/third_party/compiler_rt/fixtfti.c +++ b/third_party/compiler_rt/fixtfti.c @@ -9,7 +9,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define QUAD_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/fixunsdfdi.c b/third_party/compiler_rt/fixunsdfdi.c index 72ad0e863..161078cff 100644 --- a/third_party/compiler_rt/fixunsdfdi.c +++ b/third_party/compiler_rt/fixunsdfdi.c @@ -9,7 +9,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define DOUBLE_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/fixunsdfsi.c b/third_party/compiler_rt/fixunsdfsi.c index d36652d1b..2e340fe8f 100644 --- a/third_party/compiler_rt/fixunsdfsi.c +++ b/third_party/compiler_rt/fixunsdfsi.c @@ -9,7 +9,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define DOUBLE_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/fixunsdfti.c b/third_party/compiler_rt/fixunsdfti.c index 2451e1b80..ee518700f 100644 --- a/third_party/compiler_rt/fixunsdfti.c +++ b/third_party/compiler_rt/fixunsdfti.c @@ -9,7 +9,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/fixunssfdi.c b/third_party/compiler_rt/fixunssfdi.c index bc7da50fb..47692e9b0 100644 --- a/third_party/compiler_rt/fixunssfdi.c +++ b/third_party/compiler_rt/fixunssfdi.c @@ -9,7 +9,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define SINGLE_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/fixunssfsi.c b/third_party/compiler_rt/fixunssfsi.c index cb5327016..21a04e8fd 100644 --- a/third_party/compiler_rt/fixunssfsi.c +++ b/third_party/compiler_rt/fixunssfsi.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define SINGLE_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/fixunssfti.c b/third_party/compiler_rt/fixunssfti.c index 0a9e936c8..5cf032011 100644 --- a/third_party/compiler_rt/fixunssfti.c +++ b/third_party/compiler_rt/fixunssfti.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define SINGLE_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/fixunstfdi.c b/third_party/compiler_rt/fixunstfdi.c index 7b032b61b..1bc370bb3 100644 --- a/third_party/compiler_rt/fixunstfdi.c +++ b/third_party/compiler_rt/fixunstfdi.c @@ -9,7 +9,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define QUAD_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/fixunstfsi.c b/third_party/compiler_rt/fixunstfsi.c index 3195c3596..17c6915da 100644 --- a/third_party/compiler_rt/fixunstfsi.c +++ b/third_party/compiler_rt/fixunstfsi.c @@ -9,7 +9,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define QUAD_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/fixunstfti.c b/third_party/compiler_rt/fixunstfti.c index 474bfa56c..1ddaca8d1 100644 --- a/third_party/compiler_rt/fixunstfti.c +++ b/third_party/compiler_rt/fixunstfti.c @@ -9,7 +9,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define QUAD_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/fixunsxfdi.c b/third_party/compiler_rt/fixunsxfdi.c index 74df1c457..0885e97c7 100644 --- a/third_party/compiler_rt/fixunsxfdi.c +++ b/third_party/compiler_rt/fixunsxfdi.c @@ -15,7 +15,7 @@ #include "libc/math.h" #if !(LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024) -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #if !_ARCH_PPC diff --git a/third_party/compiler_rt/fixunsxfsi.c b/third_party/compiler_rt/fixunsxfsi.c index 4cd4e92b4..8ecc69604 100644 --- a/third_party/compiler_rt/fixunsxfsi.c +++ b/third_party/compiler_rt/fixunsxfsi.c @@ -15,7 +15,7 @@ #include "libc/math.h" #if !(LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024) -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #if !_ARCH_PPC diff --git a/third_party/compiler_rt/fixunsxfti.c b/third_party/compiler_rt/fixunsxfti.c index 5fd8bc4ef..5ba62d4e1 100644 --- a/third_party/compiler_rt/fixunsxfti.c +++ b/third_party/compiler_rt/fixunsxfti.c @@ -15,7 +15,7 @@ #include "libc/math.h" #if !(LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024) -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/fixxfdi.c b/third_party/compiler_rt/fixxfdi.c index e6d002b8e..153294a72 100644 --- a/third_party/compiler_rt/fixxfdi.c +++ b/third_party/compiler_rt/fixxfdi.c @@ -15,7 +15,7 @@ #include "libc/math.h" #if !(LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024) -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #if !_ARCH_PPC diff --git a/third_party/compiler_rt/fixxfti.c b/third_party/compiler_rt/fixxfti.c index 2c3039c90..4338fe32e 100644 --- a/third_party/compiler_rt/fixxfti.c +++ b/third_party/compiler_rt/fixxfti.c @@ -15,7 +15,7 @@ #include "libc/math.h" #if !(LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024) -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/floatdidf.c b/third_party/compiler_rt/floatdidf.c index aed5781f3..db623cec9 100644 --- a/third_party/compiler_rt/floatdidf.c +++ b/third_party/compiler_rt/floatdidf.c @@ -13,7 +13,7 @@ *===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "libc/literal.h" #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/floatdisf.c b/third_party/compiler_rt/floatdisf.c index a508ced5d..3a08358d1 100644 --- a/third_party/compiler_rt/floatdisf.c +++ b/third_party/compiler_rt/floatdisf.c @@ -13,7 +13,7 @@ *===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); /* Returns: convert a to a float, rounding toward even.*/ diff --git a/third_party/compiler_rt/floatditf.c b/third_party/compiler_rt/floatditf.c index 5cfdea1bf..46614f0d5 100644 --- a/third_party/compiler_rt/floatditf.c +++ b/third_party/compiler_rt/floatditf.c @@ -14,7 +14,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define QUAD_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/floatdixf.c b/third_party/compiler_rt/floatdixf.c index 8043e1601..447c43b52 100644 --- a/third_party/compiler_rt/floatdixf.c +++ b/third_party/compiler_rt/floatdixf.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #if !_ARCH_PPC diff --git a/third_party/compiler_rt/floatsidf.c b/third_party/compiler_rt/floatsidf.c index 0c06a6532..9138e52f6 100644 --- a/third_party/compiler_rt/floatsidf.c +++ b/third_party/compiler_rt/floatsidf.c @@ -14,7 +14,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define DOUBLE_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/floatsisf.c b/third_party/compiler_rt/floatsisf.c index 414353330..1cfa4b6b9 100644 --- a/third_party/compiler_rt/floatsisf.c +++ b/third_party/compiler_rt/floatsisf.c @@ -14,7 +14,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define SINGLE_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/floatsitf.c b/third_party/compiler_rt/floatsitf.c index f872cff8b..1131277ef 100644 --- a/third_party/compiler_rt/floatsitf.c +++ b/third_party/compiler_rt/floatsitf.c @@ -14,7 +14,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define QUAD_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/floattidf.c b/third_party/compiler_rt/floattidf.c index 63e8906dd..4a546d65d 100644 --- a/third_party/compiler_rt/floattidf.c +++ b/third_party/compiler_rt/floattidf.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/floattisf.c b/third_party/compiler_rt/floattisf.c index 8caae762f..c8dc92a64 100644 --- a/third_party/compiler_rt/floattisf.c +++ b/third_party/compiler_rt/floattisf.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/floattitf.c b/third_party/compiler_rt/floattitf.c index eb1c2ffa4..09ef61626 100644 --- a/third_party/compiler_rt/floattitf.c +++ b/third_party/compiler_rt/floattitf.c @@ -14,7 +14,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define QUAD_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/floattixf.c b/third_party/compiler_rt/floattixf.c index 1236afa0c..6101c9ad5 100644 --- a/third_party/compiler_rt/floattixf.c +++ b/third_party/compiler_rt/floattixf.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/floatundidf.c b/third_party/compiler_rt/floatundidf.c index 3f4507890..ff66ac432 100644 --- a/third_party/compiler_rt/floatundidf.c +++ b/third_party/compiler_rt/floatundidf.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); /* Returns: convert a to a double, rounding toward even. */ diff --git a/third_party/compiler_rt/floatundisf.c b/third_party/compiler_rt/floatundisf.c index 179d18955..df4f31593 100644 --- a/third_party/compiler_rt/floatundisf.c +++ b/third_party/compiler_rt/floatundisf.c @@ -13,7 +13,7 @@ *===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); /* Returns: convert a to a float, rounding toward even. */ diff --git a/third_party/compiler_rt/floatunditf.c b/third_party/compiler_rt/floatunditf.c index 9a37481fb..8390100f4 100644 --- a/third_party/compiler_rt/floatunditf.c +++ b/third_party/compiler_rt/floatunditf.c @@ -14,7 +14,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define QUAD_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/floatundixf.c b/third_party/compiler_rt/floatundixf.c index 69ba1dae5..a7c79c58e 100644 --- a/third_party/compiler_rt/floatundixf.c +++ b/third_party/compiler_rt/floatundixf.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #if !_ARCH_PPC diff --git a/third_party/compiler_rt/floatunsidf.c b/third_party/compiler_rt/floatunsidf.c index e06933eb4..6b876e3b6 100644 --- a/third_party/compiler_rt/floatunsidf.c +++ b/third_party/compiler_rt/floatunsidf.c @@ -14,7 +14,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define DOUBLE_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/floatunsisf.c b/third_party/compiler_rt/floatunsisf.c index 37ada245f..f0e6a1815 100644 --- a/third_party/compiler_rt/floatunsisf.c +++ b/third_party/compiler_rt/floatunsisf.c @@ -14,7 +14,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define SINGLE_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/floatunsitf.c b/third_party/compiler_rt/floatunsitf.c index 439ef857b..e35ca67f2 100644 --- a/third_party/compiler_rt/floatunsitf.c +++ b/third_party/compiler_rt/floatunsitf.c @@ -14,7 +14,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define QUAD_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/floatuntidf.c b/third_party/compiler_rt/floatuntidf.c index d3d206d81..63d62bfa4 100644 --- a/third_party/compiler_rt/floatuntidf.c +++ b/third_party/compiler_rt/floatuntidf.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/floatuntisf.c b/third_party/compiler_rt/floatuntisf.c index 79b78c9ba..0cee56321 100644 --- a/third_party/compiler_rt/floatuntisf.c +++ b/third_party/compiler_rt/floatuntisf.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/floatuntitf.c b/third_party/compiler_rt/floatuntitf.c index 1b1355269..f58a98a87 100644 --- a/third_party/compiler_rt/floatuntitf.c +++ b/third_party/compiler_rt/floatuntitf.c @@ -14,7 +14,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define QUAD_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/floatuntixf.c b/third_party/compiler_rt/floatuntixf.c index 03c2e68ce..b2d6b3b63 100644 --- a/third_party/compiler_rt/floatuntixf.c +++ b/third_party/compiler_rt/floatuntixf.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/lshrdi3.c b/third_party/compiler_rt/lshrdi3.c index 02fedf838..8d2af3c9d 100644 --- a/third_party/compiler_rt/lshrdi3.c +++ b/third_party/compiler_rt/lshrdi3.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/mingw_fixfloat.c b/third_party/compiler_rt/mingw_fixfloat.c index 6078cc2e0..7d3f3f957 100644 --- a/third_party/compiler_rt/mingw_fixfloat.c +++ b/third_party/compiler_rt/mingw_fixfloat.c @@ -9,7 +9,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/moddi3.c b/third_party/compiler_rt/moddi3.c index 62bb28514..2539b2cb4 100644 --- a/third_party/compiler_rt/moddi3.c +++ b/third_party/compiler_rt/moddi3.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/modsi3.c b/third_party/compiler_rt/modsi3.c index 7d65ae3eb..8fc16a414 100644 --- a/third_party/compiler_rt/modsi3.c +++ b/third_party/compiler_rt/modsi3.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/modti3.c b/third_party/compiler_rt/modti3.c index 5a30fd221..aae613943 100644 --- a/third_party/compiler_rt/modti3.c +++ b/third_party/compiler_rt/modti3.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/muldc3.c b/third_party/compiler_rt/muldc3.c index 5b54fe39b..748d21fda 100644 --- a/third_party/compiler_rt/muldc3.c +++ b/third_party/compiler_rt/muldc3.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" #include "third_party/compiler_rt/int_math.h" diff --git a/third_party/compiler_rt/muldf3.c b/third_party/compiler_rt/muldf3.c index 07fe0a178..f64236544 100644 --- a/third_party/compiler_rt/muldf3.c +++ b/third_party/compiler_rt/muldf3.c @@ -13,7 +13,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define DOUBLE_PRECISION #include "third_party/compiler_rt/fp_mul_impl.inc" diff --git a/third_party/compiler_rt/muldi3.c b/third_party/compiler_rt/muldi3.c index ecf3065c0..8f894d27c 100644 --- a/third_party/compiler_rt/muldi3.c +++ b/third_party/compiler_rt/muldi3.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/mulsc3.c b/third_party/compiler_rt/mulsc3.c index 519d18621..5cd9be749 100644 --- a/third_party/compiler_rt/mulsc3.c +++ b/third_party/compiler_rt/mulsc3.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" #include "third_party/compiler_rt/int_math.h" diff --git a/third_party/compiler_rt/mulsf3.c b/third_party/compiler_rt/mulsf3.c index d3a6437fa..03405a2d8 100644 --- a/third_party/compiler_rt/mulsf3.c +++ b/third_party/compiler_rt/mulsf3.c @@ -13,7 +13,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define SINGLE_PRECISION #include "third_party/compiler_rt/fp_mul_impl.inc" diff --git a/third_party/compiler_rt/multc3.c b/third_party/compiler_rt/multc3.c index e6dc3ab5a..187b7af1e 100644 --- a/third_party/compiler_rt/multc3.c +++ b/third_party/compiler_rt/multc3.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" #include "third_party/compiler_rt/int_math.h" diff --git a/third_party/compiler_rt/multi3.c b/third_party/compiler_rt/multi3.c index 130a47b90..46c044b16 100644 --- a/third_party/compiler_rt/multi3.c +++ b/third_party/compiler_rt/multi3.c @@ -8,7 +8,7 @@ * * ===----------------------------------------------------------------------=== -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); * This file implements __multi3 for the compiler_rt library. * diff --git a/third_party/compiler_rt/mulxc3.c b/third_party/compiler_rt/mulxc3.c index 43cf4af7b..f9d904c17 100644 --- a/third_party/compiler_rt/mulxc3.c +++ b/third_party/compiler_rt/mulxc3.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #if !_ARCH_PPC diff --git a/third_party/compiler_rt/negdf2.c b/third_party/compiler_rt/negdf2.c index 25df24dd6..1800784d6 100644 --- a/third_party/compiler_rt/negdf2.c +++ b/third_party/compiler_rt/negdf2.c @@ -12,7 +12,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define DOUBLE_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/negdi2.c b/third_party/compiler_rt/negdi2.c index 8389752ba..8bfeccc36 100644 --- a/third_party/compiler_rt/negdi2.c +++ b/third_party/compiler_rt/negdi2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/negsf2.c b/third_party/compiler_rt/negsf2.c index acae8a2b3..5e1e01c17 100644 --- a/third_party/compiler_rt/negsf2.c +++ b/third_party/compiler_rt/negsf2.c @@ -12,7 +12,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define SINGLE_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/negti2.c b/third_party/compiler_rt/negti2.c index 457cf71a3..d6bfc97ad 100644 --- a/third_party/compiler_rt/negti2.c +++ b/third_party/compiler_rt/negti2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/nexgen32e/floatdidf.c b/third_party/compiler_rt/nexgen32e/floatdidf.c index 73dc47926..546d10317 100644 --- a/third_party/compiler_rt/nexgen32e/floatdidf.c +++ b/third_party/compiler_rt/nexgen32e/floatdidf.c @@ -3,7 +3,7 @@ * License. See LICENSE.TXT for details. */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); /* double __floatdidf(di_int a); */ diff --git a/third_party/compiler_rt/nexgen32e/floatdisf.c b/third_party/compiler_rt/nexgen32e/floatdisf.c index 5d5fcd2df..ccc05ab7a 100644 --- a/third_party/compiler_rt/nexgen32e/floatdisf.c +++ b/third_party/compiler_rt/nexgen32e/floatdisf.c @@ -3,7 +3,7 @@ * License. See LICENSE.TXT for details. */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #if defined(__x86_64__) || defined(_M_X64) diff --git a/third_party/compiler_rt/nexgen32e/floatdixf.c b/third_party/compiler_rt/nexgen32e/floatdixf.c index 48b2ea4e3..611e0b5aa 100644 --- a/third_party/compiler_rt/nexgen32e/floatdixf.c +++ b/third_party/compiler_rt/nexgen32e/floatdixf.c @@ -3,7 +3,7 @@ * License. See LICENSE.TXT for details. */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); /* long double __floatdixf(di_int a); */ diff --git a/third_party/compiler_rt/os_version_check.c b/third_party/compiler_rt/os_version_check.c index 590e3473d..202fa80a4 100644 --- a/third_party/compiler_rt/os_version_check.c +++ b/third_party/compiler_rt/os_version_check.c @@ -14,7 +14,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #ifdef __APPLE__ diff --git a/third_party/compiler_rt/paritydi2.c b/third_party/compiler_rt/paritydi2.c index b08396e97..0203dc32d 100644 --- a/third_party/compiler_rt/paritydi2.c +++ b/third_party/compiler_rt/paritydi2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/paritysi2.c b/third_party/compiler_rt/paritysi2.c index 2b54c7471..fe4c92da0 100644 --- a/third_party/compiler_rt/paritysi2.c +++ b/third_party/compiler_rt/paritysi2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/parityti2.c b/third_party/compiler_rt/parityti2.c index 0105965e7..2452546e8 100644 --- a/third_party/compiler_rt/parityti2.c +++ b/third_party/compiler_rt/parityti2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/popcountdi2.c b/third_party/compiler_rt/popcountdi2.c index ae21c6c47..05974b2e0 100644 --- a/third_party/compiler_rt/popcountdi2.c +++ b/third_party/compiler_rt/popcountdi2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/popcountsi2.c b/third_party/compiler_rt/popcountsi2.c index b427e66c6..bcebe49a3 100644 --- a/third_party/compiler_rt/popcountsi2.c +++ b/third_party/compiler_rt/popcountsi2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/popcountti2.c b/third_party/compiler_rt/popcountti2.c index cc2afb243..1d54829a8 100644 --- a/third_party/compiler_rt/popcountti2.c +++ b/third_party/compiler_rt/popcountti2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/powidf2.c b/third_party/compiler_rt/powidf2.c index 8120ea91e..59d5bac63 100644 --- a/third_party/compiler_rt/powidf2.c +++ b/third_party/compiler_rt/powidf2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/powisf2.c b/third_party/compiler_rt/powisf2.c index 7a12977e4..28b420395 100644 --- a/third_party/compiler_rt/powisf2.c +++ b/third_party/compiler_rt/powisf2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/powitf2.c b/third_party/compiler_rt/powitf2.c index 611053bc0..8f2fa20d7 100644 --- a/third_party/compiler_rt/powitf2.c +++ b/third_party/compiler_rt/powitf2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/powixf2.c b/third_party/compiler_rt/powixf2.c index c7253c032..2c844cd64 100644 --- a/third_party/compiler_rt/powixf2.c +++ b/third_party/compiler_rt/powixf2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #if !_ARCH_PPC diff --git a/third_party/compiler_rt/subdf3.c b/third_party/compiler_rt/subdf3.c index e60bcec20..b969e26f9 100644 --- a/third_party/compiler_rt/subdf3.c +++ b/third_party/compiler_rt/subdf3.c @@ -13,7 +13,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define DOUBLE_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/subsf3.c b/third_party/compiler_rt/subsf3.c index 586f3c76c..2f9b57c9e 100644 --- a/third_party/compiler_rt/subsf3.c +++ b/third_party/compiler_rt/subsf3.c @@ -13,7 +13,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define SINGLE_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/subtf3.c b/third_party/compiler_rt/subtf3.c index 56f30f1ae..5dcf27f2c 100644 --- a/third_party/compiler_rt/subtf3.c +++ b/third_party/compiler_rt/subtf3.c @@ -13,7 +13,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define QUAD_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/truncdfhf2.c b/third_party/compiler_rt/truncdfhf2.c index 7b02a818d..fd7b5a192 100644 --- a/third_party/compiler_rt/truncdfhf2.c +++ b/third_party/compiler_rt/truncdfhf2.c @@ -8,7 +8,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define SRC_DOUBLE #define DST_HALF diff --git a/third_party/compiler_rt/truncdfsf2.c b/third_party/compiler_rt/truncdfsf2.c index 41ef176f4..84689fb49 100644 --- a/third_party/compiler_rt/truncdfsf2.c +++ b/third_party/compiler_rt/truncdfsf2.c @@ -8,7 +8,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define SRC_DOUBLE #define DST_SINGLE diff --git a/third_party/compiler_rt/truncsfhf2.c b/third_party/compiler_rt/truncsfhf2.c index 5e0905f4e..27105daa3 100644 --- a/third_party/compiler_rt/truncsfhf2.c +++ b/third_party/compiler_rt/truncsfhf2.c @@ -8,7 +8,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define SRC_SINGLE #define DST_HALF diff --git a/third_party/compiler_rt/trunctfdf2.c b/third_party/compiler_rt/trunctfdf2.c index 61614e978..59fa047fe 100644 --- a/third_party/compiler_rt/trunctfdf2.c +++ b/third_party/compiler_rt/trunctfdf2.c @@ -8,7 +8,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define QUAD_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/trunctfsf2.c b/third_party/compiler_rt/trunctfsf2.c index cc3ba6e96..89e8bd5bc 100644 --- a/third_party/compiler_rt/trunctfsf2.c +++ b/third_party/compiler_rt/trunctfsf2.c @@ -8,7 +8,7 @@ // //===----------------------------------------------------------------------===// -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #define QUAD_PRECISION #include "third_party/compiler_rt/fp_lib.inc" diff --git a/third_party/compiler_rt/ucmpdi2.c b/third_party/compiler_rt/ucmpdi2.c index 6da61b61c..99f0b2c79 100644 --- a/third_party/compiler_rt/ucmpdi2.c +++ b/third_party/compiler_rt/ucmpdi2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/ucmpti2.c b/third_party/compiler_rt/ucmpti2.c index 41ca69c22..13cc81136 100644 --- a/third_party/compiler_rt/ucmpti2.c +++ b/third_party/compiler_rt/ucmpti2.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/udivdi3.c b/third_party/compiler_rt/udivdi3.c index 96ac0d619..5c472ade6 100644 --- a/third_party/compiler_rt/udivdi3.c +++ b/third_party/compiler_rt/udivdi3.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/udivmoddi4.c b/third_party/compiler_rt/udivmoddi4.c index 2599d078b..6bdc9f54a 100644 --- a/third_party/compiler_rt/udivmoddi4.c +++ b/third_party/compiler_rt/udivmoddi4.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/udivmodsi4.c b/third_party/compiler_rt/udivmodsi4.c index 386da175f..6124b3252 100644 --- a/third_party/compiler_rt/udivmodsi4.c +++ b/third_party/compiler_rt/udivmodsi4.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/udivsi3.c b/third_party/compiler_rt/udivsi3.c index c293490b0..04ccf17ac 100644 --- a/third_party/compiler_rt/udivsi3.c +++ b/third_party/compiler_rt/udivsi3.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/umoddi3.c b/third_party/compiler_rt/umoddi3.c index 7edfc3de7..750f8e31c 100644 --- a/third_party/compiler_rt/umoddi3.c +++ b/third_party/compiler_rt/umoddi3.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/umodsi3.c b/third_party/compiler_rt/umodsi3.c index 62571a3bf..03ec8c929 100644 --- a/third_party/compiler_rt/umodsi3.c +++ b/third_party/compiler_rt/umodsi3.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/compiler_rt/umodti3.c b/third_party/compiler_rt/umodti3.c index 399ecc1cf..7cc3a9ab2 100644 --- a/third_party/compiler_rt/umodti3.c +++ b/third_party/compiler_rt/umodti3.c @@ -13,7 +13,7 @@ * ===----------------------------------------------------------------------=== */ -STATIC_YOINK("huge_compiler_rt_license"); +__static_yoink("huge_compiler_rt_license"); #include "third_party/compiler_rt/int_lib.h" diff --git a/third_party/dlmalloc/dlmalloc.c b/third_party/dlmalloc/dlmalloc.c index c0ec8ec55..548ca8d78 100644 --- a/third_party/dlmalloc/dlmalloc.c +++ b/third_party/dlmalloc/dlmalloc.c @@ -45,7 +45,7 @@ #endif #undef assert -#define assert(x) _npassert(x) +#define assert(x) npassert(x) #include "third_party/dlmalloc/platform.inc" #include "third_party/dlmalloc/locks.inc" diff --git a/third_party/double-conversion/README.cosmo b/third_party/double-conversion/README.cosmo index 1d8a81cfd..3ed7a05ad 100644 --- a/third_party/double-conversion/README.cosmo +++ b/third_party/double-conversion/README.cosmo @@ -14,4 +14,4 @@ LICENSE LOCAL CHANGES - - Use _unassert() macro for undefined behavior on failed assertions + - Use unassert() macro for undefined behavior on failed assertions diff --git a/third_party/double-conversion/utils.h b/third_party/double-conversion/utils.h index 1c369c906..81718ae6c 100644 --- a/third_party/double-conversion/utils.h +++ b/third_party/double-conversion/utils.h @@ -11,7 +11,7 @@ // [jart] use undefined behaavior to make code tinier // use ubsan build mode to troubleshoot errors -#define DOUBLE_CONVERSION_ASSERT(x) _unassert(x) +#define DOUBLE_CONVERSION_ASSERT(x) unassert(x) #define DOUBLE_CONVERSION_UNREACHABLE() __builtin_unreachable() #define DOUBLE_CONVERSION_UNIMPLEMENTED() notpossible diff --git a/third_party/ggml/common.cc b/third_party/ggml/common.cc index b478bc3ce..09a9cd5c4 100644 --- a/third_party/ggml/common.cc +++ b/third_party/ggml/common.cc @@ -45,7 +45,7 @@ #include "third_party/libcxx/sstream" #include "third_party/libcxx/string" -STATIC_YOINK("zipos"); +__static_yoink("zipos"); asm(".ident\t\"\\n\\n\ llama.cpp (MIT License)\\n\ diff --git a/third_party/linenoise/linenoise.c b/third_party/linenoise/linenoise.c index 4f7c23f7c..5893bf80e 100644 --- a/third_party/linenoise/linenoise.c +++ b/third_party/linenoise/linenoise.c @@ -1560,7 +1560,7 @@ static void linenoiseEditTranspose(struct linenoiseState *l) { p = q = malloc(c - a); p = mempcpy(p, l->buf + b, c - b); p = mempcpy(p, l->buf + a, b - a); - _unassert(p - q == c - a); + unassert(p - q == c - a); memcpy(l->buf + a, q, p - q); l->pos = c; free(q); @@ -1581,7 +1581,7 @@ static void linenoiseEditTransposeWords(struct linenoiseState *l) { p = mempcpy(p, l->buf + yi, yj - yi); p = mempcpy(p, l->buf + xj, yi - xj); p = mempcpy(p, l->buf + xi, xj - xi); - _unassert(p - q == yj - xi); + unassert(p - q == yj - xi); memcpy(l->buf + xi, q, p - q); l->pos = yj; free(q); diff --git a/third_party/lua/lauxlib.h b/third_party/lua/lauxlib.h index 062726617..6d8d024a9 100644 --- a/third_party/lua/lauxlib.h +++ b/third_party/lua/lauxlib.h @@ -159,7 +159,7 @@ LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname, #if defined LUAI_ASSERT #define lua_assert(c) assert(c) #else - #define lua_assert(c) _unassert(c) + #define lua_assert(c) unassert(c) #endif #endif diff --git a/third_party/lua/luaencodejsondata.c b/third_party/lua/luaencodejsondata.c index badfb16ba..528f7d6d9 100644 --- a/third_party/lua/luaencodejsondata.c +++ b/third_party/lua/luaencodejsondata.c @@ -24,10 +24,12 @@ #include "libc/log/rop.internal.h" #include "libc/mem/gc.internal.h" #include "libc/mem/mem.h" +#include "libc/runtime/runtime.h" #include "libc/runtime/stack.h" #include "libc/stdio/append.h" #include "libc/stdio/strlist.internal.h" #include "libc/str/str.h" +#include "libc/sysv/consts/auxv.h" #include "net/http/escape.h" #include "third_party/double-conversion/wrapper.h" #include "third_party/lua/cosmo.h" @@ -169,7 +171,7 @@ static int SerializeTable(lua_State *L, char **buf, int idx, bool multi; bool isarray; lua_Unsigned n; - if (UNLIKELY(!HaveStackMemory(APE_GUARDSIZE))) { + if (UNLIKELY(!HaveStackMemory(getauxval(AT_PAGESZ)))) { z->reason = "out of stack"; return -1; } diff --git a/third_party/lua/luaencodeluadata.c b/third_party/lua/luaencodeluadata.c index b8a76a062..92bdf8ee9 100644 --- a/third_party/lua/luaencodeluadata.c +++ b/third_party/lua/luaencodeluadata.c @@ -22,10 +22,12 @@ #include "libc/log/rop.internal.h" #include "libc/math.h" #include "libc/mem/mem.h" +#include "libc/runtime/runtime.h" #include "libc/runtime/stack.h" #include "libc/stdio/append.h" #include "libc/stdio/strlist.internal.h" #include "libc/str/str.h" +#include "libc/sysv/consts/auxv.h" #include "libc/x/x.h" #include "third_party/double-conversion/wrapper.h" #include "third_party/lua/cosmo.h" @@ -353,7 +355,7 @@ static int SerializeTable(lua_State *L, char **buf, int idx, int rc; bool multi; intptr_t rsp, bot; - if (UNLIKELY(!HaveStackMemory(APE_GUARDSIZE))) { + if (UNLIKELY(!HaveStackMemory(getauxval(AT_PAGESZ)))) { z->reason = "out of stack"; return -1; } diff --git a/third_party/lua/lunix.c b/third_party/lua/lunix.c index 79867a7f9..9d485d016 100644 --- a/third_party/lua/lunix.c +++ b/third_party/lua/lunix.c @@ -2869,7 +2869,7 @@ static int LuaUnixMemoryWake(lua_State *L) { count = luaL_optinteger(L, 3, INT_MAX); woken = nsync_futex_wake_((atomic_int *)GetWord(L), count, PTHREAD_PROCESS_SHARED); - _npassert(woken >= 0); + npassert(woken >= 0); return ReturnInteger(L, woken); } @@ -2886,7 +2886,7 @@ static int LuaUnixMemoryGc(lua_State *L) { struct Memory *m; m = luaL_checkudata(L, 1, "unix.Memory"); if (m->u.bytes) { - _npassert(!munmap(m->map, m->mapsize)); + npassert(!munmap(m->map, m->mapsize)); m->u.bytes = 0; } return 0; diff --git a/third_party/mbedtls/bignum.c b/third_party/mbedtls/bignum.c index a682d977d..45a37b81f 100644 --- a/third_party/mbedtls/bignum.c +++ b/third_party/mbedtls/bignum.c @@ -15,6 +15,7 @@ │ See the License for the specific language governing permissions and │ │ limitations under the License. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "third_party/mbedtls/bignum.h" #include "libc/intrin/bits.h" #include "libc/intrin/bsf.h" #include "libc/intrin/bswap.h" @@ -23,7 +24,6 @@ #include "libc/nexgen32e/x86feature.h" #include "libc/runtime/runtime.h" #include "libc/str/str.h" -#include "third_party/mbedtls/bignum.h" #include "third_party/mbedtls/bignum_internal.h" #include "third_party/mbedtls/chk.h" #include "third_party/mbedtls/common.h" @@ -291,7 +291,7 @@ int mbedtls_mpi_safe_cond_assign(mbedtls_mpi *X, for (i = 0; i < Y->n; i++) X->p[i] = Select(Y->p[i], X->p[i], -assign); for (i = Y->n; i < X->n; i++) - X->p[i] &= CONCEAL("r", assign - 1); + X->p[i] &= __conceal("r", assign - 1); cleanup: return( ret ); } diff --git a/third_party/mbedtls/platform.h b/third_party/mbedtls/platform.h index 11d426046..f2b2cdae9 100644 --- a/third_party/mbedtls/platform.h +++ b/third_party/mbedtls/platform.h @@ -52,7 +52,7 @@ COSMOPOLITAN_C_START_ #define MBEDTLS_ASSERT(EXPR) \ ((void)((EXPR) || (__assert_fail(#EXPR, __FILE__, __LINE__), 0))) #else -#define MBEDTLS_ASSERT(EXPR) _unassert(EXPR) +#define MBEDTLS_ASSERT(EXPR) unassert(EXPR) #endif typedef struct mbedtls_platform_context { diff --git a/third_party/mbedtls/rsa.c b/third_party/mbedtls/rsa.c index d510a80c1..c29a18540 100644 --- a/third_party/mbedtls/rsa.c +++ b/third_party/mbedtls/rsa.c @@ -15,6 +15,7 @@ │ See the License for the specific language governing permissions and │ │ limitations under the License. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "third_party/mbedtls/rsa.h" #include "libc/intrin/strace.internal.h" #include "libc/runtime/runtime.h" #include "libc/stdio/rand.h" @@ -24,7 +25,6 @@ #include "third_party/mbedtls/oid.h" #include "third_party/mbedtls/platform.h" #include "third_party/mbedtls/profile.h" -#include "third_party/mbedtls/rsa.h" #include "third_party/mbedtls/rsa_internal.h" #include "third_party/mbedtls/sha1.h" @@ -1353,8 +1353,8 @@ forceinline unsigned size_greater_than( size_t size, size_t max ) forceinline unsigned if_int( unsigned cond, unsigned if1, unsigned if0 ) { unsigned mask = all_or_nothing_int( cond ); - return( ( CONCEAL( "r", mask ) & if1 ) | - ( CONCEAL( "r", ~mask ) & if0 ) ); + return( ( __conceal( "r", mask ) & if1 ) | + ( __conceal( "r", ~mask ) & if0 ) ); } /** diff --git a/third_party/mbedtls/secp384r1.c b/third_party/mbedtls/secp384r1.c index 02153e9c4..c1418eb0d 100644 --- a/third_party/mbedtls/secp384r1.c +++ b/third_party/mbedtls/secp384r1.c @@ -234,7 +234,7 @@ void secp384r1(uint64_t p[12]) { p[4] = E; p[5] = F; p[6] = G; - G = CONCEAL("r", 0L); + G = __conceal("r", 0L); p[7] = G; p[8] = G; p[9] = G; diff --git a/third_party/mbedtls/select.h b/third_party/mbedtls/select.h index ea467500b..28f3f7b86 100644 --- a/third_party/mbedtls/select.h +++ b/third_party/mbedtls/select.h @@ -4,7 +4,7 @@ COSMOPOLITAN_C_START_ static inline uint64_t Select(uint64_t a, uint64_t b, uint64_t mask) { - return (CONCEAL("r", mask) & a) | (CONCEAL("r", ~mask) & b); + return (__conceal("r", mask) & a) | (__conceal("r", ~mask) & b); } COSMOPOLITAN_C_END_ diff --git a/third_party/mbedtls/test/lib.c b/third_party/mbedtls/test/lib.c index 391d6e9f9..d3ae618ab 100644 --- a/third_party/mbedtls/test/lib.c +++ b/third_party/mbedtls/test/lib.c @@ -50,7 +50,7 @@ Copyright ARM Limited\\n\ Copyright Mbed TLS Contributors\""); asm(".include \"libc/disclaimer.inc\""); -STATIC_YOINK("zipos"); +__static_yoink("zipos"); #if defined(MBEDTLS_PLATFORM_C) static mbedtls_platform_context platform_ctx; diff --git a/third_party/mbedtls/test/test.inc b/third_party/mbedtls/test/test.inc index 05e1da945..9412aac12 100644 --- a/third_party/mbedtls/test/test.inc +++ b/third_party/mbedtls/test/test.inc @@ -13,4 +13,4 @@ Copyright ARM Limited\\n\ Copyright Mbed TLS Contributors\""); asm(".include \"libc/disclaimer.inc\""); -STATIC_YOINK("zipos"); +__static_yoink("zipos"); diff --git a/third_party/mbedtls/zeroize.c b/third_party/mbedtls/zeroize.c index bae6eef66..f1045af9b 100644 --- a/third_party/mbedtls/zeroize.c +++ b/third_party/mbedtls/zeroize.c @@ -20,7 +20,7 @@ #include "third_party/mbedtls/platform.h" // disable ubsan because n=0 is defined behavior in cosmopolitan -noubsan void mbedtls_platform_zeroize(void *p, size_t n) { +dontubsan void mbedtls_platform_zeroize(void *p, size_t n) { MBEDTLS_INTERNAL_VALIDATE(!n || p); bzero(p, n); } diff --git a/third_party/nsync/common.internal.h b/third_party/nsync/common.internal.h index 113a9b909..7d452c7be 100644 --- a/third_party/nsync/common.internal.h +++ b/third_party/nsync/common.internal.h @@ -222,7 +222,7 @@ static const uint32_t NSYNC_WAITER_TAG = 0x726d2ba9; 0x1 /* waiter reserved by a thread, even when not in use */ #define WAITER_IN_USE 0x2 /* waiter in use by a thread */ -#define ASSERT(x) _npassert(x) +#define ASSERT(x) npassert(x) /* Return a pointer to the nsync_waiter_s containing struct Dll *e. */ #define DLL_NSYNC_WAITER(e) \ diff --git a/third_party/nsync/mem/nsync_cv.c b/third_party/nsync/mem/nsync_cv.c index fab7ac716..63b7a1c6c 100644 --- a/third_party/nsync/mem/nsync_cv.c +++ b/third_party/nsync/mem/nsync_cv.c @@ -28,7 +28,7 @@ // once we're paying the cost of nsync we might as well get the benefit // of a better pthread_once(), since no other component pulls it in now -STATIC_YOINK("nsync_run_once"); +__static_yoink("nsync_run_once"); asm(".ident\t\"\\n\\n\ *NSYNC (Apache 2.0)\\n\ diff --git a/third_party/nsync/mu_semaphore_futex.c b/third_party/nsync/mu_semaphore_futex.c index 2a3c69b6e..eb219291e 100644 --- a/third_party/nsync/mu_semaphore_futex.c +++ b/third_party/nsync/mu_semaphore_futex.c @@ -29,7 +29,7 @@ * @fileoverview Semaphores w/ Linux Futexes API. */ -#define ASSERT(x) _npassert(x) +#define ASSERT(x) npassert(x) /* Check that atomic operations on nsync_atomic_uint32_ can be applied to int. */ static const int assert_int_size = 1 / diff --git a/third_party/nsync/mu_semaphore_sem.c b/third_party/nsync/mu_semaphore_sem.c index 3f13b8ffe..8c120085b 100644 --- a/third_party/nsync/mu_semaphore_sem.c +++ b/third_party/nsync/mu_semaphore_sem.c @@ -33,7 +33,7 @@ * @fileoverview Semaphores w/ POSIX Semaphores API. */ -#define ASSERT(x) _npassert(x) +#define ASSERT(x) npassert(x) struct sem { int64_t id; diff --git a/third_party/python/Modules/cjkcodecs/xloadzd.c b/third_party/python/Modules/cjkcodecs/xloadzd.c index 94eae7b3b..718f078cb 100644 --- a/third_party/python/Modules/cjkcodecs/xloadzd.c +++ b/third_party/python/Modules/cjkcodecs/xloadzd.c @@ -47,7 +47,7 @@ void *xloadzd(_Atomic(void *) *a, const void *p, size_t n, size_t m, size_t c, void *r, *g; int64_t x, y; if ((r = atomic_load_explicit(a, memory_order_acquire))) return r; - _unassert(z == 2 || z == 4); + unassert(z == 2 || z == 4); if (!(b = q = malloc(m))) return 0; if (__inflate(q, m, p, n)) { free(q); diff --git a/third_party/python/Modules/main.c b/third_party/python/Modules/main.c index ad87a68dd..85a3a80c3 100644 --- a/third_party/python/Modules/main.c +++ b/third_party/python/Modules/main.c @@ -8,8 +8,8 @@ #include "libc/dce.h" #include "libc/errno.h" #include "libc/stdio/stdio.h" -#include "libc/sysv/consts/s.h" #include "libc/str/locale.h" +#include "libc/sysv/consts/s.h" #include "third_party/python/Include/abstract.h" #include "third_party/python/Include/bytesobject.h" #include "third_party/python/Include/ceval.h" @@ -29,16 +29,16 @@ #include "third_party/python/pyconfig.h" /* clang-format off */ -STATIC_YOINK("PyInit__codecs"); // for pylifecycle.o -STATIC_YOINK("PyInit__collections"); // for pylifecycle.o -STATIC_YOINK("PyInit__functools"); // for pylifecycle.o -STATIC_YOINK("PyInit__locale"); // for pylifecycle.o -STATIC_YOINK("PyInit__operator"); // for pylifecycle.o -STATIC_YOINK("PyInit__signal"); // for pylifecycle.o -STATIC_YOINK("PyInit__sre"); // for pylifecycle.o -STATIC_YOINK("PyInit__stat"); // for pylifecycle.o -STATIC_YOINK("PyInit_errno"); // for pylifecycle.o -STATIC_YOINK("PyInit_itertools"); // for pylifecycle.o +__static_yoink("PyInit__codecs"); // for pylifecycle.o +__static_yoink("PyInit__collections"); // for pylifecycle.o +__static_yoink("PyInit__functools"); // for pylifecycle.o +__static_yoink("PyInit__locale"); // for pylifecycle.o +__static_yoink("PyInit__operator"); // for pylifecycle.o +__static_yoink("PyInit__signal"); // for pylifecycle.o +__static_yoink("PyInit__sre"); // for pylifecycle.o +__static_yoink("PyInit__stat"); // for pylifecycle.o +__static_yoink("PyInit_errno"); // for pylifecycle.o +__static_yoink("PyInit_itertools"); // for pylifecycle.o PYTHON_YOINK("site"); // for pylifecycle.o PYTHON_YOINK("struct"); // for memoryobject.o diff --git a/third_party/python/Objects/object.c b/third_party/python/Objects/object.c index 844aead36..78c025688 100644 --- a/third_party/python/Objects/object.c +++ b/third_party/python/Objects/object.c @@ -4,6 +4,7 @@ │ Python 3 │ │ https://docs.python.org/3/license.html │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "third_party/python/Include/object.h" #include "libc/intrin/likely.h" #include "libc/log/countbranch.h" #include "third_party/python/Include/abstract.h" @@ -28,7 +29,6 @@ #include "third_party/python/Include/memoryobject.h" #include "third_party/python/Include/modsupport.h" #include "third_party/python/Include/namespaceobject.h" -#include "third_party/python/Include/object.h" #include "third_party/python/Include/objimpl.h" #include "third_party/python/Include/odictobject.h" #include "third_party/python/Include/pycapsule.h" @@ -1897,7 +1897,7 @@ _Py_NewReference(PyObject *op) _Py_INC_TPALLOCS(op); } -noasan void +dontasan void _Py_ForgetReference(PyObject *op) { #ifdef SLOW_UNREF_CHECK diff --git a/third_party/python/Objects/obmalloc.c b/third_party/python/Objects/obmalloc.c index bd45b7785..e9166b5b8 100644 --- a/third_party/python/Objects/obmalloc.c +++ b/third_party/python/Objects/obmalloc.c @@ -5,11 +5,11 @@ │ https://docs.python.org/3/license.html │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" -#include "libc/intrin/bits.h" #include "libc/calls/calls.h" #include "libc/dce.h" #include "libc/fmt/fmt.h" #include "libc/intrin/asan.internal.h" +#include "libc/intrin/bits.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/sysv/consts/map.h" @@ -1910,13 +1910,13 @@ bumpserialno(void) #define SST SIZEOF_SIZE_T -static inline optimizespeed noasan size_t +static inline optimizespeed dontasan size_t read_size_t(const void *p) { return READ64BE(p); } -static inline optimizespeed noasan void +static inline optimizespeed dontasan void write_size_t(void *p, size_t n) { WRITE64BE((char *)p, n); @@ -2049,7 +2049,7 @@ _PyMem_DebugRawFree(void *ctx, void *p) api->alloc.free(api->alloc.ctx, q); } -static noasan void * +static dontasan void * _PyMem_DebugRawRealloc(void *ctx, void *p, size_t nbytes) { _Static_assert(sizeof(size_t) == 8, ""); @@ -2138,7 +2138,7 @@ _PyMem_DebugRealloc(void *ctx, void *ptr, size_t nbytes) * and call Py_FatalError to kill the program. * The API id, is also checked. */ -static noasan void +static dontasan void _PyMem_DebugCheckAddress(char api, const void *p) { const uint8_t *q = (const uint8_t *)p; @@ -2191,7 +2191,7 @@ error: } /* Display info to stderr about the memory block at p. */ -static noasan void +static dontasan void _PyObject_DebugDumpAddress(const void *p) { const uint8_t *q = (const uint8_t *)p; diff --git a/third_party/python/Python/pystate.c b/third_party/python/Python/pystate.c index a14dcee22..c748bb071 100644 --- a/third_party/python/Python/pystate.c +++ b/third_party/python/Python/pystate.c @@ -4,6 +4,7 @@ │ Python 3 │ │ https://docs.python.org/3/license.html │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "third_party/python/Include/pystate.h" #include "libc/errno.h" #include "libc/intrin/pushpop.internal.h" #include "libc/runtime/dlfcn.h" @@ -15,11 +16,10 @@ #include "third_party/python/Include/pydebug.h" #include "third_party/python/Include/pyerrors.h" #include "third_party/python/Include/pymem.h" -#include "third_party/python/Include/pystate.h" /* clang-format off */ #if defined(__SANITIZE_ADDRESS__) || defined(__SANITIZE_UNDEFINED__) -STATIC_YOINK("__die"); /* to guarantee backtraces */ +__static_yoink("__die"); /* to guarantee backtraces */ #endif /* Thread and interpreter state structures and their interfaces */ diff --git a/third_party/python/launch.c b/third_party/python/launch.c index 994d6c975..fc6d8a9bc 100644 --- a/third_party/python/launch.c +++ b/third_party/python/launch.c @@ -41,7 +41,7 @@ #define USE_COSMO_CRASH MODE_DBG + 0 -STATIC_YOINK("zipos"); +__static_yoink("zipos"); PYTHON_YOINK("_bootlocale"); PYTHON_YOINK("_locale"); PYTHON_YOINK("encodings.aliases"); diff --git a/third_party/python/pycomp.c b/third_party/python/pycomp.c index e69e82e05..ce96b9e4d 100644 --- a/third_party/python/pycomp.c +++ b/third_party/python/pycomp.c @@ -44,7 +44,7 @@ #include "tool/build/lib/stripcomponents.h" /* clang-format off */ -STATIC_YOINK("_PyUnicode_GetCode"); +__static_yoink("_PyUnicode_GetCode"); #define MANUAL "\ SYNOPSIS\n\ diff --git a/third_party/python/pyobj.c b/third_party/python/pyobj.c index 8f1cb90b1..19427152f 100644 --- a/third_party/python/pyobj.c +++ b/third_party/python/pyobj.c @@ -64,7 +64,7 @@ #include "tool/build/lib/stripcomponents.h" /* clang-format off */ -STATIC_YOINK("_PyUnicode_GetCode"); +__static_yoink("_PyUnicode_GetCode"); #define MANUAL "\ SYNOPSIS\n\ diff --git a/third_party/python/python.c b/third_party/python/python.c index 1757bac95..3ae9cecc1 100644 --- a/third_party/python/python.c +++ b/third_party/python/python.c @@ -137,58 +137,58 @@ PYTHON_YOINK("encodings.utf_7"); #ifndef TINY PYTHON_YOINK("pydoc_data.topics"); -STATIC_YOINK(".python/pydoc_data/_pydoc.css"); +__static_yoink(".python/pydoc_data/_pydoc.css"); #endif /* todo(jart): delete nonessential yoinks */ -STATIC_YOINK("_PyImport_Inittab__bisect"); -STATIC_YOINK("_PyImport_Inittab__codecs_cn"); -STATIC_YOINK("_PyImport_Inittab__codecs_hk"); -STATIC_YOINK("_PyImport_Inittab__codecs_iso2022"); -STATIC_YOINK("_PyImport_Inittab__codecs_jp"); -STATIC_YOINK("_PyImport_Inittab__codecs_kr"); -STATIC_YOINK("_PyImport_Inittab__codecs_tw"); -STATIC_YOINK("_PyImport_Inittab__csv"); -STATIC_YOINK("_PyImport_Inittab__datetime"); -STATIC_YOINK("_PyImport_Inittab__decimal"); -STATIC_YOINK("_PyImport_Inittab__elementtree"); -STATIC_YOINK("_PyImport_Inittab__json"); -STATIC_YOINK("_PyImport_Inittab__lsprof"); -STATIC_YOINK("_PyImport_Inittab__multibytecodec"); -STATIC_YOINK("_PyImport_Inittab__multiprocessing"); -STATIC_YOINK("_PyImport_Inittab__opcode"); -STATIC_YOINK("_PyImport_Inittab__pickle"); -STATIC_YOINK("_PyImport_Inittab__posixsubprocess"); -STATIC_YOINK("_PyImport_Inittab__random"); -STATIC_YOINK("_PyImport_Inittab__socket"); -STATIC_YOINK("_PyImport_Inittab__sqlite3"); -STATIC_YOINK("_PyImport_Inittab__stat"); -STATIC_YOINK("_PyImport_Inittab__struct"); -STATIC_YOINK("_PyImport_Inittab__symtable"); -STATIC_YOINK("_PyImport_Inittab__testcapi"); -STATIC_YOINK("_PyImport_Inittab__tracemalloc"); -STATIC_YOINK("_PyImport_Inittab_array"); -STATIC_YOINK("_PyImport_Inittab_atexit"); -STATIC_YOINK("_PyImport_Inittab_audioop"); -STATIC_YOINK("_PyImport_Inittab_binascii"); -STATIC_YOINK("_PyImport_Inittab_cmath"); -STATIC_YOINK("_PyImport_Inittab_faulthandler"); -STATIC_YOINK("_PyImport_Inittab_fcntl"); -STATIC_YOINK("_PyImport_Inittab_fpectl"); -STATIC_YOINK("_PyImport_Inittab_grp"); -STATIC_YOINK("_PyImport_Inittab_math"); -STATIC_YOINK("_PyImport_Inittab_mmap"); -STATIC_YOINK("_PyImport_Inittab_parser"); -STATIC_YOINK("_PyImport_Inittab_pwd"); -STATIC_YOINK("_PyImport_Inittab_pyexpat"); -STATIC_YOINK("_PyImport_Inittab_resource"); -STATIC_YOINK("_PyImport_Inittab_select"); -STATIC_YOINK("_PyImport_Inittab_syslog"); -STATIC_YOINK("_PyImport_Inittab_termios"); -STATIC_YOINK("_PyImport_Inittab_time"); -STATIC_YOINK("_PyImport_Inittab_unicodedata"); -STATIC_YOINK("_PyImport_Inittab_zipimport"); +__static_yoink("_PyImport_Inittab__bisect"); +__static_yoink("_PyImport_Inittab__codecs_cn"); +__static_yoink("_PyImport_Inittab__codecs_hk"); +__static_yoink("_PyImport_Inittab__codecs_iso2022"); +__static_yoink("_PyImport_Inittab__codecs_jp"); +__static_yoink("_PyImport_Inittab__codecs_kr"); +__static_yoink("_PyImport_Inittab__codecs_tw"); +__static_yoink("_PyImport_Inittab__csv"); +__static_yoink("_PyImport_Inittab__datetime"); +__static_yoink("_PyImport_Inittab__decimal"); +__static_yoink("_PyImport_Inittab__elementtree"); +__static_yoink("_PyImport_Inittab__json"); +__static_yoink("_PyImport_Inittab__lsprof"); +__static_yoink("_PyImport_Inittab__multibytecodec"); +__static_yoink("_PyImport_Inittab__multiprocessing"); +__static_yoink("_PyImport_Inittab__opcode"); +__static_yoink("_PyImport_Inittab__pickle"); +__static_yoink("_PyImport_Inittab__posixsubprocess"); +__static_yoink("_PyImport_Inittab__random"); +__static_yoink("_PyImport_Inittab__socket"); +__static_yoink("_PyImport_Inittab__sqlite3"); +__static_yoink("_PyImport_Inittab__stat"); +__static_yoink("_PyImport_Inittab__struct"); +__static_yoink("_PyImport_Inittab__symtable"); +__static_yoink("_PyImport_Inittab__testcapi"); +__static_yoink("_PyImport_Inittab__tracemalloc"); +__static_yoink("_PyImport_Inittab_array"); +__static_yoink("_PyImport_Inittab_atexit"); +__static_yoink("_PyImport_Inittab_audioop"); +__static_yoink("_PyImport_Inittab_binascii"); +__static_yoink("_PyImport_Inittab_cmath"); +__static_yoink("_PyImport_Inittab_faulthandler"); +__static_yoink("_PyImport_Inittab_fcntl"); +__static_yoink("_PyImport_Inittab_fpectl"); +__static_yoink("_PyImport_Inittab_grp"); +__static_yoink("_PyImport_Inittab_math"); +__static_yoink("_PyImport_Inittab_mmap"); +__static_yoink("_PyImport_Inittab_parser"); +__static_yoink("_PyImport_Inittab_pwd"); +__static_yoink("_PyImport_Inittab_pyexpat"); +__static_yoink("_PyImport_Inittab_resource"); +__static_yoink("_PyImport_Inittab_select"); +__static_yoink("_PyImport_Inittab_syslog"); +__static_yoink("_PyImport_Inittab_termios"); +__static_yoink("_PyImport_Inittab_time"); +__static_yoink("_PyImport_Inittab_unicodedata"); +__static_yoink("_PyImport_Inittab_zipimport"); PYTHON_YOINK("__future__"); PYTHON_YOINK("_bootlocale"); @@ -397,7 +397,7 @@ PYTHON_YOINK("email.parser"); PYTHON_YOINK("email.policy"); PYTHON_YOINK("email.quoprimime"); PYTHON_YOINK("email.utils"); -STATIC_YOINK(".python/email/architecture.rst"); +__static_yoink(".python/email/architecture.rst"); PYTHON_YOINK("importlib"); PYTHON_YOINK("importlib.abc"); diff --git a/third_party/python/runpythonmodule.c b/third_party/python/runpythonmodule.c index 249ae05ff..9500b0235 100644 --- a/third_party/python/runpythonmodule.c +++ b/third_party/python/runpythonmodule.c @@ -54,8 +54,8 @@ STATIC_STACK_SIZE(0x100000); -STATIC_YOINK("__die"); -STATIC_YOINK("zipos"); +__static_yoink("__die"); +__static_yoink("zipos"); PYTHON_YOINK("cosmo"); PYTHON_YOINK("_locale"); diff --git a/third_party/regex/regcomp.c b/third_party/regex/regcomp.c index 59e1a0f52..4b03aa929 100644 --- a/third_party/regex/regcomp.c +++ b/third_party/regex/regcomp.c @@ -334,7 +334,7 @@ static reg_errcode_t tre_stack_push(tre_stack_t *s, if (new_buffer == NULL) { return REG_ESPACE; } - _unassert(new_size > s->size); + unassert(new_size > s->size); s->size = new_size; s->stack = new_buffer; tre_stack_push(s, value); @@ -1209,7 +1209,7 @@ static reg_errcode_t tre_add_tags(tre_mem_t mem, tre_stack_t *stack, status = REG_ESPACE; break; } - _unassert(tnfa->submatch_data[id].parents == NULL); + unassert(tnfa->submatch_data[id].parents == NULL); tnfa->submatch_data[id].parents = p; for (i = 0; parents[i] >= 0; i++) p[i] = parents[i]; p[i] = -1; @@ -1254,7 +1254,7 @@ static reg_errcode_t tre_add_tags(tre_mem_t mem, tre_stack_t *stack, next_tag++; } } else { - _unassert(!IS_TAG(lit)); + unassert(!IS_TAG(lit)); } break; } @@ -1516,7 +1516,7 @@ static reg_errcode_t tre_add_tags(tre_mem_t mem, tre_stack_t *stack, num_minimals++; } - _unassert(tree->num_tags == num_tags); + unassert(tree->num_tags == num_tags); tnfa->end_tag = num_tags; tnfa->num_tags = num_tags; tnfa->num_minimals = num_minimals; @@ -1954,7 +1954,7 @@ static reg_errcode_t tre_match_empty(tre_stack_t *stack, tre_ast_node_t *node, } break; case ASSERTION: - _unassert(lit->code_max >= 1 || lit->code_max <= ASSERT_LAST); + unassert(lit->code_max >= 1 || lit->code_max <= ASSERT_LAST); if (assertions != NULL) *assertions |= lit->code_max; break; case EMPTY: @@ -1980,8 +1980,8 @@ static reg_errcode_t tre_match_empty(tre_stack_t *stack, tre_ast_node_t *node, case CATENATION: /* The path must go through both children. */ cat = (tre_catenation_t *)node->obj; - _unassert(cat->left->nullable); - _unassert(cat->right->nullable); + unassert(cat->left->nullable); + unassert(cat->right->nullable); STACK_PUSHX(stack, voidptr, cat->left); STACK_PUSHX(stack, voidptr, cat->right); break; @@ -2245,8 +2245,8 @@ static reg_errcode_t tre_make_trans(tre_pos_and_tags_t *p1, (p1->class ? ASSERT_CHAR_CLASS : 0) | (p1->neg_classes != NULL ? ASSERT_CHAR_CLASS_NEG : 0); if (p1->backref >= 0) { - _unassert((trans->assertions & ASSERT_CHAR_CLASS) == 0); - _unassert(p2->backref < 0); + unassert((trans->assertions & ASSERT_CHAR_CLASS) == 0); + unassert(p2->backref < 0); trans->u.backref = p1->backref; trans->assertions |= ASSERT_BACKREF; } else @@ -2356,10 +2356,10 @@ static reg_errcode_t tre_ast_to_tnfa(tre_ast_node_t *node, case ITERATION: iter = (tre_iteration_t *)node->obj; - _unassert(iter->max == -1 || iter->max == 1); + unassert(iter->max == -1 || iter->max == 1); if (iter->max == -1) { - _unassert(iter->min == 0 || iter->min == 1); + unassert(iter->min == 0 || iter->min == 1); /* Add a transition from each last position in the iterated expression to each first position. */ errcode = tre_make_trans(iter->arg->lastpos, iter->arg->firstpos, diff --git a/third_party/regex/regexec.c b/third_party/regex/regexec.c index 548d70c22..0b559d477 100644 --- a/third_party/regex/regexec.c +++ b/third_party/regex/regexec.c @@ -394,7 +394,7 @@ static reg_errcode_t tre_tnfa_run_parallel(const tre_tnfa_t *tnfa, reach_next_i++; } else { - _unassert(reach_pos[trans_i->state_id].pos == pos); + unassert(reach_pos[trans_i->state_id].pos == pos); /* Another path has also reached this state. We choose the winner by examining the tag values for both paths. */ @@ -521,7 +521,7 @@ typedef struct tre_backtrack_struct { #define BT_STACK_POP() \ do { \ int i; \ - _unassert(stack->prev); \ + unassert(stack->prev); \ pos = stack->item.pos; \ str_byte = stack->item.str_byte; \ state = stack->item.state; \ @@ -847,8 +847,8 @@ static void tre_fill_pmatch(size_t nmatch, regmatch_t pmatch[], int cflags, submatches. */ i = 0; while (i < tnfa->num_submatches && i < nmatch) { - if (pmatch[i].rm_eo == -1) _unassert(pmatch[i].rm_so == -1); - _unassert(pmatch[i].rm_so <= pmatch[i].rm_eo); + if (pmatch[i].rm_eo == -1) unassert(pmatch[i].rm_so == -1); + unassert(pmatch[i].rm_so <= pmatch[i].rm_eo); parents = submatch_data[i].parents; if (parents != NULL) diff --git a/third_party/sqlite3/main.shell.c b/third_party/sqlite3/main.shell.c index 681aa77a2..083c25117 100644 --- a/third_party/sqlite3/main.shell.c +++ b/third_party/sqlite3/main.shell.c @@ -1,2 +1,2 @@ -STATIC_YOINK("zipos"); +__static_yoink("zipos"); #include "third_party/sqlite3/main.c" diff --git a/third_party/sqlite3/shell.c b/third_party/sqlite3/shell.c index ce01c2686..4cbd7d9e3 100644 --- a/third_party/sqlite3/shell.c +++ b/third_party/sqlite3/shell.c @@ -11429,7 +11429,7 @@ static char *cmdline_option_value(int argc, char **argv, int i){ # define main fiddle_main #endif -STATIC_YOINK("zipos"); // for symtab +__static_yoink("zipos"); // for symtab #if SQLITE_SHELL_IS_UTF8 int SQLITE_CDECL main(int argc, char **argv){ diff --git a/third_party/tr/next.c b/third_party/tr/next.c index 26eb776a5..545424e1d 100644 --- a/third_party/tr/next.c +++ b/third_party/tr/next.c @@ -295,7 +295,7 @@ backslash(STR *s) size_t i; int ch, val; - _unassert(*s->str == '\\'); + unassert(*s->str == '\\'); s->str++; /* Empty escapes become plain backslashes. */ diff --git a/tool/ape/ape.c b/tool/ape/ape.c index 56c80360f..44f83b604 100644 --- a/tool/ape/ape.c +++ b/tool/ape/ape.c @@ -277,17 +277,17 @@ int _curl(int argc, char *argv[]) { mbedtls_ssl_init(&ssl); mbedtls_ctr_drbg_init(&drbg); mbedtls_ssl_config_init(&conf); - _unassert(!mbedtls_ctr_drbg_seed(&drbg, GetSslEntropy, 0, "justine", 7)); - _unassert(!mbedtls_ssl_config_defaults(&conf, MBEDTLS_SSL_IS_CLIENT, - MBEDTLS_SSL_TRANSPORT_STREAM, - MBEDTLS_SSL_PRESET_DEFAULT)); + unassert(!mbedtls_ctr_drbg_seed(&drbg, GetSslEntropy, 0, "justine", 7)); + unassert(!mbedtls_ssl_config_defaults(&conf, MBEDTLS_SSL_IS_CLIENT, + MBEDTLS_SSL_TRANSPORT_STREAM, + MBEDTLS_SSL_PRESET_DEFAULT)); mbedtls_ssl_conf_ca_chain(&conf, GetSslRoots(), 0); mbedtls_ssl_conf_rng(&conf, mbedtls_ctr_drbg_random, &drbg); #ifndef NDEBUG mbedtls_ssl_conf_dbg(&conf, OnSslDebug, 0); #endif - _unassert(!mbedtls_ssl_setup(&ssl, &conf)); - _unassert(!mbedtls_ssl_set_hostname(&ssl, host)); + unassert(!mbedtls_ssl_setup(&ssl, &conf)); + unassert(!mbedtls_ssl_set_hostname(&ssl, host)); mbedtls_ssl_set_bio(&ssl, &sock, TlsSend, 0, TlsRecv); if ((ret = mbedtls_ssl_handshake(&ssl))) { tinyprint(2, prog, ": ssl negotiation with ", host, @@ -340,7 +340,7 @@ int _curl(int argc, char *argv[]) { i += g; switch (t) { case kHttpClientStateHeaders: - _unassert(g); + unassert(g); if ((rc = ParseHttpMessage(&msg, p, i)) == -1) { tinyprint(2, prog, ": ", host, " sent bad http message\n", NULL); exit(1); @@ -376,7 +376,7 @@ int _curl(int argc, char *argv[]) { } break; case kHttpClientStateBodyLengthed: - _unassert(g); + unassert(g); if (i - hdrlen > paylen) { g = hdrlen + paylen - (i - g); } diff --git a/tool/args/args.c b/tool/args/args.c index 18729cdfd..05fe970cc 100644 --- a/tool/args/args.c +++ b/tool/args/args.c @@ -27,7 +27,7 @@ #include "libc/sysv/consts/o.h" #include "libc/x/x.h" -STATIC_YOINK("zipos"); +__static_yoink("zipos"); static struct ZipArgs { bool initialized; diff --git a/tool/build/assimilate.c b/tool/build/assimilate.c index 7d28e8088..5aec3be3c 100644 --- a/tool/build/assimilate.c +++ b/tool/build/assimilate.c @@ -35,7 +35,7 @@ #include "third_party/getopt/getopt.internal.h" #include "third_party/regex/regex.h" -STATIC_YOINK("strerror_wr"); +__static_yoink("strerror_wr"); // options used: fhem // letters not used: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdgijklnopqrstuvwxyz diff --git a/tool/build/cocmd.c b/tool/build/cocmd.c index 0dfab8b6f..22690a95f 100644 --- a/tool/build/cocmd.c +++ b/tool/build/cocmd.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/runtime/runtime.h" -STATIC_YOINK("glob"); +__static_yoink("glob"); int main(int argc, char **argv, char **envp) { return _cocmd(argc, argv, envp); diff --git a/tool/build/package.c b/tool/build/package.c index 821522d8d..953c40882 100644 --- a/tool/build/package.c +++ b/tool/build/package.c @@ -43,7 +43,7 @@ #include "third_party/xed/x86.h" #include "tool/build/lib/getargs.h" -STATIC_YOINK("realloc"); +__static_yoink("realloc"); /** * @fileoverview Build Package Script. diff --git a/tool/build/pledge.c b/tool/build/pledge.c index 765a91831..7e67632e9 100644 --- a/tool/build/pledge.c +++ b/tool/build/pledge.c @@ -69,8 +69,8 @@ // test/tool/build/pledge_test.sh // -STATIC_YOINK("strerror_wr"); -STATIC_YOINK("zipos"); +__static_yoink("strerror_wr"); +__static_yoink("zipos"); #define USAGE \ "\ diff --git a/tool/build/sha256sum.c b/tool/build/sha256sum.c index 806b9221b..7b358591c 100644 --- a/tool/build/sha256sum.c +++ b/tool/build/sha256sum.c @@ -119,15 +119,15 @@ static bool GetDigest(const char *path, FILE *f, unsigned char digest[32]) { unsigned char buf[512]; mbedtls_sha256_context ctx; mbedtls_sha256_init(&ctx); - _unassert(!mbedtls_sha256_starts_ret(&ctx, false)); + unassert(!mbedtls_sha256_starts_ret(&ctx, false)); while ((got = fread(buf, 1, sizeof(buf), f))) { - _unassert(!mbedtls_sha256_update_ret(&ctx, buf, got)); + unassert(!mbedtls_sha256_update_ret(&ctx, buf, got)); } if (ferror(f)) { tinyprint(2, prog, ": ", path, ": ", strerror(errno), "\n", NULL); return false; } - _unassert(!mbedtls_sha256_finish_ret(&ctx, digest)); + unassert(!mbedtls_sha256_finish_ret(&ctx, digest)); mbedtls_sha256_free(&ctx); return true; } diff --git a/tool/curl/curl.c b/tool/curl/curl.c index 4ae79e7c1..dd718064d 100644 --- a/tool/curl/curl.c +++ b/tool/curl/curl.c @@ -364,18 +364,18 @@ int _curl(int argc, char *argv[]) { mbedtls_ssl_init(&ssl); mbedtls_ctr_drbg_init(&drbg); mbedtls_ssl_config_init(&conf); - _unassert(!mbedtls_ctr_drbg_seed(&drbg, GetSslEntropy, 0, "justine", 7)); - _unassert(!mbedtls_ssl_config_defaults(&conf, MBEDTLS_SSL_IS_CLIENT, - MBEDTLS_SSL_TRANSPORT_STREAM, - ciphersuite)); + unassert(!mbedtls_ctr_drbg_seed(&drbg, GetSslEntropy, 0, "justine", 7)); + unassert(!mbedtls_ssl_config_defaults(&conf, MBEDTLS_SSL_IS_CLIENT, + MBEDTLS_SSL_TRANSPORT_STREAM, + ciphersuite)); mbedtls_ssl_conf_authmode(&conf, authmode); mbedtls_ssl_conf_ca_chain(&conf, GetSslRoots(), 0); mbedtls_ssl_conf_rng(&conf, mbedtls_ctr_drbg_random, &drbg); #ifndef NDEBUG mbedtls_ssl_conf_dbg(&conf, OnSslDebug, 0); #endif - _unassert(!mbedtls_ssl_setup(&ssl, &conf)); - _unassert(!mbedtls_ssl_set_hostname(&ssl, host)); + unassert(!mbedtls_ssl_setup(&ssl, &conf)); + unassert(!mbedtls_ssl_set_hostname(&ssl, host)); mbedtls_ssl_set_bio(&ssl, &sock, TlsSend, 0, TlsRecv); if ((ret = mbedtls_ssl_handshake(&ssl))) { tinyprint(2, prog, ": ssl negotiation with ", host, @@ -444,7 +444,7 @@ int _curl(int argc, char *argv[]) { i += g; switch (t) { case kHttpClientStateHeaders: - _unassert(g); + unassert(g); if ((rc = ParseHttpMessage(&msg, p, i)) == -1) { tinyprint(2, prog, ": ", host, " sent bad http message\n", NULL); exit(1); @@ -501,7 +501,7 @@ int _curl(int argc, char *argv[]) { if (!g) goto Finished; break; case kHttpClientStateBodyLengthed: - _unassert(g); + unassert(g); if (i - hdrlen > paylen) { g = hdrlen + paylen - (i - g); } diff --git a/tool/emacs/c.lang b/tool/emacs/c.lang index b9d450b2d..15761c496 100644 --- a/tool/emacs/c.lang +++ b/tool/emacs/c.lang @@ -1663,12 +1663,12 @@ Keywords={ "MACHINE_CODE_ANALYSIS_BEGIN_", "MACHINE_CODE_ANALYSIS_END_", "DebugBreak", -"VEIL", -"CONCEAL", -"EXPROPRIATE", -"YOINK", -"STATIC_YOINK", -"STATIC_YOINK_SOURCE", +"__veil", +"__conceal", +"__expropriate", +"__yoink", +"__static_yoink", +"__static_yoink_source", "STRINGIFY", "likely", "unlikely", diff --git a/tool/emacs/cosmo-c-builtins.el b/tool/emacs/cosmo-c-builtins.el index 14c9dbfc0..f044b54ec 100644 --- a/tool/emacs/cosmo-c-builtins.el +++ b/tool/emacs/cosmo-c-builtins.el @@ -202,11 +202,11 @@ (cosmopolitan-builtin-functions '("DebugBreak" - "VEIL" - "CONCEAL" - "EXPROPRIATE" - "YOINK" - "STATIC_YOINK" + "__veil" + "__conceal" + "__expropriate" + "__yoink" + "__static_yoink" "PYTHON_YOINK" "PYTHON_PROVIDE" "STATIC_STACK_ADDR" diff --git a/tool/emacs/cosmo-c-keywords.el b/tool/emacs/cosmo-c-keywords.el index ba97f28db..708a67df6 100644 --- a/tool/emacs/cosmo-c-keywords.el +++ b/tool/emacs/cosmo-c-keywords.el @@ -71,9 +71,9 @@ "nodebuginfo" "frownedupon" "wontreturn" - "noasan" + "dontasan" "nomsan" - "noubsan" + "dontubsan" "nostackprotector" "initarray" "mayalias" diff --git a/tool/emacs/cosmo-cpp-constants.el b/tool/emacs/cosmo-cpp-constants.el index b4d3da5b1..9f7bec4f1 100644 --- a/tool/emacs/cosmo-cpp-constants.el +++ b/tool/emacs/cosmo-cpp-constants.el @@ -178,7 +178,6 @@ '("__SAUCE__" "PAGESIZE" "APE_STACKSIZE" - "APE_GUARDSIZE" "FRAMESIZE" "ARG_MAX" "PATH_MAX" diff --git a/tool/net/ljson.c b/tool/net/ljson.c index ded945f35..0d10b7bca 100644 --- a/tool/net/ljson.c +++ b/tool/net/ljson.c @@ -21,11 +21,13 @@ #include "libc/intrin/likely.h" #include "libc/log/check.h" #include "libc/log/log.h" +#include "libc/runtime/runtime.h" #include "libc/runtime/stack.h" #include "libc/stdckdint.h" #include "libc/str/str.h" #include "libc/str/tab.internal.h" #include "libc/str/utf16.h" +#include "libc/sysv/consts/auxv.h" #include "third_party/double-conversion/wrapper.h" #include "third_party/lua/cosmo.h" #include "third_party/lua/lauxlib.h" @@ -99,7 +101,7 @@ static struct DecodeJson Parse(struct lua_State *L, const char *p, if (UNLIKELY(!depth)) { return (struct DecodeJson){-1, "maximum depth exceeded"}; } - if (UNLIKELY(!HaveStackMemory(APE_GUARDSIZE))) { + if (UNLIKELY(!HaveStackMemory(getauxval(AT_PAGESZ)))) { return (struct DecodeJson){-1, "out of stack"}; } for (a = p, d = +1; p < e;) { diff --git a/tool/net/redbean.c b/tool/net/redbean.c index 19da60bb9..60b1127d7 100644 --- a/tool/net/redbean.c +++ b/tool/net/redbean.c @@ -141,16 +141,16 @@ STATIC_STACK_SIZE(0x80000); -STATIC_YOINK("zipos"); +__static_yoink("zipos"); #ifdef USE_BLINK -STATIC_YOINK("blink_linux_aarch64"); // for raspberry pi -STATIC_YOINK("blink_xnu_aarch64"); // is apple silicon +__static_yoink("blink_linux_aarch64"); // for raspberry pi +__static_yoink("blink_xnu_aarch64"); // is apple silicon #endif #if !IsTiny() #ifdef __x86_64__ -STATIC_YOINK("ShowCrashReportsEarly"); +__static_yoink("ShowCrashReportsEarly"); #endif #endif @@ -4948,7 +4948,7 @@ static int LuaProgramTokenBucket(lua_State *L) { tokenbucket.ban = ban; tokenbucket.replenish = timespec_fromnanos(1 / replenish * 1e9); int pid = fork(); - _npassert(pid != -1); + npassert(pid != -1); if (!pid) Replenisher(); return 0; } diff --git a/tool/plinko/plinko.c b/tool/plinko/plinko.c index 2c53e875a..fc1039948 100644 --- a/tool/plinko/plinko.c +++ b/tool/plinko/plinko.c @@ -19,7 +19,7 @@ #include "tool/plinko/lib/plinko.h" #include "libc/thread/tls.h" -STATIC_YOINK("__zipos_get"); +__static_yoink("__zipos_get"); int main(int argc, char *argv[]) { __tls_enabled = false; diff --git a/tool/viz/life.c b/tool/viz/life.c index 617baee45..02ebf904c 100644 --- a/tool/viz/life.c +++ b/tool/viz/life.c @@ -55,11 +55,13 @@ #include "libc/nt/struct/openfilename.h" #include "libc/nt/windows.h" #include "libc/runtime/runtime.h" +#include "libc/runtime/sysconf.h" #include "libc/sock/struct/pollfd.h" #include "libc/stdio/rand.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/str/strwidth.h" +#include "libc/sysv/consts/auxv.h" #include "libc/sysv/consts/ex.h" #include "libc/sysv/consts/exit.h" #include "libc/sysv/consts/poll.h" @@ -481,17 +483,17 @@ static void *NewBoard(size_t *out_size) { char *p; size_t s, n, k; s = (byn * bxn) >> 3; - k = APE_GUARDSIZE + ROUNDUP(s, APE_GUARDSIZE); - n = ROUNDUP(k + APE_GUARDSIZE, FRAMESIZE); + k = getauxval(AT_PAGESZ) + ROUNDUP(s, getauxval(AT_PAGESZ)); + n = ROUNDUP(k + getauxval(AT_PAGESZ), sysconf(_SC_PAGESIZE)); p = _mapanon(n); - mprotect(p, APE_GUARDSIZE, 0); + mprotect(p, getauxval(AT_PAGESZ), 0); mprotect(p + k, n - k, 0); if (out_size) *out_size = n; - return p + APE_GUARDSIZE; + return p + getauxval(AT_PAGESZ); } static void FreeBoard(void *p, size_t n) { - munmap((char *)p - APE_GUARDSIZE, n); + munmap((char *)p - getauxval(AT_PAGESZ), n); } static void AllocateBoardsWithHardwareAcceleratedMemorySafety(void) { diff --git a/tool/viz/printimage.c b/tool/viz/printimage.c index c57deb6ca..582984da6 100644 --- a/tool/viz/printimage.c +++ b/tool/viz/printimage.c @@ -45,7 +45,7 @@ #include "third_party/stb/stb_image.h" #include "tool/viz/lib/graphic.h" -STATIC_YOINK("__zipos_get"); +__static_yoink("__zipos_get"); static struct Flags { const char *out; diff --git a/tool/viz/printpeb.c b/tool/viz/printpeb.c index 89c869e7c..ff0f8729e 100644 --- a/tool/viz/printpeb.c +++ b/tool/viz/printpeb.c @@ -82,7 +82,7 @@ const struct IdName kNtStartfFlagNames[] = { {0, 0}, }; -noasan void PrintStartupInfo(void) { +dontasan void PrintStartupInfo(void) { #if 0 printf("\n\ ╔──────────────────────────────────────────────────────────────────────────────╗\n\ @@ -161,7 +161,7 @@ void PrintStdioInfo(void) { ft2str(GetFileType(g_fds.p[2].handle))); } -noasan void PrintTeb(void) { +dontasan void PrintTeb(void) { GetCurrentProcessId(); SetLastError(0x1234); printf("\n\