From 83d41e45880255727066b3d904a35e871af6d891 Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Sat, 20 Aug 2022 12:32:51 -0700 Subject: [PATCH] Clean up some code --- ape/loader.c | 4 +- examples/cosh.c | 1 - examples/forkrand.c | 3 +- examples/rlimit.c | 1 - libc/calls/arememoryintervalsok.c | 1 - libc/calls/copyfile.c | 1 - libc/calls/directmap.c | 4 -- libc/calls/execve-nt.greg.c | 1 - libc/calls/execve-sysv.c | 5 +- libc/calls/fcntl-nt.c | 3 +- libc/calls/fstat-nt.c | 1 - libc/calls/fstatat.c | 1 - libc/calls/fstatfs-nt.c | 1 - libc/calls/kill-nt.c | 1 - libc/calls/mkntenvblock.c | 5 +- libc/calls/pledge-linux.c | 25 +++++++-- libc/calls/poll-nt.c | 1 - libc/calls/raise.c | 1 - libc/calls/read.c | 1 - libc/calls/setitimer-nt.c | 3 +- libc/calls/sigenter-freebsd.c | 1 - libc/calls/sigenter-xnu.c | 1 - libc/calls/syscall-sysv.internal.h | 3 +- libc/calls/tkill.c | 1 - libc/calls/ttyname_r.c | 1 - libc/calls/unveil.c | 1 - libc/calls/vdsofunc.greg.c | 3 +- libc/calls/wait4-nt.c | 1 - libc/elf/checkelfaddress.c | 1 - libc/intrin/describeflags.c | 1 - libc/intrin/describentfileflagattr.c | 1 - libc/intrin/exit1.greg.c | 1 - libc/intrin/getenv.greg.c | 1 - libc/intrin/pthread_mutex_unlock.c | 3 +- libc/intrin/spinlock.h | 22 -------- libc/intrin/wsawaitformultipleevents.c | 1 - libc/log/attachdebugger.c | 2 +- libc/log/startfatal.c | 3 +- libc/runtime/enable_tls.c | 5 +- libc/runtime/hook.greg.c | 3 +- libc/runtime/mmap.c | 11 ++-- libc/runtime/mprotect.c | 5 +- libc/runtime/munmap.c | 5 +- libc/runtime/opensymboltable.greg.c | 5 +- libc/runtime/stackuse.c | 3 +- libc/runtime/winmain.greg.c | 7 ++- libc/sock/closesocket-nt.c | 1 - libc/sock/connect.c | 1 - libc/sock/recv-nt.c | 1 - libc/sock/sendfile.c | 1 - libc/sock/sock.h | 1 + libc/sock/sockaddr2linux.c | 1 - libc/sock/sockatmark.c | 52 +++++++++++++++++++ libc/stdio/fgets_unlocked.c | 1 - libc/sysv/consts.sh | 5 +- libc/sysv/consts/SIOCATMARK.s | 2 +- libc/testlib/runner.c | 1 - libc/testlib/testmain.c | 1 - libc/zipos/open.c | 3 +- test/libc/calls/_timespec_test.c | 1 - test/libc/calls/clock_getres_test.c | 1 - test/libc/calls/fcntl_test.c | 26 +++++----- test/libc/calls/nanosleep_test.c | 1 - test/libc/calls/open_test.c | 9 ++-- test/libc/calls/pledge2_test.c | 1 - test/libc/calls/pledge_test.c | 41 ++------------- test/libc/calls/poll_test.c | 1 - test/libc/calls/reservefd_test.c | 1 - test/libc/calls/sched_setscheduler_test.c | 3 +- test/libc/calls/test.mk | 6 +++ test/libc/intrin/describeflags_test.c | 1 - test/libc/intrin/kprintf_test.c | 8 ++- test/libc/intrin/pthread_mutex_lock_test.c | 1 - test/libc/intrin/rand64_test.c | 5 +- test/libc/log/backtrace_test.c | 1 - test/libc/mem/malloc_test.c | 7 ++- test/libc/nexgen32e/stackrw_test.c | 1 - test/libc/runtime/clone_test.c | 1 - test/libc/runtime/mmap_test.c | 11 ++-- test/libc/runtime/mprotect_test.c | 1 - test/libc/runtime/munmap_test.c | 3 +- test/libc/runtime/tls_test.c | 19 ------- test/libc/sock/unix_test.c | 1 - test/libc/stdio/dtoa_test.c | 1 - test/libc/stdio/getdelim_test.c | 1 - test/libc/stdio/spawn_test.c | 3 +- test/libc/stdio/tmpfile_test.c | 1 - test/libc/stdio/vappendf_test.c | 5 -- test/libc/str/undeflate_test.c | 1 - test/libc/thread/spawn_test.c | 3 +- third_party/chibicc/chibicc.c | 1 - third_party/chibicc/preprocess.c | 1 - third_party/dlmalloc/dlmalloc.c | 1 - third_party/dlmalloc/statistics.inc | 1 + third_party/make/job.c | 7 --- third_party/mbedtls/rsa.c | 3 +- third_party/mbedtls/test/lib.c | 1 - .../mbedtls/test/test_suite_ctr_drbg.c | 1 - third_party/python/runpythonmodule.c | 9 ++-- tool/build/ar.c | 1 - tool/build/cp.c | 1 - tool/build/mv.c | 1 - tool/build/pledge.c | 3 +- tool/build/printf.c | 1 - tool/build/symtab.c | 1 - tool/build/unveil.c | 1 - tool/decode/ar.c | 3 +- tool/decode/lib/asmcodegen.c | 3 +- tool/lambda/bru2bin.c | 2 +- tool/lambda/lam2bin.c | 2 +- tool/net/lfuncs.c | 7 ++- tool/net/ljson.c | 1 - tool/plinko/lib/plinko.c | 3 +- tool/plinko/plinko.c | 3 -- 114 files changed, 172 insertions(+), 279 deletions(-) create mode 100644 libc/sock/sockatmark.c diff --git a/ape/loader.c b/ape/loader.c index 33088d176..08a736709 100644 --- a/ape/loader.c +++ b/ape/loader.c @@ -379,7 +379,7 @@ __attribute__((__noinline__)) static long Mmap(long addr, long size, int prot, return ax; } -static int MunmapLinux(const void *addr, unsigned long size) { +int MunmapLinux(const void *addr, unsigned long size) { int ax; asm volatile("syscall" : "=a"(ax) @@ -388,7 +388,7 @@ static int MunmapLinux(const void *addr, unsigned long size) { return ax; } -static int PrctlLinux(int op, long a, long b, long c, long d) { +int PrctlLinux(int op, long a, long b, long c, long d) { int rc; asm volatile("mov\t%5,%%r10\n\t" "mov\t%6,%%r8\n\t" diff --git a/examples/cosh.c b/examples/cosh.c index 6fe9bb60d..bf91bc7a1 100644 --- a/examples/cosh.c +++ b/examples/cosh.c @@ -14,7 +14,6 @@ #include "libc/calls/struct/timespec.h" #include "libc/fmt/fmt.h" #include "libc/fmt/itoa.h" -#include "libc/intrin/kprintf.h" #include "libc/log/internal.h" #include "libc/log/log.h" #include "libc/macros.internal.h" diff --git a/examples/forkrand.c b/examples/forkrand.c index 3365eee35..691fdb6b4 100644 --- a/examples/forkrand.c +++ b/examples/forkrand.c @@ -8,14 +8,13 @@ ╚─────────────────────────────────────────────────────────────────*/ #endif #include "libc/calls/calls.h" -#include "libc/intrin/kprintf.h" #include "libc/log/check.h" #include "libc/log/log.h" #include "libc/nt/nt/process.h" -#include "libc/stdio/rand.h" #include "libc/runtime/gc.h" #include "libc/runtime/memtrack.internal.h" #include "libc/runtime/runtime.h" +#include "libc/stdio/rand.h" #include "libc/stdio/stdio.h" #include "libc/time/time.h" #include "libc/x/x.h" diff --git a/examples/rlimit.c b/examples/rlimit.c index 894d2a665..04d0e4796 100644 --- a/examples/rlimit.c +++ b/examples/rlimit.c @@ -12,7 +12,6 @@ #include "libc/calls/struct/rlimit.h" #include "libc/errno.h" #include "libc/intrin/describeflags.internal.h" -#include "libc/intrin/kprintf.h" #include "libc/log/color.internal.h" #include "libc/macros.internal.h" #include "libc/stdio/stdio.h" diff --git a/libc/calls/arememoryintervalsok.c b/libc/calls/arememoryintervalsok.c index bc2731e69..fc3bf76ec 100644 --- a/libc/calls/arememoryintervalsok.c +++ b/libc/calls/arememoryintervalsok.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/strace.internal.h" -#include "libc/intrin/kprintf.h" #include "libc/runtime/memtrack.internal.h" noasan bool AreMemoryIntervalsOk(const struct MemoryIntervals *mm) { diff --git a/libc/calls/copyfile.c b/libc/calls/copyfile.c index e1f034f86..288b716c4 100644 --- a/libc/calls/copyfile.c +++ b/libc/calls/copyfile.c @@ -21,7 +21,6 @@ #include "libc/calls/struct/stat.h" #include "libc/calls/syscall_support-nt.internal.h" #include "libc/dce.h" -#include "libc/intrin/kprintf.h" #include "libc/nt/createfile.h" #include "libc/nt/enum/accessmask.h" #include "libc/nt/enum/creationdisposition.h" diff --git a/libc/calls/directmap.c b/libc/calls/directmap.c index afb1265d3..d2e29ec5c 100644 --- a/libc/calls/directmap.c +++ b/libc/calls/directmap.c @@ -16,17 +16,13 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/likely.h" #include "libc/calls/strace.internal.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/errno.h" #include "libc/intrin/describeflags.internal.h" -#include "libc/intrin/kprintf.h" -#include "libc/intrin/spinlock.h" #include "libc/nt/runtime.h" #include "libc/runtime/directmap.internal.h" #include "libc/runtime/memtrack.internal.h" -#include "libc/str/str.h" /** * Obtains memory mapping directly from system. diff --git a/libc/calls/execve-nt.greg.c b/libc/calls/execve-nt.greg.c index d7c565197..1971c6240 100644 --- a/libc/calls/execve-nt.greg.c +++ b/libc/calls/execve-nt.greg.c @@ -22,7 +22,6 @@ #include "libc/calls/ntspawn.h" #include "libc/calls/strace.internal.h" #include "libc/calls/syscall-nt.internal.h" -#include "libc/intrin/kprintf.h" #include "libc/intrin/weaken.h" #include "libc/mem/alloca.h" #include "libc/nt/accounting.h" diff --git a/libc/calls/execve-sysv.c b/libc/calls/execve-sysv.c index 67e34dcce..38add6742 100644 --- a/libc/calls/execve-sysv.c +++ b/libc/calls/execve-sysv.c @@ -16,13 +16,12 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/bits.h" -#include "libc/intrin/safemacros.internal.h" #include "libc/calls/calls.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/dce.h" #include "libc/errno.h" -#include "libc/intrin/kprintf.h" +#include "libc/intrin/bits.h" +#include "libc/intrin/safemacros.internal.h" #include "libc/mem/alloca.h" #include "libc/paths.h" #include "libc/runtime/runtime.h" diff --git a/libc/calls/fcntl-nt.c b/libc/calls/fcntl-nt.c index 36300cd8e..9ddd29789 100644 --- a/libc/calls/fcntl-nt.c +++ b/libc/calls/fcntl-nt.c @@ -25,7 +25,6 @@ #include "libc/calls/wincrash.internal.h" #include "libc/errno.h" #include "libc/intrin/cmpxchg.h" -#include "libc/intrin/kprintf.h" #include "libc/macros.internal.h" #include "libc/nt/createfile.h" #include "libc/nt/enum/accessmask.h" @@ -117,6 +116,8 @@ textwindows int sys_fcntl_nt(int fd, int cmd, uintptr_t arg) { // O_APPEND doesn't appear to be tunable at cursory glance // O_NONBLOCK might require we start doing all i/o in threads // O_DSYNC / O_RSYNC / O_SYNC maybe if we fsync() everything + // O_DIRECT | O_RANDOM | O_SEQUENTIAL | O_NDELAY possible but + // not worth it. return einval(); } else if (cmd == F_GETFD) { if (g_fds.p[fd].flags & O_CLOEXEC) { diff --git a/libc/calls/fstat-nt.c b/libc/calls/fstat-nt.c index c869fb6d9..1fe589451 100644 --- a/libc/calls/fstat-nt.c +++ b/libc/calls/fstat-nt.c @@ -21,7 +21,6 @@ #include "libc/calls/struct/stat.h" #include "libc/calls/syscall_support-nt.internal.h" #include "libc/fmt/conv.h" -#include "libc/intrin/kprintf.h" #include "libc/macros.internal.h" #include "libc/nexgen32e/bsr.h" #include "libc/nt/enum/fileflagandattributes.h" diff --git a/libc/calls/fstatat.c b/libc/calls/fstatat.c index 0f446bf6d..27958a2b0 100644 --- a/libc/calls/fstatat.c +++ b/libc/calls/fstatat.c @@ -26,7 +26,6 @@ #include "libc/fmt/itoa.h" #include "libc/intrin/asan.internal.h" #include "libc/intrin/describeflags.internal.h" -#include "libc/intrin/kprintf.h" #include "libc/intrin/weaken.h" #include "libc/log/log.h" #include "libc/mem/alloca.h" diff --git a/libc/calls/fstatfs-nt.c b/libc/calls/fstatfs-nt.c index d4b7d1152..0d6e3b5b4 100644 --- a/libc/calls/fstatfs-nt.c +++ b/libc/calls/fstatfs-nt.c @@ -21,7 +21,6 @@ #include "libc/calls/struct/statfs.h" #include "libc/calls/struct/statfs.internal.h" #include "libc/calls/syscall_support-nt.internal.h" -#include "libc/intrin/kprintf.h" #include "libc/limits.h" #include "libc/macros.internal.h" #include "libc/nt/enum/fsinformationclass.h" diff --git a/libc/calls/kill-nt.c b/libc/calls/kill-nt.c index 60f909fc3..818b46e6f 100644 --- a/libc/calls/kill-nt.c +++ b/libc/calls/kill-nt.c @@ -20,7 +20,6 @@ #include "libc/calls/getconsolectrlevent.internal.h" #include "libc/calls/internal.h" #include "libc/dce.h" -#include "libc/intrin/kprintf.h" #include "libc/macros.internal.h" #include "libc/nt/console.h" #include "libc/nt/enum/ctrlevent.h" diff --git a/libc/calls/mkntenvblock.c b/libc/calls/mkntenvblock.c index 0b740ce18..62042bb2f 100644 --- a/libc/calls/mkntenvblock.c +++ b/libc/calls/mkntenvblock.c @@ -16,13 +16,12 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/mem/arraylist2.internal.h" -#include "libc/intrin/bits.h" #include "libc/calls/ntspawn.h" #include "libc/fmt/conv.h" -#include "libc/intrin/kprintf.h" +#include "libc/intrin/bits.h" #include "libc/macros.internal.h" #include "libc/mem/alloca.h" +#include "libc/mem/arraylist2.internal.h" #include "libc/mem/mem.h" #include "libc/str/oldutf16.internal.h" #include "libc/str/str.h" diff --git a/libc/calls/pledge-linux.c b/libc/calls/pledge-linux.c index f5c0ad4b0..2ba7f51c2 100644 --- a/libc/calls/pledge-linux.c +++ b/libc/calls/pledge-linux.c @@ -23,7 +23,6 @@ #include "libc/calls/struct/seccomp.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/syscall_support-sysv.internal.h" -#include "libc/intrin/kprintf.h" #include "libc/intrin/likely.h" #include "libc/intrin/promises.internal.h" #include "libc/macros.internal.h" @@ -58,7 +57,7 @@ #define SPECIAL 0xf000 #define SELF 0x8000 #define ADDRLESS 0x2000 -#define INET 0x8000 +#define INET 0x2000 #define LOCK 0x4000 #define NOEXEC 0x8000 #define EXEC 0x4000 @@ -440,7 +439,7 @@ static const uint16_t kPledgeDefault[] = { __NR_linux_exit, // thread return / exit() }; -// the stdio contains all the benign system calls. openbsd makes the +// stdio contains all the benign system calls. openbsd makes the // assumption that preexisting file descriptors are trustworthy. we // implement checking for these as a simple linear scan rather than // binary search, since there doesn't appear to be any measurable @@ -645,6 +644,7 @@ static const uint16_t kPledgeInet[] = { __NR_linux_connect, // __NR_linux_accept, // __NR_linux_accept4, // + __NR_linux_ioctl | INET, // __NR_linux_getsockopt | RESTRICT, // __NR_linux_setsockopt | RESTRICT, // __NR_linux_getpeername, // @@ -1178,6 +1178,22 @@ static privileged void AllowIoctlStdio(struct Filter *f) { AppendFilter(f, PLEDGE(fragment)); } +// The second argument of ioctl() must be one of: +// +// - SIOCATMARK (0x8905) +// +static privileged void AllowIoctlInet(struct Filter *f) { + static const struct sock_filter fragment[] = { + /*L0*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_linux_ioctl, 0, 4), + /*L1*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(args[1])), + /*L5*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0x8905, 0, 1), + /*L6*/ BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW), + /*L7*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(nr)), + /*L8*/ /* next filter */ + }; + AppendFilter(f, PLEDGE(fragment)); +} + // The second argument of ioctl() must be one of: // // - TCGETS (0x5401) @@ -1908,6 +1924,9 @@ static privileged void AppendPledge(struct Filter *f, // case __NR_linux_ioctl | TTY: AllowIoctlTty(f); break; + case __NR_linux_ioctl | INET: + AllowIoctlInet(f); + break; case __NR_linux_socket | INET: AllowSocketInet(f); break; diff --git a/libc/calls/poll-nt.c b/libc/calls/poll-nt.c index 34ff5669f..abb2d7770 100644 --- a/libc/calls/poll-nt.c +++ b/libc/calls/poll-nt.c @@ -24,7 +24,6 @@ #include "libc/calls/struct/sigaction.h" #include "libc/errno.h" #include "libc/intrin/bits.h" -#include "libc/intrin/kprintf.h" #include "libc/intrin/spinlock.h" #include "libc/intrin/weaken.h" #include "libc/macros.internal.h" diff --git a/libc/calls/raise.c b/libc/calls/raise.c index 81705058d..54665886e 100644 --- a/libc/calls/raise.c +++ b/libc/calls/raise.c @@ -23,7 +23,6 @@ #include "libc/calls/struct/sigset.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/calls/syscall_support-nt.internal.h" -#include "libc/intrin/kprintf.h" #include "libc/nt/console.h" #include "libc/nt/errors.h" #include "libc/nt/process.h" diff --git a/libc/calls/read.c b/libc/calls/read.c index c09023c64..2108b4d3f 100644 --- a/libc/calls/read.c +++ b/libc/calls/read.c @@ -24,7 +24,6 @@ #include "libc/calls/syscall-sysv.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" -#include "libc/intrin/kprintf.h" #include "libc/intrin/weaken.h" #include "libc/sock/internal.h" #include "libc/sock/sock.h" diff --git a/libc/calls/setitimer-nt.c b/libc/calls/setitimer-nt.c index 882e8369b..eab41d87b 100644 --- a/libc/calls/setitimer-nt.c +++ b/libc/calls/setitimer-nt.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" -#include "libc/intrin/bits.h" #include "libc/calls/calls.h" #include "libc/calls/sig.internal.h" #include "libc/calls/strace.internal.h" @@ -26,7 +25,7 @@ #include "libc/dce.h" #include "libc/errno.h" #include "libc/fmt/conv.h" -#include "libc/intrin/kprintf.h" +#include "libc/intrin/bits.h" #include "libc/log/check.h" #include "libc/math.h" #include "libc/nexgen32e/nexgen32e.h" diff --git a/libc/calls/sigenter-freebsd.c b/libc/calls/sigenter-freebsd.c index fce6e3af2..20e6b4a39 100644 --- a/libc/calls/sigenter-freebsd.c +++ b/libc/calls/sigenter-freebsd.c @@ -25,7 +25,6 @@ #include "libc/calls/struct/siginfo.h" #include "libc/calls/struct/ucontext-freebsd.internal.h" #include "libc/calls/ucontext.h" -#include "libc/intrin/kprintf.h" #include "libc/log/libfatal.internal.h" #include "libc/macros.internal.h" #include "libc/runtime/runtime.h" diff --git a/libc/calls/sigenter-xnu.c b/libc/calls/sigenter-xnu.c index c60ea522b..82d5e716a 100644 --- a/libc/calls/sigenter-xnu.c +++ b/libc/calls/sigenter-xnu.c @@ -24,7 +24,6 @@ #include "libc/calls/struct/siginfo-xnu.internal.h" #include "libc/calls/struct/siginfo.h" #include "libc/calls/ucontext.h" -#include "libc/intrin/kprintf.h" #include "libc/intrin/repstosb.h" #include "libc/log/libfatal.internal.h" #include "libc/runtime/runtime.h" diff --git a/libc/calls/syscall-sysv.internal.h b/libc/calls/syscall-sysv.internal.h index 387116b1d..3a400d7ed 100644 --- a/libc/calls/syscall-sysv.internal.h +++ b/libc/calls/syscall-sysv.internal.h @@ -61,7 +61,6 @@ i32 sys_ioctl(i32, u64, ...) hidden; i32 sys_issetugid(void) hidden; i32 sys_kill(i32, i32, i32) hidden; i32 sys_linkat(i32, const char *, i32, const char *, i32) hidden; -i64 sys_lseek(i32, i64, i64, i64) hidden; i32 sys_madvise(void *, size_t, i32) hidden; i32 sys_memfd_create(const char *, u32) hidden; i32 sys_mincore(void *, u64, unsigned char *) hidden; @@ -101,12 +100,14 @@ i32 sys_tgkill(i32, i32, i32) hidden; i32 sys_tkill(i32, i32, void *) hidden; i32 sys_truncate(const char *, u64, u64) hidden; i32 sys_uname(void *) hidden; +i32 sys_unlink(const char *) hidden; i32 sys_unlinkat(i32, const char *, i32) hidden; i32 sys_unmount(const char *, i32) hidden; i32 sys_unveil(const char *, const char *) hidden; i64 __sys_ptrace(i32, i32, i64, long *) hidden; i64 sys_copy_file_range(i32, long *, i32, long *, u64, u32) hidden; i64 sys_getrandom(void *, u64, u32) hidden; +i64 sys_lseek(i32, i64, i64, i64) hidden; i64 sys_pread(i32, void *, u64, i64, i64) hidden; i64 sys_pwrite(i32, const void *, u64, i64, i64) hidden; i64 sys_read(i32, void *, u64) hidden; diff --git a/libc/calls/tkill.c b/libc/calls/tkill.c index 0d20432de..845f2b0ad 100644 --- a/libc/calls/tkill.c +++ b/libc/calls/tkill.c @@ -21,7 +21,6 @@ #include "libc/calls/syscall-sysv.internal.h" #include "libc/calls/syscall_support-nt.internal.h" #include "libc/dce.h" -#include "libc/intrin/kprintf.h" #include "libc/nt/enum/threadaccess.h" #include "libc/nt/runtime.h" #include "libc/nt/thread.h" diff --git a/libc/calls/ttyname_r.c b/libc/calls/ttyname_r.c index 900895c48..278119a14 100644 --- a/libc/calls/ttyname_r.c +++ b/libc/calls/ttyname_r.c @@ -26,7 +26,6 @@ #include "libc/errno.h" #include "libc/fmt/fmt.h" #include "libc/fmt/itoa.h" -#include "libc/intrin/kprintf.h" #include "libc/log/log.h" #include "libc/nt/console.h" #include "libc/nt/enum/consolemodeflags.h" diff --git a/libc/calls/unveil.c b/libc/calls/unveil.c index f76dc8212..759ad3db8 100644 --- a/libc/calls/unveil.c +++ b/libc/calls/unveil.c @@ -29,7 +29,6 @@ #include "libc/calls/syscall_support-sysv.internal.h" #include "libc/errno.h" #include "libc/fmt/conv.h" -#include "libc/intrin/kprintf.h" #include "libc/macros.internal.h" #include "libc/nexgen32e/threaded.h" #include "libc/runtime/internal.h" diff --git a/libc/calls/vdsofunc.greg.c b/libc/calls/vdsofunc.greg.c index 44828984e..9a988e138 100644 --- a/libc/calls/vdsofunc.greg.c +++ b/libc/calls/vdsofunc.greg.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/bits.h" #include "libc/calls/calls.h" #include "libc/calls/strace.internal.h" #include "libc/elf/scalar.h" @@ -26,7 +25,7 @@ #include "libc/elf/struct/sym.h" #include "libc/elf/struct/verdaux.h" #include "libc/elf/struct/verdef.h" -#include "libc/intrin/kprintf.h" +#include "libc/intrin/bits.h" #include "libc/runtime/runtime.h" #include "libc/sysv/consts/auxv.h" diff --git a/libc/calls/wait4-nt.c b/libc/calls/wait4-nt.c index 20b08eee2..bd3a9ba45 100644 --- a/libc/calls/wait4-nt.c +++ b/libc/calls/wait4-nt.c @@ -25,7 +25,6 @@ #include "libc/calls/struct/rusage.h" #include "libc/calls/syscall_support-nt.internal.h" #include "libc/fmt/conv.h" -#include "libc/intrin/kprintf.h" #include "libc/intrin/spinlock.h" #include "libc/macros.internal.h" #include "libc/nt/accounting.h" diff --git a/libc/elf/checkelfaddress.c b/libc/elf/checkelfaddress.c index 12e38520c..e336c8b33 100644 --- a/libc/elf/checkelfaddress.c +++ b/libc/elf/checkelfaddress.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/elf/elf.h" -#include "libc/intrin/kprintf.h" #include "libc/runtime/runtime.h" void CheckElfAddress(const Elf64_Ehdr *elf, size_t mapsize, intptr_t addr, diff --git a/libc/intrin/describeflags.c b/libc/intrin/describeflags.c index 09089d540..84bf670c3 100644 --- a/libc/intrin/describeflags.c +++ b/libc/intrin/describeflags.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/intrin/describeflags.internal.h" -#include "libc/intrin/kprintf.h" // TODO(jart): Fork this function into ASAN and non-ASAN versions. const char *DescribeFlags(char *p, size_t n, struct DescribeFlags *d, size_t m, diff --git a/libc/intrin/describentfileflagattr.c b/libc/intrin/describentfileflagattr.c index 5b1517b2f..d86d35ac4 100644 --- a/libc/intrin/describentfileflagattr.c +++ b/libc/intrin/describentfileflagattr.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/intrin/describeflags.internal.h" -#include "libc/intrin/kprintf.h" #include "libc/macros.internal.h" #include "libc/nt/enum/fileflagandattributes.h" #include "libc/runtime/runtime.h" diff --git a/libc/intrin/exit1.greg.c b/libc/intrin/exit1.greg.c index 7dc596e27..a63877462 100644 --- a/libc/intrin/exit1.greg.c +++ b/libc/intrin/exit1.greg.c @@ -18,7 +18,6 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/strace.internal.h" #include "libc/dce.h" -#include "libc/intrin/kprintf.h" #include "libc/intrin/promises.internal.h" #include "libc/nt/thread.h" #include "libc/runtime/runtime.h" diff --git a/libc/intrin/getenv.greg.c b/libc/intrin/getenv.greg.c index c4039bd6b..800db2808 100644 --- a/libc/intrin/getenv.greg.c +++ b/libc/intrin/getenv.greg.c @@ -20,7 +20,6 @@ #include "libc/calls/strace.internal.h" #include "libc/dce.h" #include "libc/errno.h" -#include "libc/intrin/kprintf.h" #include "libc/log/libfatal.internal.h" #include "libc/runtime/runtime.h" diff --git a/libc/intrin/pthread_mutex_unlock.c b/libc/intrin/pthread_mutex_unlock.c index 3a82fa163..2f03a4464 100644 --- a/libc/intrin/pthread_mutex_unlock.c +++ b/libc/intrin/pthread_mutex_unlock.c @@ -17,11 +17,10 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" -#include "libc/intrin/atomic.h" #include "libc/calls/calls.h" #include "libc/dce.h" #include "libc/errno.h" -#include "libc/intrin/kprintf.h" +#include "libc/intrin/atomic.h" #include "libc/intrin/pthread.h" /** diff --git a/libc/intrin/spinlock.h b/libc/intrin/spinlock.h index 8ac51a226..58d666b76 100644 --- a/libc/intrin/spinlock.h +++ b/libc/intrin/spinlock.h @@ -2,10 +2,6 @@ #define COSMOPOLITAN_LIBC_INTRIN_SPINLOCK_H_ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -/*───────────────────────────────────────────────────────────────────────────│─╗ -│ cosmopolitan § spinlocks ─╬─│┼ -╚────────────────────────────────────────────────────────────────────────────│─╝ - fast tiny inline synchronization routines */ #ifdef TINY #define _spinlock(lock) _spinlock_tiny(lock) @@ -31,24 +27,6 @@ COSMOPOLITAN_C_START_ }) #define _spinlock_cooperative(lock) \ - ({ \ - char __x; \ - unsigned __tries = 0; \ - char *__lock = (lock); \ - for (;;) { \ - __atomic_load(__lock, &__x, __ATOMIC_RELAXED); \ - if (!__x && !_trylock(__lock)) { \ - break; \ - } else if (++__tries & 7) { \ - __builtin_ia32_pause(); \ - } else { \ - _spinlock_yield(); \ - } \ - } \ - 0; \ - }) - -#define _spinlock_cooperative_(lock) \ ({ \ char __x; \ volatile int __i; \ diff --git a/libc/intrin/wsawaitformultipleevents.c b/libc/intrin/wsawaitformultipleevents.c index 879625683..c578ff0fe 100644 --- a/libc/intrin/wsawaitformultipleevents.c +++ b/libc/intrin/wsawaitformultipleevents.c @@ -19,7 +19,6 @@ #include "libc/calls/strace.internal.h" #include "libc/calls/syscall_support-nt.internal.h" #include "libc/intrin/describeflags.internal.h" -#include "libc/intrin/kprintf.h" #include "libc/nt/thunk/msabi.h" #include "libc/nt/winsock.h" diff --git a/libc/log/attachdebugger.c b/libc/log/attachdebugger.c index 37117f9f4..454dd53c1 100644 --- a/libc/log/attachdebugger.c +++ b/libc/log/attachdebugger.c @@ -16,10 +16,10 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/safemacros.internal.h" #include "libc/calls/calls.h" #include "libc/fmt/fmt.h" #include "libc/intrin/kprintf.h" +#include "libc/intrin/safemacros.internal.h" #include "libc/log/color.internal.h" #include "libc/log/gdb.h" #include "libc/log/internal.h" diff --git a/libc/log/startfatal.c b/libc/log/startfatal.c index 0b88985d8..3fe945c48 100644 --- a/libc/log/startfatal.c +++ b/libc/log/startfatal.c @@ -16,9 +16,8 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/safemacros.internal.h" #include "libc/intrin/kprintf.h" -#include "libc/log/color.internal.h" +#include "libc/intrin/safemacros.internal.h" #include "libc/log/internal.h" #include "libc/runtime/runtime.h" diff --git a/libc/runtime/enable_tls.c b/libc/runtime/enable_tls.c index 7fb3768df..f16f8793f 100644 --- a/libc/runtime/enable_tls.c +++ b/libc/runtime/enable_tls.c @@ -17,14 +17,13 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" -#include "libc/intrin/bits.h" -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/strace.internal.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/dce.h" #include "libc/errno.h" -#include "libc/intrin/kprintf.h" +#include "libc/intrin/bits.h" +#include "libc/intrin/weaken.h" #include "libc/log/libfatal.internal.h" #include "libc/macros.internal.h" #include "libc/nexgen32e/msr.h" diff --git a/libc/runtime/hook.greg.c b/libc/runtime/hook.greg.c index a80df3168..c68cbb904 100644 --- a/libc/runtime/hook.greg.c +++ b/libc/runtime/hook.greg.c @@ -16,12 +16,11 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/bits.h" #include "libc/calls/calls.h" #include "libc/calls/struct/sigset.h" #include "libc/dce.h" #include "libc/errno.h" -#include "libc/intrin/kprintf.h" +#include "libc/intrin/bits.h" #include "libc/log/libfatal.internal.h" #include "libc/runtime/runtime.h" #include "libc/runtime/symbols.internal.h" diff --git a/libc/runtime/mmap.c b/libc/runtime/mmap.c index 1e07db63d..97b00ec93 100644 --- a/libc/runtime/mmap.c +++ b/libc/runtime/mmap.c @@ -17,10 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" -#include "libc/intrin/bits.h" -#include "libc/intrin/likely.h" -#include "libc/intrin/safemacros.internal.h" -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" @@ -29,10 +25,13 @@ #include "libc/errno.h" #include "libc/intrin/asan.internal.h" #include "libc/intrin/asancodes.h" +#include "libc/intrin/bits.h" #include "libc/intrin/describeflags.internal.h" -#include "libc/intrin/kprintf.h" +#include "libc/intrin/likely.h" #include "libc/intrin/pthread.h" +#include "libc/intrin/safemacros.internal.h" #include "libc/intrin/spinlock.h" +#include "libc/intrin/weaken.h" #include "libc/limits.h" #include "libc/log/backtrace.internal.h" #include "libc/log/libfatal.internal.h" @@ -41,11 +40,11 @@ #include "libc/nt/process.h" #include "libc/nt/runtime.h" #include "libc/nt/struct/processmemorycounters.h" -#include "libc/stdio/rand.h" #include "libc/runtime/directmap.internal.h" #include "libc/runtime/internal.h" #include "libc/runtime/memtrack.internal.h" #include "libc/runtime/runtime.h" +#include "libc/stdio/rand.h" #include "libc/str/str.h" #include "libc/sysv/consts/map.h" #include "libc/sysv/consts/o.h" diff --git a/libc/runtime/mprotect.c b/libc/runtime/mprotect.c index e9a911d20..39dfe6c82 100644 --- a/libc/runtime/mprotect.c +++ b/libc/runtime/mprotect.c @@ -16,17 +16,14 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/likely.h" #include "libc/calls/strace.internal.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/dce.h" #include "libc/errno.h" #include "libc/intrin/describeflags.internal.h" -#include "libc/intrin/kprintf.h" +#include "libc/intrin/likely.h" #include "libc/runtime/internal.h" -#include "libc/runtime/runtime.h" #include "libc/sysv/consts/prot.h" -#include "libc/sysv/errfuns.h" /** * Modifies restrictions on virtual memory address range. diff --git a/libc/runtime/munmap.c b/libc/runtime/munmap.c index 27e47588f..a42b300e6 100644 --- a/libc/runtime/munmap.c +++ b/libc/runtime/munmap.c @@ -17,16 +17,15 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" -#include "libc/intrin/likely.h" -#include "libc/intrin/weaken.h" #include "libc/calls/state.internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/dce.h" #include "libc/errno.h" #include "libc/intrin/asan.internal.h" -#include "libc/intrin/kprintf.h" +#include "libc/intrin/likely.h" #include "libc/intrin/spinlock.h" +#include "libc/intrin/weaken.h" #include "libc/log/backtrace.internal.h" #include "libc/log/libfatal.internal.h" #include "libc/log/log.h" diff --git a/libc/runtime/opensymboltable.greg.c b/libc/runtime/opensymboltable.greg.c index 0ab75a744..b0d6ffe73 100644 --- a/libc/runtime/opensymboltable.greg.c +++ b/libc/runtime/opensymboltable.greg.c @@ -16,9 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/mem/alg.h" #include "libc/assert.h" -#include "libc/intrin/bits.h" #include "libc/calls/calls.h" #include "libc/calls/strace.internal.h" #include "libc/dce.h" @@ -28,10 +26,11 @@ #include "libc/elf/struct/shdr.h" #include "libc/elf/struct/sym.h" #include "libc/errno.h" -#include "libc/intrin/kprintf.h" +#include "libc/intrin/bits.h" #include "libc/limits.h" #include "libc/log/libfatal.internal.h" #include "libc/macros.internal.h" +#include "libc/mem/alg.h" #include "libc/runtime/internal.h" #include "libc/runtime/runtime.h" #include "libc/runtime/symbols.internal.h" diff --git a/libc/runtime/stackuse.c b/libc/runtime/stackuse.c index 4e2557bd9..8b8217f4f 100644 --- a/libc/runtime/stackuse.c +++ b/libc/runtime/stackuse.c @@ -16,11 +16,10 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/atomic.h" #include "libc/calls/calls.h" #include "libc/dce.h" #include "libc/fmt/itoa.h" -#include "libc/intrin/kprintf.h" +#include "libc/intrin/atomic.h" #include "libc/intrin/promises.internal.h" #include "libc/runtime/runtime.h" #include "libc/runtime/stack.h" diff --git a/libc/runtime/winmain.greg.c b/libc/runtime/winmain.greg.c index 7836d27cc..ae5f027a1 100644 --- a/libc/runtime/winmain.greg.c +++ b/libc/runtime/winmain.greg.c @@ -16,9 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/bits.h" -#include "libc/intrin/pushpop.h" -#include "libc/intrin/weaken.h" #include "libc/calls/state.internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/syscall_support-nt.internal.h" @@ -26,9 +23,11 @@ #include "libc/elf/pf2prot.internal.h" #include "libc/errno.h" #include "libc/fmt/fmt.h" +#include "libc/intrin/bits.h" #include "libc/intrin/describeflags.internal.h" -#include "libc/intrin/kprintf.h" #include "libc/intrin/nomultics.internal.h" +#include "libc/intrin/pushpop.h" +#include "libc/intrin/weaken.h" #include "libc/log/libfatal.internal.h" #include "libc/macros.internal.h" #include "libc/nexgen32e/bsr.h" diff --git a/libc/sock/closesocket-nt.c b/libc/sock/closesocket-nt.c index 1ea05fc9a..56d644400 100644 --- a/libc/sock/closesocket-nt.c +++ b/libc/sock/closesocket-nt.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/intrin/weaken.h" -#include "libc/intrin/kprintf.h" #include "libc/log/backtrace.internal.h" #include "libc/mem/mem.h" #include "libc/sock/internal.h" diff --git a/libc/sock/connect.c b/libc/sock/connect.c index 2395ce371..c5714b7a0 100644 --- a/libc/sock/connect.c +++ b/libc/sock/connect.c @@ -20,7 +20,6 @@ #include "libc/calls/strace.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" -#include "libc/intrin/kprintf.h" #include "libc/sock/internal.h" #include "libc/sock/sock.h" #include "libc/sock/struct/sockaddr.internal.h" diff --git a/libc/sock/recv-nt.c b/libc/sock/recv-nt.c index 1d62eaaa5..20f17ca09 100644 --- a/libc/sock/recv-nt.c +++ b/libc/sock/recv-nt.c @@ -20,7 +20,6 @@ #include "libc/calls/strace.internal.h" #include "libc/calls/struct/iovec.h" #include "libc/errno.h" -#include "libc/intrin/kprintf.h" #include "libc/intrin/likely.h" #include "libc/nt/struct/overlapped.h" #include "libc/nt/winsock.h" diff --git a/libc/sock/sendfile.c b/libc/sock/sendfile.c index ac3910b17..2a1350a33 100644 --- a/libc/sock/sendfile.c +++ b/libc/sock/sendfile.c @@ -23,7 +23,6 @@ #include "libc/calls/syscall-sysv.internal.h" #include "libc/calls/syscall_support-nt.internal.h" #include "libc/dce.h" -#include "libc/intrin/kprintf.h" #include "libc/intrin/safemacros.internal.h" #include "libc/nt/enum/wait.h" #include "libc/nt/errors.h" diff --git a/libc/sock/sock.h b/libc/sock/sock.h index f07ad3af9..dcb753ca5 100644 --- a/libc/sock/sock.h +++ b/libc/sock/sock.h @@ -40,6 +40,7 @@ int getsockopt(int, int, int, void *, uint32_t *); int setsockopt(int, int, int, const void *, uint32_t); int socketpair(int, int, int, int[2]); ssize_t sendto(int, const void *, size_t, uint32_t, const void *, uint32_t); +int sockatmark(int); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/sock/sockaddr2linux.c b/libc/sock/sockaddr2linux.c index 91fed584d..143b858c9 100644 --- a/libc/sock/sockaddr2linux.c +++ b/libc/sock/sockaddr2linux.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/kprintf.h" #include "libc/macros.internal.h" #include "libc/sock/internal.h" #include "libc/sock/struct/sockaddr.internal.h" diff --git a/libc/sock/sockatmark.c b/libc/sock/sockatmark.c new file mode 100644 index 000000000..a7e022cbd --- /dev/null +++ b/libc/sock/sockatmark.c @@ -0,0 +1,52 @@ +/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ +│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ +╞══════════════════════════════════════════════════════════════════════════════╡ +│ Copyright 2022 Justine Alexandra Roberts Tunney │ +│ │ +│ Permission to use, copy, modify, and/or distribute this software for │ +│ any purpose with or without fee is hereby granted, provided that the │ +│ above copyright notice and this permission notice appear in all copies. │ +│ │ +│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ +│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ +│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ +│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ +│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ +│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ +│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ +│ PERFORMANCE OF THIS SOFTWARE. │ +╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/calls/strace.internal.h" +#include "libc/calls/syscall-sysv.internal.h" +#include "libc/dce.h" +#include "libc/nt/winsock.h" +#include "libc/sock/sock.h" +#include "libc/sysv/consts/sio.h" + +static textwindows int sockatmark_nt(int64_t fd) { + bool32 res; + uint32_t bytes; + if (WSAIoctl(fd, SIOCATMARK, 0, 0, &res, sizeof(res), &bytes, 0, 0) != -1) { + return !res; + } else { + return -1; + } +} + +/** + * Returns true if out of band data is available on socket for reading. + * + * @return 1 if OOB'd, 0 if not, or -1 w/ errno + */ +int sockatmark(int fd) { + int rc; + if (!IsWindows()) { + if (sys_ioctl(fd, SIOCATMARK, &rc) == -1) { + rc = -1; + } + } else { + rc = sockatmark_nt(fd); + } + STRACE("sockatmark(%d) → %d% m", fd, rc); + return rc; +} diff --git a/libc/stdio/fgets_unlocked.c b/libc/stdio/fgets_unlocked.c index de4c94ef8..026ccd7f5 100644 --- a/libc/stdio/fgets_unlocked.c +++ b/libc/stdio/fgets_unlocked.c @@ -18,7 +18,6 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/dce.h" #include "libc/errno.h" -#include "libc/intrin/kprintf.h" #include "libc/macros.internal.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" diff --git a/libc/sysv/consts.sh b/libc/sysv/consts.sh index 47c578cb2..f0f790521 100755 --- a/libc/sysv/consts.sh +++ b/libc/sysv/consts.sh @@ -951,8 +951,11 @@ syscon iproto IPPROTO_BEETPH 94 -1 -1 -1 -1 -1 syscon iproto IPPROTO_COMP 108 -1 -1 -1 -1 -1 syscon iproto IPPROTO_DCCP 33 -1 -1 -1 -1 -1 +# socket ioctl() +# +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary +syscon sio SIOCATMARK 0x8905 0x40047307 0x40047307 0x40047307 0x40047307 0x40047307 # use sockatmark(); determines if oob is available; bsd consensus syscon sio SIOCADDMULTI 0x8931 0x80206931 0x80206931 0x80206931 0x80206931 0 # bsd consensus -syscon sio SIOCATMARK 0x8905 0x40047307 0x40047307 0x40047307 0x40047307 0 # bsd consensus syscon sio SIOCDELMULTI 0x8932 0x80206932 0x80206932 0x80206932 0x80206932 0 # bsd consensus syscon sio SIOCDIFADDR 0x8936 0x80206919 0x80206919 0x80206919 0x80206919 0 # bsd consensus syscon sio SIOCGIFADDR 0x8915 0xc0206921 0xc0206921 0xc0206921 0xc0206921 0 # bsd consensus diff --git a/libc/sysv/consts/SIOCATMARK.s b/libc/sysv/consts/SIOCATMARK.s index 8a5e9ca06..a6ad4fe05 100644 --- a/libc/sysv/consts/SIOCATMARK.s +++ b/libc/sysv/consts/SIOCATMARK.s @@ -1,2 +1,2 @@ .include "o/libc/sysv/consts/syscon.internal.inc" -.syscon sio,SIOCATMARK,0x8905,0x40047307,0x40047307,0x40047307,0x40047307,0 +.syscon sio,SIOCATMARK,0x8905,0x40047307,0x40047307,0x40047307,0x40047307,0x40047307 diff --git a/libc/testlib/runner.c b/libc/testlib/runner.c index 868a4e633..e21ef413c 100644 --- a/libc/testlib/runner.c +++ b/libc/testlib/runner.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/intrin/kprintf.h" #include "libc/log/log.h" #include "libc/nexgen32e/nexgen32e.h" #include "libc/runtime/runtime.h" diff --git a/libc/testlib/testmain.c b/libc/testlib/testmain.c index 4eed3f7fa..af8ed85fa 100644 --- a/libc/testlib/testmain.c +++ b/libc/testlib/testmain.c @@ -26,7 +26,6 @@ #include "libc/errno.h" #include "libc/intrin/asan.internal.h" #include "libc/intrin/bits.h" -#include "libc/intrin/kprintf.h" #include "libc/intrin/safemacros.internal.h" #include "libc/intrin/weaken.h" #include "libc/log/check.h" diff --git a/libc/zipos/open.c b/libc/zipos/open.c index b889b6a50..3a879cea8 100644 --- a/libc/zipos/open.c +++ b/libc/zipos/open.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" -#include "libc/intrin/atomic.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/state.internal.h" @@ -26,8 +25,8 @@ #include "libc/dce.h" #include "libc/errno.h" #include "libc/intrin/asan.internal.h" +#include "libc/intrin/atomic.h" #include "libc/intrin/cmpxchg.h" -#include "libc/intrin/kprintf.h" #include "libc/intrin/lockcmpxchg.h" #include "libc/intrin/spinlock.h" #include "libc/nexgen32e/crc32.h" diff --git a/test/libc/calls/_timespec_test.c b/test/libc/calls/_timespec_test.c index 0a0b43dde..4f5887609 100644 --- a/test/libc/calls/_timespec_test.c +++ b/test/libc/calls/_timespec_test.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/struct/timespec.h" -#include "libc/intrin/kprintf.h" #include "libc/stdio/rand.h" #include "libc/testlib/testlib.h" diff --git a/test/libc/calls/clock_getres_test.c b/test/libc/calls/clock_getres_test.c index 34d055b3d..4aace707c 100644 --- a/test/libc/calls/clock_getres_test.c +++ b/test/libc/calls/clock_getres_test.c @@ -18,7 +18,6 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/calls/struct/timespec.h" -#include "libc/intrin/kprintf.h" #include "libc/runtime/runtime.h" #include "libc/sysv/consts/clock.h" #include "libc/testlib/testlib.h" diff --git a/test/libc/calls/fcntl_test.c b/test/libc/calls/fcntl_test.c index 1489fcce3..e4c4a4ce6 100644 --- a/test/libc/calls/fcntl_test.c +++ b/test/libc/calls/fcntl_test.c @@ -45,22 +45,20 @@ TEST(fcntl_getfl, testRemembersAccessMode) { } TEST(fcntl_setfl, testChangeAppendStatus) { - if (IsWindows()) { - // no obvious way to do fcntl(fd, F_SETFL, O_APPEND) - return; - } - int fd; + if (IsWindows()) return; // Can't ReOpenFile() w/ O_APPEND char buf[8] = {0}; - ASSERT_NE(-1, (fd = open("foo", O_CREAT | O_RDWR, 0644))); - EXPECT_EQ(3, write(fd, "foo", 3)); - EXPECT_NE(-1, lseek(fd, 0, SEEK_SET)); - EXPECT_NE(-1, fcntl(fd, F_SETFL, O_APPEND)); - EXPECT_EQ(3, write(fd, "bar", 3)); - EXPECT_NE(-1, lseek(fd, 0, SEEK_SET)); - EXPECT_NE(-1, fcntl(fd, F_SETFL, 0)); - EXPECT_EQ(6, read(fd, buf, 6)); + ASSERT_SYS(0, 3, open("foo", O_CREAT | O_WRONLY, 0644)); + EXPECT_SYS(0, 3, write(3, "foo", 3)); + EXPECT_SYS(0, 0, lseek(3, 0, SEEK_SET)); + EXPECT_SYS(0, 0, fcntl(3, F_SETFL, O_APPEND)); + EXPECT_SYS(0, 3, write(3, "bar", 3)); + EXPECT_SYS(0, 0, lseek(3, 0, SEEK_SET)); + EXPECT_SYS(0, 0, fcntl(3, F_SETFL, 0)); + EXPECT_SYS(0, 0, close(3)); + ASSERT_SYS(0, 3, open("foo", 0)); + EXPECT_SYS(0, 6, read(3, buf, 6)); EXPECT_STREQ("foobar", buf); - EXPECT_NE(-1, close(fd)); + EXPECT_SYS(0, 0, close(3)); } TEST(fcntl, getfd) { diff --git a/test/libc/calls/nanosleep_test.c b/test/libc/calls/nanosleep_test.c index d7f15d4d2..369a259f3 100644 --- a/test/libc/calls/nanosleep_test.c +++ b/test/libc/calls/nanosleep_test.c @@ -22,7 +22,6 @@ #include "libc/calls/struct/timespec.h" #include "libc/errno.h" #include "libc/intrin/describeflags.internal.h" -#include "libc/intrin/kprintf.h" #include "libc/sysv/consts/itimer.h" #include "libc/sysv/consts/sa.h" #include "libc/sysv/consts/sig.h" diff --git a/test/libc/calls/open_test.c b/test/libc/calls/open_test.c index 5bd30ab4b..4d5b9df89 100644 --- a/test/libc/calls/open_test.c +++ b/test/libc/calls/open_test.c @@ -19,7 +19,6 @@ #include "libc/calls/internal.h" #include "libc/dce.h" #include "libc/errno.h" -#include "libc/intrin/kprintf.h" #include "libc/macros.internal.h" #include "libc/runtime/gc.internal.h" #include "libc/str/str.h" @@ -107,14 +106,16 @@ TEST(open, testOpenExistingForReadWrite_seeksToStart) { } TEST(open, testOpenExistingForAppendWriteOnly_seeksToEnd) { - char buf[8] = {0}; + char buf[16] = {0}; ASSERT_SYS(0, 0, xbarf("hello.txt", "hell", -1)); ASSERT_SYS(0, 3, open("hello.txt", O_WRONLY | O_APPEND)); EXPECT_SYS(0, 1, write(3, "o", 1)); + EXPECT_SYS(0, 0, lseek(3, 0, SEEK_SET)); + EXPECT_SYS(0, 1, write(3, "!", 1)); EXPECT_SYS(0, 0, close(3)); ASSERT_SYS(0, 3, open("hello.txt", O_RDONLY)); - EXPECT_SYS(0, 5, read(3, buf, 7)); - EXPECT_STREQ("hello", buf); + EXPECT_SYS(0, 6, read(3, buf, 8)); + EXPECT_STREQ("hello!", buf); EXPECT_SYS(0, 0, close(3)); } diff --git a/test/libc/calls/pledge2_test.c b/test/libc/calls/pledge2_test.c index 1d5b35b0e..a5a1bfe79 100644 --- a/test/libc/calls/pledge2_test.c +++ b/test/libc/calls/pledge2_test.c @@ -22,7 +22,6 @@ #include "libc/calls/syscall_support-sysv.internal.h" #include "libc/dce.h" #include "libc/errno.h" -#include "libc/intrin/kprintf.h" #include "libc/intrin/promises.internal.h" #include "libc/runtime/runtime.h" #include "libc/sock/sock.h" diff --git a/test/libc/calls/pledge_test.c b/test/libc/calls/pledge_test.c index 1b5a910af..b037d50f8 100644 --- a/test/libc/calls/pledge_test.c +++ b/test/libc/calls/pledge_test.c @@ -29,7 +29,6 @@ #include "libc/calls/syscall_support-sysv.internal.h" #include "libc/dce.h" #include "libc/errno.h" -#include "libc/intrin/kprintf.h" #include "libc/macros.internal.h" #include "libc/mem/io.h" #include "libc/mem/mem.h" @@ -37,6 +36,7 @@ #include "libc/runtime/runtime.h" #include "libc/sock/sock.h" #include "libc/sock/struct/sockaddr.h" +#include "libc/stdio/lock.h" #include "libc/stdio/stdio.h" #include "libc/sysv/consts/af.h" #include "libc/sysv/consts/at.h" @@ -110,7 +110,6 @@ TEST(pledge, default_allowsExit) { EXPECT_SYS(0, 0, munmap(job, FRAMESIZE)); } -#if 0 TEST(pledge, execpromises_notok) { if (IsOpenbsd()) return; // b/c testing linux bpf int ws, pid; @@ -167,7 +166,7 @@ TEST(pledge, stdio_forbidsOpeningPasswd2) { } EXPECT_NE(-1, wait(&ws)); EXPECT_TRUE(WIFSIGNALED(ws)); - EXPECT_EQ(SIGABRT, WTERMSIG(ws)); + EXPECT_EQ(IsOpenbsd() ? SIGABRT : SIGSYS, WTERMSIG(ws)); } TEST(pledge, multipleCalls_canOnlyBecomeMoreRestrictive1) { @@ -375,24 +374,6 @@ TEST(pledge, mmapProtExec) { EXPECT_TRUE(WIFEXITED(ws) && !WEXITSTATUS(ws)); } -TEST(pledge, msyscall) { - if (IsOpenbsd()) return; // b/c testing linux bpf - int ax, ws, pid; - ASSERT_NE(-1, (pid = fork())); - if (!pid) { - ASSERT_SYS(0, 0, pledge("stdio", 0)); - // now issue authorized syscall where rip isn't privileged - asm volatile("syscall" - : "=a"(ax) - : "0"(__NR_linux_dup), "D"(2) - : "rcx", "r11", "memory"); - _Exit(1); - } - EXPECT_NE(-1, wait(&ws)); - EXPECT_TRUE(WIFSIGNALED(ws)); - EXPECT_EQ(SIGSYS, WTERMSIG(ws)); -} - TEST(pledge, chmod_ignoresDangerBits) { if (IsOpenbsd()) return; // b/c testing linux bpf int ws, pid; @@ -467,21 +448,6 @@ TEST(pledge, open_cpath) { EXPECT_TRUE(WIFEXITED(ws) && !WEXITSTATUS(ws)); } -TEST(pledge, sigaction_isFineButForbidsSigsys) { - if (IsOpenbsd()) return; // b/c testing linux bpf - int ws, pid; - ASSERT_NE(-1, (pid = fork())); - if (!pid) { - ASSERT_SYS(0, 0, pledge("stdio", 0)); - struct sigaction sa = {.sa_handler = OnSig}; - ASSERT_SYS(0, 0, sigaction(SIGINT, &sa, 0)); - ASSERT_SYS(EPERM, -1, sigaction(SIGSYS, &sa, 0)); - _Exit(0); - } - EXPECT_NE(-1, wait(&ws)); - EXPECT_TRUE(WIFEXITED(ws) && !WEXITSTATUS(ws)); -} - TEST(pledge, execpromises_ok) { if (IsOpenbsd()) return; // b/c testing linux bpf int ws, pid; @@ -618,7 +584,7 @@ TEST(pledge, threadWithLocks_canCodeMorph) { TEST(pledge, everything) { int ws, pid; if (!fork()) { - // contains 548 bpf instructions [2022-07-24] + // contains 591 bpf instructions [2022-07-24] ASSERT_SYS(0, 0, pledge("stdio rpath wpath cpath dpath " "flock fattr inet unix dns tty " @@ -665,4 +631,3 @@ BENCH(pledge, bench) { } wait(0); } -#endif diff --git a/test/libc/calls/poll_test.c b/test/libc/calls/poll_test.c index 4be1720cb..3e7c8711e 100644 --- a/test/libc/calls/poll_test.c +++ b/test/libc/calls/poll_test.c @@ -20,7 +20,6 @@ #include "libc/calls/pledge.h" #include "libc/dce.h" #include "libc/errno.h" -#include "libc/intrin/kprintf.h" #include "libc/log/libfatal.internal.h" #include "libc/nexgen32e/rdtsc.h" #include "libc/nexgen32e/rdtscp.h" diff --git a/test/libc/calls/reservefd_test.c b/test/libc/calls/reservefd_test.c index c7119e0a2..c0054063a 100644 --- a/test/libc/calls/reservefd_test.c +++ b/test/libc/calls/reservefd_test.c @@ -23,7 +23,6 @@ #include "libc/calls/struct/rlimit.h" #include "libc/calls/struct/sigaction.h" #include "libc/errno.h" -#include "libc/intrin/kprintf.h" #include "libc/intrin/spinlock.h" #include "libc/intrin/wait0.internal.h" #include "libc/macros.internal.h" diff --git a/test/libc/calls/sched_setscheduler_test.c b/test/libc/calls/sched_setscheduler_test.c index 15e551390..bae41c467 100644 --- a/test/libc/calls/sched_setscheduler_test.c +++ b/test/libc/calls/sched_setscheduler_test.c @@ -16,12 +16,11 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/midpoint.h" #include "libc/calls/calls.h" #include "libc/calls/struct/sched_param.h" #include "libc/dce.h" #include "libc/errno.h" -#include "libc/intrin/kprintf.h" +#include "libc/intrin/midpoint.h" #include "libc/limits.h" #include "libc/runtime/runtime.h" #include "libc/sysv/consts/sched.h" diff --git a/test/libc/calls/test.mk b/test/libc/calls/test.mk index 8d64542c2..25b3e1846 100644 --- a/test/libc/calls/test.mk +++ b/test/libc/calls/test.mk @@ -103,6 +103,12 @@ o/$(MODE)/test/libc/calls/poll_test.com.runs: \ o/$(MODE)/test/libc/calls/fcntl_test.com.runs: \ private .PLEDGE = stdio rpath wpath cpath fattr proc flock +# TODO(jart): Update nointernet() to allow AF_INET6 +o/$(MODE)/test/libc/calls/pledge_test.com.runs: \ + private .INTERNET = 1 +o/$(MODE)/test/libc/calls/pledge_test.com.runs: \ + private .PLEDGE = + .PHONY: o/$(MODE)/test/libc/calls o/$(MODE)/test/libc/calls: \ $(TEST_LIBC_CALLS_BINS) \ diff --git a/test/libc/intrin/describeflags_test.c b/test/libc/intrin/describeflags_test.c index f23a33b35..52ea00221 100644 --- a/test/libc/intrin/describeflags_test.c +++ b/test/libc/intrin/describeflags_test.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/intrin/describeflags.internal.h" -#include "libc/intrin/kprintf.h" #include "libc/macros.internal.h" #include "libc/testlib/testlib.h" diff --git a/test/libc/intrin/kprintf_test.c b/test/libc/intrin/kprintf_test.c index c1153d73a..1997bae6b 100644 --- a/test/libc/intrin/kprintf_test.c +++ b/test/libc/intrin/kprintf_test.c @@ -16,19 +16,19 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/bits.h" #include "libc/calls/calls.h" #include "libc/dce.h" #include "libc/errno.h" #include "libc/fmt/fmt.h" +#include "libc/intrin/bits.h" #include "libc/intrin/kprintf.h" #include "libc/limits.h" #include "libc/log/libfatal.internal.h" #include "libc/macros.internal.h" -#include "libc/stdio/rand.h" #include "libc/runtime/memtrack.internal.h" #include "libc/runtime/runtime.h" #include "libc/runtime/symbols.internal.h" +#include "libc/stdio/rand.h" #include "libc/str/str.h" #include "libc/sysv/consts/map.h" #include "libc/sysv/consts/prot.h" @@ -43,8 +43,7 @@ */ static uint64_t Rando(void) { uint64_t x; - do - x = lemur64(); + do x = lemur64(); while (((x ^ READ64LE("!!!!!!!!")) - 0x0101010101010101) & ~(x ^ READ64LE("!!!!!!!!")) & 0x8080808080808080); return x; @@ -250,7 +249,6 @@ TEST(kprintf, testFailure_wontClobberErrnoAndBypassesSystemCallSupport) { EXPECT_SYS(0, 3, dup(2)); EXPECT_SYS(0, 0, close(2)); n = __syscount; - kprintf("hello%n"); EXPECT_EQ(n, __syscount); EXPECT_EQ(0, errno); EXPECT_SYS(0, 2, dup2(3, 2)); diff --git a/test/libc/intrin/pthread_mutex_lock_test.c b/test/libc/intrin/pthread_mutex_lock_test.c index f60e28f1e..f31437b5a 100644 --- a/test/libc/intrin/pthread_mutex_lock_test.c +++ b/test/libc/intrin/pthread_mutex_lock_test.c @@ -22,7 +22,6 @@ #include "libc/calls/strace.internal.h" #include "libc/errno.h" #include "libc/intrin/futex.internal.h" -#include "libc/intrin/kprintf.h" #include "libc/intrin/pthread.h" #include "libc/intrin/spinlock.h" #include "libc/intrin/wait0.internal.h" diff --git a/test/libc/intrin/rand64_test.c b/test/libc/intrin/rand64_test.c index 83ace3f87..2fda6c521 100644 --- a/test/libc/intrin/rand64_test.c +++ b/test/libc/intrin/rand64_test.c @@ -16,21 +16,20 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/atomic.h" #include "libc/calls/calls.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/sigset.h" #include "libc/dce.h" #include "libc/errno.h" -#include "libc/intrin/kprintf.h" +#include "libc/intrin/atomic.h" #include "libc/intrin/spinlock.h" #include "libc/limits.h" #include "libc/macros.internal.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/threaded.h" -#include "libc/stdio/rand.h" #include "libc/runtime/internal.h" #include "libc/runtime/stack.h" +#include "libc/stdio/rand.h" #include "libc/str/str.h" #include "libc/sysv/consts/clone.h" #include "libc/sysv/consts/map.h" diff --git a/test/libc/log/backtrace_test.c b/test/libc/log/backtrace_test.c index df2c20922..1d1afdfb6 100644 --- a/test/libc/log/backtrace_test.c +++ b/test/libc/log/backtrace_test.c @@ -22,7 +22,6 @@ #include "libc/errno.h" #include "libc/fmt/conv.h" #include "libc/intrin/asan.internal.h" -#include "libc/intrin/kprintf.h" #include "libc/limits.h" #include "libc/log/libfatal.internal.h" #include "libc/log/log.h" diff --git a/test/libc/mem/malloc_test.c b/test/libc/mem/malloc_test.c index 4f78b72dd..c2088a704 100644 --- a/test/libc/mem/malloc_test.c +++ b/test/libc/mem/malloc_test.c @@ -16,19 +16,18 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/bits.h" -#include "libc/intrin/safemacros.internal.h" #include "libc/calls/calls.h" #include "libc/calls/struct/stat.h" #include "libc/dce.h" +#include "libc/intrin/bits.h" #include "libc/intrin/cxaatexit.internal.h" -#include "libc/intrin/kprintf.h" +#include "libc/intrin/safemacros.internal.h" #include "libc/macros.internal.h" #include "libc/mem/mem.h" -#include "libc/stdio/rand.h" #include "libc/runtime/gc.internal.h" #include "libc/runtime/memtrack.internal.h" #include "libc/runtime/runtime.h" +#include "libc/stdio/rand.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/map.h" diff --git a/test/libc/nexgen32e/stackrw_test.c b/test/libc/nexgen32e/stackrw_test.c index 56c8b11af..97f85d28c 100644 --- a/test/libc/nexgen32e/stackrw_test.c +++ b/test/libc/nexgen32e/stackrw_test.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/struct/sigaction.h" -#include "libc/intrin/kprintf.h" #include "libc/runtime/runtime.h" #include "libc/sysv/consts/sa.h" #include "libc/sysv/consts/sig.h" diff --git a/test/libc/runtime/clone_test.c b/test/libc/runtime/clone_test.c index ae142bc6d..bfd748fad 100644 --- a/test/libc/runtime/clone_test.c +++ b/test/libc/runtime/clone_test.c @@ -21,7 +21,6 @@ #include "libc/dce.h" #include "libc/errno.h" #include "libc/intrin/futex.internal.h" -#include "libc/intrin/kprintf.h" #include "libc/intrin/spinlock.h" #include "libc/intrin/wait0.internal.h" #include "libc/log/backtrace.internal.h" diff --git a/test/libc/runtime/mmap_test.c b/test/libc/runtime/mmap_test.c index f8ecbcdce..33838ee4a 100644 --- a/test/libc/runtime/mmap_test.c +++ b/test/libc/runtime/mmap_test.c @@ -16,23 +16,22 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/atomic.h" -#include "libc/intrin/bits.h" -#include "libc/intrin/safemacros.internal.h" -#include "libc/intrin/xchg.internal.h" #include "libc/calls/calls.h" #include "libc/calls/ucontext.h" #include "libc/dce.h" #include "libc/fmt/fmt.h" -#include "libc/intrin/kprintf.h" +#include "libc/intrin/atomic.h" +#include "libc/intrin/bits.h" +#include "libc/intrin/safemacros.internal.h" +#include "libc/intrin/xchg.internal.h" #include "libc/linux/mmap.h" #include "libc/linux/munmap.h" #include "libc/log/log.h" #include "libc/mem/mem.h" -#include "libc/stdio/rand.h" #include "libc/runtime/gc.internal.h" #include "libc/runtime/memtrack.internal.h" #include "libc/runtime/runtime.h" +#include "libc/stdio/rand.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/map.h" diff --git a/test/libc/runtime/mprotect_test.c b/test/libc/runtime/mprotect_test.c index 911fa0483..e01f4ba2d 100644 --- a/test/libc/runtime/mprotect_test.c +++ b/test/libc/runtime/mprotect_test.c @@ -21,7 +21,6 @@ #include "libc/dce.h" #include "libc/errno.h" #include "libc/fmt/fmt.h" -#include "libc/intrin/kprintf.h" #include "libc/log/log.h" #include "libc/mem/mem.h" #include "libc/runtime/gc.internal.h" diff --git a/test/libc/runtime/munmap_test.c b/test/libc/runtime/munmap_test.c index 49424da8f..ac5218f03 100644 --- a/test/libc/runtime/munmap_test.c +++ b/test/libc/runtime/munmap_test.c @@ -16,13 +16,12 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/atomic.h" #include "libc/calls/calls.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/siginfo.h" #include "libc/calls/ucontext.h" #include "libc/errno.h" -#include "libc/intrin/kprintf.h" +#include "libc/intrin/atomic.h" #include "libc/runtime/memtrack.internal.h" #include "libc/runtime/runtime.h" #include "libc/str/str.h" diff --git a/test/libc/runtime/tls_test.c b/test/libc/runtime/tls_test.c index ae21ec0a0..59e2ad501 100644 --- a/test/libc/runtime/tls_test.c +++ b/test/libc/runtime/tls_test.c @@ -16,31 +16,12 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/asan.internal.h" -#include "libc/intrin/kprintf.h" -#include "libc/runtime/internal.h" -#include "libc/runtime/runtime.h" #include "libc/testlib/testlib.h" _Thread_local int x; _Thread_local int y = 40; int z = 2; -void PrintInfo(void) { - kprintf("_tdata_size = %d\n", _tdata_size); - kprintf("_tls_size = %d\n", _tls_size); - kprintf("_tls_content = %d\n", _tls_content); - kprintf("__data_start = %p\n", __data_start); - kprintf("__data_end = %p\n", __data_end); - kprintf("_tdata_start = %p\n", _tdata_start); - kprintf("_tdata_end = %p\n", _tdata_end); - kprintf("_tbss_start = %p\n", _tbss_start); - kprintf("_tbss_end = %p\n", _tbss_end); - kprintf("&y = %p\n", &y); - kprintf("__bss_start = %p\n", __bss_start); - kprintf("__bss_end = %p\n", __bss_end); -} - TEST(tls, test) { EXPECT_EQ(42, x + y + z); } diff --git a/test/libc/sock/unix_test.c b/test/libc/sock/unix_test.c index 0f2f97d03..421552ed4 100644 --- a/test/libc/sock/unix_test.c +++ b/test/libc/sock/unix_test.c @@ -20,7 +20,6 @@ #include "libc/calls/internal.h" #include "libc/calls/struct/timeval.h" #include "libc/dce.h" -#include "libc/intrin/kprintf.h" #include "libc/nt/version.h" #include "libc/runtime/runtime.h" #include "libc/sock/sock.h" diff --git a/test/libc/stdio/dtoa_test.c b/test/libc/stdio/dtoa_test.c index cf3dc9436..8d63a4997 100644 --- a/test/libc/stdio/dtoa_test.c +++ b/test/libc/stdio/dtoa_test.c @@ -20,7 +20,6 @@ #include "libc/calls/struct/sched_param.h" #include "libc/dce.h" #include "libc/fmt/fmt.h" -#include "libc/intrin/kprintf.h" #include "libc/intrin/spinlock.h" #include "libc/intrin/wait0.internal.h" #include "libc/macros.internal.h" diff --git a/test/libc/stdio/getdelim_test.c b/test/libc/stdio/getdelim_test.c index be962890f..7b29c9069 100644 --- a/test/libc/stdio/getdelim_test.c +++ b/test/libc/stdio/getdelim_test.c @@ -18,7 +18,6 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" #include "libc/intrin/bits.h" -#include "libc/intrin/kprintf.h" #include "libc/log/libfatal.internal.h" #include "libc/mem/mem.h" #include "libc/runtime/symbols.internal.h" diff --git a/test/libc/stdio/spawn_test.c b/test/libc/stdio/spawn_test.c index aecdd73cf..6defbd214 100644 --- a/test/libc/stdio/spawn_test.c +++ b/test/libc/stdio/spawn_test.c @@ -16,11 +16,10 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/safemacros.internal.h" #include "libc/calls/calls.h" #include "libc/dce.h" #include "libc/fmt/conv.h" -#include "libc/intrin/kprintf.h" +#include "libc/intrin/safemacros.internal.h" #include "libc/runtime/internal.h" #include "libc/runtime/runtime.h" #include "libc/stdio/spawn.h" diff --git a/test/libc/stdio/tmpfile_test.c b/test/libc/stdio/tmpfile_test.c index d8cdde3f5..fbba8ae5c 100644 --- a/test/libc/stdio/tmpfile_test.c +++ b/test/libc/stdio/tmpfile_test.c @@ -21,7 +21,6 @@ #include "libc/calls/struct/stat.h" #include "libc/calls/syscall_support-sysv.internal.h" #include "libc/dce.h" -#include "libc/intrin/kprintf.h" #include "libc/runtime/gc.internal.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" diff --git a/test/libc/stdio/vappendf_test.c b/test/libc/stdio/vappendf_test.c index 49edf2105..ca28bdb91 100644 --- a/test/libc/stdio/vappendf_test.c +++ b/test/libc/stdio/vappendf_test.c @@ -17,17 +17,12 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/intrin/bits.h" -#include "libc/intrin/kprintf.h" #include "libc/mem/mem.h" #include "libc/stdio/append.internal.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" -static void PrintMemory(void *p) { - kprintf("%#.*hhs%n", malloc_usable_size(p), p); -} - TEST(vappendf, test) { char *b = 0; ASSERT_NE(-1, appendf(&b, "hello ")); diff --git a/test/libc/str/undeflate_test.c b/test/libc/str/undeflate_test.c index 651b29218..0f6cbf755 100644 --- a/test/libc/str/undeflate_test.c +++ b/test/libc/str/undeflate_test.c @@ -19,7 +19,6 @@ #include "libc/calls/calls.h" #include "libc/calls/struct/stat.h" #include "libc/errno.h" -#include "libc/intrin/kprintf.h" #include "libc/log/check.h" #include "libc/macros.internal.h" #include "libc/mem/mem.h" diff --git a/test/libc/thread/spawn_test.c b/test/libc/thread/spawn_test.c index 633559697..88193d605 100644 --- a/test/libc/thread/spawn_test.c +++ b/test/libc/thread/spawn_test.c @@ -17,10 +17,9 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" -#include "libc/intrin/atomic.h" #include "libc/calls/calls.h" #include "libc/calls/syscall-sysv.internal.h" -#include "libc/intrin/kprintf.h" +#include "libc/intrin/atomic.h" #include "libc/macros.internal.h" #include "libc/mem/mem.h" #include "libc/runtime/gc.internal.h" diff --git a/third_party/chibicc/chibicc.c b/third_party/chibicc/chibicc.c index 46ca870a8..a50108441 100644 --- a/third_party/chibicc/chibicc.c +++ b/third_party/chibicc/chibicc.c @@ -1,7 +1,6 @@ #include "libc/calls/calls.h" #include "libc/calls/struct/siginfo.h" #include "libc/calls/ucontext.h" -#include "libc/intrin/kprintf.h" #include "libc/runtime/gc.internal.h" #include "libc/runtime/runtime.h" #include "libc/x/x.h" diff --git a/third_party/chibicc/preprocess.c b/third_party/chibicc/preprocess.c index df1aeb2a4..5ef0d743f 100644 --- a/third_party/chibicc/preprocess.c +++ b/third_party/chibicc/preprocess.c @@ -22,7 +22,6 @@ // standard's wording: // https://github.com/rui314/chibicc/wiki/cpp.algo.pdf -#include "libc/intrin/kprintf.h" #include "libc/log/libfatal.internal.h" #include "libc/mem/arena.h" #include "libc/runtime/runtime.h" diff --git a/third_party/dlmalloc/dlmalloc.c b/third_party/dlmalloc/dlmalloc.c index 3eba80b64..7dccc2058 100644 --- a/third_party/dlmalloc/dlmalloc.c +++ b/third_party/dlmalloc/dlmalloc.c @@ -2,7 +2,6 @@ #include "libc/calls/calls.h" #include "libc/dce.h" #include "libc/errno.h" -#include "libc/intrin/kprintf.h" #include "libc/intrin/likely.h" #include "libc/intrin/weaken.h" #include "libc/macros.internal.h" diff --git a/third_party/dlmalloc/statistics.inc b/third_party/dlmalloc/statistics.inc index 6df79d0b6..16a9c4aba 100644 --- a/third_party/dlmalloc/statistics.inc +++ b/third_party/dlmalloc/statistics.inc @@ -1,4 +1,5 @@ // clang-format off +#include "libc/intrin/kprintf.h" /* ----------------------------- statistics ------------------------------ */ diff --git a/third_party/make/job.c b/third_party/make/job.c index 3dba95454..914f716a0 100644 --- a/third_party/make/job.c +++ b/third_party/make/job.c @@ -38,7 +38,6 @@ this program. If not, see . */ #include "libc/fmt/fmt.h" #include "libc/fmt/itoa.h" #include "libc/intrin/bits.h" -#include "libc/intrin/kprintf.h" #include "libc/intrin/promises.internal.h" #include "libc/intrin/safemacros.internal.h" #include "libc/log/backtrace.internal.h" @@ -66,12 +65,6 @@ this program. If not, see . */ #include "third_party/make/variable.h" // clang-format off -#define GOTO_SLOW \ - do { \ - kprintf("%s:%d: goto slow\n", __FILE__, __LINE__); \ - goto slow; \ - } while (0) - #ifdef WINDOWS32 const char *default_shell = "sh.exe"; int no_default_sh_exe = 1; diff --git a/third_party/mbedtls/rsa.c b/third_party/mbedtls/rsa.c index d80e88dd2..cac5d2afa 100644 --- a/third_party/mbedtls/rsa.c +++ b/third_party/mbedtls/rsa.c @@ -16,9 +16,8 @@ │ limitations under the License. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/strace.internal.h" -#include "libc/intrin/kprintf.h" -#include "libc/stdio/rand.h" #include "libc/runtime/runtime.h" +#include "libc/stdio/rand.h" #include "third_party/mbedtls/common.h" #include "third_party/mbedtls/error.h" #include "third_party/mbedtls/md.h" diff --git a/third_party/mbedtls/test/lib.c b/third_party/mbedtls/test/lib.c index 7557a4014..82d3fbe0a 100644 --- a/third_party/mbedtls/test/lib.c +++ b/third_party/mbedtls/test/lib.c @@ -20,7 +20,6 @@ #include "libc/fmt/conv.h" #include "libc/fmt/fmt.h" #include "libc/intrin/bits.h" -#include "libc/intrin/kprintf.h" #include "libc/intrin/safemacros.internal.h" #include "libc/log/backtrace.internal.h" #include "libc/log/check.h" diff --git a/third_party/mbedtls/test/test_suite_ctr_drbg.c b/third_party/mbedtls/test/test_suite_ctr_drbg.c index 75537963c..781c2093f 100644 --- a/third_party/mbedtls/test/test_suite_ctr_drbg.c +++ b/third_party/mbedtls/test/test_suite_ctr_drbg.c @@ -15,7 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "libc/intrin/kprintf.h" #include "third_party/mbedtls/test/test.inc" /* * *** THIS FILE WAS MACHINE GENERATED *** diff --git a/third_party/python/runpythonmodule.c b/third_party/python/runpythonmodule.c index 69d6de764..b54ea0350 100644 --- a/third_party/python/runpythonmodule.c +++ b/third_party/python/runpythonmodule.c @@ -5,9 +5,6 @@ │ https://docs.python.org/3/license.html │ ╚─────────────────────────────────────────────────────────────────────────────*/ #define PY_SSIZE_T_CLEAN -#include "libc/intrin/bits.h" -#include "libc/intrin/safemacros.internal.h" -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/struct/siginfo.h" @@ -15,7 +12,9 @@ #include "libc/calls/ucontext.h" #include "libc/dce.h" #include "libc/errno.h" -#include "libc/intrin/kprintf.h" +#include "libc/intrin/bits.h" +#include "libc/intrin/safemacros.internal.h" +#include "libc/intrin/weaken.h" #include "libc/log/check.h" #include "libc/log/log.h" #include "libc/macros.internal.h" @@ -24,12 +23,12 @@ #include "libc/runtime/runtime.h" #include "libc/runtime/symbols.internal.h" #include "libc/stdio/stdio.h" +#include "libc/str/locale.h" #include "libc/str/str.h" #include "libc/sysv/consts/fileno.h" #include "libc/sysv/consts/prot.h" #include "libc/sysv/consts/sig.h" #include "libc/time/time.h" -#include "libc/str/locale.h" #include "libc/x/x.h" #include "third_party/linenoise/linenoise.h" #include "third_party/python/Include/abstract.h" diff --git a/tool/build/ar.c b/tool/build/ar.c index 8c32db94f..9f8314ce0 100644 --- a/tool/build/ar.c +++ b/tool/build/ar.c @@ -25,7 +25,6 @@ #include "libc/fmt/conv.h" #include "libc/fmt/itoa.h" #include "libc/intrin/bits.h" -#include "libc/intrin/kprintf.h" #include "libc/intrin/safemacros.internal.h" #include "libc/log/check.h" #include "libc/log/log.h" diff --git a/tool/build/cp.c b/tool/build/cp.c index 91434684a..789e254f6 100644 --- a/tool/build/cp.c +++ b/tool/build/cp.c @@ -22,7 +22,6 @@ #include "libc/errno.h" #include "libc/fmt/conv.h" #include "libc/fmt/fmt.h" -#include "libc/intrin/kprintf.h" #include "libc/mem/io.h" #include "libc/runtime/gc.h" #include "libc/runtime/runtime.h" diff --git a/tool/build/mv.c b/tool/build/mv.c index e7a7e02d6..895ab0bad 100644 --- a/tool/build/mv.c +++ b/tool/build/mv.c @@ -21,7 +21,6 @@ #include "libc/errno.h" #include "libc/fmt/conv.h" #include "libc/fmt/fmt.h" -#include "libc/intrin/kprintf.h" #include "libc/runtime/gc.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" diff --git a/tool/build/pledge.c b/tool/build/pledge.c index b092aee89..c17f1ab7e 100644 --- a/tool/build/pledge.c +++ b/tool/build/pledge.c @@ -20,6 +20,7 @@ #include "libc/calls/calls.h" #include "libc/calls/landlock.h" #include "libc/calls/pledge.h" +#include "libc/calls/pledge.internal.h" #include "libc/calls/struct/rlimit.h" #include "libc/calls/struct/sched_param.h" #include "libc/calls/struct/seccomp.h" @@ -127,8 +128,6 @@ the https://justine.lol/pledge/ page for online documentation.\n\ \n\ " -int ParsePromises(const char *, unsigned long *); - int g_gflag; int g_uflag; int g_kflag; diff --git a/tool/build/printf.c b/tool/build/printf.c index bc3293b52..2895c4951 100644 --- a/tool/build/printf.c +++ b/tool/build/printf.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/kprintf.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" diff --git a/tool/build/symtab.c b/tool/build/symtab.c index 4dbde5f81..a5145e2c2 100644 --- a/tool/build/symtab.c +++ b/tool/build/symtab.c @@ -18,7 +18,6 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/errno.h" -#include "libc/intrin/kprintf.h" #include "libc/runtime/runtime.h" #include "libc/runtime/symbols.internal.h" #include "libc/stdio/stdio.h" diff --git a/tool/build/unveil.c b/tool/build/unveil.c index bbce0aa9d..035207fd7 100644 --- a/tool/build/unveil.c +++ b/tool/build/unveil.c @@ -19,7 +19,6 @@ #include "libc/calls/calls.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/dce.h" -#include "libc/intrin/kprintf.h" #include "libc/log/bsd.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" diff --git a/tool/decode/ar.c b/tool/decode/ar.c index ed19bb81a..6df0a60e2 100644 --- a/tool/decode/ar.c +++ b/tool/decode/ar.c @@ -16,11 +16,10 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/bits.h" #include "libc/calls/calls.h" #include "libc/calls/struct/stat.h" #include "libc/fmt/conv.h" -#include "libc/intrin/kprintf.h" +#include "libc/intrin/bits.h" #include "libc/log/check.h" #include "libc/log/log.h" #include "libc/mem/mem.h" diff --git a/tool/decode/lib/asmcodegen.c b/tool/decode/lib/asmcodegen.c index 8ce7634e1..be1957f0f 100644 --- a/tool/decode/lib/asmcodegen.c +++ b/tool/decode/lib/asmcodegen.c @@ -16,9 +16,8 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/safemacros.internal.h" #include "libc/fmt/fmt.h" -#include "libc/intrin/kprintf.h" +#include "libc/intrin/safemacros.internal.h" #include "libc/mem/mem.h" #include "libc/runtime/gc.internal.h" #include "libc/stdio/stdio.h" diff --git a/tool/lambda/bru2bin.c b/tool/lambda/bru2bin.c index 274a29f05..ecfd25a35 100644 --- a/tool/lambda/bru2bin.c +++ b/tool/lambda/bru2bin.c @@ -21,8 +21,8 @@ #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" -#include "libc/str/str.h" #include "libc/str/locale.h" +#include "libc/str/str.h" #include "third_party/getopt/getopt.h" #define USAGE \ diff --git a/tool/lambda/lam2bin.c b/tool/lambda/lam2bin.c index 3d5e97493..17e3810f0 100644 --- a/tool/lambda/lam2bin.c +++ b/tool/lambda/lam2bin.c @@ -21,8 +21,8 @@ #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" -#include "libc/str/str.h" #include "libc/str/locale.h" +#include "libc/str/str.h" #include "third_party/getopt/getopt.h" #define USAGE \ diff --git a/tool/net/lfuncs.c b/tool/net/lfuncs.c index 51efeecf6..41b760658 100644 --- a/tool/net/lfuncs.c +++ b/tool/net/lfuncs.c @@ -17,8 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "dsp/scale/cdecimate2xuint8x8.h" -#include "libc/intrin/bits.h" -#include "libc/intrin/popcnt.h" #include "libc/calls/calls.h" #include "libc/calls/struct/rusage.h" #include "libc/calls/struct/stat.h" @@ -26,7 +24,8 @@ #include "libc/errno.h" #include "libc/fmt/itoa.h" #include "libc/fmt/leb128.h" -#include "libc/intrin/kprintf.h" +#include "libc/intrin/bits.h" +#include "libc/intrin/popcnt.h" #include "libc/log/check.h" #include "libc/log/log.h" #include "libc/macros.internal.h" @@ -38,11 +37,11 @@ #include "libc/nexgen32e/crc32.h" #include "libc/nexgen32e/rdtsc.h" #include "libc/nexgen32e/rdtscp.h" -#include "libc/stdio/rand.h" #include "libc/runtime/gc.internal.h" #include "libc/runtime/runtime.h" #include "libc/runtime/sysconf.h" #include "libc/sock/sock.h" +#include "libc/stdio/rand.h" #include "libc/str/str.h" #include "libc/sysv/consts/af.h" #include "libc/sysv/consts/ipproto.h" diff --git a/tool/net/ljson.c b/tool/net/ljson.c index 5d3780fb3..ac998c7f0 100644 --- a/tool/net/ljson.c +++ b/tool/net/ljson.c @@ -18,7 +18,6 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/intrin/bits.h" #include "libc/intrin/likely.h" -#include "libc/intrin/kprintf.h" #include "libc/log/check.h" #include "libc/log/log.h" #include "libc/runtime/stack.h" diff --git a/tool/plinko/lib/plinko.c b/tool/plinko/lib/plinko.c index d086b2303..64f74ad69 100644 --- a/tool/plinko/lib/plinko.c +++ b/tool/plinko/lib/plinko.c @@ -16,12 +16,11 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/likely.h" #include "libc/calls/calls.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/sigaction.h" #include "libc/errno.h" -#include "libc/intrin/kprintf.h" +#include "libc/intrin/likely.h" #include "libc/log/countbranch.h" #include "libc/log/countexpr.h" #include "libc/log/log.h" diff --git a/tool/plinko/plinko.c b/tool/plinko/plinko.c index 21823eeed..7a6120a16 100644 --- a/tool/plinko/plinko.c +++ b/tool/plinko/plinko.c @@ -16,10 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/kprintf.h" -#include "libc/log/log.h" #include "libc/nexgen32e/threaded.h" -#include "libc/stdio/stdio.h" #include "tool/plinko/lib/plinko.h" STATIC_YOINK("__zipos_get");