diff --git a/ape/ape-m1.c b/ape/ape-m1.c index d31ca0b27..b81bebb71 100644 --- a/ape/ape-m1.c +++ b/ape/ape-m1.c @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include #include #include @@ -39,7 +41,7 @@ /* maximum path size that cosmo can take */ #define PATHSIZE (PATH_MAX < 1024 ? PATH_MAX : 1024) #define SYSLIB_MAGIC ('s' | 'l' << 8 | 'i' << 16 | 'b' << 24) -#define SYSLIB_VERSION 9 /* sync with libc/runtime/syslib.internal.h */ +#define SYSLIB_VERSION 10 /* sync with libc/runtime/syslib.internal.h */ struct Syslib { int magic; @@ -106,6 +108,10 @@ struct Syslib { OPTIONAL (cosmo lib should check __syslib->version) */ /* v9 (2024-01-31) */ int (*pthread_cpu_number_np)(size_t *); + /* v10 (2024-05-02) */ + long (*sysctl)(int *, u_int, void *, size_t *, void *, size_t); + long (*sysctlbyname)(const char *, void *, size_t *, void *, size_t); + long (*sysctlnametomib)(const char *, int *, size_t *); }; #define ELFCLASS32 1 @@ -148,8 +154,8 @@ struct Syslib { #define _COMM_PAGE_APRR_WRITE_ENABLE (_COMM_PAGE_START_ADDRESS + 0x110) #define _COMM_PAGE_APRR_WRITE_DISABLE (_COMM_PAGE_START_ADDRESS + 0x118) -#define MIN(X, Y) ((Y) > (X) ? (X) : (Y)) -#define MAX(X, Y) ((Y) < (X) ? (X) : (Y)) +#define Min(X, Y) ((Y) > (X) ? (X) : (Y)) +#define Max(X, Y) ((Y) < (X) ? (X) : (Y)) #define READ32(S) \ ((unsigned)(255 & (S)[3]) << 030 | (unsigned)(255 & (S)[2]) << 020 | \ @@ -552,6 +558,20 @@ static long sys_pselect(int nfds, fd_set *readfds, fd_set *writefds, return sysret(pselect(nfds, readfds, writefds, errorfds, timeout, sigmask)); } +static long sys_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, + void *newp, size_t newlen) { + return sysret(sysctl(name, namelen, oldp, oldlenp, newp, newlen)); +} + +static long sys_sysctlbyname(const char *name, void *oldp, size_t *oldlenp, + void *newp, size_t newlen) { + return sysret(sysctlbyname(name, oldp, oldlenp, newp, newlen)); +} + +static long sys_sysctlnametomib(const char *name, int *mibp, size_t *sizep) { + return sysret(sysctlnametomib(name, mibp, sizep)); +} + __attribute__((__noreturn__)) static void Spawn(const char *exe, int fd, long *sp, struct ElfEhdr *e, struct ElfPhdr *p, @@ -596,7 +616,7 @@ __attribute__((__noreturn__)) static void Spawn(const char *exe, int fd, continue; c = p[j].p_vaddr & -pagesz; d = (p[j].p_vaddr + p[j].p_memsz + (pagesz - 1)) & -pagesz; - if (MAX(a, c) < MIN(b, d)) { + if (Max(a, c) < Min(b, d)) { Pexit(exe, 0, "ELF segments overlap each others virtual memory"); } } @@ -670,7 +690,7 @@ __attribute__((__noreturn__)) static void Spawn(const char *exe, int fd, a = p[i].p_vaddr + p[i].p_filesz; /* end of file content */ b = (a + (pagesz - 1)) & -pagesz; /* first pure bss page */ c = p[i].p_vaddr + p[i].p_memsz; /* end of segment data */ - wipe = MIN(b - a, c - a); + wipe = Min(b - a, c - a); if (wipe && (~prot1 & PROT_WRITE)) { prot1 = PROT_READ | PROT_WRITE; } @@ -970,6 +990,9 @@ int main(int argc, char **argv, char **envp) { M->lib.dlclose = dlclose; M->lib.dlerror = dlerror; M->lib.pthread_cpu_number_np = pthread_cpu_number_np; + M->lib.sysctl = sys_sysctl; + M->lib.sysctlbyname = sys_sysctlbyname; + M->lib.sysctlnametomib = sys_sysctlnametomib; /* getenv("_") is close enough to at_execfn */ execfn = 0; diff --git a/libc/calls/calls.h b/libc/calls/calls.h index eab5592f4..f2b8985ca 100644 --- a/libc/calls/calls.h +++ b/libc/calls/calls.h @@ -237,7 +237,9 @@ int sys_munlock(const void *, size_t) libcesque; int sys_munlockall(void) libcesque; int sys_personality(uint64_t) libcesque; int sys_ptrace(int, ...) libcesque; -int sys_sysctl(const int *, unsigned, void *, size_t *, void *, size_t); +int sysctl(int *, unsigned, void *, size_t *, void *, size_t) libcesque; +int sysctlbyname(const char *, void *, size_t *, void *, size_t) libcesque; +int sysctlnametomib(const char *, int *, size_t *) libcesque; int tmpfd(void) libcesque; int touch(const char *, unsigned) libcesque; int unveil(const char *, const char *) libcesque; diff --git a/libc/calls/clktck.c b/libc/calls/clktck.c index ead1400e0..b59a73711 100644 --- a/libc/calls/clktck.c +++ b/libc/calls/clktck.c @@ -53,7 +53,7 @@ static dontinline int __clk_tck_init(void) { cmd[0] = 1; // CTL_KERN cmd[1] = 12; // KERN_CLOCKRATE len = sizeof(clock); - if (sys_sysctl(cmd, 2, &clock, &len, NULL, 0) != -1) { + if (sysctl(cmd, 2, &clock, &len, NULL, 0) != -1) { x = clock.hz; } else { x = -1; diff --git a/libc/calls/clock_gettime-xnu.c b/libc/calls/clock_gettime-xnu.c index 990f87331..e9548884e 100644 --- a/libc/calls/clock_gettime-xnu.c +++ b/libc/calls/clock_gettime-xnu.c @@ -67,7 +67,7 @@ int sys_clock_gettime_xnu(int clock, struct timespec *ts) { struct timeval x; size_t n = sizeof(x); int mib[] = {CTL_KERN, KERN_BOOTTIME}; - if (sys_sysctl(mib, ARRAYLEN(mib), &x, &n, 0, 0) == -1) + if (sysctl(mib, ARRAYLEN(mib), &x, &n, 0, 0) == -1) return -1; if (ts) *ts = timeval_totimespec(timeval_sub(timeval_real(), x)); diff --git a/libc/calls/getcpucount.c b/libc/calls/getcpucount.c index 0ca1a4152..73d362ac2 100644 --- a/libc/calls/getcpucount.c +++ b/libc/calls/getcpucount.c @@ -51,7 +51,7 @@ static int __get_cpu_count_bsd(void) { } else { cmd[1] = HW_NCPU; } - if (!sys_sysctl(cmd, 2, &c, &n, 0, 0)) { + if (!sysctl(cmd, 2, &c, &n, 0, 0)) { return c; } else { return -1; diff --git a/libc/calls/gethostname-bsd.c b/libc/calls/gethostname-bsd.c index c9080e460..37c2e2f63 100644 --- a/libc/calls/gethostname-bsd.c +++ b/libc/calls/gethostname-bsd.c @@ -24,7 +24,7 @@ int gethostname_bsd(char *name, size_t len, int kind) { int cmd[2] = {CTL_KERN, kind}; - if (sys_sysctl(cmd, 2, name, &len, 0, 0) != -1) { + if (sysctl(cmd, 2, name, &len, 0, 0) != -1) { return 0; } else { if (errno == ENOMEM) { diff --git a/libc/calls/getloadavg.c b/libc/calls/getloadavg.c index 818a63c67..eb28d34c4 100644 --- a/libc/calls/getloadavg.c +++ b/libc/calls/getloadavg.c @@ -64,7 +64,7 @@ int getloadavg(double *a, int n) { struct loadavg loadinfo; int mib[2] = {CTL_VM, VM_LOADAVG}; size = sizeof(loadinfo); - if ((rc = sys_sysctl(mib, 2, &loadinfo, &size, 0, 0)) != -1) { + if ((rc = sysctl(mib, 2, &loadinfo, &size, 0, 0)) != -1) { for (i = 0; i < n; i++) { a[i] = (double)loadinfo.ldavg[i] / loadinfo.fscale; } diff --git a/libc/calls/getprogramexecutablename.greg.c b/libc/calls/getprogramexecutablename.greg.c index 02bf1472f..067e7a0a3 100644 --- a/libc/calls/getprogramexecutablename.greg.c +++ b/libc/calls/getprogramexecutablename.greg.c @@ -195,7 +195,7 @@ static inline void InitProgramExecutableNameImpl(void) { cmd[2] = KERN_PROC_PATHNAME_NETBSD; } cmd[3] = -1; // current process - if (sys_sysctl(cmd, ARRAYLEN(cmd), b, &n, 0, 0) != -1) { + if (sysctl(cmd, ARRAYLEN(cmd), b, &n, 0, 0) != -1) { if (!OldApeLoader(b)) { goto UseBuf; } diff --git a/libc/calls/getrandom.c b/libc/calls/getrandom.c index 643801fac..1e5abd48a 100644 --- a/libc/calls/getrandom.c +++ b/libc/calls/getrandom.c @@ -70,7 +70,7 @@ static void GetRandomArnd(char *p, size_t n) { cmd[0] = 1; // CTL_KERN cmd[1] = IsFreebsd() ? 37 : 81; // KERN_ARND unassert((m = n) <= 256); - if (sys_sysctl(cmd, 2, p, &n, 0, 0) == -1) + if (sysctl(cmd, 2, p, &n, 0, 0) == -1) notpossible; if (m != n) notpossible; diff --git a/libc/calls/sysctl.c b/libc/calls/sysctl.c new file mode 100644 index 000000000..7597cc939 --- /dev/null +++ b/libc/calls/sysctl.c @@ -0,0 +1,33 @@ +/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ +│ vi: set et ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi │ +╞══════════════════════════════════════════════════════════════════════════════╡ +│ Copyright 2024 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/calls.h" +#include "libc/calls/syscall-sysv.internal.h" +#include "libc/runtime/syslib.internal.h" + +int sys_sysctl(int *, unsigned, void *, size_t *, void *, size_t) libcesque; + +int sysctl(int *name, unsigned namelen, void *oldp, size_t *oldlenp, void *newp, + size_t newlen) { + if (__syslib && __syslib->__version >= 10) { + return _sysret( + __syslib->__sysctl(name, namelen, oldp, oldlenp, newp, newlen)); + } else { + return sys_sysctl(name, namelen, oldp, oldlenp, newp, newlen); + } +} diff --git a/libc/calls/sysctlbyname.c b/libc/calls/sysctlbyname.c new file mode 100644 index 000000000..78d0de4b3 --- /dev/null +++ b/libc/calls/sysctlbyname.c @@ -0,0 +1,31 @@ +/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ +│ vi: set et ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi │ +╞══════════════════════════════════════════════════════════════════════════════╡ +│ Copyright 2024 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/calls.h" +#include "libc/calls/syscall-sysv.internal.h" +#include "libc/runtime/syslib.internal.h" +#include "libc/sysv/errfuns.h" + +int sysctlbyname(const char *name, void *oldp, size_t *oldlenp, void *newp, + size_t newlen) { + if (__syslib && __syslib->__version >= 10) { + return _sysret(__syslib->__sysctlbyname(name, oldp, oldlenp, newp, newlen)); + } else { + return enosys(); + } +} diff --git a/libc/calls/sysctlnametomib.c b/libc/calls/sysctlnametomib.c new file mode 100644 index 000000000..f8cceab97 --- /dev/null +++ b/libc/calls/sysctlnametomib.c @@ -0,0 +1,30 @@ +/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ +│ vi: set et ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi │ +╞══════════════════════════════════════════════════════════════════════════════╡ +│ Copyright 2024 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/calls.h" +#include "libc/calls/syscall-sysv.internal.h" +#include "libc/runtime/syslib.internal.h" +#include "libc/sysv/errfuns.h" + +int sysctlnametomib(const char *name, int *mibp, size_t *sizep) { + if (__syslib && __syslib->__version >= 10) { + return _sysret(__syslib->__sysctlnametomib(name, mibp, sizep)); + } else { + return enosys(); + } +} diff --git a/libc/calls/sysinfo.c b/libc/calls/sysinfo.c index 63661a7f1..dd18a7fee 100644 --- a/libc/calls/sysinfo.c +++ b/libc/calls/sysinfo.c @@ -46,7 +46,7 @@ static int64_t GetUptime(void) { struct timeval x; size_t n = sizeof(x); int mib[] = {CTL_KERN, KERN_BOOTTIME}; - if (sys_sysctl(mib, ARRAYLEN(mib), &x, &n, 0, 0) == -1) + if (sysctl(mib, ARRAYLEN(mib), &x, &n, 0, 0) == -1) return 0; return timespec_real().tv_sec - x.tv_sec; } @@ -55,7 +55,7 @@ static int64_t GetPhysmem(void) { uint64_t x = 0; size_t n = sizeof(x); int mib[] = {CTL_HW, HW_PHYSMEM}; - if (sys_sysctl(mib, ARRAYLEN(mib), &x, &n, 0, 0) == -1) + if (sysctl(mib, ARRAYLEN(mib), &x, &n, 0, 0) == -1) return 0; return x; } @@ -65,7 +65,7 @@ static void GetLoads(uint64_t loads[3]) { struct loadavg loadinfo; int mib[2] = {CTL_VM, VM_LOADAVG}; size = sizeof(loadinfo); - if (sys_sysctl(mib, 2, &loadinfo, &size, 0, 0) != -1) { + if (sysctl(mib, 2, &loadinfo, &size, 0, 0) != -1) { for (int i = 0; i < 3; i++) { loads[i] = (double)loadinfo.ldavg[i] / loadinfo.fscale * 65536; } diff --git a/libc/calls/uname.c b/libc/calls/uname.c index 2f03c15b4..6c139776b 100644 --- a/libc/calls/uname.c +++ b/libc/calls/uname.c @@ -62,7 +62,7 @@ static void GetBsdStr(int c0, int c1, char *s) { size_t n = SYS_NMLN; int cmd[2] = {c0, c1}; bzero(s, n), --n; - sys_sysctl(cmd, 2, s, &n, NULL, 0); + sysctl(cmd, 2, s, &n, NULL, 0); errno = e; // sysctl kern.version is too verbose for uname if ((p = strchr(s, '\n'))) { diff --git a/libc/log/oncrash_amd64.c b/libc/log/oncrash_amd64.c index dccb03682..0c965faec 100644 --- a/libc/log/oncrash_amd64.c +++ b/libc/log/oncrash_amd64.c @@ -254,10 +254,28 @@ static relegated void ShowCrashReport(int err, int sig, struct siginfo *si, kprintf("\n"); } +static inline void SpinLock(atomic_uint *lock) { + int x; + for (;;) { + x = atomic_exchange_explicit(lock, 1, memory_order_acquire); + if (!x) + break; + } +} + +static inline void SpinUnlock(atomic_uint *lock) { + atomic_store_explicit(lock, 0, memory_order_release); +} + relegated void __oncrash(int sig, struct siginfo *si, void *arg) { + static atomic_uint lock; + BLOCK_CANCELATION; + SpinLock(&lock); int err = errno; __restore_tty(); ShowCrashReport(err, sig, si, arg); + SpinUnlock(&lock); + ALLOW_CANCELATION; } #endif /* __x86_64__ */ diff --git a/libc/log/oncrash_arm64.c b/libc/log/oncrash_arm64.c index ba0ba4019..47106759f 100644 --- a/libc/log/oncrash_arm64.c +++ b/libc/log/oncrash_arm64.c @@ -18,6 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "ape/sections.internal.h" #include "libc/assert.h" +#include "libc/atomic.h" #include "libc/calls/blockcancel.internal.h" #include "libc/calls/calls.h" #include "libc/calls/struct/aarch64.internal.h" @@ -32,6 +33,7 @@ #include "libc/calls/ucontext.h" #include "libc/cxxabi.h" #include "libc/errno.h" +#include "libc/intrin/atomic.h" #include "libc/intrin/describebacktrace.internal.h" #include "libc/intrin/describeflags.internal.h" #include "libc/intrin/kprintf.h" @@ -377,10 +379,25 @@ static relegated void __oncrash_impl(int sig, struct siginfo *si, klog(b->p, MIN(b->i, b->n)); } +static inline void SpinLock(atomic_uint *lock) { + int x; + for (;;) { + x = atomic_exchange_explicit(lock, 1, memory_order_acquire); + if (!x) + break; + } +} + +static inline void SpinUnlock(atomic_uint *lock) { + atomic_store_explicit(lock, 0, memory_order_release); +} + relegated void __oncrash(int sig, struct siginfo *si, void *arg) { - ucontext_t *ctx = arg; + static atomic_uint lock; BLOCK_CANCELATION; - __oncrash_impl(sig, si, ctx); + SpinLock(&lock); + __oncrash_impl(sig, si, arg); + SpinUnlock(&lock); ALLOW_CANCELATION; } diff --git a/libc/runtime/getinterpreterexecutablename.c b/libc/runtime/getinterpreterexecutablename.c index 81fef93e0..a5857faa4 100644 --- a/libc/runtime/getinterpreterexecutablename.c +++ b/libc/runtime/getinterpreterexecutablename.c @@ -74,9 +74,9 @@ char *GetInterpreterExecutableName(char *p, size_t n) { cmd[2] = 12; // KERN_PROC_PATHNAME } else { // cmd[2] = 5; // KERN_PROC_PATHNAME - } // - cmd[3] = -1; // current process - if (sys_sysctl(cmd, ARRAYLEN(cmd), p, &n, 0, 0) != -1) { + } // + cmd[3] = -1; // current process + if (sysctl(cmd, ARRAYLEN(cmd), p, &n, 0, 0) != -1) { errno = e; return p; } diff --git a/libc/runtime/getsysctl.c b/libc/runtime/getsysctl.c index 16602eff2..fe97f57a8 100644 --- a/libc/runtime/getsysctl.c +++ b/libc/runtime/getsysctl.c @@ -23,7 +23,7 @@ long __get_sysctl(int x, int y) { int value; int mib[2] = {x, y}; size_t len = sizeof(value); - if (sys_sysctl(mib, 2, &value, &len, 0, 0) != -1) { + if (sysctl(mib, 2, &value, &len, 0, 0) != -1) { return value; } else { return -1; diff --git a/libc/runtime/syslib.internal.h b/libc/runtime/syslib.internal.h index ec6d87fe5..90ed2994f 100644 --- a/libc/runtime/syslib.internal.h +++ b/libc/runtime/syslib.internal.h @@ -12,7 +12,7 @@ COSMOPOLITAN_C_START_ #define SYSLIB_MAGIC ('s' | 'l' << 8 | 'i' << 16 | 'b' << 24) -#define SYSLIB_VERSION 9 /* sync with ape/ape-m1.c */ +#define SYSLIB_VERSION 10 /* sync with ape/ape-m1.c */ /* if this number increases, then everyone on macos arm will need to reinstall ape loader in order to run newer ape binaries so please @@ -82,6 +82,9 @@ struct Syslib { char *(*__dlerror)(void); /* v9 (2024-01-31) */ int (*__pthread_cpu_number_np)(size_t *); + long (*__sysctl)(int *, unsigned, void *, size_t *, void *, size_t); + long (*__sysctlbyname)(const char *, void *, size_t *, void *, size_t); + long (*__sysctlnametomib)(const char *, int *, size_t *); }; extern struct Syslib *__syslib; diff --git a/third_party/awk/b.c b/third_party/awk/b.c index 870eecf58..3559e83c4 100644 --- a/third_party/awk/b.c +++ b/third_party/awk/b.c @@ -1463,6 +1463,7 @@ rescan: } break; } + __builtin_unreachable(); } int cgoto(fa *f, int s, int c) diff --git a/tool/emacs/cosmo-stuff.el b/tool/emacs/cosmo-stuff.el index 771b45ea3..bfca961fe 100644 --- a/tool/emacs/cosmo-stuff.el +++ b/tool/emacs/cosmo-stuff.el @@ -215,7 +215,7 @@ (runs (format "o/$m/%s%s V=5 TESTARGS=-b" name runsuffix)) (buns (format "o/$m/test/%s_test%s V=5 TESTARGS=-b" name runsuffix))) (cond ((not (member ext '("c" "cc" "cpp" "s" "S" "rl" "f" "cu"))) - (format "m=%s; make -j32 MODE=$m o/$m/%s" + (format "m=%s; make -j96 MODE=$m o/$m/%s" mode (directory-file-name (or (file-name-directory @@ -226,7 +226,7 @@ (cosmo-join " && " `("m=%s; f=o/$m/%s" - ,(concat "make -j32 $f MODE=$m") + ,(concat "make -j96 $f MODE=$m") "scp $f $f.dbg win10:; ssh win10 ./%s")) mode name (file-name-nondirectory name))) ((eq kind 'run-xnu) @@ -234,19 +234,19 @@ (cosmo-join " && " `("m=%s; f=o/$m/%s" - ,(concat "make -j32 $f MODE=$m") + ,(concat "make -j96 $f MODE=$m") "scp $f $f.dbg xnu:" "ssh xnu ./%s")) mode name (file-name-nondirectory name))) ((and (equal suffix "") (cosmo-contains "_test." (buffer-file-name))) - (format "m=%s; make -j32 MODE=$m %s" + (format "m=%s; make -j96 MODE=$m %s" mode runs)) ((and (equal suffix "") (file-exists-p (format "%s" buddy))) (format (cosmo-join " && " - '("m=%s; n=%s; make -j32 o/$m/$n%s.o MODE=$m" + '("m=%s; n=%s; make -j96 o/$m/$n%s.o MODE=$m" ;; "bloat o/$m/%s.o | head" ;; "nm -C --size o/$m/%s.o | sort -r" "echo" @@ -258,11 +258,11 @@ (cosmo-join " && " `("m=%s; f=o/$m/%s" - ,(concat "make -j32 $f MODE=$m") + ,(concat "make -j96 $f MODE=$m") "build/run ./$f")) mode name)) ((eq kind 'test) - (format `"m=%s; f=o/$m/%s.ok && make -j32 $f MODE=$m" mode name)) + (format `"m=%s; f=o/$m/%s.ok && make -j96 $f MODE=$m" mode name)) ((and (file-regular-p this) (file-executable-p this)) (format "build/run ./%s" file)) @@ -271,7 +271,7 @@ (cosmo-join " && " `("m=%s; f=o/$m/%s%s.o" - ,(concat "make -j32 $f MODE=$m") + ,(concat "make -j96 $f MODE=$m") ;; "nm -C --size $f | sort -r" "echo" "size -A $f | grep '^[.T]' | grep -v 'debug\\|command.line\\|stack' | sort -rnk2" @@ -481,7 +481,7 @@ (error "don't know how to show assembly for non c/c++ source file")) (let* ((default-directory root) (compile-command - (format "make %s -j32 MODE=%s %s %s" + (format "make %s -j96 MODE=%s %s %s" (or extra-make-flags "") mode asm-gcc asm-clang))) (save-buffer) (set-visited-file-modtime (current-time)) @@ -641,11 +641,11 @@ (compile (format "sh -c %s" file))) ((eq major-mode 'lua-mode) (let* ((mode (cosmo--make-mode arg))) - (compile (format "make -j32 MODE=%s o/%s/tool/net/redbean && build/run o/%s/tool/net/redbean -i %s" mode mode mode file)))) + (compile (format "make -j96 MODE=%s o/%s/tool/net/redbean && build/run o/%s/tool/net/redbean -i %s" mode mode mode file)))) ((and (eq major-mode 'python-mode) (cosmo-startswith "third_party/python/Lib/test/" file)) (let ((mode (cosmo--make-mode arg))) - (compile (format "make -j32 MODE=%s PYHARNESSARGS=-vv PYTESTARGS=-v o/%s/%s.py.runs" + (compile (format "make -j96 MODE=%s PYHARNESSARGS=-vv PYTESTARGS=-v o/%s/%s.py.runs" mode mode (file-name-sans-extension file))))) ((eq major-mode 'python-mode) (compile (format "python %s" file)))