diff --git a/examples/hello4.c b/examples/hello4.c index ee44444b0..960c530a9 100644 --- a/examples/hello4.c +++ b/examples/hello4.c @@ -13,6 +13,6 @@ int main(int argc, char *argv[]) { volatile long double x = -.5; volatile long double y = 1.5; - printf("atan2l(%.19Lg, %.19Lg) is %.19Lg\n", x, y, atan2l(x, y)); + printf("Hello World! %.19Lg\n", atan2l(x, y)); return 0; } diff --git a/libc/calls/addrusage.c b/libc/calls/addrusage.c index 7a72548c8..8572da2c6 100644 --- a/libc/calls/addrusage.c +++ b/libc/calls/addrusage.c @@ -16,15 +16,15 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/math.h" +#include "libc/calls/struct/rusage.h" #include "libc/macros.internal.h" /** - * Adds resource usages. + * Accumulates resource statistics in `y` to `x`. */ -void AddRusage(struct rusage *x, const struct rusage *y) { - x->ru_utime = AddTimeval(x->ru_utime, y->ru_utime); - x->ru_stime = AddTimeval(x->ru_stime, y->ru_stime); +void _addrusage(struct rusage *x, const struct rusage *y) { + x->ru_utime = _timeval_add(x->ru_utime, y->ru_utime); + x->ru_stime = _timeval_add(x->ru_stime, y->ru_stime); x->ru_maxrss = MAX(x->ru_maxrss, y->ru_maxrss); x->ru_ixrss += y->ru_ixrss; x->ru_idrss += y->ru_idrss; diff --git a/libc/calls/addtimeval.c b/libc/calls/addtimeval.c index ed3e522a9..6659bc085 100644 --- a/libc/calls/addtimeval.c +++ b/libc/calls/addtimeval.c @@ -16,12 +16,12 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/math.h" +#include "libc/calls/struct/timeval.h" /** * Adds two microsecond timestamps. */ -struct timeval AddTimeval(struct timeval x, struct timeval y) { +struct timeval _timeval_add(struct timeval x, struct timeval y) { x.tv_sec += y.tv_sec; x.tv_usec += y.tv_usec; if (x.tv_usec >= 1000000) { diff --git a/libc/calls/clock_getres.c b/libc/calls/clock_getres.c new file mode 100644 index 000000000..5258c2a36 --- /dev/null +++ b/libc/calls/clock_getres.c @@ -0,0 +1,69 @@ +/*-*- 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/asan.internal.h" +#include "libc/calls/strace.internal.h" +#include "libc/dce.h" +#include "libc/intrin/describeflags.internal.h" +#include "libc/sysv/consts/clock.h" +#include "libc/sysv/errfuns.h" +#include "libc/time/time.h" + +int sys_clock_getres(int, struct timespec *) hidden; + +static int sys_clock_getres_poly(int clock, struct timespec *ts, int64_t real) { + if (clock == CLOCK_REALTIME) { + ts->tv_sec = 0; + ts->tv_nsec = real; + return 0; + } else if (clock == CLOCK_MONOTONIC) { + ts->tv_sec = 0; + ts->tv_nsec = 1; + return 0; + } else { + return einval(); + } +} + +static int sys_clock_getres_nt(int clock, struct timespec *ts) { + return sys_clock_getres_poly(clock, ts, 100); +} + +static int sys_clock_getres_xnu(int clock, struct timespec *ts) { + return sys_clock_getres_poly(clock, ts, 1000); +} + +/** + * Returns granularity of clock. + */ +int clock_getres(int clock, struct timespec *ts) { + int rc; + if (!ts || (IsAsan() && !__asan_is_valid_timespec(ts))) { + rc = efault(); + } else if (clock == 127) { + rc = einval(); // 127 is used by consts.sh to mean unsupported + } else if (IsWindows()) { + rc = sys_clock_getres_nt(clock, ts); + } else if (IsXnu()) { + rc = sys_clock_getres_xnu(clock, ts); + } else { + rc = sys_clock_getres(clock, ts); + } + STRACE("clock_getres(%d, [%s]) → %d% m", clock, DescribeTimespec(rc, ts), rc); + return rc; +} diff --git a/libc/calls/clock_gettime-mono.c b/libc/calls/clock_gettime-mono.c new file mode 100644 index 000000000..474cb8eb8 --- /dev/null +++ b/libc/calls/clock_gettime-mono.c @@ -0,0 +1,60 @@ +/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ +│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ +╞══════════════════════════════════════════════════════════════════════════════╡ +│ Copyright 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/bits/likely.h" +#include "libc/calls/clock_gettime.internal.h" +#include "libc/intrin/spinlock.h" +#include "libc/nexgen32e/rdtsc.h" +#include "libc/nexgen32e/threaded.h" +#include "libc/nexgen32e/x86feature.h" +#include "libc/sysv/consts/clock.h" +#include "libc/sysv/errfuns.h" +#include "libc/time/clockstonanos.internal.h" +#include "libc/time/time.h" + +static struct { + bool once; + char lock; + uint64_t base; + struct timespec mono; +} g_mono; + +int sys_clock_gettime_mono(struct timespec *ts) { + // this routine stops being monotonic after 194 years of uptime + uint64_t nanos; + struct timespec res; + if (X86_HAVE(INVTSC)) { + if (__threaded) { + _spinlock(&g_mono.lock); + } + if (UNLIKELY(!g_mono.once)) { + clock_gettime(CLOCK_REALTIME, &g_mono.mono); + g_mono.base = rdtsc(); + g_mono.once = true; + } + nanos = ClocksToNanos(rdtsc(), g_mono.base); + res = g_mono.mono; + res.tv_sec += nanos / 1000000000; + res.tv_nsec += nanos % 1000000000; + _spunlock(&g_mono.lock); + *ts = res; + return 0; + } else { + return einval(); + } +} diff --git a/libc/calls/clock_gettime-nt.c b/libc/calls/clock_gettime-nt.c index 4330bf588..109886601 100644 --- a/libc/calls/clock_gettime-nt.c +++ b/libc/calls/clock_gettime-nt.c @@ -16,51 +16,22 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/bits/likely.h" +#include "libc/calls/clock_gettime.internal.h" #include "libc/calls/internal.h" -#include "libc/calls/struct/timespec.h" #include "libc/fmt/conv.h" -#include "libc/intrin/kprintf.h" -#include "libc/intrin/spinlock.h" -#include "libc/nexgen32e/rdtsc.h" -#include "libc/nexgen32e/threaded.h" -#include "libc/nexgen32e/x86feature.h" #include "libc/nt/struct/filetime.h" #include "libc/nt/synchronization.h" #include "libc/sysv/consts/clock.h" #include "libc/sysv/errfuns.h" -#include "libc/time/clockstonanos.internal.h" -textwindows int sys_clock_gettime_nt(int clockid, struct timespec *ts) { - uint64_t nanos; - static bool once; - static char lock; - struct timespec res; - static uint64_t base; +textwindows int sys_clock_gettime_nt(int clock, struct timespec *ts) { struct NtFileTime ft; - static struct timespec mono; - if (!ts) return efault(); - if (clockid == CLOCK_REALTIME) { + if (clock == CLOCK_REALTIME) { GetSystemTimeAsFileTime(&ft); *ts = FileTimeToTimeSpec(ft); return 0; - } else if ((clockid == CLOCK_MONOTONIC || clockid == CLOCK_MONOTONIC_RAW) && - X86_HAVE(INVTSC)) { - // this routine stops being monotonic after 194 years of uptime - if (__threaded) _spinlock(&lock); - if (UNLIKELY(!once)) { - GetSystemTimeAsFileTime(&ft); - mono = FileTimeToTimeSpec(ft); - base = rdtsc(); - once = true; - } - nanos = ClocksToNanos(rdtsc(), base); - res = mono; - res.tv_sec += nanos / 1000000000; - res.tv_nsec += nanos % 1000000000; - _spunlock(&lock); - *ts = res; - return 0; + } else if (clock == CLOCK_MONOTONIC) { + return sys_clock_gettime_mono(ts); } else { return einval(); } diff --git a/libc/calls/clock_gettime-xnu.c b/libc/calls/clock_gettime-xnu.c index 3b911f9c2..0c154c6bf 100644 --- a/libc/calls/clock_gettime-xnu.c +++ b/libc/calls/clock_gettime-xnu.c @@ -17,19 +17,28 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" +#include "libc/calls/clock_gettime.internal.h" #include "libc/calls/internal.h" +#include "libc/sysv/consts/clock.h" +#include "libc/sysv/errfuns.h" -int sys_clock_gettime_xnu(int clockid, struct timespec *ts) { +int sys_clock_gettime_xnu(int clock, struct timespec *ts) { axdx_t ad; - ad = sys_gettimeofday((struct timeval *)ts, NULL, NULL); - if (ad.ax != -1) { - if (ad.ax) { - ts->tv_sec = ad.ax; - ts->tv_nsec = ad.dx; + if (clock == CLOCK_REALTIME) { + ad = sys_gettimeofday((struct timeval *)ts, 0, 0); + if (ad.ax != -1) { + if (ad.ax) { + ts->tv_sec = ad.ax; + ts->tv_nsec = ad.dx; + } + ts->tv_nsec *= 1000; + return 0; + } else { + return -1; } - ts->tv_nsec *= 1000; - return 0; + } else if (clock == CLOCK_MONOTONIC) { + return sys_clock_gettime_mono(ts); } else { - return -1; + return einval(); } } diff --git a/libc/calls/clock_gettime.c b/libc/calls/clock_gettime.c index ee8c062ea..97238db59 100644 --- a/libc/calls/clock_gettime.c +++ b/libc/calls/clock_gettime.c @@ -48,23 +48,25 @@ * __clock_gettime l: 35𝑐 11𝑛𝑠 * sys_clock_gettime l: 220𝑐 71𝑛𝑠 * - * @param clockid can be CLOCK_REALTIME, CLOCK_MONOTONIC, etc. + * @param clock can be CLOCK_REALTIME, CLOCK_MONOTONIC, etc. * @param ts is where the result is stored * @return 0 on success, or -1 w/ errno - * @error EINVAL if clockid isn't supported on this system + * @error EINVAL if clock isn't supported on this system * @see strftime(), gettimeofday() * @asyncsignalsafe */ -int clock_gettime(int clockid, struct timespec *ts) { +int clock_gettime(int clock, struct timespec *ts) { int rc; - if (IsAsan() && !__asan_is_valid_timespec(ts)) { + if (clock == 127) { + rc = einval(); // 127 is used by consts.sh to mean unsupported + } else if (!ts || (IsAsan() && !__asan_is_valid_timespec(ts))) { rc = efault(); } else { - rc = __clock_gettime(clockid, ts); + rc = __clock_gettime(clock, ts); } #if SYSDEBUG if (!__time_critical) { - STRACE("clock_gettime(%d, [%s]) → %d% m", clockid, DescribeTimespec(rc, ts), + STRACE("clock_gettime(%d, [%s]) → %d% m", clock, DescribeTimespec(rc, ts), rc); } #endif diff --git a/libc/calls/clock_gettime.internal.h b/libc/calls/clock_gettime.internal.h index ba359b990..1e2ec68ed 100644 --- a/libc/calls/clock_gettime.internal.h +++ b/libc/calls/clock_gettime.internal.h @@ -9,6 +9,7 @@ typedef int clock_gettime_f(int, struct timespec *); extern clock_gettime_f *__clock_gettime; clock_gettime_f *__clock_gettime_get(bool *) hidden; int __clock_gettime_init(int, struct timespec *) hidden; +int sys_clock_gettime_mono(struct timespec *) hidden; COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/calls/math.h b/libc/calls/math.h deleted file mode 100644 index ce878d394..000000000 --- a/libc/calls/math.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef COSMOPOLITAN_LIBC_CALLS_MATH_H_ -#define COSMOPOLITAN_LIBC_CALLS_MATH_H_ -#include "libc/calls/struct/rusage.h" -#include "libc/calls/struct/timespec.h" -#include "libc/calls/struct/timeval.h" -#if !(__ASSEMBLER__ + __LINKER__ + 0) -COSMOPOLITAN_C_START_ - -struct timeval AddTimeval(struct timeval, struct timeval); -struct timespec AddTimespec(struct timespec, struct timespec); -void AddRusage(struct rusage *, const struct rusage *); - -COSMOPOLITAN_C_END_ -#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ -#endif /* COSMOPOLITAN_LIBC_CALLS_MATH_H_ */ diff --git a/libc/calls/nanosleep-nt.c b/libc/calls/nanosleep-nt.c index 4de595513..dc77434d0 100644 --- a/libc/calls/nanosleep-nt.c +++ b/libc/calls/nanosleep-nt.c @@ -16,64 +16,84 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/assert.h" #include "libc/calls/internal.h" #include "libc/calls/sig.internal.h" #include "libc/calls/state.internal.h" #include "libc/calls/strace.internal.h" -#include "libc/errno.h" -#include "libc/limits.h" #include "libc/macros.internal.h" +#include "libc/nexgen32e/rdtsc.h" #include "libc/nt/errors.h" -#include "libc/nt/nt/time.h" #include "libc/nt/synchronization.h" +#include "libc/sysv/consts/clock.h" #include "libc/sysv/errfuns.h" +#include "libc/time/clockstonanos.internal.h" -textwindows noinstrument int sys_nanosleep_nt(const struct timespec *req, - struct timespec *rem) { - int rc; +textwindows int sys_nanosleep_nt(const struct timespec *req, + struct timespec *rem) { bool alertable; uint32_t slice; - int64_t ms, sec, nsec; + uint64_t begin; + int64_t ms, toto, nanos; + struct timespec elapsed; + + // check req is legal timespec + if (!(0 <= req->tv_nsec && req->tv_nsec < 1000000000)) { + return einval(); + } + + // save beginning timestamp + if (!__time_critical && rem) { + begin = rdtsc(); + } else { + begin = 0; // to prevent uninitialized warning + } + + // convert timespec to milliseconds if (__builtin_mul_overflow(req->tv_sec, 1000, &ms) || - __builtin_add_overflow(ms, req->tv_nsec / 1000000, &ms)) { + __builtin_add_overflow(ms, (req->tv_nsec + 999999) / 1000000, &ms)) { ms = INT64_MAX; } - if (!ms && (req->tv_sec || req->tv_nsec)) { - ms = 1; - } - rc = 0; - do { + + for (toto = ms;;) { + + // check if signal was delivered if (!__time_critical && _check_interrupts(false, g_fds.p)) { - rc = eintr(); - break; + if (rem) { + nanos = ClocksToNanos(rdtsc(), begin); + elapsed.tv_sec = nanos / 1000000000; + elapsed.tv_nsec = nanos % 1000000000; + *rem = _timespec_sub(*req, elapsed); + if (rem->tv_sec < 0) { + rem->tv_sec = 0; + rem->tv_nsec = 0; + } + } + return eintr(); } + + // configure the sleep slice = MIN(__SIG_POLLING_INTERVAL_MS, ms); if (__time_critical) { alertable = false; } else { alertable = true; - POLLTRACE("sys_nanosleep_nt polling for %'ldms of %'ld"); + POLLTRACE("... sleeping %'ldms of %'ld", toto - ms, toto); } + + // perform the sleep if (SleepEx(slice, alertable) == kNtWaitIoCompletion) { - POLLTRACE("IOCP EINTR"); + POLLTRACE("IOCP EINTR"); // in case we ever figure it out continue; } - ms -= slice; - } while (ms > 0); - ms = MAX(ms, 0); - if (rem) { - sec = ms / 1000; - nsec = ms % 1000 * 1000000000; - rem->tv_nsec -= nsec; - if (rem->tv_nsec < 0) { - --rem->tv_sec; - rem->tv_nsec = 1000000000 - rem->tv_nsec; - } - rem->tv_sec -= sec; - if (rem->tv_sec < 0) { - rem->tv_sec = 0; - rem->tv_nsec = 0; + + // check if full duration has elapsed + if ((ms -= slice) <= 0) { + if (rem) { + rem->tv_sec = 0; + rem->tv_nsec = 0; + } + return 0; } } - return rc; } diff --git a/libc/calls/nanosleep-xnu.c b/libc/calls/nanosleep-xnu.c index fd279330a..ce6818c97 100644 --- a/libc/calls/nanosleep-xnu.c +++ b/libc/calls/nanosleep-xnu.c @@ -16,15 +16,43 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/calls.h" +#include "libc/calls/internal.h" +#include "libc/calls/struct/timespec.h" #include "libc/calls/struct/timeval.h" -#include "libc/macros.internal.h" -#include "libc/nexgen32e/nexgen32e.h" +#include "libc/errno.h" +#include "libc/fmt/conv.h" #include "libc/sock/internal.h" +#include "libc/sysv/consts/clock.h" int sys_nanosleep_xnu(const struct timespec *req, struct timespec *rem) { - long millis; - millis = req->tv_nsec / 1000; - millis = MAX(1, millis); - return sys_select(0, 0, 0, 0, &(struct timeval){req->tv_sec, millis}); + int rc; + axdx_t axdx; + struct timeval tv; + struct timespec begin, end, elapsed; + + if (rem) { + if (sys_clock_gettime_xnu(CLOCK_MONOTONIC, &begin) == -1) { + return -1; + } + } + + tv = _timespec2timeval(*req); + rc = sys_select(0, 0, 0, 0, &tv); + + if (rem) { + if (!rc) { + rem->tv_sec = 0; + rem->tv_nsec = 0; + } else if (rc == -1 && errno == EINTR) { + sys_clock_gettime_xnu(CLOCK_MONOTONIC, &end); + elapsed = _timespec_sub(end, begin); + *rem = _timespec_sub(*req, elapsed); + if (rem->tv_sec < 0) { + rem->tv_sec = 0; + rem->tv_nsec = 0; + } + } + } + + return rc; } diff --git a/libc/calls/nanosleep.c b/libc/calls/nanosleep.c index 153acc2be..c9ca75452 100644 --- a/libc/calls/nanosleep.c +++ b/libc/calls/nanosleep.c @@ -27,10 +27,26 @@ /** * Sleeps for a particular amount of time. + * + * @param req is the duration of time we should sleep + * @param rem if non-NULL will receive the amount of time that wasn't + * slept because a signal was delivered. If no signal's delivered + * then this value will be set to `{0, 0}`. It's also fine to set + * this value to the same pointer as `req`. + * @return 0 on success, or -1 w/ errno + * @raise EINVAL if `req->tv_nsec ∉ [0,1000000000)` + * @raise EINTR if a signal was delivered, and `rem` is updated + * @raise EFAULT if `req` is NULL or `req` / `rem` is a bad pointer + * @raise ENOSYS on bare metal + * @note POSIX.1 specifies nanosleep() measures against `CLOCK_REALTIME` + * however Linux measures uses `CLOCK_MONOTONIC`. This shouldn't + * matter, since POSIX.1 further specifies that discontinuous + * changes in `CLOCK_REALTIME` shouldn't impact nanosleep() * @norestart */ -noinstrument int nanosleep(const struct timespec *req, struct timespec *rem) { +int nanosleep(const struct timespec *req, struct timespec *rem) { int rc; + if (!req || (IsAsan() && (!__asan_is_valid_timespec(req) || (rem && !__asan_is_valid_timespec(rem))))) { rc = efault(); @@ -46,9 +62,21 @@ noinstrument int nanosleep(const struct timespec *req, struct timespec *rem) { } else { rc = sys_nanosleep_nt(req, rem); } + + // Linux Kernel doesn't change the remainder value on success, but + // some kernels like OpenBSD will. POSIX doesn't specify the Linux + // behavior. So we polyfill it here. + if (!rc && rem) { + rem->tv_sec = 0; + rem->tv_nsec = 0; + } + +#if defined(SYSDEBUG) && _POLLTRACE if (!__time_critical) { POLLTRACE("nanosleep(%s, [%s]) → %d% m", DescribeTimespec(rc, req), DescribeTimespec(rc, rem), rc); } +#endif + return rc; } diff --git a/libc/calls/pause-nt.c b/libc/calls/pause-nt.c new file mode 100644 index 000000000..24963db15 --- /dev/null +++ b/libc/calls/pause-nt.c @@ -0,0 +1,50 @@ +/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ +│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ +╞══════════════════════════════════════════════════════════════════════════════╡ +│ Copyright 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/internal.h" +#include "libc/calls/sig.internal.h" +#include "libc/calls/strace.internal.h" +#include "libc/calls/syscall_support-nt.internal.h" +#include "libc/nt/errors.h" +#include "libc/nt/synchronization.h" +#include "libc/sysv/errfuns.h" + +textwindows int sys_pause_nt(void) { + long ms, totoms; + ms = 0; + totoms = 0; + for (;;) { + + if (_check_interrupts(false, g_fds.p)) { + return eintr(); + } + + if (SleepEx(__SIG_POLLING_INTERVAL_MS, true) == kNtWaitIoCompletion) { + POLLTRACE("IOCP EINTR"); // in case we ever figure it out + continue; + } + +#if defined(SYSDEBUG) && defined(_POLLTRACE) + ms += __SIG_POLLING_INTERVAL_MS; + if (ms >= __SIG_LOGGING_INTERVAL_MS) { + totoms += ms, ms = 0; + POLLTRACE("... pausing for %'lums...", totoms); + } +#endif + } +} diff --git a/libc/calls/pause.c b/libc/calls/pause.c index 23886a070..7815d070d 100644 --- a/libc/calls/pause.c +++ b/libc/calls/pause.c @@ -18,34 +18,51 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/calls/strace.internal.h" -#include "libc/calls/struct/sigset.h" -#include "libc/calls/syscall-sysv.internal.h" +#include "libc/calls/syscall_support-nt.internal.h" #include "libc/dce.h" -#include "libc/errno.h" -#include "libc/nt/synchronization.h" -#include "libc/sysv/consts/sig.h" -#include "libc/sysv/errfuns.h" +#include "libc/sock/internal.h" /** * Waits for signal. * - * This suspends execution until an unmasked signal is delivered and its - * callback function has been called. The current signal mask is used. + * This suspends execution until an unmasked signal is delivered. If the + * signal delivery kills the process, this won't return. The signal mask + * of the current thread is used. If a signal handler exists, this shall + * return after it's been invoked. * - * @return should always be -1 w/ EINTR + * This function is equivalent to: + * + * select(0, 0, 0, 0, 0); + * + * However this has a tinier footprint and better logging. + * + * @return -1 w/ errno set to EINTR * @see sigsuspend() * @norestart */ int pause(void) { - int e, rc; - sigset_t mask; - e = errno; + int rc; STRACE("pause() → [...]"); - if ((rc = sys_pause()) == -1 && errno == ENOSYS) { - errno = e; - if (sigprocmask(SIG_BLOCK, 0, &mask) == -1) return -1; - rc = sigsuspend(&mask); + + if (!IsWindows()) { + // We'll polyfill pause() using select() with a null timeout, which + // should hopefully do the same thing, which means wait forever but + // the usual signal interrupt rules apply. + // + // "If the readfds, writefds, and errorfds arguments are all null + // pointers and the timeout argument is not a null pointer, the + // pselect() or select() function shall block for the time + // specified, or until interrupted by a signal. If the readfds, + // writefds, and errorfds arguments are all null pointers and the + // timeout argument is a null pointer, the pselect() or select() + // function shall block until interrupted by a signal." ──Quoth + // IEEE 1003.1-2017 §functions/select + // + rc = sys_select(0, 0, 0, 0, 0); + } else { + rc = sys_pause_nt(); } + STRACE("[...] pause → %d% m", rc); return rc; } diff --git a/libc/calls/prctl.c b/libc/calls/prctl.c index 500742d33..f9e7b94a6 100644 --- a/libc/calls/prctl.c +++ b/libc/calls/prctl.c @@ -26,7 +26,7 @@ /** * Tunes process on Linux. * - * @raise ENOSYS on non-Linux. + * @raise ENOSYS on non-Linux */ privileged int prctl(int operation, ...) { int rc; diff --git a/libc/calls/sched-sysv.internal.h b/libc/calls/sched-sysv.internal.h new file mode 100644 index 000000000..7da6db8f5 --- /dev/null +++ b/libc/calls/sched-sysv.internal.h @@ -0,0 +1,33 @@ +#ifndef COSMOPOLITAN_LIBC_CALLS_SCHED_SYSV_INTERNAL_H_ +#define COSMOPOLITAN_LIBC_CALLS_SCHED_SYSV_INTERNAL_H_ +#include "libc/calls/struct/sched_param.h" +#if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ + +#define MAXCPUS_NETBSD 256 +#define MAXCPUS_OPENBSD 64 +#define P_ALL_LWPS 0 /* for effect on all threads in pid */ + +int sys_sched_get_priority_max(int); +int sys_sched_get_priority_min(int); +int sys_sched_getparam(int, struct sched_param *); +int sys_sched_getscheduler(int); +int sys_sched_setaffinity(int, uint64_t, const void *) hidden; +int sys_sched_setparam(int, const struct sched_param *); +int sys_sched_setscheduler(int, int, const struct sched_param *); +int sys_sched_yield(void) hidden; +int64_t sys_sched_getaffinity(int, uint64_t, void *) hidden; + +int sys_sched_getscheduler_netbsd(int); +int sys_sched_setparam_netbsd(int, int, int, const struct sched_param *) // + asm("sys_sched_setparam"); +int sys_sched_getparam_netbsd(int, int, int *, struct sched_param *) // + asm("sys_sched_getparam"); +int sys_sched_setaffinity_netbsd(int, int, size_t, const void *) // + asm("sys_sched_setaffinity"); +int sys_sched_getaffinity_netbsd(int, int, size_t, void *) // + asm("sys_sched_setaffinity"); + +COSMOPOLITAN_C_END_ +#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ +#endif /* COSMOPOLITAN_LIBC_CALLS_SCHED_SYSV_INTERNAL_H_ */ diff --git a/libc/calls/sched_get_priority_max.c b/libc/calls/sched_get_priority_max.c new file mode 100644 index 000000000..e76043931 --- /dev/null +++ b/libc/calls/sched_get_priority_max.c @@ -0,0 +1,53 @@ +/*-*- 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/calls.h" +#include "libc/calls/sched-sysv.internal.h" +#include "libc/calls/strace.internal.h" +#include "libc/dce.h" +#include "libc/intrin/describeflags.internal.h" +#include "libc/sysv/consts/sched.h" +#include "libc/sysv/errfuns.h" + +static int sys_sched_get_priority_max_netbsd(int policy) { + if (policy == SCHED_OTHER) { + return -1; + } else if (policy == SCHED_RR || policy == SCHED_FIFO) { + return 63; // NetBSD Libc needs 19 system calls to compute this! + } else { + return einval(); + } +} + +/** + * Returns maximum `sched_param::sched_priority` for `policy`. + * + * @return priority, or -1 w/ errno + * @raise ENOSYS on XNU, Windows, OpenBSD + * @raise EINVAL if `policy` is invalid + */ +int sched_get_priority_max(int policy) { + int rc; + if (IsNetbsd()) { + rc = sys_sched_get_priority_max_netbsd(policy); + } else { + rc = sys_sched_get_priority_max(policy); + } + STRACE("sched_get_priority_max(%s) → %d% m", DescribeSchedPolicy(policy), rc); + return rc; +} diff --git a/libc/calls/sched_get_priority_min.c b/libc/calls/sched_get_priority_min.c new file mode 100644 index 000000000..7592ffae5 --- /dev/null +++ b/libc/calls/sched_get_priority_min.c @@ -0,0 +1,53 @@ +/*-*- 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/calls.h" +#include "libc/calls/sched-sysv.internal.h" +#include "libc/calls/strace.internal.h" +#include "libc/dce.h" +#include "libc/intrin/describeflags.internal.h" +#include "libc/sysv/consts/sched.h" +#include "libc/sysv/errfuns.h" + +static int sys_sched_get_priority_min_netbsd(int policy) { + if (policy == SCHED_OTHER) { + return -1; + } else if (policy == SCHED_RR || policy == SCHED_FIFO) { + return 0; // NetBSD Libc needs 19 system calls to compute this! + } else { + return einval(); + } +} + +/** + * Returns minimum `sched_param::sched_priority` for `policy`. + * + * @return priority, or -1 w/ errno + * @raise ENOSYS on XNU, Windows, OpenBSD + * @raise EINVAL if `policy` is invalid + */ +int sched_get_priority_min(int policy) { + int rc; + if (IsNetbsd()) { + rc = sys_sched_get_priority_min_netbsd(policy); + } else { + rc = sys_sched_get_priority_min(policy); + } + STRACE("sched_get_priority_min(%s) → %d% m", DescribeSchedPolicy(policy), rc); + return rc; +} diff --git a/libc/calls/sched_getaffinity.c b/libc/calls/sched_getaffinity.c index cc9362e95..08065f0f0 100644 --- a/libc/calls/sched_getaffinity.c +++ b/libc/calls/sched_getaffinity.c @@ -17,6 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" +#include "libc/calls/sched-sysv.internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/str/str.h" diff --git a/libc/calls/sched_getparam.c b/libc/calls/sched_getparam.c new file mode 100644 index 000000000..4482d81bc --- /dev/null +++ b/libc/calls/sched_getparam.c @@ -0,0 +1,28 @@ +/*-*- 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/sched-sysv.internal.h" +#include "libc/calls/struct/sched_param.h" + +/** + * Gets scheduler policy parameter. + * @raise ENOSYS on XNU, Windows + */ +int sched_getparam(int pid, struct sched_param *param) { + return sys_sched_getparam(pid, param); +} diff --git a/libc/calls/sched_getscheduler-netbsd.c b/libc/calls/sched_getscheduler-netbsd.c new file mode 100644 index 000000000..860acbc2b --- /dev/null +++ b/libc/calls/sched_getscheduler-netbsd.c @@ -0,0 +1,31 @@ +/*-*- 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/calls.h" +#include "libc/calls/sched-sysv.internal.h" +#include "libc/calls/struct/sched_param.h" + +int sys_sched_getscheduler_netbsd(int pid) { + int policy; + struct sched_param sp; + if (sys_sched_getparam_netbsd(pid, P_ALL_LWPS, &policy, &sp) != -1) { + return policy; + } else { + return -1; + } +} diff --git a/libc/calls/sched_getscheduler.c b/libc/calls/sched_getscheduler.c new file mode 100644 index 000000000..e25f06764 --- /dev/null +++ b/libc/calls/sched_getscheduler.c @@ -0,0 +1,39 @@ +/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ +│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ +╞══════════════════════════════════════════════════════════════════════════════╡ +│ Copyright 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/sched-sysv.internal.h" +#include "libc/calls/strace.internal.h" +#include "libc/calls/struct/sched_param.h" +#include "libc/dce.h" + +/** + * Gets scheduler policy for `pid`. + * + * @param pid is id of process (where 0 is same as getpid()) + * @return scheduler policy, or -1 w/ errno + */ +int sched_getscheduler(int pid) { + int rc; + if (IsNetbsd()) { + rc = sys_sched_getscheduler_netbsd(pid); + } else { + rc = sys_sched_getscheduler(pid); + } + STRACE("sched_getscheduler(%d) → %d% m", pid, rc); + return rc; +} diff --git a/libc/calls/sched_setaffinity.c b/libc/calls/sched_setaffinity.c index 3d917e045..d5c7ab6d9 100644 --- a/libc/calls/sched_setaffinity.c +++ b/libc/calls/sched_setaffinity.c @@ -18,6 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/bits/safemacros.internal.h" #include "libc/calls/calls.h" +#include "libc/calls/sched-sysv.internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/calls/syscall_support-nt.internal.h" diff --git a/libc/calls/sched_setparam.c b/libc/calls/sched_setparam.c new file mode 100644 index 000000000..fcb31c091 --- /dev/null +++ b/libc/calls/sched_setparam.c @@ -0,0 +1,28 @@ +/*-*- 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/sched-sysv.internal.h" +#include "libc/calls/struct/sched_param.h" + +/** + * Sets scheduler policy parameter. + * @raise ENOSYS on XNU, Windows + */ +int sched_setparam(int pid, const struct sched_param *param) { + return sys_sched_setparam(pid, param); +} diff --git a/libc/calls/sched_setscheduler.c b/libc/calls/sched_setscheduler.c new file mode 100644 index 000000000..018c29059 --- /dev/null +++ b/libc/calls/sched_setscheduler.c @@ -0,0 +1,106 @@ +/*-*- 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/sched-sysv.internal.h" +#include "libc/calls/strace.internal.h" +#include "libc/calls/struct/sched_param.h" +#include "libc/dce.h" +#include "libc/intrin/describeflags.internal.h" +#include "libc/nexgen32e/threaded.h" +#include "libc/str/str.h" +#include "libc/sysv/errfuns.h" + +/** + * Sets scheduling policy of process, e.g. + * + * struct sched_param p = {sched_get_priority_max(SCHED_OTHER)}; + * LOGIFNEG1(sched_setscheduler(0, SCHED_OTHER, &p)); + * + * Processes with numerically higher priority values are scheduled + * before processes with numerically lower priority values. + * + * @param pid is the id of the process whose scheduling policy should be + * changed. This applies to all threads associated with the process. + * Linux is special; the kernel treats this as a thread id (noting + * that `getpid() == gettid()` is always the case on Linux for the + * main thread) and will only take effect for the specified tid. + * Therefore this function is POSIX-compliant iif `!__threaded`. + * Setting `pid` to zero means the same thing as getpid(). + * + * @param policy specifies the kernel's timesharing strategy. + * + * The `policy` must have one of: + * + * - `SCHED_OTHER` (or `SCHED_NORMAL`) for the default policy + * - `SCHED_RR` for real-time round-robin scheduling + * - `SCHED_FIFO` for real-time first-in first-out scheduling + * - `SCHED_BATCH` for "batch" style execution of processes if + * supported (Linux), otherwise it's treated as `SCHED_OTHER` + * - `SCHED_IDLE` for running very low priority background jobs + * if it's supported (Linux), otherwise this is `SCHED_OTHER` + * + * The `policy` may optionally bitwise-or any one of: + * + * - `SCHED_RESET_ON_FORK` will cause the scheduling policy to be + * automatically reset to `SCHED_NORMAL` upon fork() if supported; + * otherwise this flag is polyfilled as zero, so that it may be + * safely used (without having to check if the o/s is Linux). + * + * @param param must be set to the scheduler parameter, which should be + * greater than or equal to sched_get_priority_min(policy) and less + * than or equal to sched_get_priority_max(policy). Linux allows the + * static priority range 1 to 99 for the `SCHED_FIFO` and `SCHED_RR` + * policies, and the priority 0 for the remaining policies. + * + * @return the former scheduling policy of the specified process. If + * this function fails, then the scheduling policy is not changed, + * and -1 w/ errno is returned. + * + * @raise ENOSYS on XNU, Windows, OpenBSD + * @raise EPERM if not authorized to use scheduler in question (e.g. + * trying to use a real-time scheduler as non-root on Linux) or + * possibly because pledge() was used and isn't allowing this + * @raise EINVAL if `param` is NULL + * @raise EINVAL if `policy` is invalid + * @raise EINVAL if `param` has value out of ranges defined by `policy` + */ +int sched_setscheduler(int pid, int policy, const struct sched_param *param) { + int rc, old; + + if (IsNetbsd()) { + rc = sys_sched_getscheduler_netbsd(pid); + } else { + rc = sys_sched_getscheduler(pid); + } + + if (rc != -1) { + old = rc; + if (IsNetbsd()) { + rc = sys_sched_setparam_netbsd(pid, P_ALL_LWPS, policy, param); + } else { + rc = sys_sched_setscheduler(pid, policy, param); + } + if (rc != -1) { + rc = old; + } + } + + STRACE("sched_setscheduler(%d, %s, %s) → %d% m", pid, + DescribeSchedPolicy(policy), DescribeSchedParam(param), rc); + return rc; +} diff --git a/libc/calls/scheduler.h b/libc/calls/scheduler.h deleted file mode 100644 index 079f33c5e..000000000 --- a/libc/calls/scheduler.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef COSMOPOLITAN_LIBC_CALLS_SCHED_H_ -#define COSMOPOLITAN_LIBC_CALLS_SCHED_H_ -#include "libc/calls/struct/sched_param.h" -#if !(__ASSEMBLER__ + __LINKER__ + 0) -COSMOPOLITAN_C_START_ - -int sched_setscheduler(int, int, const struct sched_param *); -int sched_getscheduler(int); -int sched_setparam(int, const struct sched_param *); -int sched_getparam(int, struct sched_param *); - -COSMOPOLITAN_C_END_ -#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ -#endif /* COSMOPOLITAN_LIBC_CALLS_SCHED_H_ */ diff --git a/libc/calls/setitimer-nt.c b/libc/calls/setitimer-nt.c index 32e8e4fa4..974ab8aa6 100644 --- a/libc/calls/setitimer-nt.c +++ b/libc/calls/setitimer-nt.c @@ -26,6 +26,7 @@ #include "libc/dce.h" #include "libc/errno.h" #include "libc/fmt/conv.h" +#include "libc/intrin/kprintf.h" #include "libc/log/check.h" #include "libc/math.h" #include "libc/nexgen32e/nexgen32e.h" @@ -80,6 +81,7 @@ textwindows void _check_sigalrm(void) { textwindows int sys_setitimer_nt(int which, const struct itimerval *newvalue, struct itimerval *out_opt_oldvalue) { long double elapsed, untilnext; + if (which != ITIMER_REAL || (newvalue && (!(0 <= newvalue->it_value.tv_usec && newvalue->it_value.tv_usec < 1000000) || @@ -87,6 +89,7 @@ textwindows int sys_setitimer_nt(int which, const struct itimerval *newvalue, newvalue->it_interval.tv_usec < 1000000)))) { return einval(); } + if (out_opt_oldvalue) { if (__hastimer) { elapsed = nowl() - __lastalrm; @@ -106,6 +109,7 @@ textwindows int sys_setitimer_nt(int which, const struct itimerval *newvalue, out_opt_oldvalue->it_value.tv_usec = 0; } } + if (newvalue) { if (newvalue->it_interval.tv_sec || newvalue->it_interval.tv_usec || newvalue->it_value.tv_sec || newvalue->it_value.tv_usec) { @@ -124,5 +128,6 @@ textwindows int sys_setitimer_nt(int which, const struct itimerval *newvalue, __hastimer = false; } } + return 0; } diff --git a/libc/calls/sleep.c b/libc/calls/sleep.c index f4dea02a5..aaacfaf02 100644 --- a/libc/calls/sleep.c +++ b/libc/calls/sleep.c @@ -16,16 +16,32 @@ │ 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/struct/timespec.h" -#include "libc/sysv/errfuns.h" +#include "libc/errno.h" +#include "libc/limits.h" #include "libc/time/time.h" /** - * Sleeps for a particular amount of time. + * Sleeps for particular number of seconds. + * + * @return 0 if the full time elapsed, otherwise we assume an interrupt + * was delivered, in which case the errno condition is ignored, and + * this function shall return the number of unslept seconds rounded + * using the ceiling function + * @see nanosleep(), usleep() * @asyncsignalsafe * @norestart */ -int sleep(uint32_t seconds) { - return nanosleep(&(struct timespec){seconds, 0}, NULL); +unsigned sleep(unsigned seconds) { + int err; + unsigned unslept; + struct timespec tv = {seconds}; + err = errno; + nanosleep(&tv, &tv); + errno = err; + unslept = tv.tv_sec; + if (tv.tv_nsec && unslept < UINT_MAX) { + ++unslept; + } + return unslept; } diff --git a/libc/calls/struct/bpf.h b/libc/calls/struct/bpf.h index 804a2b298..4021c1799 100644 --- a/libc/calls/struct/bpf.h +++ b/libc/calls/struct/bpf.h @@ -6,8 +6,8 @@ COSMOPOLITAN_C_START_ #define BPF_MAXINSNS 4096 #define BPF_CLASS(code) ((code)&0x07) -#define BPF_LD 0x00 /* load ops */ -#define BPF_LDX 0x01 /* load into register */ +#define BPF_LD 0x00 /* load into accumulator */ +#define BPF_LDX 0x01 /* load into index register */ #define BPF_ST 0x02 /* store from immediate */ #define BPF_STX 0x03 /* store from register */ #define BPF_ALU 0x04 /* 32-bit arithmetic */ @@ -19,6 +19,7 @@ COSMOPOLITAN_C_START_ #define BPF_W 0x00 /* 32-bit */ #define BPF_H 0x08 /* 16-bit */ #define BPF_B 0x10 /* 8-bit */ +#define BPF_DW 0x18 /* 64-bit (eBPF only) */ #define BPF_MODE(code) ((code)&0xe0) #define BPF_IMM 0x00 /* 64-bit immediate */ @@ -52,7 +53,6 @@ COSMOPOLITAN_C_START_ #define BPF_JMP32 0x06 #define BPF_ALU64 0x07 -#define BPF_DW 0x18 #define BPF_ATOMIC 0xc0 #define BPF_XADD 0xc0 #define BPF_MOV 0xb0 diff --git a/libc/calls/struct/rusage.h b/libc/calls/struct/rusage.h index d3902d037..64a8c3cb8 100644 --- a/libc/calls/struct/rusage.h +++ b/libc/calls/struct/rusage.h @@ -25,6 +25,7 @@ struct rusage { int getrusage(int, struct rusage *); int wait3(int *, int, struct rusage *); int wait4(int, int *, int, struct rusage *); +void _addrusage(struct rusage *, const struct rusage *); #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_RUSAGE_H_ */ diff --git a/libc/calls/struct/sched_param.h b/libc/calls/struct/sched_param.h index 718eb6e8c..4b67bb5f4 100644 --- a/libc/calls/struct/sched_param.h +++ b/libc/calls/struct/sched_param.h @@ -6,5 +6,12 @@ struct sched_param { int32_t sched_priority; }; +int sched_get_priority_max(int); +int sched_get_priority_min(int); +int sched_getparam(int, struct sched_param *); +int sched_getscheduler(int); +int sched_setparam(int, const struct sched_param *); +int sched_setscheduler(int, int, const struct sched_param *); + #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SCHED_PARAM_H_ */ diff --git a/libc/calls/struct/timespec.h b/libc/calls/struct/timespec.h index f5c407c4d..720d9c480 100644 --- a/libc/calls/struct/timespec.h +++ b/libc/calls/struct/timespec.h @@ -8,6 +8,9 @@ struct timespec { }; int sys_futex(int *, int, int, const struct timespec *, int *); +bool _timespec_gt(struct timespec, struct timespec); +struct timespec _timespec_add(struct timespec, struct timespec); +struct timespec _timespec_sub(struct timespec, struct timespec); #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMESPEC_H_ */ diff --git a/libc/calls/struct/timespec_gt.c b/libc/calls/struct/timespec_gt.c new file mode 100644 index 000000000..9cd111da2 --- /dev/null +++ b/libc/calls/struct/timespec_gt.c @@ -0,0 +1,34 @@ +/*-*- 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/struct/timespec.h" + +/** + * Returns true if timespec `x` is greater than `y`. + */ +bool _timespec_gt(struct timespec x, struct timespec y) { + if (x.tv_sec > y.tv_sec) { + return true; + } + if (x.tv_sec == y.tv_sec) { + if (x.tv_nsec > y.tv_nsec) { + return true; + } + } + return false; +} diff --git a/libc/calls/struct/timeval.h b/libc/calls/struct/timeval.h index 00b6ce22e..427e346f1 100644 --- a/libc/calls/struct/timeval.h +++ b/libc/calls/struct/timeval.h @@ -8,6 +8,7 @@ struct timeval { }; int lutimes(const char *, const struct timeval[2]); +struct timeval _timeval_add(struct timeval, struct timeval); #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMEVAL_H_ */ diff --git a/libc/calls/syscall-sysv.internal.h b/libc/calls/syscall-sysv.internal.h index d1ddb20d9..01391c428 100644 --- a/libc/calls/syscall-sysv.internal.h +++ b/libc/calls/syscall-sysv.internal.h @@ -74,8 +74,6 @@ i32 sys_pipe2(i32[hasatleast 2], u32) hidden; i32 sys_pledge(const char *, const char *) hidden; i32 sys_posix_openpt(i32) hidden; i32 sys_renameat(i32, const char *, i32, const char *) hidden; -i32 sys_sched_setaffinity(i32, u64, const void *) hidden; -i32 sys_sched_yield(void) hidden; i32 sys_setgid(i32) hidden; i32 sys_setpgid(i32, i32) hidden; i32 sys_setpriority(i32, u32, i32) hidden; @@ -103,7 +101,6 @@ i64 sys_pwrite(i32, const void *, u64, i64, i64) hidden; i64 sys_read(i32, void *, u64) hidden; i64 sys_readlink(const char *, char *, u64) hidden; i64 sys_readlinkat(int, const char *, char *, u64) hidden; -i64 sys_sched_getaffinity(i32, u64, void *) hidden; i64 sys_sendfile(i32, i32, i64 *, u64) hidden; i64 sys_splice(i32, i64 *, i32, i64 *, u64, u32) hidden; i64 sys_write(i32, const void *, u64) hidden; diff --git a/libc/calls/syscall_support-nt.internal.h b/libc/calls/syscall_support-nt.internal.h index d4beaee79..4ded0b8ce 100644 --- a/libc/calls/syscall_support-nt.internal.h +++ b/libc/calls/syscall_support-nt.internal.h @@ -13,6 +13,7 @@ int __mkntpath2(const char *, char16_t[hasatleast PATH_MAX], int) hidden; int __mkntpathat(int, const char *, int, char16_t[hasatleast PATH_MAX]) hidden; int __sample_pids(int[hasatleast 64], int64_t[hasatleast 64], bool) hidden; int ntaccesscheck(const char16_t *, uint32_t) paramsnonnull() hidden; +int sys_pause_nt(void) hidden; int64_t __fix_enotdir(int64_t, char16_t *) hidden; int64_t __fix_enotdir3(int64_t, char16_t *, char16_t *) hidden; int64_t __winerr(void) nocallback privileged; diff --git a/libc/calls/addtimespec.c b/libc/calls/timespec_add.c similarity index 94% rename from libc/calls/addtimespec.c rename to libc/calls/timespec_add.c index 889a64484..163cddf1e 100644 --- a/libc/calls/addtimespec.c +++ b/libc/calls/timespec_add.c @@ -16,12 +16,12 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/math.h" +#include "libc/calls/struct/timespec.h" /** * Adds two nanosecond timestamps. */ -struct timespec AddTimespec(struct timespec x, struct timespec y) { +struct timespec _timespec_add(struct timespec x, struct timespec y) { x.tv_sec += y.tv_sec; x.tv_nsec += y.tv_nsec; if (x.tv_nsec >= 10000000000) { diff --git a/libc/calls/timespec_sub.c b/libc/calls/timespec_sub.c new file mode 100644 index 000000000..5ba0d0fb4 --- /dev/null +++ b/libc/calls/timespec_sub.c @@ -0,0 +1,32 @@ +/*-*- 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/struct/timespec.h" + +/** + * Subtracts two nanosecond timestamps. + */ +struct timespec _timespec_sub(struct timespec x, struct timespec y) { + x.tv_sec -= y.tv_sec; + x.tv_nsec -= y.tv_nsec; + if (x.tv_nsec < 0) { + x.tv_nsec += 1000000000; + x.tv_sec -= 1; + } + return x; +} diff --git a/libc/calls/usleep.c b/libc/calls/usleep.c index 5160fb372..4c8ccf6bc 100644 --- a/libc/calls/usleep.c +++ b/libc/calls/usleep.c @@ -16,17 +16,21 @@ │ 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/struct/timespec.h" -#include "libc/sysv/errfuns.h" #include "libc/time/time.h" /** - * Sleeps for particular amount of microseconds. + * Sleeps for particular number of microseconds. + * + * @return 0 on success, or -1 w/ errno + * @raise EINTR if a signal was delivered while sleeping + * @see nanosleep(), sleep() * @norestart */ -int usleep(uint32_t microseconds) { - return nanosleep(&(struct timespec){(uint64_t)microseconds / 1000000, - (uint64_t)microseconds % 1000000 * 1000}, - NULL); +int usleep(uint32_t micros) { + struct timespec ts = { + micros / 1000000, + micros % 1000000 * 1000, + }; + return nanosleep(&ts, 0); } diff --git a/libc/calls/utimensat-sysv.c b/libc/calls/utimensat-sysv.c index 9ffabbe95..c2718e336 100644 --- a/libc/calls/utimensat-sysv.c +++ b/libc/calls/utimensat-sysv.c @@ -19,6 +19,7 @@ #include "libc/bits/weaken.h" #include "libc/calls/internal.h" #include "libc/errno.h" +#include "libc/fmt/conv.h" #include "libc/sysv/consts/at.h" #include "libc/time/time.h" #include "libc/zipos/zipos.internal.h" @@ -37,10 +38,8 @@ int sys_utimensat(int dirfd, const char *path, const struct timespec ts[2], if (rc == -1 && errno == ENOSYS && path) { errno = olderr; if (ts) { - tv[0].tv_sec = ts[0].tv_sec; - tv[0].tv_usec = ts[0].tv_nsec / 1000; - tv[1].tv_sec = ts[1].tv_sec; - tv[1].tv_usec = ts[1].tv_nsec / 1000; + tv[0] = _timespec2timeval(ts[0]); + tv[1] = _timespec2timeval(ts[1]); rc = sys_utimes(path, tv); } else { rc = sys_utimes(path, NULL); diff --git a/libc/calls/utimensat-xnu.c b/libc/calls/utimensat-xnu.c index 5f585a810..cc0b659b3 100644 --- a/libc/calls/utimensat-xnu.c +++ b/libc/calls/utimensat-xnu.c @@ -18,6 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/internal.h" #include "libc/calls/struct/stat.h" +#include "libc/fmt/conv.h" #include "libc/nexgen32e/nexgen32e.h" #include "libc/sysv/consts/at.h" #include "libc/sysv/consts/utime.h" @@ -40,20 +41,16 @@ int sys_utimensat_xnu(int dirfd, const char *path, const struct timespec ts[2], if (ts[0].tv_nsec == UTIME_NOW) { tv[0] = now; } else if (ts[0].tv_nsec == UTIME_OMIT) { - tv[0].tv_sec = st.st_atim.tv_sec; - tv[0].tv_usec = st.st_atim.tv_nsec / 1000; + tv[0] = _timespec2timeval(st.st_atim); } else { - tv[0].tv_sec = ts[0].tv_sec; - tv[0].tv_usec = ts[0].tv_nsec / 1000; + tv[0] = _timespec2timeval(ts[0]); } if (ts[1].tv_nsec == UTIME_NOW) { tv[1] = now; } else if (ts[1].tv_nsec == UTIME_OMIT) { - tv[1].tv_sec = st.st_mtim.tv_sec; - tv[1].tv_usec = st.st_mtim.tv_nsec / 1000; + tv[1] = _timespec2timeval(st.st_mtim); } else { - tv[1].tv_sec = ts[1].tv_sec; - tv[1].tv_usec = ts[1].tv_nsec / 1000; + tv[1] = _timespec2timeval(ts[1]); } } else { tv[0] = now; diff --git a/libc/dns/dns.h b/libc/dns/dns.h index 60f9f0b7d..ac83fa121 100644 --- a/libc/dns/dns.h +++ b/libc/dns/dns.h @@ -37,6 +37,15 @@ #define AI_ADDRCONFIG 0x0400 #define AI_V4MAPPED 0x0800 +#define NI_NUMERICSCOPE 0 +#define NI_NUMERICHOST 1 +#define NI_NUMERICSERV 2 +#define NI_NOFQDN 4 +#define NI_NAMEREQD 8 +#define NI_DGRAM 16 +#define NI_MAXSERV 32 +#define NI_MAXHOST 1025 + #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ diff --git a/libc/dns/ent.h b/libc/dns/ent.h index 13180ba92..c27f233fd 100644 --- a/libc/dns/ent.h +++ b/libc/dns/ent.h @@ -1,11 +1,15 @@ #ifndef COSMOPOLITAN_LIBC_DNS_ENT_H_ #define COSMOPOLITAN_LIBC_DNS_ENT_H_ #include "libc/dns/dns.h" + +#define HOST_NOT_FOUND 1 +#define TRY_AGAIN 2 +#define NO_RECOVERY 3 +#define NO_DATA 4 + #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -extern int h_errno; - struct netent { char *n_name; /* official network name */ char **n_aliases; /* alias list */ @@ -35,6 +39,10 @@ struct servent { char *s_proto; /* protocol to use */ }; +extern int h_errno; +void herror(const char *); +const char *hstrerror(int); + struct netent *getnetent(void); struct netent *getnetbyname(const char *); struct netent *getnetbyaddr(uint32_t, int); diff --git a/libc/dns/h_errno.c b/libc/dns/h_errno.c new file mode 100644 index 000000000..02f6afad8 --- /dev/null +++ b/libc/dns/h_errno.c @@ -0,0 +1,24 @@ +/*-*- 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/dns/dns.h" + +/** + * Error number global for gethostbyname*(), gethostbyaddr*(), etc. + */ +int h_errno; diff --git a/libc/dns/herror.c b/libc/dns/herror.c index 7b9480714..e08ef1f60 100644 --- a/libc/dns/herror.c +++ b/libc/dns/herror.c @@ -25,12 +25,12 @@ │ OTHER DEALINGS IN THE SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/dns/ent.h" +#include "libc/stdio/stdio.h" -int h_errno; - +/** + * Prints `h_errno` description to stderr. + * @see perror() + */ void herror(const char *s) { -} - -const char *hstrerror(int err) { - return "unknown"; + fprintf(stderr, "%s%s%s\n", s ? s : "", s ? ": " : "", hstrerror(h_errno)); } diff --git a/libc/dns/hstrerror.c b/libc/dns/hstrerror.c new file mode 100644 index 000000000..83ad3573d --- /dev/null +++ b/libc/dns/hstrerror.c @@ -0,0 +1,37 @@ +/*-*- 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/dns/ent.h" + +/** + * Turns `h_errno` value into string. + */ +const char *hstrerror(int err) { + switch (err) { + case HOST_NOT_FOUND: + return "HOST_NOT_FOUND"; + case TRY_AGAIN: + return "TRY_AGAIN"; + case NO_RECOVERY: + return "NO_RECOVERY"; + case NO_DATA: + return "NO_DATA"; + default: + return "UNKNOWN"; + } +} diff --git a/libc/fmt/conv.h b/libc/fmt/conv.h index cc67298b9..5c22bca1c 100644 --- a/libc/fmt/conv.h +++ b/libc/fmt/conv.h @@ -42,6 +42,7 @@ size_t wcsxfrm(wchar_t *, const wchar_t *, size_t); │ cosmopolitan § conversion » time ─╬─│┼ ╚────────────────────────────────────────────────────────────────────────────│*/ +struct timeval _timespec2timeval(struct timespec); int64_t DosDateTimeToUnix(unsigned, unsigned) libcesque nosideeffect; struct timeval WindowsTimeToTimeVal(int64_t) libcesque nosideeffect; struct timespec WindowsTimeToTimeSpec(int64_t) libcesque nosideeffect; diff --git a/libc/intrin/describeflags.internal.h b/libc/intrin/describeflags.internal.h index 7f7130c68..726797097 100644 --- a/libc/intrin/describeflags.internal.h +++ b/libc/intrin/describeflags.internal.h @@ -2,11 +2,13 @@ #define COSMOPOLITAN_LIBC_INTRIN_DESCRIBEFLAGS_INTERNAL_H_ #include "libc/calls/struct/iovec.h" #include "libc/calls/struct/rlimit.h" +#include "libc/calls/struct/sched_param.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/sigaltstack.h" #include "libc/calls/struct/sigset.h" #include "libc/calls/struct/stat.h" #include "libc/calls/struct/timespec.h" +#include "libc/calls/struct/timeval.h" #include "libc/mem/alloca.h" #include "libc/nt/struct/iovec.h" #include "libc/nt/struct/securityattributes.h" @@ -52,6 +54,8 @@ const char *DescribeProtFlags(char[48], int); const char *DescribeRemapFlags(char[48], int); const char *DescribeRlimit(char[64], int, const struct rlimit *); const char *DescribeRlimitName(char[20], int); +const char *DescribeSchedParam(char[32], const struct sched_param *); +const char *DescribeSchedPolicy(char[48], int); const char *DescribeSeccompOperation(int); const char *DescribeSigaction(char[128], int, const struct sigaction *); const char *DescribeSigaltstk(char[128], int, const struct sigaltstack *); @@ -64,6 +68,7 @@ const char *DescribeSocketProtocol(char[12], int); const char *DescribeSocketType(char[64], int); const char *DescribeStat(char[300], int, const struct stat *); const char *DescribeTimespec(char[45], int, const struct timespec *); +const char *DescribeTimeval(char[45], int, const struct timeval *); void DescribeIov(const struct iovec *, int, ssize_t); void DescribeIovNt(const struct NtIovec *, uint32_t, ssize_t); @@ -95,6 +100,8 @@ void DescribeIovNt(const struct NtIovec *, uint32_t, ssize_t); #define DescribeRemapFlags(dirfd) DescribeRemapFlags(alloca(48), dirfd) #define DescribeRlimit(rc, rl) DescribeRlimit(alloca(64), rc, rl) #define DescribeRlimitName(rl) DescribeRlimitName(alloca(20), rl) +#define DescribeSchedParam(x) DescribeSchedParam(alloca(32), x) +#define DescribeSchedPolicy(x) DescribeSchedPolicy(alloca(48), x) #define DescribeSigaction(rc, sa) DescribeSigaction(alloca(128), rc, sa) #define DescribeSigaltstk(rc, ss) DescribeSigaltstk(alloca(128), rc, ss) #define DescribeSigset(rc, ss) DescribeSigset(alloca(64), rc, ss) @@ -106,6 +113,7 @@ void DescribeIovNt(const struct NtIovec *, uint32_t, ssize_t); #define DescribeSocketType(x) DescribeSocketType(alloca(64), x) #define DescribeStat(rc, st) DescribeStat(alloca(300), rc, st) #define DescribeTimespec(rc, ts) DescribeTimespec(alloca(45), rc, ts) +#define DescribeTimeval(rc, ts) DescribeTimeval(alloca(45), rc, ts) COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/intrin/describeschedparam.c b/libc/intrin/describeschedparam.c new file mode 100644 index 000000000..bb453a29b --- /dev/null +++ b/libc/intrin/describeschedparam.c @@ -0,0 +1,36 @@ +/*-*- 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/struct/sched_param.h" +#include "libc/fmt/itoa.h" +#include "libc/intrin/describeflags.internal.h" +#include "libc/str/str.h" + +/** + * Describes clock_gettime() clock argument. + */ +const char *(DescribeSchedParam)(char buf[32], const struct sched_param *x) { + char *p; + if (!x) return "0"; + p = buf; + *p++ = '{'; + p = FormatInt32(p, x->sched_priority); + *p++ = '}'; + *p = 0; + return buf; +} diff --git a/libc/intrin/describeschedpolicy.c b/libc/intrin/describeschedpolicy.c new file mode 100644 index 000000000..529e5b661 --- /dev/null +++ b/libc/intrin/describeschedpolicy.c @@ -0,0 +1,40 @@ +/*-*- 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/fmt/itoa.h" +#include "libc/fmt/magnumstrs.internal.h" +#include "libc/intrin/describeflags.internal.h" +#include "libc/macros.internal.h" +#include "libc/str/str.h" +#include "libc/sysv/consts/sched.h" + +/** + * Describes clock_gettime() clock argument. + */ +const char *(DescribeSchedPolicy)(char buf[48], int x) { + struct DescribeFlags flags[] = { + {SCHED_RESET_ON_FORK, "RESET_ON_FORK"}, // + {SCHED_OTHER, "OTHER"}, // + {SCHED_FIFO, "FIFO"}, // + {SCHED_RR, "RR"}, // + {SCHED_BATCH, "BATCH"}, // + {SCHED_IDLE, "IDLE"}, // + {SCHED_DEADLINE, "DEADLINE"}, // + }; + return DescribeFlags(buf, 48, flags, ARRAYLEN(flags), "SCHED_", x); +} diff --git a/libc/intrin/describetimeval.c b/libc/intrin/describetimeval.c new file mode 100644 index 000000000..9fe88d7b8 --- /dev/null +++ b/libc/intrin/describetimeval.c @@ -0,0 +1,35 @@ +/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ +│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ +╞══════════════════════════════════════════════════════════════════════════════╡ +│ Copyright 2021 Justine Alexandra Roberts Tunney │ +│ │ +│ Permission to use, copy, modify, and/or distribute this software for │ +│ any purpose with or without fee is hereby granted, provided that the │ +│ above copyright notice and this permission notice appear in all copies. │ +│ │ +│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ +│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ +│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ +│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ +│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ +│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ +│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ +│ PERFORMANCE OF THIS SOFTWARE. │ +╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/calls/struct/timeval.h" +#include "libc/dce.h" +#include "libc/intrin/asan.internal.h" +#include "libc/intrin/describeflags.internal.h" +#include "libc/intrin/kprintf.h" + +const char *(DescribeTimeval)(char buf[45], int rc, const struct timeval *tv) { + if (rc == -1) return "n/a"; + if (!tv) return "NULL"; + if ((!IsAsan() && kisdangerous(tv)) || + (IsAsan() && !__asan_is_valid(tv, sizeof(*tv)))) { + ksnprintf(buf, 45, "%p", tv); + } else { + ksnprintf(buf, 45, "{%ld, %ld}", tv->tv_sec, tv->tv_usec); + } + return buf; +} diff --git a/libc/intrin/intrin.mk b/libc/intrin/intrin.mk index 6928d282a..62f3ed6be 100644 --- a/libc/intrin/intrin.mk +++ b/libc/intrin/intrin.mk @@ -145,10 +145,7 @@ o/$(MODE)/libc/intrin/createfilemapping.o \ o/$(MODE)/libc/intrin/createfilemappingnuma.o \ o/$(MODE)/libc/intrin/waitformultipleobjects.o \ o/$(MODE)/libc/intrin/generateconsolectrlevent.o \ -o/$(MODE)/libc/intrin/wsawaitformultipleevents.o \ -o/$(MODE)/libc/intrin/kstarttsc.o \ -o/$(MODE)/libc/intrin/nomultics.o \ -o/$(MODE)/libc/intrin/ntconsolemode.o: \ +o/$(MODE)/libc/intrin/wsawaitformultipleevents.o: \ OVERRIDE_CFLAGS += \ -Os \ -fwrapv \ diff --git a/libc/intrin/sched_yield.S b/libc/intrin/sched_yield.S index ab6384fff..6af736ef6 100644 --- a/libc/intrin/sched_yield.S +++ b/libc/intrin/sched_yield.S @@ -22,17 +22,11 @@ .privileged // Asks kernel to let other threads be scheduled. -// -// @return 0 on success, or -1 w/ errno +// @return 0 on success, or non-zero on failure +// @norestart sched_yield: - -#if SupportsXnu() - testb IsXnu() - jz 1f - pause - xor %eax,%eax - ret -#endif + push %rbp + mov %rsp,%rbp #if SupportsWindows() // Windows Support @@ -46,32 +40,43 @@ sched_yield: // ──Quoth MSDN testb IsWindows() jz 1f - push %rbp - mov %rsp,%rbp xor %ecx,%ecx xor %edx,%edx ntcall __imp_SleepEx xor %eax,%eax - pop %rbp - ret + jmp 9f +1: #endif #if SupportsSystemv() -// UNIX Support -1: mov __NR_sched_yield,%eax -#if SupportsBsd() && SupportsLinux() - clc -#endif +// On XNU we polyfill sched_yield() using sleep() which'll +// be polyfilled using select() with a zero timeout, which +// means to wait zero microseconds and then returns a zero +// and this hopefully will give other threads a chance too +// +// "If the readfds, writefds, and errorfds arguments are +// all null pointers and the timeout argument is not a +// null pointer, the pselect() or select() function shall +// block for the time specified, or until interrupted by +// a signal." ──Quoth IEEE 1003.1-2017 §functions/select +// +// On other platforms, sched_yield() takes no arguments. + push $0 # timeout.tv_usec + push $0 # timeout.tv_sec + xor %edi,%edi # nfds + xor %esi,%esi # readfds + xor %edx,%edx # writefds + xor %r10d,%r10d # exceptfds + mov %rsp,%r8 # timeout + mov __NR_sched_yield,%eax # ordinal + clc # linux syscall -#if SupportsBsd() - jc systemfive_errno -#endif -#if SupportsLinux() - cmp $-4095,%rax - jae systemfive_error -#endif +// It should not be possible for this to fail so we don't +// bother going through the errno ritual. If this somehow +// fails a positive or negative errno might get returned. #endif -2: ret +9: leave + ret .endfn sched_yield,globl .previous diff --git a/libc/intrin/timespec2timeval.c b/libc/intrin/timespec2timeval.c new file mode 100644 index 000000000..b19456080 --- /dev/null +++ b/libc/intrin/timespec2timeval.c @@ -0,0 +1,45 @@ +/*-*- 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/struct/timespec.h" +#include "libc/dce.h" +#include "libc/fmt/conv.h" + +// we don't want instrumentation because: +// - nanosleep() depends on this and ftrace can take microsecs + +/** + * Converts `struct timespec` to `struct timeval`. + * + * This divides ts.tv_nsec by 1000 with upward rounding and overflow + * handling. Your ts.tv_nsec must be on the interval `[0,1000000000)` + * otherwise `{-1, -1}` is returned. + * + * @return converted timeval whose tv_usec will be -1 on error + */ +noinstrument struct timeval _timespec2timeval(struct timespec ts) { + if (0 <= ts.tv_nsec && ts.tv_nsec < 1000000000) { + if (0 <= ts.tv_nsec && ts.tv_nsec < 1000000000 - 999) { + return (struct timeval){ts.tv_sec, (ts.tv_nsec + 999) / 1000}; + } else { + return (struct timeval){ts.tv_sec + 1, 0}; + } + } else { + return (struct timeval){-1, -1}; + } +} diff --git a/libc/intrin/tls.greg.c b/libc/intrin/tls.greg.c index a15bf9575..1df8109d2 100644 --- a/libc/intrin/tls.greg.c +++ b/libc/intrin/tls.greg.c @@ -92,9 +92,7 @@ privileged void __install_tls(char tib[64]) { assert(!__tls_enabled); assert(*(int *)(tib + 0x38) != -1); if (IsWindows()) { - if (!__tls_index) { - __tls_index = TlsAlloc(); - } + __tls_index = TlsAlloc(); asm("mov\t%1,%%gs:%0" : "=m"(*((long *)0x1480 + __tls_index)) : "r"(tib)); } else if (IsFreebsd()) { asm volatile("syscall" diff --git a/libc/log/showcrashreports.c b/libc/log/showcrashreports.c index 5827f3d96..d757ce568 100644 --- a/libc/log/showcrashreports.c +++ b/libc/log/showcrashreports.c @@ -42,6 +42,7 @@ static struct sigaltstack g_oldsigaltstack; static struct sigaction g_oldcrashacts[8]; static void InstallCrashHandlers(int extraflags) { + int e; size_t i; struct sigaction sa; bzero(&sa, sizeof(sa)); @@ -53,19 +54,24 @@ static void InstallCrashHandlers(int extraflags) { for (i = 0; i < ARRAYLEN(kCrashSigs); ++i) { if (kCrashSigs[i]) { sa.sa_sigaction = (sigaction_f)__oncrash_thunks[i]; + e = errno; sigaction(kCrashSigs[i], &sa, &g_oldcrashacts[i]); + errno = e; } } } relegated void RestoreDefaultCrashSignalHandlers(void) { + int e; size_t i; sigset_t ss; sigemptyset(&ss); sigprocmask(SIG_SETMASK, &ss, NULL); for (i = 0; i < ARRAYLEN(kCrashSigs); ++i) { if (kCrashSigs[i]) { + e = errno; sigaction(kCrashSigs[i], &g_oldcrashacts[i], NULL); + errno = e; } } } diff --git a/libc/mem/pledge.c b/libc/mem/pledge.c index bbbb6f6b4..921e78807 100644 --- a/libc/mem/pledge.c +++ b/libc/mem/pledge.c @@ -16,6 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/assert.h" #include "libc/calls/calls.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/bpf.h" @@ -25,12 +26,16 @@ #include "libc/calls/syscall_support-sysv.internal.h" #include "libc/dce.h" #include "libc/intrin/kprintf.h" +#include "libc/limits.h" #include "libc/macros.internal.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" +#include "libc/sock/struct/sockaddr.h" #include "libc/str/str.h" +#include "libc/sysv/consts/af.h" #include "libc/sysv/consts/audit.h" #include "libc/sysv/consts/f.h" +#include "libc/sysv/consts/map.h" #include "libc/sysv/consts/nrlinux.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/pr.h" @@ -38,9 +43,9 @@ #include "libc/sysv/errfuns.h" #define READONLY 0x8000 -#define ADDRLESS 0x8000 #define INET 0x8000 #define UNIX 0x4000 +#define ADDRLESS 0x2000 #define LOCK 0x8000 #define TTY 0x8000 @@ -58,8 +63,9 @@ static const uint16_t kPledgeLinuxDefault[] = { }; static const uint16_t kPledgeLinuxStdio[] = { - __NR_linux_clock_gettime, // __NR_linux_clock_getres, // + __NR_linux_clock_gettime, // + __NR_linux_clock_nanosleep, // __NR_linux_close, // __NR_linux_write, // __NR_linux_writev, // @@ -117,7 +123,6 @@ static const uint16_t kPledgeLinuxStdio[] = { __NR_linux_pipe2, // __NR_linux_poll, // __NR_linux_select, // - __NR_linux_recvmsg, // __NR_linux_recvfrom, // __NR_linux_sendto | ADDRLESS, // __NR_linux_ioctl, // @@ -131,6 +136,7 @@ static const uint16_t kPledgeLinuxStdio[] = { __NR_linux_umask, // __NR_linux_wait4, // __NR_linux_uname, // + __NR_linux_prctl, // }; static const uint16_t kPledgeLinuxFlock[] = { @@ -151,9 +157,6 @@ static const uint16_t kPledgeLinuxRpath[] = { __NR_linux_faccessat, // __NR_linux_readlink, // __NR_linux_readlinkat, // - __NR_linux_chmod, // - __NR_linux_fchmod, // - __NR_linux_fchmodat, // }; static const uint16_t kPledgeLinuxWpath[] = { @@ -167,6 +170,7 @@ static const uint16_t kPledgeLinuxWpath[] = { __NR_linux_access, // __NR_linux_faccessat, // __NR_linux_readlinkat, // + __NR_linux_chmod, // __NR_linux_fchmod, // __NR_linux_fchmodat, // }; @@ -186,6 +190,11 @@ static const uint16_t kPledgeLinuxCpath[] = { __NR_linux_mkdirat, // }; +static const uint16_t kPledgeLinuxDpath[] = { + __NR_linux_mknod, // + __NR_linux_mknodat, // +}; + static const uint16_t kPledgeLinuxFattr[] = { __NR_linux_chmod, // __NR_linux_fchmod, // @@ -235,6 +244,10 @@ static const uint16_t kPledgeLinuxTty[] = { __NR_linux_ioctl | TTY, // }; +static const uint16_t kPledgeLinuxRecvfd[] = { + __NR_linux_recvmsg, // +}; + static const uint16_t kPledgeLinuxProc[] = { __NR_linux_fork, // __NR_linux_vfork, // @@ -282,12 +295,14 @@ static const struct Pledges { {"rpath", PLEDGE(kPledgeLinuxRpath)}, // {"wpath", PLEDGE(kPledgeLinuxWpath)}, // {"cpath", PLEDGE(kPledgeLinuxCpath)}, // + {"dpath", PLEDGE(kPledgeLinuxDpath)}, // {"flock", PLEDGE(kPledgeLinuxFlock)}, // {"fattr", PLEDGE(kPledgeLinuxFattr)}, // {"inet", PLEDGE(kPledgeLinuxInet)}, // {"unix", PLEDGE(kPledgeLinuxUnix)}, // {"dns", PLEDGE(kPledgeLinuxDns)}, // {"tty", PLEDGE(kPledgeLinuxTty)}, // + {"recvfd", PLEDGE(kPledgeLinuxRecvfd)}, // {"proc", PLEDGE(kPledgeLinuxProc)}, // {"thread", PLEDGE(kPledgeLinuxThread)}, // {"exec", PLEDGE(kPledgeLinuxExec)}, // @@ -321,16 +336,20 @@ static bool AppendFilter(struct Filter *f, struct sock_filter *p, size_t n) { } // SYSCALL is only allowed in the .privileged section +// We assume program image is loaded in 32-bit spaces static bool AppendOriginVerification(struct Filter *f) { intptr_t x = (intptr_t)__privileged_start; intptr_t y = (intptr_t)__privileged_end; + assert(0 < x && x < y && y < INT_MAX); struct sock_filter fragment[] = { - /*L1*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(instruction_pointer)), - /*L2*/ BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, x, 0, 4 - 3), - /*L3*/ BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, y, 0, 5 - 4), - /*L4*/ BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_KILL), - /*L5*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(nr)), - /*L6*/ /* next filter */ + /*L0*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(instruction_pointer) + 4), + /*L1*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0, 0, 5 - 2), + /*L2*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(instruction_pointer)), + /*L3*/ BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, x, 0, 5 - 4), + /*L4*/ BPF_JUMP(BPF_JMP | BPF_JGE | BPF_K, y, 0, 6 - 5), + /*L5*/ BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_KILL), + /*L6*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(nr)), + /*L7*/ /* next filter */ }; return AppendFilter(f, PLEDGE(fragment)); } @@ -469,7 +488,7 @@ static bool AllowGetsockopt(struct Filter *f) { return AppendFilter(f, PLEDGE(fragment)); } -// The flags parameter must not have: +// The flags parameter of mmap() must not have: // // - MAP_LOCKED (0x02000) // - MAP_POPULATE (0x08000) @@ -477,24 +496,25 @@ static bool AllowGetsockopt(struct Filter *f) { // - MAP_HUGETLB (0x40000) // static bool AllowMmap(struct Filter *f) { - static const struct sock_filter fragment[] = { - /*L0*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_linux_mmap, 0, 9 - 1), - /*L1*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(args[2])), // prot - /*L2*/ BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0x80), // lazy - /*L3*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0, 0, 8 - 4), - /*L4*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(args[3])), // flags - /*L5*/ BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0x5a000), - /*L6*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0, 0, 8 - 7), - /*L7*/ BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW), - /*L8*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(nr)), - /*L9*/ /* next filter */ + intptr_t y = (intptr_t)__privileged_end; + assert(0 < y && y < INT_MAX); + struct sock_filter fragment[] = { + /*L0*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_linux_mmap, 0, 6 - 1), + /*L1*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(args[3])), // flags + /*L2*/ BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0x5a000), + /*L3*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0, 0, 5 - 4), + /*L4*/ BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW), + /*L5*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(nr)), + /*L6*/ /* next filter */ }; return AppendFilter(f, PLEDGE(fragment)); } -// The prot parameter of mmap() must not have: +// The prot parameter of mmap() may only have: // -// - PROT_EXEC (4) +// - PROT_NONE (0) +// - PROT_READ (1) +// - PROT_WRITE (2) // // The flags parameter must not have: // @@ -507,7 +527,7 @@ static bool AllowMmapNoexec(struct Filter *f) { static const struct sock_filter fragment[] = { /*L0*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_linux_mmap, 0, 9 - 1), /*L1*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(args[2])), // prot - /*L2*/ BPF_STMT(BPF_ALU | BPF_AND | BPF_K, PROT_EXEC), + /*L2*/ BPF_STMT(BPF_ALU | BPF_AND | BPF_K, ~(PROT_READ | PROT_WRITE)), /*L3*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0, 0, 8 - 4), /*L4*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(args[3])), // flags /*L5*/ BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0x5a000), @@ -519,15 +539,17 @@ static bool AllowMmapNoexec(struct Filter *f) { return AppendFilter(f, PLEDGE(fragment)); } -// The prot parameter of mprotect() must not have: +// The prot parameter of mprotect() may only have: // -// - PROT_EXEC (4) +// - PROT_NONE (0) +// - PROT_READ (1) +// - PROT_WRITE (2) // static bool AllowMprotectNoexec(struct Filter *f) { static const struct sock_filter fragment[] = { /*L0*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_linux_mprotect, 0, 6 - 1), /*L1*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(args[2])), // prot - /*L2*/ BPF_STMT(BPF_ALU | BPF_AND | BPF_K, PROT_EXEC), + /*L2*/ BPF_STMT(BPF_ALU | BPF_AND | BPF_K, ~(PROT_READ | PROT_WRITE)), /*L3*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0, 0, 5 - 4), /*L4*/ BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW), /*L5*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(nr)), @@ -536,10 +558,9 @@ static bool AllowMprotectNoexec(struct Filter *f) { return AppendFilter(f, PLEDGE(fragment)); } -// The flags parameter of open() must not have: +// The open() system call is permitted only when // -// - O_WRONLY (1) -// - O_RDWR (2) +// - (flags & O_ACCMODE) == O_RDONLY // static bool AllowOpenReadonly(struct Filter *f) { static const struct sock_filter fragment[] = { @@ -677,11 +698,30 @@ static bool AllowFcntlLock(struct Filter *f) { // // - NULL // -static bool AllowSendtoRestricted(struct Filter *f) { +static bool AllowSendtoAddrless(struct Filter *f) { static const struct sock_filter fragment[] = { - /*L0*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_linux_sendto, 0, 5 - 1), - /*L1*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(args[4])), - /*L2*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0, 0, 4 - 3), + /*L0*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_linux_sendto, 0, 7 - 1), + /*L1*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(args[4]) + 0), + /*L2*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0, 0, 6 - 3), + /*L3*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(args[4]) + 4), + /*L4*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0, 0, 6 - 3), + /*L5*/ BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW), + /*L6*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(nr)), + /*L7*/ /* next filter */ + }; + return AppendFilter(f, PLEDGE(fragment)); +} + +// The sig parameter of sigaction() must NOT be +// +// - SIGSYS (31) +// +static bool AllowSigaction(struct Filter *f) { + static const int nr = __NR_linux_sigaction; + static const struct sock_filter fragment[] = { + /*L0*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, nr, 0, 5 - 1), + /*L1*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(args[0])), + /*L2*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 31, 4 - 3, 0), /*L3*/ BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW), /*L4*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(nr)), /*L5*/ /* next filter */ @@ -691,18 +731,42 @@ static bool AllowSendtoRestricted(struct Filter *f) { // The family parameter of socket() must be one of: // -// - AF_INET (2) +// - AF_INET (2) // - AF_INET6 (10) // +// The type parameter of socket() will ignore: +// +// - SOCK_CLOEXEC (0x80000) +// - SOCK_NONBLOCK (0x00800) +// +// The type parameter of socket() must be one of: +// +// - SOCK_STREAM (1) +// - SOCK_DGRAM (2) +// +// The protocol parameter of socket() must be one of: +// +// - 0 +// - IPPROTO_TCP (6) +// - IPPROTO_UDP (17) +// static bool AllowSocketInet(struct Filter *f) { static const struct sock_filter fragment[] = { - /*L0*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_linux_socket, 0, 6 - 1), - /*L1*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(args[0])), - /*L2*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 2, 4 - 3, 0), - /*L3*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 10, 0, 5 - 4), - /*L4*/ BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW), - /*L5*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(nr)), - /*L6*/ /* next filter */ + /* L0*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_linux_socket, 0, 14 - 1), + /* L1*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(args[0])), + /* L2*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 2, 4 - 3, 0), + /* L3*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 10, 0, 13 - 4), + /* L4*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(args[1])), + /* L5*/ BPF_STMT(BPF_ALU | BPF_AND | BPF_K, ~0x80800), + /* L6*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 1, 8 - 7, 0), + /* L7*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 2, 0, 13 - 8), + /* L8*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(args[2])), + /* L9*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0, 12 - 10, 0), + /*L10*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 6, 12 - 11, 0), + /*L11*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 17, 0, 13 - 11), + /*L12*/ BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW), + /*L13*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(nr)), + /*L14*/ /* next filter */ }; return AppendFilter(f, PLEDGE(fragment)); } @@ -712,14 +776,60 @@ static bool AllowSocketInet(struct Filter *f) { // - AF_UNIX (1) // - AF_LOCAL (1) // +// The type parameter of socket() will ignore: +// +// - SOCK_CLOEXEC (0x80000) +// - SOCK_NONBLOCK (0x00800) +// +// The type parameter of socket() must be one of: +// +// - SOCK_STREAM (1) +// - SOCK_DGRAM (2) +// +// The protocol parameter of socket() must be one of: +// +// - 0 +// static bool AllowSocketUnix(struct Filter *f) { static const struct sock_filter fragment[] = { - /*L0*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_linux_socket, 0, 5 - 1), + /* L0*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_linux_socket, 0, 11 - 1), + /* L1*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(args[0])), + /* L2*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 1, 0, 10 - 3), + /* L3*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(args[1])), + /* L5*/ BPF_STMT(BPF_ALU | BPF_AND | BPF_K, ~0x80800), + /* L5*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 1, 7 - 6, 0), + /* L6*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 2, 0, 10 - 7), + /* L7*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(args[2])), + /* L8*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0, 0, 10 - 9), + /* L9*/ BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW), + /*L10*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(nr)), + /*L11*/ /* next filter */ + }; + return AppendFilter(f, PLEDGE(fragment)); +} + +// The first parameter of prctl() can be any of +// +// - PR_SET_NO_NEW_PRIVS (38) +// - PR_SET_SECCOMP (22) +// +// The second parameter of prctl() can be any of +// +// - true (1) +// - SECCOMP_MODE_FILTER (2) +// +static bool AllowPrctl(struct Filter *f) { + static const struct sock_filter fragment[] = { + /*L0*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_linux_prctl, 0, 9 - 1), /*L1*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(args[0])), - /*L2*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 1, 0, 4 - 3), - /*L3*/ BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW), - /*L4*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(nr)), - /*L5*/ /* next filter */ + /*L2*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 38, 4 - 3, 0), + /*L3*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 22, 0, 8 - 4), + /*L4*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(args[1])), + /*L5*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 1, 7 - 6, 0), + /*L6*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 2, 0, 8 - 7), + /*L7*/ BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW), + /*L8*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(nr)), + /*L9*/ /* next filter */ }; return AppendFilter(f, PLEDGE(fragment)); } @@ -809,6 +919,12 @@ static bool AppendPledge(struct Filter *f, const uint16_t *p, size_t len, case __NR_linux_fchmodat: if (!AllowFchmodat(f)) return false; break; + case __NR_linux_sigaction: + if (!AllowSigaction(f)) return false; + break; + case __NR_linux_prctl: + if (!AllowPrctl(f)) return false; + break; case __NR_linux_open: if (!AllowOpen(f)) return false; break; @@ -846,9 +962,10 @@ static bool AppendPledge(struct Filter *f, const uint16_t *p, size_t len, if (!AllowSocketUnix(f)) return false; break; case __NR_linux_sendto | ADDRLESS: - if (!AllowSendtoRestricted(f)) return false; + if (!AllowSendtoAddrless(f)) return false; break; default: + assert(~p[i] & ~0xfff); if (!AllowSyscall(f, p[i])) return false; break; } @@ -912,11 +1029,13 @@ static int sys_pledge_linux(const char *promises, const char *execpromises) { * * pledge("stdio tty", 0); * - * Pledging causes most system calls to become unavailable. On Linux the - * disabled calls will return EPERM whereas OpenBSD kills the process. - * - * Using pledge is irreversible. On Linux it causes PR_SET_NO_NEW_PRIVS - * to be set on your process. + * Pledging causes most system calls to become unavailable. Your system + * call policy is enforced by the kernel, which means it can propagate + * across execve() if permitted. This system call is supported on + * OpenBSD and Linux where it's polyfilled using SECCOMP BPF. The way it + * works on Linux is verboten system calls will raise EPERM whereas + * OpenBSD just kills the process while logging a helpful message to + * /var/log/messages explaining which promise category you needed. * * By default exit and exit_group are always allowed. This is useful * for processes that perform pure computation and interface with the @@ -926,9 +1045,8 @@ static int sys_pledge_linux(const char *promises, const char *execpromises) { * permit the sticky/setuid/setgid bits to change. Linux will EPERM here * and OpenBSD should ignore those three bits rather than crashing. * - * User and group IDs also can't be changed once pledge is in effect. - * OpenBSD should ignore the chown functions without crashing. Linux - * will just EPERM. + * User and group IDs can't be changed once pledge is in effect. OpenBSD + * should ignore chown without crashing; whereas Linux will just EPERM. * * Memory functions won't permit creating executable code after pledge. * Restrictions on origin of SYSCALL instructions will become enforced @@ -937,26 +1055,40 @@ static int sys_pledge_linux(const char *promises, const char *execpromises) { * exception is if the "exec" group is specified, in which case these * restrictions need to be loosened. * + * Using pledge is irreversible. On Linux it causes PR_SET_NO_NEW_PRIVS + * to be set on your process; however, if "id" or "recvfd" are allowed + * then then they theoretically could permit the gaining of some new + * privileges. You may call pledge() multiple times if "stdio" is + * allowed. In that case, the process can only move towards a more + * restrictive state. + * + * pledge() can't filter file system paths or internet addresses. For + * example, if you enable a category like "inet" then your process will + * be able to talk to any internet address. The same applies to + * categories like "wpath" and "cpath"; if enabled, any path the + * effective user id is permitted to change will be changeable. + * * `promises` is a string that may include any of the following groups * delimited by spaces. * - * - "stdio" allows clock_getres, clock_gettime, close, dup, dup2, dup3, - * fchdir, fstat, fsync, fdatasync, ftruncate, getdents, getegid, - * getrandom, geteuid, getgid, getgroups, getitimer, getpgid, getpgrp, - * getpid, getppid, getresgid, getresuid, getrlimit, getsid, - * gettimeofday, getuid, lseek, madvise, brk, arch_prctl, uname, - * set_tid_address, mmap (PROT_EXEC and weird flags aren't allowed), - * mprotect (PROT_EXEC isn't allowed), msync, munmap, nanosleep, pipe, - * pipe2, read, readv, pread, recv, recvmsg, poll, recvfrom, preadv, - * write, writev, pwrite, pwritev, select, send, sendto (only if addr - * is null), setitimer, shutdown, sigaction, sigaltstack, sigprocmask, - * sigreturn, sigsuspend, umask socketpair, wait4, ioctl(FIONREAD), - * ioctl(FIONBIO), ioctl(FIOCLEX), ioctl(FIONCLEX), fcntl(F_GETFD), - * fcntl(F_SETFD), fcntl(F_GETFL), fcntl(F_SETFL). + * - "stdio" allows close, dup, dup2, dup3, fchdir, fstat, fsync, + * fdatasync, ftruncate, getdents, getegid, getrandom, geteuid, + * getgid, getgroups, getitimer, getpgid, getpgrp, getpid, getppid, + * getresgid, getresuid, getrlimit, getsid, wait4, gettimeofday, + * getuid, lseek, madvise, brk, arch_prctl, uname, set_tid_address, + * clock_getres, clock_gettime, clock_nanosleep, mmap (PROT_EXEC and + * weird flags aren't allowed), mprotect (PROT_EXEC isn't allowed), + * msync, munmap, nanosleep, pipe, pipe2, read, readv, pread, recv, + * poll, recvfrom, preadv, write, writev, pwrite, pwritev, select, + * send, sendto (only if addr is null), setitimer, shutdown, sigaction + * (but SIGSYS is forbidden), sigaltstack, sigprocmask, sigreturn, + * sigsuspend, umask, socketpair, ioctl(FIONREAD), ioctl(FIONBIO), + * ioctl(FIOCLEX), ioctl(FIONCLEX), fcntl(F_GETFD), fcntl(F_SETFD), + * fcntl(F_GETFL), fcntl(F_SETFL). * * - "rpath" (read-only path ops) allows chdir, getcwd, open(O_RDONLY), * openat(O_RDONLY), stat, fstat, lstat, fstatat, access, faccessat, - * readlink, readlinkat, chmod, fchmod, fchmodat. + * readlink, readlinkat. * * - "wpath" (write path ops) allows getcwd, open, openat, stat, fstat, * lstat, fstatat, access, faccessat, readlink, readlinkat, chmod, @@ -966,12 +1098,16 @@ static int sys_pledge_linux(const char *promises, const char *execpromises) { * linkat, symlink, symlinkat, unlink, rmdir, unlinkat, mkdir, * mkdirat. * + * - "dpath" (create special path ops) allows mknod, mknodat, mkfifo. + * * - "flock" allows flock, fcntl(F_GETLK), fcntl(F_SETLK), * fcntl(F_SETLKW). * * - "tty" allows ioctl(TIOCGWINSZ), ioctl(TCGETS), ioctl(TCSETS), * ioctl(TCSETSW), ioctl(TCSETSF). * + * - "recvfd" allows recvmsg(SCM_RIGHTS). + * * - "fattr" allows chmod, fchmod, fchmodat, utime, utimes, futimens, * utimensat. * @@ -998,6 +1134,7 @@ static int sys_pledge_linux(const char *promises, const char *execpromises) { * * @return 0 on success, or -1 w/ errno * @raise ENOSYS if host os isn't Linux or OpenBSD + * @raise EINVAL if `execpromises` is used on Linux */ int pledge(const char *promises, const char *execpromises) { int rc; diff --git a/libc/runtime/runtime.h b/libc/runtime/runtime.h index 81266e839..75b74683e 100644 --- a/libc/runtime/runtime.h +++ b/libc/runtime/runtime.h @@ -117,6 +117,7 @@ unsigned char *GetFirstInstruction(void); unsigned char *GetInstructionLengths(void); void __print_maps(void); void __warn_if_powersave(void); +const char *__describe_os(void); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/sock/select.c b/libc/sock/select.c index e322a2db7..7afa8f3b8 100644 --- a/libc/sock/select.c +++ b/libc/sock/select.c @@ -16,8 +16,10 @@ │ 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/struct/timeval.h" #include "libc/dce.h" +#include "libc/intrin/describeflags.internal.h" #include "libc/sock/internal.h" #include "libc/sock/select.h" @@ -30,9 +32,15 @@ */ int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) { + int rc; + POLLTRACE("select(%d, %p, %p, %p, %s) → ...", nfds, readfds, writefds, + exceptfds, DescribeTimeval(0, timeout)); if (!IsWindows()) { - return sys_select(nfds, readfds, writefds, exceptfds, timeout); + rc = sys_select(nfds, readfds, writefds, exceptfds, timeout); } else { - return sys_select_nt(nfds, readfds, writefds, exceptfds, timeout); + rc = sys_select_nt(nfds, readfds, writefds, exceptfds, timeout); } + POLLTRACE("select(%d, %p, %p, %p, [%s]) → %d% m", nfds, readfds, writefds, + exceptfds, DescribeTimeval(rc, timeout), rc); + return rc; } diff --git a/libc/sock/sock.h b/libc/sock/sock.h index 2426aff32..74e24ddc8 100644 --- a/libc/sock/sock.h +++ b/libc/sock/sock.h @@ -15,15 +15,6 @@ COSMOPOLITAN_C_START_ #define INET_ADDRSTRLEN 22 -#define NI_NUMERICHOST 0x01 -#define NI_NUMERICSERV 0x02 -#define NI_NOFQDN 0x04 -#define NI_NAMEREQD 0x08 -#define NI_DGRAM 0x10 - -#define NI_MAXHOST 0xff -#define NI_MAXSERV 0x20 - #define htons(u16) bswap_16(u16) #define ntohs(u16) bswap_16(u16) #define htonl(u32) bswap_32(u32) @@ -70,12 +61,12 @@ struct ifreq { } ifr_ifru; }; -#define ifr_name ifr_ifrn.ifrn_name /* interface name */ -#define ifr_addr ifr_ifru.ifru_addr /* address */ -#define ifr_netmask ifr_ifru.ifru_netmask /* netmask */ +#define ifr_name ifr_ifrn.ifrn_name /* interface name */ +#define ifr_addr ifr_ifru.ifru_addr /* address */ +#define ifr_netmask ifr_ifru.ifru_netmask /* netmask */ #define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ -#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* destination address */ -#define ifr_flags ifr_ifru.ifru_flags /* flags */ +#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* destination address */ +#define ifr_flags ifr_ifru.ifru_flags /* flags */ #define _IOT_ifreq _IOT(_IOTS(char), IFNAMSIZ, _IOTS(char), 16, 0, 0) #define _IOT_ifreq_short _IOT(_IOTS(char), IFNAMSIZ, _IOTS(short), 1, 0, 0) diff --git a/libc/stdio/spawn.c b/libc/stdio/spawn.c index 4f0ec0f97..59270ae6d 100644 --- a/libc/stdio/spawn.c +++ b/libc/stdio/spawn.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/calls/scheduler.h" +#include "libc/calls/struct/sched_param.h" #include "libc/calls/struct/sigaction.h" #include "libc/errno.h" #include "libc/fmt/fmt.h" diff --git a/libc/stdio/spawna.c b/libc/stdio/spawna.c index f5dc634b7..9a923f94c 100644 --- a/libc/stdio/spawna.c +++ b/libc/stdio/spawna.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/calls/scheduler.h" #include "libc/stdio/spawn.h" #include "libc/stdio/spawna.internal.h" diff --git a/libc/sysv/calls/clock_getres.s b/libc/sysv/calls/clock_getres.s deleted file mode 100644 index 8cb50dea5..000000000 --- a/libc/sysv/calls/clock_getres.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall clock_getres,0x1ad0590eaffff0e5,globl diff --git a/libc/sysv/calls/sched_get_priority_max.s b/libc/sysv/calls/sched_get_priority_max.s deleted file mode 100644 index f2cd0ec29..000000000 --- a/libc/sysv/calls/sched_get_priority_max.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall sched_get_priority_max,0xffffff14cffff092,globl diff --git a/libc/sysv/calls/sched_get_priority_min.s b/libc/sysv/calls/sched_get_priority_min.s deleted file mode 100644 index d746a3cfc..000000000 --- a/libc/sysv/calls/sched_get_priority_min.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall sched_get_priority_min,0xffffff14dffff093,globl diff --git a/libc/sysv/calls/sched_getparam.s b/libc/sysv/calls/sched_getparam.s deleted file mode 100644 index 48462d66a..000000000 --- a/libc/sysv/calls/sched_getparam.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall sched_getparam,0xffffff148ffff08f,globl diff --git a/libc/sysv/calls/sched_getscheduler.s b/libc/sysv/calls/sched_getscheduler.s deleted file mode 100644 index 5939a7b03..000000000 --- a/libc/sysv/calls/sched_getscheduler.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall sched_getscheduler,0xffffff14affff091,globl diff --git a/libc/sysv/calls/sched_setparam.s b/libc/sysv/calls/sched_setparam.s deleted file mode 100644 index 0b6694b5a..000000000 --- a/libc/sysv/calls/sched_setparam.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall sched_setparam,0xffffff147ffff08e,globl diff --git a/libc/sysv/calls/sched_setscheduler.s b/libc/sysv/calls/sched_setscheduler.s deleted file mode 100644 index 25e7a6404..000000000 --- a/libc/sysv/calls/sched_setscheduler.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall sched_setscheduler,0xffffff149ffff090,globl diff --git a/libc/sysv/calls/sys_clock_getres.s b/libc/sysv/calls/sys_clock_getres.s new file mode 100644 index 000000000..dba0942b0 --- /dev/null +++ b/libc/sysv/calls/sys_clock_getres.s @@ -0,0 +1,2 @@ +.include "o/libc/sysv/macros.internal.inc" +.scall sys_clock_getres,0x1ad0590eaffff0e5,globl,hidden diff --git a/libc/sysv/calls/sys_sched_get_priority_max.s b/libc/sysv/calls/sys_sched_get_priority_max.s new file mode 100644 index 000000000..391013ae7 --- /dev/null +++ b/libc/sysv/calls/sys_sched_get_priority_max.s @@ -0,0 +1,2 @@ +.include "o/libc/sysv/macros.internal.inc" +.scall sys_sched_get_priority_max,0xffffff14cffff092,globl,hidden diff --git a/libc/sysv/calls/sys_sched_get_priority_min.s b/libc/sysv/calls/sys_sched_get_priority_min.s new file mode 100644 index 000000000..12aaeda13 --- /dev/null +++ b/libc/sysv/calls/sys_sched_get_priority_min.s @@ -0,0 +1,2 @@ +.include "o/libc/sysv/macros.internal.inc" +.scall sys_sched_get_priority_min,0xffffff14dffff093,globl,hidden diff --git a/libc/sysv/calls/sys_sched_getaffinity.s b/libc/sysv/calls/sys_sched_getaffinity.s index fd8de6319..ac9bba7c9 100644 --- a/libc/sysv/calls/sys_sched_getaffinity.s +++ b/libc/sysv/calls/sys_sched_getaffinity.s @@ -1,2 +1,2 @@ .include "o/libc/sysv/macros.internal.inc" -.scall sys_sched_getaffinity,0xfffffffffffff0cc,globl,hidden +.scall sys_sched_getaffinity,0x15dffffffffff0cc,globl,hidden diff --git a/libc/sysv/calls/sys_sched_getparam.s b/libc/sysv/calls/sys_sched_getparam.s new file mode 100644 index 000000000..d905252e2 --- /dev/null +++ b/libc/sysv/calls/sys_sched_getparam.s @@ -0,0 +1,2 @@ +.include "o/libc/sysv/macros.internal.inc" +.scall sys_sched_getparam,0x15bfff148ffff08f,globl,hidden diff --git a/libc/sysv/calls/sys_sched_getscheduler.s b/libc/sysv/calls/sys_sched_getscheduler.s new file mode 100644 index 000000000..ec34e8528 --- /dev/null +++ b/libc/sysv/calls/sys_sched_getscheduler.s @@ -0,0 +1,2 @@ +.include "o/libc/sysv/macros.internal.inc" +.scall sys_sched_getscheduler,0xffffff14affff091,globl,hidden diff --git a/libc/sysv/calls/sys_sched_setaffinity.s b/libc/sysv/calls/sys_sched_setaffinity.s index 7636e0f01..f7f6d4323 100644 --- a/libc/sysv/calls/sys_sched_setaffinity.s +++ b/libc/sysv/calls/sys_sched_setaffinity.s @@ -1,2 +1,2 @@ .include "o/libc/sysv/macros.internal.inc" -.scall sys_sched_setaffinity,0xfffffffffffff0cb,globl,hidden +.scall sys_sched_setaffinity,0x15cffffffffff0cb,globl,hidden diff --git a/libc/sysv/calls/sys_sched_setparam.s b/libc/sysv/calls/sys_sched_setparam.s new file mode 100644 index 000000000..d59c844c5 --- /dev/null +++ b/libc/sysv/calls/sys_sched_setparam.s @@ -0,0 +1,2 @@ +.include "o/libc/sysv/macros.internal.inc" +.scall sys_sched_setparam,0x15afff147ffff08e,globl,hidden diff --git a/libc/sysv/calls/sys_sched_setscheduler.s b/libc/sysv/calls/sys_sched_setscheduler.s new file mode 100644 index 000000000..1361eff68 --- /dev/null +++ b/libc/sysv/calls/sys_sched_setscheduler.s @@ -0,0 +1,2 @@ +.include "o/libc/sysv/macros.internal.inc" +.scall sys_sched_setscheduler,0xffffff149ffff090,globl,hidden diff --git a/libc/sysv/calls/sys_sched_yield.s b/libc/sysv/calls/sys_sched_yield.s index 9aa933153..278338dca 100644 --- a/libc/sysv/calls/sys_sched_yield.s +++ b/libc/sysv/calls/sys_sched_yield.s @@ -1,2 +1,2 @@ .include "o/libc/sysv/macros.internal.inc" -.scall sys_sched_yield,0x15e12a14bffff018,globl,hidden +.scall sys_sched_yield,0x15e12a14bf25d018,globl,hidden diff --git a/libc/sysv/consts.sh b/libc/sysv/consts.sh index b91f6bfb3..926645a0f 100755 --- a/libc/sysv/consts.sh +++ b/libc/sysv/consts.sh @@ -589,25 +589,25 @@ syscon ss SS_DISABLE 2 4 4 4 4 2 # bsd consensus # # group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon clock CLOCK_REALTIME 0 0 0 0 0 0 # consensus +syscon clock CLOCK_REALTIME_PRECISE 0 0 9 0 0 0 # syscon clock CLOCK_REALTIME_FAST 0 0 10 0 0 0 # +syscon clock CLOCK_REALTIME_COARSE 5 0 10 0 0 0 # Linux 2.6.32+; bsd consensus; not available on RHEL5 syscon clock CLOCK_MONOTONIC 1 1 4 3 3 1 # XNU/NT faked; could move backwards if NTP introduces negative leap second +syscon clock CLOCK_MONOTONIC_PRECISE 1 1 11 3 3 1 # syscon clock CLOCK_MONOTONIC_FAST 1 1 12 3 3 1 # -syscon clock CLOCK_PROCESS_CPUTIME_ID 2 -1 15 2 0x40000000 -1 # -syscon clock CLOCK_THREAD_CPUTIME_ID 3 -1 14 4 0x20000000 -1 # -syscon clock CLOCK_MONOTONIC_RAW 4 4 0x4000 0x4000 0x4000 4 # actually monotonic; not subject to NTP adjustments; Linux 2.6.28+; XNU/NT/FreeBSD/OpenBSD faked; not available on RHEL5 -syscon clock CLOCK_REALTIME_COARSE 5 -1 -1 -1 -1 -1 # Linux 2.6.32+; bsd consensus; not available on RHEL5 -syscon clock CLOCK_MONOTONIC_COARSE 6 -1 -1 -1 -1 -1 # Linux 2.6.32+; bsd consensus; not available on RHEL5 -syscon clock CLOCK_PROF -1 -1 2 -1 2 -1 # -syscon clock CLOCK_BOOTTIME 7 -1 -1 6 -1 -1 # -syscon clock CLOCK_REALTIME_ALARM 8 -1 -1 -1 -1 -1 # -syscon clock CLOCK_BOOTTIME_ALARM 9 -1 -1 -1 -1 -1 # -syscon clock CLOCK_TAI 11 -1 -1 -1 -1 -1 # -syscon clock CLOCK_UPTIME -1 -1 5 5 -1 -1 # -syscon clock CLOCK_UPTIME_PRECISE -1 -1 7 -1 -1 -1 # -syscon clock CLOCK_UPTIME_FAST -1 -1 8 -1 -1 -1 # -syscon clock CLOCK_REALTIME_PRECISE -1 -1 9 -1 -1 -1 # -syscon clock CLOCK_MONOTONIC_PRECISE -1 -1 11 -1 -1 -1 # -syscon clock CLOCK_SECOND -1 -1 13 -1 -1 -1 # +syscon clock CLOCK_MONOTONIC_COARSE 6 1 12 3 3 1 # Linux 2.6.32+; bsd consensus; not available on RHEL5 +syscon clock CLOCK_MONOTONIC_RAW 4 127 127 127 127 127 # actually monotonic; not subject to NTP adjustments; Linux 2.6.28+; XNU/NT/FreeBSD/OpenBSD faked; not available on RHEL5 +syscon clock CLOCK_PROCESS_CPUTIME_ID 2 127 15 2 0x40000000 127 # +syscon clock CLOCK_THREAD_CPUTIME_ID 3 127 14 4 0x20000000 127 # +syscon clock CLOCK_PROF 127 127 2 127 2 127 # +syscon clock CLOCK_BOOTTIME 7 127 127 6 127 127 # +syscon clock CLOCK_REALTIME_ALARM 8 127 127 127 127 127 # +syscon clock CLOCK_BOOTTIME_ALARM 9 127 127 127 127 127 # +syscon clock CLOCK_TAI 11 127 127 127 127 127 # +syscon clock CLOCK_UPTIME 127 127 5 5 127 127 # +syscon clock CLOCK_UPTIME_PRECISE 127 127 7 127 127 127 # +syscon clock CLOCK_UPTIME_FAST 127 127 8 127 127 127 # +syscon clock CLOCK_SECOND 127 127 13 127 127 127 # # poll() # @@ -793,6 +793,16 @@ syscon tcp TCP_REPAIR_OPTIONS 22 0 0 0 0 0 # what is it syscon tcp TCP_REPAIR_QUEUE 20 0 0 0 0 0 # what is it syscon tcp TCP_THIN_LINEAR_TIMEOUTS 16 0 0 0 0 0 # what is it +# https://blog.cloudflare.com/know-your-scm_rights/ +# +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary +syscon scm SCM_RIGHTS 1 1 1 1 1 1 # unix consensus; faked nt +syscon scm SCM_TIMESTAMP 29 2 2 4 8 0 +syscon scm SCM_CREDENTIALS 2 0 0 0 0 0 +syscon scm SCM_TIMESTAMPING 37 0 0 0 0 0 +syscon scm SCM_TIMESTAMPNS 35 0 0 0 0 0 +syscon scm SCM_WIFI_STATUS 41 0 0 0 0 0 + # group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary syscon ip IP_TOS 1 3 3 3 3 8 # bsd consensus syscon ip IP_TTL 2 4 4 4 4 7 # bsd consensus @@ -1306,6 +1316,26 @@ syscon futex FUTEX_WAKE 1 0 0 2 0 0 syscon futex FUTEX_REQUEUE 3 0 0 3 0 0 syscon futex FUTEX_PRIVATE_FLAG 128 0 0 128 0 0 +# lio_listio() magnums +# +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary +syscon lio LIO_WRITE 127 2 1 127 1 127 +syscon lio LIO_NOWAIT 127 1 0 127 0 127 +syscon lio LIO_READ 127 1 2 127 2 127 +syscon lio LIO_WAIT 127 2 1 127 1 127 +syscon lio LIO_NOP 127 0 0 127 0 127 + +# posix scheduling +# +# group name GNU/Systemd XNU's Not UNIX! FreeBSD OpenBSD NetBSD The New Technology Commentary +syscon sched SCHED_OTHER 0 127 2 127 0 127 # standard round-robin time-sharing policy +syscon sched SCHED_FIFO 1 127 1 127 1 127 # [real-time] first-in, first-out policy +syscon sched SCHED_RR 2 127 3 127 2 127 # [real-time] round-robin policy +syscon sched SCHED_BATCH 3 127 2 127 0 127 # for "batch" style execution of processes; polyfilled as SCHED_OTHER on non-Linux +syscon sched SCHED_IDLE 5 127 2 127 0 127 # for running very low priority background jobs; polyfilled as SCHED_OTHER on non-Linux +syscon sched SCHED_DEADLINE 6 127 127 127 127 127 # can only be set by sched_setattr() +syscon sched SCHED_RESET_ON_FORK 0x40000000 0 0 0 0 0 # Can be ORed in to make sure the process is reverted back to SCHED_NORMAL on fork(); no-op on non-Linux + # Teletypewriter Control, e.g. # # TCSETS → About 70,800 results (0.31 seconds) @@ -1616,14 +1646,6 @@ syscon shm SHM_LOCKED 0x0400 0 0 0 0 0 syscon shm SHM_NORESERVE 0x1000 0 0 0 0 0 syscon shm SHM_REMAP 0x4000 0 0 0 0 0 -syscon misc TCPOPT_EOL 0 0 0 0 0 0 # consensus -syscon misc TCPOPT_MAXSEG 2 2 2 2 2 0 # unix consensus -syscon misc TCPOPT_NOP 1 1 1 1 1 0 # unix consensus -syscon misc TCPOPT_SACK 5 5 5 5 5 0 # unix consensus -syscon misc TCPOPT_SACK_PERMITTED 4 4 4 4 4 0 # unix consensus -syscon misc TCPOPT_TIMESTAMP 8 8 8 8 8 0 # unix consensus -syscon misc TCPOPT_WINDOW 3 3 3 3 3 0 # unix consensus - syscon lock LOCK_UNLOCK_CACHE 54 0 0 0 0 0 # wut syscon misc IP6F_MORE_FRAG 0x0100 0x0100 0x0100 0x0100 0x0100 0x0100 # consensus @@ -1632,37 +1654,6 @@ syscon misc IP6F_RESERVED_MASK 0x0600 0x0600 0x0600 0x0600 0x0600 0x syscon misc NO_SENSE 0 0 0 0 0 0 # consensus syscon misc NO_ADDRESS 4 4 4 4 4 0x2afc # unix consensus -syscon misc NO_DATA 4 4 4 4 4 0x2afc # unix consensus -syscon misc NO_RECOVERY 3 3 3 3 3 0x2afb # unix consensus - -syscon misc NI_DGRAM 0x10 0x10 0x10 0x10 0x10 0x10 # consensus -syscon misc NI_MAXSERV 0x20 0x20 0x20 0x20 0x20 0x20 # consensus -syscon misc NI_MAXHOST 0x0401 0x0401 0x0401 0x0100 0x0100 0x0401 -syscon misc NI_NAMEREQD 8 4 4 8 8 4 -syscon misc NI_NOFQDN 4 1 1 4 4 1 -syscon misc NI_NUMERICHOST 1 2 2 1 1 2 -syscon misc NI_NUMERICSERV 2 8 8 2 2 8 -syscon misc NI_NUMERICSCOPE 0 0 0x20 0 0 0 - -syscon misc TCPOLEN_MAXSEG 4 4 4 4 4 0 # unix consensus -syscon misc TCPOLEN_SACK_PERMITTED 2 2 2 2 2 0 # unix consensus -syscon misc TCPOLEN_TIMESTAMP 10 10 10 10 10 0 # unix consensus -syscon misc TCPOLEN_WINDOW 3 3 3 3 3 0 # unix consensus - -syscon misc TELOPT_NAOL 8 8 8 8 8 0 # unix consensus -syscon misc TELOPT_NAOP 9 9 9 9 9 0 # unix consensus -syscon misc TELOPT_NEW_ENVIRON 39 39 39 39 39 0 # unix consensus -syscon misc TELOPT_OLD_ENVIRON 36 36 36 36 36 0 # unix consensus - -syscon misc EXTENDED_MODIFY_DATA_POINTER 0 0 0 0 0 0 # consensus -syscon misc EXTENDED_EXTENDED_IDENTIFY 2 0 0 0 0 0 -syscon misc EXTENDED_MESSAGE 1 0 0 0 0 0 -syscon misc EXTENDED_SDTR 1 0 0 0 0 0 -syscon misc EXTENDED_WDTR 3 0 0 0 0 0 - -syscon misc ITIMER_REAL 0 0 0 0 0 0 # consensus -syscon misc ITIMER_VIRTUAL 1 1 1 1 1 1 # unix consensus (force win) -syscon misc ITIMER_PROF 2 2 2 2 2 2 # unix consensus (force win) syscon misc L_SET 0 0 0 0 0 0 # consensus syscon misc L_INCR 1 1 1 1 1 0 # unix consensus @@ -1681,36 +1672,10 @@ syscon misc Q_GETFMT 0x800004 0 0 0 0 0 syscon misc Q_GETINFO 0x800005 0 0 0 0 0 syscon misc Q_SETINFO 0x800006 0 0 0 0 0 -syscon misc SCM_RIGHTS 1 1 1 1 1 0 # unix consensus -syscon misc SCM_TIMESTAMP 29 2 2 4 8 0 -syscon misc SCM_CREDENTIALS 2 0 0 0 0 0 -syscon misc SCM_TIMESTAMPING 37 0 0 0 0 0 -syscon misc SCM_TIMESTAMPNS 35 0 0 0 0 0 -syscon misc SCM_WIFI_STATUS 41 0 0 0 0 0 - -syscon misc FORM_C 3 3 3 3 3 0 # unix consensus -syscon misc FORM_N 1 1 1 1 1 0 # unix consensus -syscon misc FORM_T 2 2 2 2 2 0 # unix consensus - -syscon misc REC_EOF 2 2 2 2 2 0 # unix consensus -syscon misc REC_EOR 1 1 1 1 1 0 # unix consensus -syscon misc REC_ESC -1 -1 -1 -1 -1 0 # unix consensus - syscon misc RPM_PCO_ADD 1 1 1 1 1 0 # unix consensus syscon misc RPM_PCO_CHANGE 2 2 2 2 2 0 # unix consensus syscon misc RPM_PCO_SETGLOBAL 3 3 3 3 3 0 # unix consensus -syscon misc SEARCH_EQUAL 49 0 0 0 0 0 -syscon misc SEARCH_EQUAL_12 177 0 0 0 0 0 -syscon misc SEARCH_HIGH 48 0 0 0 0 0 -syscon misc SEARCH_HIGH_12 176 0 0 0 0 0 -syscon misc SEARCH_LOW 50 0 0 0 0 0 -syscon misc SEARCH_LOW_12 178 0 0 0 0 0 - -syscon misc STRU_F 1 1 1 1 1 0 # unix consensus -syscon misc STRU_P 3 3 3 3 3 0 # unix consensus -syscon misc STRU_R 2 2 2 2 2 0 # unix consensus - syscon misc _XOPEN_IOV_MAX 0x10 0x10 0x10 0x10 0x10 0 # unix consensus syscon misc _XOPEN_ENH_I18N 1 1 -1 -1 -1 0 syscon misc _XOPEN_UNIX 1 1 -1 -1 -1 0 @@ -1740,26 +1705,6 @@ syscon mlock MCL_CURRENT 1 1 1 1 1 0 # unix consensus syscon mlock MCL_FUTURE 2 2 2 2 2 0 # unix consensus syscon mlock MCL_ONFAULT 4 0 0 0 0 0 -syscon misc NS_DSA_MAX_BYTES 405 405 405 0 0 0 -syscon misc NS_DSA_MIN_SIZE 213 213 213 0 0 0 -syscon misc NS_DSA_SIG_SIZE 41 41 41 0 0 0 -syscon misc NS_KEY_PROT_DNSSEC 3 3 3 0 0 0 -syscon misc NS_KEY_PROT_EMAIL 2 2 2 0 0 0 -syscon misc NS_KEY_PROT_IPSEC 4 4 4 0 0 0 -syscon misc NS_KEY_PROT_TLS 1 1 1 0 0 0 -syscon misc NS_KEY_RESERVED_BITMASK2 0xffff 0xffff 0xffff 0 0 0 -syscon misc NS_NXT_MAX 127 127 127 0 0 0 -syscon misc NS_OPT_DNSSEC_OK 0x8000 0x8000 0x8000 0 0 0 -syscon misc NS_TSIG_ERROR_FORMERR -12 -12 -12 0 0 0 -syscon misc NS_TSIG_ERROR_NO_SPACE -11 -11 -11 0 0 0 -syscon misc NS_TSIG_ERROR_NO_TSIG -10 -10 -10 0 0 0 -syscon misc NS_TSIG_FUDGE 300 300 300 0 0 0 -syscon misc NS_TSIG_TCP_COUNT 100 100 100 0 0 0 - -syscon misc _IOC_NONE 0 0 0 0 0 0 # consensus -syscon misc _IOC_READ 2 0 0 0 0 0 -syscon misc _IOC_WRITE 1 0 0 0 0 0 - syscon misc MLD_LISTENER_QUERY 130 130 130 130 130 0 # unix consensus syscon misc MLD_LISTENER_REPORT 131 131 131 131 131 0 # unix consensus syscon misc MLD_LISTENER_REDUCTION 132 132 132 0 0 0 @@ -1781,13 +1726,6 @@ syscon select FD_SETSIZE 0x0400 0x0400 0x0400 0x0400 0x0400 0x0400 syscon misc MATH_ERREXCEPT 2 2 2 2 2 0 # unix consensus syscon misc MATH_ERRNO 1 1 1 1 1 0 # unix consensus -syscon misc SCHED_FIFO 1 4 1 1 1 0 -syscon misc SCHED_RR 2 2 3 3 3 0 -syscon misc SCHED_OTHER 0 1 2 2 2 0 -syscon misc SCHED_BATCH 3 0 0 0 0 0 -syscon misc SCHED_IDLE 5 0 0 0 0 0 -syscon misc SCHED_RESET_ON_FORK 0x40000000 0 0 0 0 0 - syscon misc MCAST_BLOCK_SOURCE 43 84 84 0 0 43 syscon misc MCAST_JOIN_GROUP 42 80 80 0 0 41 syscon misc MCAST_JOIN_SOURCE_GROUP 46 82 82 0 0 45 @@ -1804,12 +1742,7 @@ syscon misc EFD_CLOEXEC 0x080000 0 0 0 0 0 syscon misc EFD_NONBLOCK 0x0800 0 0 0 0 0 syscon misc EFD_SEMAPHORE 1 0 0 0 0 0 -syscon misc GOOD 0 0 0 0 0 0 # consensus syscon misc IPPORT_RESERVED 0x0400 0x0400 0x0400 0x0400 0x0400 0x0400 # consensus -syscon misc MTRESET 0 0 0 0 0 0 # consensus -syscon misc MT_ST_CAN_PARTITIONS 0x0400 0 0 0 0 0 -syscon misc MT_ST_HPLOADER_OFFSET 0x2710 0 0 0 0 0 -syscon misc MT_ST_SCSI2LOGICAL 0x0800 0 0 0 0 0 syscon misc SYNC_FILE_RANGE_WAIT_AFTER 4 0 0 0 0 0 syscon misc SYNC_FILE_RANGE_WAIT_BEFORE 1 0 0 0 0 0 @@ -1822,31 +1755,8 @@ syscon misc TFD_TIMER_ABSTIME 1 0 0 0 0 0 syscon misc USRQUOTA 0 0 0 0 0 0 -syscon misc ABDAY_1 0x020000 14 14 13 13 0 -syscon misc ABDAY_2 0x020001 15 15 14 14 0 -syscon misc ABDAY_3 0x020002 0x10 0x10 15 15 0 -syscon misc ABDAY_4 0x020003 17 17 0x10 0x10 0 -syscon misc ABDAY_5 0x020004 18 18 17 17 0 -syscon misc ABDAY_6 0x020005 19 19 18 18 0 -syscon misc ABDAY_7 0x020006 20 20 19 19 0 - -syscon misc DAY_1 0x020007 7 7 6 6 0 -syscon misc DAY_2 0x020008 8 8 7 7 0 -syscon misc DAY_3 0x020009 9 9 8 8 0 -syscon misc DAY_4 0x02000a 10 10 9 9 0 -syscon misc DAY_5 0x02000b 11 11 10 10 0 -syscon misc DAY_6 0x02000c 12 12 11 11 0 -syscon misc DAY_7 0x02000d 13 13 12 12 0 - -syscon misc HOST_NOT_FOUND 1 1 1 1 1 0x2af9 # unix consensus syscon misc HOST_NAME_MAX 0x40 0 0 255 255 0 -syscon misc LIO_WRITE 1 2 1 0 0 0 -syscon misc LIO_NOWAIT 1 1 0 0 0 0 -syscon misc LIO_READ 0 1 2 0 0 0 -syscon misc LIO_WAIT 0 2 1 0 0 0 -syscon misc LIO_NOP 2 0 0 0 0 0 - syscon misc UDP_ENCAP_ESPINUDP_NON_IKE 1 0 1 0 0 0 syscon misc UDP_NO_CHECK6_RX 102 0 0 0 0 0 syscon misc UDP_NO_CHECK6_TX 101 0 0 0 0 0 @@ -1921,7 +1831,7 @@ syscon nr __NR_pipe 0x0016 0x200002a 0x021e 0x0107 0x02a 0xfff syscon nr __NR_select 0x0017 0x200005d 0x005d 0x0047 0x1a1 0xfff syscon nr __NR_pselect 0xfff 0x200018a 0x020a 0x006e 0x1b4 0xfff syscon nr __NR_pselect6 0x010e 0xfff 0xfff 0xfff 0xfff 0xfff -syscon nr __NR_sched_yield 0x0018 0x010003c 0x014b 0x012a 0x15e 0xfff +syscon nr __NR_sched_yield 0x0018 0x200005d 0x014b 0x012a 0x15e 0xfff # select() on XNU (previously swtch() but removed in 12.4) syscon nr __NR_mremap 0x0019 0xfff 0xfff 0xfff 0x19b 0xfff syscon nr __NR_mincore 0x001b 0x200004e 0x004e 0x004e 0x04e 0xfff syscon nr __NR_madvise 0x001c 0x200004b 0x004b 0x004b 0x04b 0xfff @@ -2889,7 +2799,6 @@ syscon misc TOEXEC 1 1 1 1 1 0 # unix consensus syscon misc TOREAD 4 4 4 4 4 0 # unix consensus syscon misc TOWRITE 2 2 2 2 2 0 # unix consensus syscon misc TRANSIENT 4 4 4 4 4 0 # unix consensus -syscon misc TRY_AGAIN 2 2 2 2 2 0x2afa # unix consensus syscon misc TSGID 0x0400 0x0400 0x0400 0x0400 0x0400 0 # unix consensus syscon misc TSUID 0x0800 0x0800 0x0800 0x0800 0x0800 0 # unix consensus syscon misc TSVTX 0x0200 0x0200 0x0200 0x0200 0x0200 0 # unix consensus @@ -3094,7 +3003,6 @@ syscon misc RUN_LVL 1 1 0 0 0 0 syscon misc STA_RONLY 0xff00 0 0xff00 0 0 0 syscon misc SYMLOOP_MAX 0 0 0 0x20 0x20 0 syscon misc THOUSEP 0x010001 51 51 45 45 0 -syscon misc TIMER_ABSTIME 1 0 1 1 1 0 syscon misc TIME_UTC 1 0 1 0 0 0 syscon misc TMP_MAX 0x03a2f8 0x1269ae40 0x1269ae40 0x7fffffff 0x7fffffff 0 syscon misc TSS_DTOR_ITERATIONS 0 0 4 0 0 0 @@ -3133,21 +3041,6 @@ syscon in IN_OPEN 0x20 0 0 0 0 0 syscon in IN_Q_OVERFLOW 0x4000 0 0 0 0 0 syscon in IN_UNMOUNT 0x2000 0 0 0 0 0 -syscon misc TYPE_DISK 0 0 0 0 0 0 # consensus -syscon misc TYPE_A 1 1 1 1 1 0 # unix consensus -syscon misc TYPE_E 2 2 2 2 2 0 # unix consensus -syscon misc TYPE_I 3 3 3 3 3 0 # unix consensus -syscon misc TYPE_L 4 4 4 4 4 0 # unix consensus -syscon misc TYPE_ENCLOSURE 13 0 0 0 0 0 -syscon misc TYPE_MEDIUM_CHANGER 8 0 0 0 0 0 -syscon misc TYPE_MOD 7 0 0 0 0 0 -syscon misc TYPE_NO_LUN 127 0 0 0 0 0 -syscon misc TYPE_PROCESSOR 3 0 0 0 0 0 -syscon misc TYPE_ROM 5 0 0 0 0 0 -syscon misc TYPE_SCANNER 6 0 0 0 0 0 -syscon misc TYPE_TAPE 1 0 0 0 0 0 -syscon misc TYPE_WORM 4 0 0 0 0 0 - syscon nd ND_RA_FLAG_MANAGED 0x80 0x80 0x80 0x80 0x80 0x80 # consensus syscon nd ND_RA_FLAG_OTHER 0x40 0x40 0x40 0x40 0x40 0x40 # consensus syscon nd ND_NA_FLAG_OVERRIDE 0x20 0x20 0x20 0x20 0x20 0x20000000 # unix consensus @@ -3160,36 +3053,4 @@ syscon nd ND_ROUTER_ADVERT 134 134 134 134 134 0 # unix consensus syscon nd ND_ROUTER_SOLICIT 133 133 133 133 133 0 # unix consensus syscon nd ND_RA_FLAG_HOME_AGENT 0x20 0 0 0 0 0x20 # bsd consensus -syscon misc N_TTY 0 0 0 0 0 0 # consensus -syscon misc N_6PACK 7 0 0 0 0 0 -syscon misc N_AX25 5 0 0 0 0 0 -syscon misc N_HCI 15 0 0 0 0 0 -syscon misc N_HDLC 13 0 0 0 0 0 -syscon misc N_IRDA 11 0 0 0 0 0 -syscon misc N_MASC 8 0 0 0 0 0 -syscon misc N_MOUSE 2 0 0 0 0 0 -syscon misc N_PPP 3 0 0 0 0 0 -syscon misc N_PROFIBUS_FDL 10 0 0 0 0 0 -syscon misc N_R3964 9 0 0 0 0 0 -syscon misc N_SLIP 1 0 0 0 0 0 -syscon misc N_SMSBLOCK 12 0 0 0 0 0 -syscon misc N_STRIP 4 0 0 0 0 0 -syscon misc N_SYNC_PPP 14 0 0 0 0 0 -syscon misc N_X25 6 0 0 0 0 0 - -syscon misc ETH_P_CUST 0x6006 0 0 0 0 0 -syscon misc ETH_P_DDCMP 6 0 0 0 0 0 -syscon misc ETH_P_DEC 0x6000 0 0 0 0 0 -syscon misc ETH_P_DIAG 0x6005 0 0 0 0 0 -syscon misc ETH_P_DNA_DL 0x6001 0 0 0 0 0 -syscon misc ETH_P_DNA_RC 0x6002 0 0 0 0 0 -syscon misc ETH_P_DNA_RT 0x6003 0 0 0 0 0 -syscon misc ETH_P_IEEE802154 246 0 0 0 0 0 -syscon misc ETH_P_LAT 0x6004 0 0 0 0 0 -syscon misc ETH_P_LOCALTALK 9 0 0 0 0 0 -syscon misc ETH_P_PPP_MP 8 0 0 0 0 0 -syscon misc ETH_P_RARP 0x8035 0 0 0 0 0 -syscon misc ETH_P_SCA 0x6007 0 0 0 0 0 -syscon misc ETH_P_WAN_PPP 7 0 0 0 0 0 - # https://youtu.be/GUQUD3IMbb4?t=85 diff --git a/libc/sysv/consts/ABDAY_1.S b/libc/sysv/consts/ABDAY_1.S deleted file mode 100644 index f074c98fa..000000000 --- a/libc/sysv/consts/ABDAY_1.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ABDAY_1,0x020000,14,14,13,13,0 diff --git a/libc/sysv/consts/ABDAY_2.S b/libc/sysv/consts/ABDAY_2.S deleted file mode 100644 index 16ca7ea51..000000000 --- a/libc/sysv/consts/ABDAY_2.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ABDAY_2,0x020001,15,15,14,14,0 diff --git a/libc/sysv/consts/ABDAY_3.S b/libc/sysv/consts/ABDAY_3.S deleted file mode 100644 index 964a1796b..000000000 --- a/libc/sysv/consts/ABDAY_3.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ABDAY_3,0x020002,0x10,0x10,15,15,0 diff --git a/libc/sysv/consts/ABDAY_4.S b/libc/sysv/consts/ABDAY_4.S deleted file mode 100644 index 7c71fcc73..000000000 --- a/libc/sysv/consts/ABDAY_4.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ABDAY_4,0x020003,17,17,0x10,0x10,0 diff --git a/libc/sysv/consts/ABDAY_5.S b/libc/sysv/consts/ABDAY_5.S deleted file mode 100644 index 86b55d21d..000000000 --- a/libc/sysv/consts/ABDAY_5.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ABDAY_5,0x020004,18,18,17,17,0 diff --git a/libc/sysv/consts/ABDAY_6.S b/libc/sysv/consts/ABDAY_6.S deleted file mode 100644 index 09d29ce5f..000000000 --- a/libc/sysv/consts/ABDAY_6.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ABDAY_6,0x020005,19,19,18,18,0 diff --git a/libc/sysv/consts/ABDAY_7.S b/libc/sysv/consts/ABDAY_7.S deleted file mode 100644 index 095cf3efb..000000000 --- a/libc/sysv/consts/ABDAY_7.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ABDAY_7,0x020006,20,20,19,19,0 diff --git a/libc/sysv/consts/CLOCK_BOOTTIME.S b/libc/sysv/consts/CLOCK_BOOTTIME.S index 05ce54ce7..2c9052ba6 100644 --- a/libc/sysv/consts/CLOCK_BOOTTIME.S +++ b/libc/sysv/consts/CLOCK_BOOTTIME.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon clock,CLOCK_BOOTTIME,7,-1,-1,6,-1,-1 +.syscon clock,CLOCK_BOOTTIME,7,127,127,6,127,127 diff --git a/libc/sysv/consts/CLOCK_BOOTTIME_ALARM.S b/libc/sysv/consts/CLOCK_BOOTTIME_ALARM.S index aa660bfd3..8bb8436ca 100644 --- a/libc/sysv/consts/CLOCK_BOOTTIME_ALARM.S +++ b/libc/sysv/consts/CLOCK_BOOTTIME_ALARM.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon clock,CLOCK_BOOTTIME_ALARM,9,-1,-1,-1,-1,-1 +.syscon clock,CLOCK_BOOTTIME_ALARM,9,127,127,127,127,127 diff --git a/libc/sysv/consts/CLOCK_MONOTONIC_COARSE.S b/libc/sysv/consts/CLOCK_MONOTONIC_COARSE.S index d12e8ec95..26b66a4df 100644 --- a/libc/sysv/consts/CLOCK_MONOTONIC_COARSE.S +++ b/libc/sysv/consts/CLOCK_MONOTONIC_COARSE.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon clock,CLOCK_MONOTONIC_COARSE,6,-1,-1,-1,-1,-1 +.syscon clock,CLOCK_MONOTONIC_COARSE,6,1,12,3,3,1 diff --git a/libc/sysv/consts/CLOCK_MONOTONIC_PRECISE.S b/libc/sysv/consts/CLOCK_MONOTONIC_PRECISE.S index c019aadf3..1e029e071 100644 --- a/libc/sysv/consts/CLOCK_MONOTONIC_PRECISE.S +++ b/libc/sysv/consts/CLOCK_MONOTONIC_PRECISE.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon clock,CLOCK_MONOTONIC_PRECISE,-1,-1,11,-1,-1,-1 +.syscon clock,CLOCK_MONOTONIC_PRECISE,1,1,11,3,3,1 diff --git a/libc/sysv/consts/CLOCK_MONOTONIC_RAW.S b/libc/sysv/consts/CLOCK_MONOTONIC_RAW.S index 0e2c8f6c5..b3a92716f 100644 --- a/libc/sysv/consts/CLOCK_MONOTONIC_RAW.S +++ b/libc/sysv/consts/CLOCK_MONOTONIC_RAW.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon clock,CLOCK_MONOTONIC_RAW,4,4,0x4000,0x4000,0x4000,4 +.syscon clock,CLOCK_MONOTONIC_RAW,4,127,127,127,127,127 diff --git a/libc/sysv/consts/CLOCK_PROCESS_CPUTIME_ID.S b/libc/sysv/consts/CLOCK_PROCESS_CPUTIME_ID.S index 5a080feb2..3b5801c9d 100644 --- a/libc/sysv/consts/CLOCK_PROCESS_CPUTIME_ID.S +++ b/libc/sysv/consts/CLOCK_PROCESS_CPUTIME_ID.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon clock,CLOCK_PROCESS_CPUTIME_ID,2,-1,15,2,0x40000000,-1 +.syscon clock,CLOCK_PROCESS_CPUTIME_ID,2,127,15,2,0x40000000,127 diff --git a/libc/sysv/consts/CLOCK_PROF.S b/libc/sysv/consts/CLOCK_PROF.S index 14d2fb8dd..bd45dc737 100644 --- a/libc/sysv/consts/CLOCK_PROF.S +++ b/libc/sysv/consts/CLOCK_PROF.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon clock,CLOCK_PROF,-1,-1,2,-1,2,-1 +.syscon clock,CLOCK_PROF,127,127,2,127,2,127 diff --git a/libc/sysv/consts/CLOCK_REALTIME_ALARM.S b/libc/sysv/consts/CLOCK_REALTIME_ALARM.S index 795e372e4..952e62db7 100644 --- a/libc/sysv/consts/CLOCK_REALTIME_ALARM.S +++ b/libc/sysv/consts/CLOCK_REALTIME_ALARM.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon clock,CLOCK_REALTIME_ALARM,8,-1,-1,-1,-1,-1 +.syscon clock,CLOCK_REALTIME_ALARM,8,127,127,127,127,127 diff --git a/libc/sysv/consts/CLOCK_REALTIME_COARSE.S b/libc/sysv/consts/CLOCK_REALTIME_COARSE.S index 7f40a4d9e..b1610e999 100644 --- a/libc/sysv/consts/CLOCK_REALTIME_COARSE.S +++ b/libc/sysv/consts/CLOCK_REALTIME_COARSE.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon clock,CLOCK_REALTIME_COARSE,5,-1,-1,-1,-1,-1 +.syscon clock,CLOCK_REALTIME_COARSE,5,0,10,0,0,0 diff --git a/libc/sysv/consts/CLOCK_REALTIME_PRECISE.S b/libc/sysv/consts/CLOCK_REALTIME_PRECISE.S index 477bd1c68..ec180dcb2 100644 --- a/libc/sysv/consts/CLOCK_REALTIME_PRECISE.S +++ b/libc/sysv/consts/CLOCK_REALTIME_PRECISE.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon clock,CLOCK_REALTIME_PRECISE,-1,-1,9,-1,-1,-1 +.syscon clock,CLOCK_REALTIME_PRECISE,0,0,9,0,0,0 diff --git a/libc/sysv/consts/CLOCK_SECOND.S b/libc/sysv/consts/CLOCK_SECOND.S index 35b892822..235f58f0f 100644 --- a/libc/sysv/consts/CLOCK_SECOND.S +++ b/libc/sysv/consts/CLOCK_SECOND.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon clock,CLOCK_SECOND,-1,-1,13,-1,-1,-1 +.syscon clock,CLOCK_SECOND,127,127,13,127,127,127 diff --git a/libc/sysv/consts/CLOCK_TAI.S b/libc/sysv/consts/CLOCK_TAI.S index 0925bb74a..3e09cb5b0 100644 --- a/libc/sysv/consts/CLOCK_TAI.S +++ b/libc/sysv/consts/CLOCK_TAI.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon clock,CLOCK_TAI,11,-1,-1,-1,-1,-1 +.syscon clock,CLOCK_TAI,11,127,127,127,127,127 diff --git a/libc/sysv/consts/CLOCK_THREAD_CPUTIME_ID.S b/libc/sysv/consts/CLOCK_THREAD_CPUTIME_ID.S index d7358df70..fc4ad1a4f 100644 --- a/libc/sysv/consts/CLOCK_THREAD_CPUTIME_ID.S +++ b/libc/sysv/consts/CLOCK_THREAD_CPUTIME_ID.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon clock,CLOCK_THREAD_CPUTIME_ID,3,-1,14,4,0x20000000,-1 +.syscon clock,CLOCK_THREAD_CPUTIME_ID,3,127,14,4,0x20000000,127 diff --git a/libc/sysv/consts/CLOCK_UPTIME.S b/libc/sysv/consts/CLOCK_UPTIME.S index bb99e79f4..4da3e9b3f 100644 --- a/libc/sysv/consts/CLOCK_UPTIME.S +++ b/libc/sysv/consts/CLOCK_UPTIME.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon clock,CLOCK_UPTIME,-1,-1,5,5,-1,-1 +.syscon clock,CLOCK_UPTIME,127,127,5,5,127,127 diff --git a/libc/sysv/consts/CLOCK_UPTIME_FAST.S b/libc/sysv/consts/CLOCK_UPTIME_FAST.S index 40a1fbc59..1f6cd6e45 100644 --- a/libc/sysv/consts/CLOCK_UPTIME_FAST.S +++ b/libc/sysv/consts/CLOCK_UPTIME_FAST.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon clock,CLOCK_UPTIME_FAST,-1,-1,8,-1,-1,-1 +.syscon clock,CLOCK_UPTIME_FAST,127,127,8,127,127,127 diff --git a/libc/sysv/consts/CLOCK_UPTIME_PRECISE.S b/libc/sysv/consts/CLOCK_UPTIME_PRECISE.S index a87f77601..26df72e2e 100644 --- a/libc/sysv/consts/CLOCK_UPTIME_PRECISE.S +++ b/libc/sysv/consts/CLOCK_UPTIME_PRECISE.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon clock,CLOCK_UPTIME_PRECISE,-1,-1,7,-1,-1,-1 +.syscon clock,CLOCK_UPTIME_PRECISE,127,127,7,127,127,127 diff --git a/libc/sysv/consts/DAY_1.S b/libc/sysv/consts/DAY_1.S deleted file mode 100644 index 07d7d4b9f..000000000 --- a/libc/sysv/consts/DAY_1.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,DAY_1,0x020007,7,7,6,6,0 diff --git a/libc/sysv/consts/DAY_2.S b/libc/sysv/consts/DAY_2.S deleted file mode 100644 index bc4438407..000000000 --- a/libc/sysv/consts/DAY_2.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,DAY_2,0x020008,8,8,7,7,0 diff --git a/libc/sysv/consts/DAY_3.S b/libc/sysv/consts/DAY_3.S deleted file mode 100644 index 8b5fc746d..000000000 --- a/libc/sysv/consts/DAY_3.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,DAY_3,0x020009,9,9,8,8,0 diff --git a/libc/sysv/consts/DAY_4.S b/libc/sysv/consts/DAY_4.S deleted file mode 100644 index fdaca424e..000000000 --- a/libc/sysv/consts/DAY_4.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,DAY_4,0x02000a,10,10,9,9,0 diff --git a/libc/sysv/consts/DAY_5.S b/libc/sysv/consts/DAY_5.S deleted file mode 100644 index f50ad1f7a..000000000 --- a/libc/sysv/consts/DAY_5.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,DAY_5,0x02000b,11,11,10,10,0 diff --git a/libc/sysv/consts/DAY_6.S b/libc/sysv/consts/DAY_6.S deleted file mode 100644 index 0d0563cac..000000000 --- a/libc/sysv/consts/DAY_6.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,DAY_6,0x02000c,12,12,11,11,0 diff --git a/libc/sysv/consts/DAY_7.S b/libc/sysv/consts/DAY_7.S deleted file mode 100644 index 192284832..000000000 --- a/libc/sysv/consts/DAY_7.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,DAY_7,0x02000d,13,13,12,12,0 diff --git a/libc/sysv/consts/ETH_P_CUST.S b/libc/sysv/consts/ETH_P_CUST.S deleted file mode 100644 index d88376526..000000000 --- a/libc/sysv/consts/ETH_P_CUST.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ETH_P_CUST,0x6006,0,0,0,0,0 diff --git a/libc/sysv/consts/ETH_P_DDCMP.S b/libc/sysv/consts/ETH_P_DDCMP.S deleted file mode 100644 index bb1af4fa1..000000000 --- a/libc/sysv/consts/ETH_P_DDCMP.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ETH_P_DDCMP,6,0,0,0,0,0 diff --git a/libc/sysv/consts/ETH_P_DEC.S b/libc/sysv/consts/ETH_P_DEC.S deleted file mode 100644 index 2562cd5ae..000000000 --- a/libc/sysv/consts/ETH_P_DEC.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ETH_P_DEC,0x6000,0,0,0,0,0 diff --git a/libc/sysv/consts/ETH_P_DIAG.S b/libc/sysv/consts/ETH_P_DIAG.S deleted file mode 100644 index 78bb165b0..000000000 --- a/libc/sysv/consts/ETH_P_DIAG.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ETH_P_DIAG,0x6005,0,0,0,0,0 diff --git a/libc/sysv/consts/ETH_P_DNA_DL.S b/libc/sysv/consts/ETH_P_DNA_DL.S deleted file mode 100644 index a0369df76..000000000 --- a/libc/sysv/consts/ETH_P_DNA_DL.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ETH_P_DNA_DL,0x6001,0,0,0,0,0 diff --git a/libc/sysv/consts/ETH_P_DNA_RC.S b/libc/sysv/consts/ETH_P_DNA_RC.S deleted file mode 100644 index 974ab05c6..000000000 --- a/libc/sysv/consts/ETH_P_DNA_RC.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ETH_P_DNA_RC,0x6002,0,0,0,0,0 diff --git a/libc/sysv/consts/ETH_P_DNA_RT.S b/libc/sysv/consts/ETH_P_DNA_RT.S deleted file mode 100644 index f3b7b0be5..000000000 --- a/libc/sysv/consts/ETH_P_DNA_RT.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ETH_P_DNA_RT,0x6003,0,0,0,0,0 diff --git a/libc/sysv/consts/ETH_P_IEEE802154.S b/libc/sysv/consts/ETH_P_IEEE802154.S deleted file mode 100644 index 51c17a0ef..000000000 --- a/libc/sysv/consts/ETH_P_IEEE802154.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ETH_P_IEEE802154,246,0,0,0,0,0 diff --git a/libc/sysv/consts/ETH_P_LAT.S b/libc/sysv/consts/ETH_P_LAT.S deleted file mode 100644 index 186f1ec5c..000000000 --- a/libc/sysv/consts/ETH_P_LAT.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ETH_P_LAT,0x6004,0,0,0,0,0 diff --git a/libc/sysv/consts/ETH_P_LOCALTALK.S b/libc/sysv/consts/ETH_P_LOCALTALK.S deleted file mode 100644 index fa4f060c2..000000000 --- a/libc/sysv/consts/ETH_P_LOCALTALK.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ETH_P_LOCALTALK,9,0,0,0,0,0 diff --git a/libc/sysv/consts/ETH_P_PPP_MP.S b/libc/sysv/consts/ETH_P_PPP_MP.S deleted file mode 100644 index 2590ac590..000000000 --- a/libc/sysv/consts/ETH_P_PPP_MP.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ETH_P_PPP_MP,8,0,0,0,0,0 diff --git a/libc/sysv/consts/ETH_P_RARP.S b/libc/sysv/consts/ETH_P_RARP.S deleted file mode 100644 index 0d4819adb..000000000 --- a/libc/sysv/consts/ETH_P_RARP.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ETH_P_RARP,0x8035,0,0,0,0,0 diff --git a/libc/sysv/consts/ETH_P_SCA.S b/libc/sysv/consts/ETH_P_SCA.S deleted file mode 100644 index 9b37f0a23..000000000 --- a/libc/sysv/consts/ETH_P_SCA.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ETH_P_SCA,0x6007,0,0,0,0,0 diff --git a/libc/sysv/consts/ETH_P_WAN_PPP.S b/libc/sysv/consts/ETH_P_WAN_PPP.S deleted file mode 100644 index c990a7f83..000000000 --- a/libc/sysv/consts/ETH_P_WAN_PPP.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ETH_P_WAN_PPP,7,0,0,0,0,0 diff --git a/libc/sysv/consts/EXTENDED_EXTENDED_IDENTIFY.S b/libc/sysv/consts/EXTENDED_EXTENDED_IDENTIFY.S deleted file mode 100644 index 4e39e5af0..000000000 --- a/libc/sysv/consts/EXTENDED_EXTENDED_IDENTIFY.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,EXTENDED_EXTENDED_IDENTIFY,2,0,0,0,0,0 diff --git a/libc/sysv/consts/EXTENDED_MESSAGE.S b/libc/sysv/consts/EXTENDED_MESSAGE.S deleted file mode 100644 index eb1638c02..000000000 --- a/libc/sysv/consts/EXTENDED_MESSAGE.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,EXTENDED_MESSAGE,1,0,0,0,0,0 diff --git a/libc/sysv/consts/EXTENDED_MODIFY_DATA_POINTER.S b/libc/sysv/consts/EXTENDED_MODIFY_DATA_POINTER.S deleted file mode 100644 index cfbf01d28..000000000 --- a/libc/sysv/consts/EXTENDED_MODIFY_DATA_POINTER.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,EXTENDED_MODIFY_DATA_POINTER,0,0,0,0,0,0 diff --git a/libc/sysv/consts/EXTENDED_SDTR.S b/libc/sysv/consts/EXTENDED_SDTR.S deleted file mode 100644 index b808da470..000000000 --- a/libc/sysv/consts/EXTENDED_SDTR.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,EXTENDED_SDTR,1,0,0,0,0,0 diff --git a/libc/sysv/consts/EXTENDED_WDTR.S b/libc/sysv/consts/EXTENDED_WDTR.S deleted file mode 100644 index c4efa3ac1..000000000 --- a/libc/sysv/consts/EXTENDED_WDTR.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,EXTENDED_WDTR,3,0,0,0,0,0 diff --git a/libc/sysv/consts/FORM_C.S b/libc/sysv/consts/FORM_C.S deleted file mode 100644 index e84cf7f2e..000000000 --- a/libc/sysv/consts/FORM_C.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,FORM_C,3,3,3,3,3,0 diff --git a/libc/sysv/consts/FORM_N.S b/libc/sysv/consts/FORM_N.S deleted file mode 100644 index b9d4154fd..000000000 --- a/libc/sysv/consts/FORM_N.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,FORM_N,1,1,1,1,1,0 diff --git a/libc/sysv/consts/FORM_T.S b/libc/sysv/consts/FORM_T.S deleted file mode 100644 index 019bcde88..000000000 --- a/libc/sysv/consts/FORM_T.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,FORM_T,2,2,2,2,2,0 diff --git a/libc/sysv/consts/GOOD.S b/libc/sysv/consts/GOOD.S deleted file mode 100644 index 7c5c2ea8c..000000000 --- a/libc/sysv/consts/GOOD.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,GOOD,0,0,0,0,0,0 diff --git a/libc/sysv/consts/HOST_NOT_FOUND.S b/libc/sysv/consts/HOST_NOT_FOUND.S deleted file mode 100644 index ac2def451..000000000 --- a/libc/sysv/consts/HOST_NOT_FOUND.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,HOST_NOT_FOUND,1,1,1,1,1,0x2af9 diff --git a/libc/sysv/consts/ITIMER_PROF.S b/libc/sysv/consts/ITIMER_PROF.S deleted file mode 100644 index 99ce09cc8..000000000 --- a/libc/sysv/consts/ITIMER_PROF.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ITIMER_PROF,2,2,2,2,2,2 diff --git a/libc/sysv/consts/ITIMER_REAL.S b/libc/sysv/consts/ITIMER_REAL.S deleted file mode 100644 index 9c0b1cb1e..000000000 --- a/libc/sysv/consts/ITIMER_REAL.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ITIMER_REAL,0,0,0,0,0,0 diff --git a/libc/sysv/consts/ITIMER_VIRTUAL.S b/libc/sysv/consts/ITIMER_VIRTUAL.S deleted file mode 100644 index 2ae5f5708..000000000 --- a/libc/sysv/consts/ITIMER_VIRTUAL.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,ITIMER_VIRTUAL,1,1,1,1,1,1 diff --git a/libc/sysv/consts/LIO_NOP.S b/libc/sysv/consts/LIO_NOP.S index 19d8a9caa..7c97e2e37 100644 --- a/libc/sysv/consts/LIO_NOP.S +++ b/libc/sysv/consts/LIO_NOP.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,LIO_NOP,2,0,0,0,0,0 +.syscon lio,LIO_NOP,127,0,0,127,0,127 diff --git a/libc/sysv/consts/LIO_NOWAIT.S b/libc/sysv/consts/LIO_NOWAIT.S index c5704071f..8490477ca 100644 --- a/libc/sysv/consts/LIO_NOWAIT.S +++ b/libc/sysv/consts/LIO_NOWAIT.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,LIO_NOWAIT,1,1,0,0,0,0 +.syscon lio,LIO_NOWAIT,127,1,0,127,0,127 diff --git a/libc/sysv/consts/LIO_READ.S b/libc/sysv/consts/LIO_READ.S index b88e3e725..36191492e 100644 --- a/libc/sysv/consts/LIO_READ.S +++ b/libc/sysv/consts/LIO_READ.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,LIO_READ,0,1,2,0,0,0 +.syscon lio,LIO_READ,127,1,2,127,2,127 diff --git a/libc/sysv/consts/LIO_WAIT.S b/libc/sysv/consts/LIO_WAIT.S index 65e7b0113..234e09b64 100644 --- a/libc/sysv/consts/LIO_WAIT.S +++ b/libc/sysv/consts/LIO_WAIT.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,LIO_WAIT,0,2,1,0,0,0 +.syscon lio,LIO_WAIT,127,2,1,127,1,127 diff --git a/libc/sysv/consts/LIO_WRITE.S b/libc/sysv/consts/LIO_WRITE.S index 43898a3c8..cb10c8f75 100644 --- a/libc/sysv/consts/LIO_WRITE.S +++ b/libc/sysv/consts/LIO_WRITE.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,LIO_WRITE,1,2,1,0,0,0 +.syscon lio,LIO_WRITE,127,2,1,127,1,127 diff --git a/libc/sysv/consts/MTRESET.S b/libc/sysv/consts/MTRESET.S deleted file mode 100644 index 4fa8ac91c..000000000 --- a/libc/sysv/consts/MTRESET.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,MTRESET,0,0,0,0,0,0 diff --git a/libc/sysv/consts/MT_ST_CAN_PARTITIONS.S b/libc/sysv/consts/MT_ST_CAN_PARTITIONS.S deleted file mode 100644 index bfec34991..000000000 --- a/libc/sysv/consts/MT_ST_CAN_PARTITIONS.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,MT_ST_CAN_PARTITIONS,0x0400,0,0,0,0,0 diff --git a/libc/sysv/consts/MT_ST_HPLOADER_OFFSET.S b/libc/sysv/consts/MT_ST_HPLOADER_OFFSET.S deleted file mode 100644 index b77990062..000000000 --- a/libc/sysv/consts/MT_ST_HPLOADER_OFFSET.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,MT_ST_HPLOADER_OFFSET,0x2710,0,0,0,0,0 diff --git a/libc/sysv/consts/MT_ST_SCSI2LOGICAL.S b/libc/sysv/consts/MT_ST_SCSI2LOGICAL.S deleted file mode 100644 index 6dfdfa0e5..000000000 --- a/libc/sysv/consts/MT_ST_SCSI2LOGICAL.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,MT_ST_SCSI2LOGICAL,0x0800,0,0,0,0,0 diff --git a/libc/sysv/consts/NI_DGRAM.S b/libc/sysv/consts/NI_DGRAM.S deleted file mode 100644 index a1c84b41d..000000000 --- a/libc/sysv/consts/NI_DGRAM.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,NI_DGRAM,0x10,0x10,0x10,0x10,0x10,0x10 diff --git a/libc/sysv/consts/NI_MAXHOST.S b/libc/sysv/consts/NI_MAXHOST.S deleted file mode 100644 index b42aeb6b6..000000000 --- a/libc/sysv/consts/NI_MAXHOST.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,NI_MAXHOST,0x0401,0x0401,0x0401,0x0100,0x0100,0x0401 diff --git a/libc/sysv/consts/NI_MAXSERV.S b/libc/sysv/consts/NI_MAXSERV.S deleted file mode 100644 index 2308db4f3..000000000 --- a/libc/sysv/consts/NI_MAXSERV.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,NI_MAXSERV,0x20,0x20,0x20,0x20,0x20,0x20 diff --git a/libc/sysv/consts/NI_NAMEREQD.S b/libc/sysv/consts/NI_NAMEREQD.S deleted file mode 100644 index e18fb32ea..000000000 --- a/libc/sysv/consts/NI_NAMEREQD.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,NI_NAMEREQD,8,4,4,8,8,4 diff --git a/libc/sysv/consts/NI_NOFQDN.S b/libc/sysv/consts/NI_NOFQDN.S deleted file mode 100644 index fa0e44510..000000000 --- a/libc/sysv/consts/NI_NOFQDN.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,NI_NOFQDN,4,1,1,4,4,1 diff --git a/libc/sysv/consts/NI_NUMERICHOST.S b/libc/sysv/consts/NI_NUMERICHOST.S deleted file mode 100644 index 74b4af407..000000000 --- a/libc/sysv/consts/NI_NUMERICHOST.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,NI_NUMERICHOST,1,2,2,1,1,2 diff --git a/libc/sysv/consts/NI_NUMERICSCOPE.S b/libc/sysv/consts/NI_NUMERICSCOPE.S deleted file mode 100644 index 8d7401dbd..000000000 --- a/libc/sysv/consts/NI_NUMERICSCOPE.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,NI_NUMERICSCOPE,0,0,0x20,0,0,0 diff --git a/libc/sysv/consts/NI_NUMERICSERV.S b/libc/sysv/consts/NI_NUMERICSERV.S deleted file mode 100644 index fe7711a70..000000000 --- a/libc/sysv/consts/NI_NUMERICSERV.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,NI_NUMERICSERV,2,8,8,2,2,8 diff --git a/libc/sysv/consts/NO_DATA.S b/libc/sysv/consts/NO_DATA.S deleted file mode 100644 index 507c5b942..000000000 --- a/libc/sysv/consts/NO_DATA.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,NO_DATA,4,4,4,4,4,0x2afc diff --git a/libc/sysv/consts/NO_RECOVERY.S b/libc/sysv/consts/NO_RECOVERY.S deleted file mode 100644 index d3fe0858f..000000000 --- a/libc/sysv/consts/NO_RECOVERY.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,NO_RECOVERY,3,3,3,3,3,0x2afb diff --git a/libc/sysv/consts/NS_DSA_MAX_BYTES.S b/libc/sysv/consts/NS_DSA_MAX_BYTES.S deleted file mode 100644 index d959e316a..000000000 --- a/libc/sysv/consts/NS_DSA_MAX_BYTES.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,NS_DSA_MAX_BYTES,405,405,405,0,0,0 diff --git a/libc/sysv/consts/NS_DSA_MIN_SIZE.S b/libc/sysv/consts/NS_DSA_MIN_SIZE.S deleted file mode 100644 index 4b0873fc8..000000000 --- a/libc/sysv/consts/NS_DSA_MIN_SIZE.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,NS_DSA_MIN_SIZE,213,213,213,0,0,0 diff --git a/libc/sysv/consts/NS_DSA_SIG_SIZE.S b/libc/sysv/consts/NS_DSA_SIG_SIZE.S deleted file mode 100644 index dbc69dc74..000000000 --- a/libc/sysv/consts/NS_DSA_SIG_SIZE.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,NS_DSA_SIG_SIZE,41,41,41,0,0,0 diff --git a/libc/sysv/consts/NS_KEY_PROT_DNSSEC.S b/libc/sysv/consts/NS_KEY_PROT_DNSSEC.S deleted file mode 100644 index 79f3efe47..000000000 --- a/libc/sysv/consts/NS_KEY_PROT_DNSSEC.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,NS_KEY_PROT_DNSSEC,3,3,3,0,0,0 diff --git a/libc/sysv/consts/NS_KEY_PROT_EMAIL.S b/libc/sysv/consts/NS_KEY_PROT_EMAIL.S deleted file mode 100644 index cdb9226e9..000000000 --- a/libc/sysv/consts/NS_KEY_PROT_EMAIL.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,NS_KEY_PROT_EMAIL,2,2,2,0,0,0 diff --git a/libc/sysv/consts/NS_KEY_PROT_IPSEC.S b/libc/sysv/consts/NS_KEY_PROT_IPSEC.S deleted file mode 100644 index 0258f1a65..000000000 --- a/libc/sysv/consts/NS_KEY_PROT_IPSEC.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,NS_KEY_PROT_IPSEC,4,4,4,0,0,0 diff --git a/libc/sysv/consts/NS_KEY_PROT_TLS.S b/libc/sysv/consts/NS_KEY_PROT_TLS.S deleted file mode 100644 index 6b12b0f2f..000000000 --- a/libc/sysv/consts/NS_KEY_PROT_TLS.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,NS_KEY_PROT_TLS,1,1,1,0,0,0 diff --git a/libc/sysv/consts/NS_KEY_RESERVED_BITMASK2.S b/libc/sysv/consts/NS_KEY_RESERVED_BITMASK2.S deleted file mode 100644 index c5dc562fc..000000000 --- a/libc/sysv/consts/NS_KEY_RESERVED_BITMASK2.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,NS_KEY_RESERVED_BITMASK2,0xffff,0xffff,0xffff,0,0,0 diff --git a/libc/sysv/consts/NS_NXT_MAX.S b/libc/sysv/consts/NS_NXT_MAX.S deleted file mode 100644 index f39fc1764..000000000 --- a/libc/sysv/consts/NS_NXT_MAX.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,NS_NXT_MAX,127,127,127,0,0,0 diff --git a/libc/sysv/consts/NS_OPT_DNSSEC_OK.S b/libc/sysv/consts/NS_OPT_DNSSEC_OK.S deleted file mode 100644 index abc510d46..000000000 --- a/libc/sysv/consts/NS_OPT_DNSSEC_OK.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,NS_OPT_DNSSEC_OK,0x8000,0x8000,0x8000,0,0,0 diff --git a/libc/sysv/consts/NS_TSIG_ERROR_FORMERR.S b/libc/sysv/consts/NS_TSIG_ERROR_FORMERR.S deleted file mode 100644 index 55b17b7d9..000000000 --- a/libc/sysv/consts/NS_TSIG_ERROR_FORMERR.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,NS_TSIG_ERROR_FORMERR,-12,-12,-12,0,0,0 diff --git a/libc/sysv/consts/NS_TSIG_ERROR_NO_SPACE.S b/libc/sysv/consts/NS_TSIG_ERROR_NO_SPACE.S deleted file mode 100644 index f08dce74b..000000000 --- a/libc/sysv/consts/NS_TSIG_ERROR_NO_SPACE.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,NS_TSIG_ERROR_NO_SPACE,-11,-11,-11,0,0,0 diff --git a/libc/sysv/consts/NS_TSIG_ERROR_NO_TSIG.S b/libc/sysv/consts/NS_TSIG_ERROR_NO_TSIG.S deleted file mode 100644 index a89012b5d..000000000 --- a/libc/sysv/consts/NS_TSIG_ERROR_NO_TSIG.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,NS_TSIG_ERROR_NO_TSIG,-10,-10,-10,0,0,0 diff --git a/libc/sysv/consts/NS_TSIG_FUDGE.S b/libc/sysv/consts/NS_TSIG_FUDGE.S deleted file mode 100644 index 24342c689..000000000 --- a/libc/sysv/consts/NS_TSIG_FUDGE.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,NS_TSIG_FUDGE,300,300,300,0,0,0 diff --git a/libc/sysv/consts/NS_TSIG_TCP_COUNT.S b/libc/sysv/consts/NS_TSIG_TCP_COUNT.S deleted file mode 100644 index 6ab057975..000000000 --- a/libc/sysv/consts/NS_TSIG_TCP_COUNT.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,NS_TSIG_TCP_COUNT,100,100,100,0,0,0 diff --git a/libc/sysv/consts/N_6PACK.S b/libc/sysv/consts/N_6PACK.S deleted file mode 100644 index e586c77c1..000000000 --- a/libc/sysv/consts/N_6PACK.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,N_6PACK,7,0,0,0,0,0 diff --git a/libc/sysv/consts/N_AX25.S b/libc/sysv/consts/N_AX25.S deleted file mode 100644 index 419af87ad..000000000 --- a/libc/sysv/consts/N_AX25.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,N_AX25,5,0,0,0,0,0 diff --git a/libc/sysv/consts/N_HCI.S b/libc/sysv/consts/N_HCI.S deleted file mode 100644 index 7ba225c8b..000000000 --- a/libc/sysv/consts/N_HCI.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,N_HCI,15,0,0,0,0,0 diff --git a/libc/sysv/consts/N_HDLC.S b/libc/sysv/consts/N_HDLC.S deleted file mode 100644 index 4bfaf6faf..000000000 --- a/libc/sysv/consts/N_HDLC.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,N_HDLC,13,0,0,0,0,0 diff --git a/libc/sysv/consts/N_IRDA.S b/libc/sysv/consts/N_IRDA.S deleted file mode 100644 index d8d0947dd..000000000 --- a/libc/sysv/consts/N_IRDA.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,N_IRDA,11,0,0,0,0,0 diff --git a/libc/sysv/consts/N_MASC.S b/libc/sysv/consts/N_MASC.S deleted file mode 100644 index fce0457fb..000000000 --- a/libc/sysv/consts/N_MASC.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,N_MASC,8,0,0,0,0,0 diff --git a/libc/sysv/consts/N_MOUSE.S b/libc/sysv/consts/N_MOUSE.S deleted file mode 100644 index 5e36ef641..000000000 --- a/libc/sysv/consts/N_MOUSE.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,N_MOUSE,2,0,0,0,0,0 diff --git a/libc/sysv/consts/N_PPP.S b/libc/sysv/consts/N_PPP.S deleted file mode 100644 index ddcc0f6a9..000000000 --- a/libc/sysv/consts/N_PPP.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,N_PPP,3,0,0,0,0,0 diff --git a/libc/sysv/consts/N_PROFIBUS_FDL.S b/libc/sysv/consts/N_PROFIBUS_FDL.S deleted file mode 100644 index 970680080..000000000 --- a/libc/sysv/consts/N_PROFIBUS_FDL.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,N_PROFIBUS_FDL,10,0,0,0,0,0 diff --git a/libc/sysv/consts/N_R3964.S b/libc/sysv/consts/N_R3964.S deleted file mode 100644 index 6eddd11ee..000000000 --- a/libc/sysv/consts/N_R3964.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,N_R3964,9,0,0,0,0,0 diff --git a/libc/sysv/consts/N_SLIP.S b/libc/sysv/consts/N_SLIP.S deleted file mode 100644 index 0b8e6b647..000000000 --- a/libc/sysv/consts/N_SLIP.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,N_SLIP,1,0,0,0,0,0 diff --git a/libc/sysv/consts/N_SMSBLOCK.S b/libc/sysv/consts/N_SMSBLOCK.S deleted file mode 100644 index e784c27ae..000000000 --- a/libc/sysv/consts/N_SMSBLOCK.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,N_SMSBLOCK,12,0,0,0,0,0 diff --git a/libc/sysv/consts/N_STRIP.S b/libc/sysv/consts/N_STRIP.S deleted file mode 100644 index 6b4e1999a..000000000 --- a/libc/sysv/consts/N_STRIP.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,N_STRIP,4,0,0,0,0,0 diff --git a/libc/sysv/consts/N_SYNC_PPP.S b/libc/sysv/consts/N_SYNC_PPP.S deleted file mode 100644 index a60901794..000000000 --- a/libc/sysv/consts/N_SYNC_PPP.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,N_SYNC_PPP,14,0,0,0,0,0 diff --git a/libc/sysv/consts/N_TTY.S b/libc/sysv/consts/N_TTY.S deleted file mode 100644 index 450c124ae..000000000 --- a/libc/sysv/consts/N_TTY.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,N_TTY,0,0,0,0,0,0 diff --git a/libc/sysv/consts/N_X25.S b/libc/sysv/consts/N_X25.S deleted file mode 100644 index afc020603..000000000 --- a/libc/sysv/consts/N_X25.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,N_X25,6,0,0,0,0,0 diff --git a/libc/sysv/consts/REC_EOF.S b/libc/sysv/consts/REC_EOF.S deleted file mode 100644 index 5cd919e3d..000000000 --- a/libc/sysv/consts/REC_EOF.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,REC_EOF,2,2,2,2,2,0 diff --git a/libc/sysv/consts/REC_EOR.S b/libc/sysv/consts/REC_EOR.S deleted file mode 100644 index 5e8f87bc5..000000000 --- a/libc/sysv/consts/REC_EOR.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,REC_EOR,1,1,1,1,1,0 diff --git a/libc/sysv/consts/REC_ESC.S b/libc/sysv/consts/REC_ESC.S deleted file mode 100644 index 0cbab97f0..000000000 --- a/libc/sysv/consts/REC_ESC.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,REC_ESC,-1,-1,-1,-1,-1,0 diff --git a/libc/sysv/consts/SCHED_BATCH.S b/libc/sysv/consts/SCHED_BATCH.S index f9ef31c0b..a81933d84 100644 --- a/libc/sysv/consts/SCHED_BATCH.S +++ b/libc/sysv/consts/SCHED_BATCH.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SCHED_BATCH,3,0,0,0,0,0 +.syscon sched,SCHED_BATCH,3,127,2,127,0,127 diff --git a/libc/sysv/consts/SCHED_DEADLINE.S b/libc/sysv/consts/SCHED_DEADLINE.S new file mode 100644 index 000000000..cff230279 --- /dev/null +++ b/libc/sysv/consts/SCHED_DEADLINE.S @@ -0,0 +1,2 @@ +#include "libc/sysv/consts/syscon.internal.h" +.syscon sched,SCHED_DEADLINE,6,127,127,127,127,127 diff --git a/libc/sysv/consts/SCHED_FIFO.S b/libc/sysv/consts/SCHED_FIFO.S index f7d8024d2..e425dadc0 100644 --- a/libc/sysv/consts/SCHED_FIFO.S +++ b/libc/sysv/consts/SCHED_FIFO.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SCHED_FIFO,1,4,1,1,1,0 +.syscon sched,SCHED_FIFO,1,127,1,127,1,127 diff --git a/libc/sysv/consts/SCHED_IDLE.S b/libc/sysv/consts/SCHED_IDLE.S index 77270d5de..39455510b 100644 --- a/libc/sysv/consts/SCHED_IDLE.S +++ b/libc/sysv/consts/SCHED_IDLE.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SCHED_IDLE,5,0,0,0,0,0 +.syscon sched,SCHED_IDLE,5,127,2,127,0,127 diff --git a/libc/sysv/consts/SCHED_OTHER.S b/libc/sysv/consts/SCHED_OTHER.S index 5c8e791a0..da8d73018 100644 --- a/libc/sysv/consts/SCHED_OTHER.S +++ b/libc/sysv/consts/SCHED_OTHER.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SCHED_OTHER,0,1,2,2,2,0 +.syscon sched,SCHED_OTHER,0,127,2,127,0,127 diff --git a/libc/sysv/consts/SCHED_RESET_ON_FORK.S b/libc/sysv/consts/SCHED_RESET_ON_FORK.S index a18a6245d..a8bbf5eb4 100644 --- a/libc/sysv/consts/SCHED_RESET_ON_FORK.S +++ b/libc/sysv/consts/SCHED_RESET_ON_FORK.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SCHED_RESET_ON_FORK,0x40000000,0,0,0,0,0 +.syscon sched,SCHED_RESET_ON_FORK,0x40000000,0,0,0,0,0 diff --git a/libc/sysv/consts/SCHED_RR.S b/libc/sysv/consts/SCHED_RR.S index fd79b4e80..e7f0210eb 100644 --- a/libc/sysv/consts/SCHED_RR.S +++ b/libc/sysv/consts/SCHED_RR.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SCHED_RR,2,2,3,3,3,0 +.syscon sched,SCHED_RR,2,127,3,127,2,127 diff --git a/libc/sysv/consts/SCM_CREDENTIALS.S b/libc/sysv/consts/SCM_CREDENTIALS.S index be0d0550f..665d0c1db 100644 --- a/libc/sysv/consts/SCM_CREDENTIALS.S +++ b/libc/sysv/consts/SCM_CREDENTIALS.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SCM_CREDENTIALS,2,0,0,0,0,0 +.syscon scm,SCM_CREDENTIALS,2,0,0,0,0,0 diff --git a/libc/sysv/consts/SCM_RIGHTS.S b/libc/sysv/consts/SCM_RIGHTS.S index ced24d0b5..9a4c6fae1 100644 --- a/libc/sysv/consts/SCM_RIGHTS.S +++ b/libc/sysv/consts/SCM_RIGHTS.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SCM_RIGHTS,1,1,1,1,1,0 +.syscon scm,SCM_RIGHTS,1,1,1,1,1,1 diff --git a/libc/sysv/consts/SCM_TIMESTAMP.S b/libc/sysv/consts/SCM_TIMESTAMP.S index 02a2f013f..a441be2b3 100644 --- a/libc/sysv/consts/SCM_TIMESTAMP.S +++ b/libc/sysv/consts/SCM_TIMESTAMP.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SCM_TIMESTAMP,29,2,2,4,8,0 +.syscon scm,SCM_TIMESTAMP,29,2,2,4,8,0 diff --git a/libc/sysv/consts/SCM_TIMESTAMPING.S b/libc/sysv/consts/SCM_TIMESTAMPING.S index c2639f805..fbabfc85c 100644 --- a/libc/sysv/consts/SCM_TIMESTAMPING.S +++ b/libc/sysv/consts/SCM_TIMESTAMPING.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SCM_TIMESTAMPING,37,0,0,0,0,0 +.syscon scm,SCM_TIMESTAMPING,37,0,0,0,0,0 diff --git a/libc/sysv/consts/SCM_TIMESTAMPNS.S b/libc/sysv/consts/SCM_TIMESTAMPNS.S index 29bde0dc6..469df11a1 100644 --- a/libc/sysv/consts/SCM_TIMESTAMPNS.S +++ b/libc/sysv/consts/SCM_TIMESTAMPNS.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SCM_TIMESTAMPNS,35,0,0,0,0,0 +.syscon scm,SCM_TIMESTAMPNS,35,0,0,0,0,0 diff --git a/libc/sysv/consts/SCM_WIFI_STATUS.S b/libc/sysv/consts/SCM_WIFI_STATUS.S index f8911bcd1..7ba70d13a 100644 --- a/libc/sysv/consts/SCM_WIFI_STATUS.S +++ b/libc/sysv/consts/SCM_WIFI_STATUS.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SCM_WIFI_STATUS,41,0,0,0,0,0 +.syscon scm,SCM_WIFI_STATUS,41,0,0,0,0,0 diff --git a/libc/sysv/consts/SEARCH_EQUAL.S b/libc/sysv/consts/SEARCH_EQUAL.S deleted file mode 100644 index 38f85063b..000000000 --- a/libc/sysv/consts/SEARCH_EQUAL.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SEARCH_EQUAL,49,0,0,0,0,0 diff --git a/libc/sysv/consts/SEARCH_EQUAL_12.S b/libc/sysv/consts/SEARCH_EQUAL_12.S deleted file mode 100644 index b3f997d76..000000000 --- a/libc/sysv/consts/SEARCH_EQUAL_12.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SEARCH_EQUAL_12,177,0,0,0,0,0 diff --git a/libc/sysv/consts/SEARCH_HIGH.S b/libc/sysv/consts/SEARCH_HIGH.S deleted file mode 100644 index f3d70378a..000000000 --- a/libc/sysv/consts/SEARCH_HIGH.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SEARCH_HIGH,48,0,0,0,0,0 diff --git a/libc/sysv/consts/SEARCH_HIGH_12.S b/libc/sysv/consts/SEARCH_HIGH_12.S deleted file mode 100644 index 5dbc3b7a7..000000000 --- a/libc/sysv/consts/SEARCH_HIGH_12.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SEARCH_HIGH_12,176,0,0,0,0,0 diff --git a/libc/sysv/consts/SEARCH_LOW.S b/libc/sysv/consts/SEARCH_LOW.S deleted file mode 100644 index ae56781ec..000000000 --- a/libc/sysv/consts/SEARCH_LOW.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SEARCH_LOW,50,0,0,0,0,0 diff --git a/libc/sysv/consts/SEARCH_LOW_12.S b/libc/sysv/consts/SEARCH_LOW_12.S deleted file mode 100644 index 328efd3ed..000000000 --- a/libc/sysv/consts/SEARCH_LOW_12.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,SEARCH_LOW_12,178,0,0,0,0,0 diff --git a/libc/sysv/consts/STRU_F.S b/libc/sysv/consts/STRU_F.S deleted file mode 100644 index 98335bc82..000000000 --- a/libc/sysv/consts/STRU_F.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,STRU_F,1,1,1,1,1,0 diff --git a/libc/sysv/consts/STRU_P.S b/libc/sysv/consts/STRU_P.S deleted file mode 100644 index fe87c8cbc..000000000 --- a/libc/sysv/consts/STRU_P.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,STRU_P,3,3,3,3,3,0 diff --git a/libc/sysv/consts/STRU_R.S b/libc/sysv/consts/STRU_R.S deleted file mode 100644 index be37801ec..000000000 --- a/libc/sysv/consts/STRU_R.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,STRU_R,2,2,2,2,2,0 diff --git a/libc/sysv/consts/TCPOLEN_MAXSEG.S b/libc/sysv/consts/TCPOLEN_MAXSEG.S deleted file mode 100644 index c5b7e3b4a..000000000 --- a/libc/sysv/consts/TCPOLEN_MAXSEG.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TCPOLEN_MAXSEG,4,4,4,4,4,0 diff --git a/libc/sysv/consts/TCPOLEN_SACK_PERMITTED.S b/libc/sysv/consts/TCPOLEN_SACK_PERMITTED.S deleted file mode 100644 index 66c9b9044..000000000 --- a/libc/sysv/consts/TCPOLEN_SACK_PERMITTED.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TCPOLEN_SACK_PERMITTED,2,2,2,2,2,0 diff --git a/libc/sysv/consts/TCPOLEN_TIMESTAMP.S b/libc/sysv/consts/TCPOLEN_TIMESTAMP.S deleted file mode 100644 index b34f89725..000000000 --- a/libc/sysv/consts/TCPOLEN_TIMESTAMP.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TCPOLEN_TIMESTAMP,10,10,10,10,10,0 diff --git a/libc/sysv/consts/TCPOLEN_WINDOW.S b/libc/sysv/consts/TCPOLEN_WINDOW.S deleted file mode 100644 index f99ddcdf0..000000000 --- a/libc/sysv/consts/TCPOLEN_WINDOW.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TCPOLEN_WINDOW,3,3,3,3,3,0 diff --git a/libc/sysv/consts/TCPOPT_EOL.S b/libc/sysv/consts/TCPOPT_EOL.S deleted file mode 100644 index e493e1f3c..000000000 --- a/libc/sysv/consts/TCPOPT_EOL.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TCPOPT_EOL,0,0,0,0,0,0 diff --git a/libc/sysv/consts/TCPOPT_MAXSEG.S b/libc/sysv/consts/TCPOPT_MAXSEG.S deleted file mode 100644 index 53791eeca..000000000 --- a/libc/sysv/consts/TCPOPT_MAXSEG.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TCPOPT_MAXSEG,2,2,2,2,2,0 diff --git a/libc/sysv/consts/TCPOPT_NOP.S b/libc/sysv/consts/TCPOPT_NOP.S deleted file mode 100644 index 2341664ae..000000000 --- a/libc/sysv/consts/TCPOPT_NOP.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TCPOPT_NOP,1,1,1,1,1,0 diff --git a/libc/sysv/consts/TCPOPT_SACK.S b/libc/sysv/consts/TCPOPT_SACK.S deleted file mode 100644 index 8072cd612..000000000 --- a/libc/sysv/consts/TCPOPT_SACK.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TCPOPT_SACK,5,5,5,5,5,0 diff --git a/libc/sysv/consts/TCPOPT_SACK_PERMITTED.S b/libc/sysv/consts/TCPOPT_SACK_PERMITTED.S deleted file mode 100644 index 0fd954d7d..000000000 --- a/libc/sysv/consts/TCPOPT_SACK_PERMITTED.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TCPOPT_SACK_PERMITTED,4,4,4,4,4,0 diff --git a/libc/sysv/consts/TCPOPT_TIMESTAMP.S b/libc/sysv/consts/TCPOPT_TIMESTAMP.S deleted file mode 100644 index de78bcf2d..000000000 --- a/libc/sysv/consts/TCPOPT_TIMESTAMP.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TCPOPT_TIMESTAMP,8,8,8,8,8,0 diff --git a/libc/sysv/consts/TCPOPT_WINDOW.S b/libc/sysv/consts/TCPOPT_WINDOW.S deleted file mode 100644 index 53362465c..000000000 --- a/libc/sysv/consts/TCPOPT_WINDOW.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TCPOPT_WINDOW,3,3,3,3,3,0 diff --git a/libc/sysv/consts/TELOPT_NAOL.S b/libc/sysv/consts/TELOPT_NAOL.S deleted file mode 100644 index bd44776b6..000000000 --- a/libc/sysv/consts/TELOPT_NAOL.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TELOPT_NAOL,8,8,8,8,8,0 diff --git a/libc/sysv/consts/TELOPT_NAOP.S b/libc/sysv/consts/TELOPT_NAOP.S deleted file mode 100644 index 7f5ef0dbd..000000000 --- a/libc/sysv/consts/TELOPT_NAOP.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TELOPT_NAOP,9,9,9,9,9,0 diff --git a/libc/sysv/consts/TELOPT_NEW_ENVIRON.S b/libc/sysv/consts/TELOPT_NEW_ENVIRON.S deleted file mode 100644 index 92f2cdd58..000000000 --- a/libc/sysv/consts/TELOPT_NEW_ENVIRON.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TELOPT_NEW_ENVIRON,39,39,39,39,39,0 diff --git a/libc/sysv/consts/TELOPT_OLD_ENVIRON.S b/libc/sysv/consts/TELOPT_OLD_ENVIRON.S deleted file mode 100644 index e65db7a5c..000000000 --- a/libc/sysv/consts/TELOPT_OLD_ENVIRON.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TELOPT_OLD_ENVIRON,36,36,36,36,36,0 diff --git a/libc/sysv/consts/TIMER_ABSTIME.S b/libc/sysv/consts/TIMER_ABSTIME.S deleted file mode 100644 index cf291d5f1..000000000 --- a/libc/sysv/consts/TIMER_ABSTIME.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TIMER_ABSTIME,1,0,1,1,1,0 diff --git a/libc/sysv/consts/TRY_AGAIN.S b/libc/sysv/consts/TRY_AGAIN.S deleted file mode 100644 index d11f83325..000000000 --- a/libc/sysv/consts/TRY_AGAIN.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TRY_AGAIN,2,2,2,2,2,0x2afa diff --git a/libc/sysv/consts/TYPE_A.S b/libc/sysv/consts/TYPE_A.S deleted file mode 100644 index df50ff628..000000000 --- a/libc/sysv/consts/TYPE_A.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TYPE_A,1,1,1,1,1,0 diff --git a/libc/sysv/consts/TYPE_DISK.S b/libc/sysv/consts/TYPE_DISK.S deleted file mode 100644 index ba2a4649b..000000000 --- a/libc/sysv/consts/TYPE_DISK.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TYPE_DISK,0,0,0,0,0,0 diff --git a/libc/sysv/consts/TYPE_E.S b/libc/sysv/consts/TYPE_E.S deleted file mode 100644 index a9018c9c2..000000000 --- a/libc/sysv/consts/TYPE_E.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TYPE_E,2,2,2,2,2,0 diff --git a/libc/sysv/consts/TYPE_ENCLOSURE.S b/libc/sysv/consts/TYPE_ENCLOSURE.S deleted file mode 100644 index 3c59b3944..000000000 --- a/libc/sysv/consts/TYPE_ENCLOSURE.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TYPE_ENCLOSURE,13,0,0,0,0,0 diff --git a/libc/sysv/consts/TYPE_I.S b/libc/sysv/consts/TYPE_I.S deleted file mode 100644 index 6fd4786c7..000000000 --- a/libc/sysv/consts/TYPE_I.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TYPE_I,3,3,3,3,3,0 diff --git a/libc/sysv/consts/TYPE_L.S b/libc/sysv/consts/TYPE_L.S deleted file mode 100644 index 1a643b834..000000000 --- a/libc/sysv/consts/TYPE_L.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TYPE_L,4,4,4,4,4,0 diff --git a/libc/sysv/consts/TYPE_MEDIUM_CHANGER.S b/libc/sysv/consts/TYPE_MEDIUM_CHANGER.S deleted file mode 100644 index 222603dec..000000000 --- a/libc/sysv/consts/TYPE_MEDIUM_CHANGER.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TYPE_MEDIUM_CHANGER,8,0,0,0,0,0 diff --git a/libc/sysv/consts/TYPE_MOD.S b/libc/sysv/consts/TYPE_MOD.S deleted file mode 100644 index 7ff91041b..000000000 --- a/libc/sysv/consts/TYPE_MOD.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TYPE_MOD,7,0,0,0,0,0 diff --git a/libc/sysv/consts/TYPE_NO_LUN.S b/libc/sysv/consts/TYPE_NO_LUN.S deleted file mode 100644 index 4e7189875..000000000 --- a/libc/sysv/consts/TYPE_NO_LUN.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TYPE_NO_LUN,127,0,0,0,0,0 diff --git a/libc/sysv/consts/TYPE_PROCESSOR.S b/libc/sysv/consts/TYPE_PROCESSOR.S deleted file mode 100644 index 817903761..000000000 --- a/libc/sysv/consts/TYPE_PROCESSOR.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TYPE_PROCESSOR,3,0,0,0,0,0 diff --git a/libc/sysv/consts/TYPE_ROM.S b/libc/sysv/consts/TYPE_ROM.S deleted file mode 100644 index 46fdb7047..000000000 --- a/libc/sysv/consts/TYPE_ROM.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TYPE_ROM,5,0,0,0,0,0 diff --git a/libc/sysv/consts/TYPE_SCANNER.S b/libc/sysv/consts/TYPE_SCANNER.S deleted file mode 100644 index 24c2db3da..000000000 --- a/libc/sysv/consts/TYPE_SCANNER.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TYPE_SCANNER,6,0,0,0,0,0 diff --git a/libc/sysv/consts/TYPE_TAPE.S b/libc/sysv/consts/TYPE_TAPE.S deleted file mode 100644 index 0e140b7aa..000000000 --- a/libc/sysv/consts/TYPE_TAPE.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TYPE_TAPE,1,0,0,0,0,0 diff --git a/libc/sysv/consts/TYPE_WORM.S b/libc/sysv/consts/TYPE_WORM.S deleted file mode 100644 index 448601bd4..000000000 --- a/libc/sysv/consts/TYPE_WORM.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,TYPE_WORM,4,0,0,0,0,0 diff --git a/libc/sysv/consts/_IOC_NONE.S b/libc/sysv/consts/_IOC_NONE.S deleted file mode 100644 index 45d0eb170..000000000 --- a/libc/sysv/consts/_IOC_NONE.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,_IOC_NONE,0,0,0,0,0,0 diff --git a/libc/sysv/consts/_IOC_READ.S b/libc/sysv/consts/_IOC_READ.S deleted file mode 100644 index ba41d4d28..000000000 --- a/libc/sysv/consts/_IOC_READ.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,_IOC_READ,2,0,0,0,0,0 diff --git a/libc/sysv/consts/_IOC_WRITE.S b/libc/sysv/consts/_IOC_WRITE.S deleted file mode 100644 index ff3ef6d70..000000000 --- a/libc/sysv/consts/_IOC_WRITE.S +++ /dev/null @@ -1,2 +0,0 @@ -#include "libc/sysv/consts/syscon.internal.h" -.syscon misc,_IOC_WRITE,1,0,0,0,0,0 diff --git a/libc/sysv/consts/__NR_sched_yield.S b/libc/sysv/consts/__NR_sched_yield.S index f39ccfe51..b4676317f 100644 --- a/libc/sysv/consts/__NR_sched_yield.S +++ b/libc/sysv/consts/__NR_sched_yield.S @@ -1,2 +1,2 @@ #include "libc/sysv/consts/syscon.internal.h" -.syscon nr,__NR_sched_yield,0x0018,0x010003c,0x014b,0x012a,0x15e,0xfff +.syscon nr,__NR_sched_yield,0x0018,0x200005d,0x014b,0x012a,0x15e,0xfff diff --git a/libc/sysv/consts/eth.h b/libc/sysv/consts/eth.h deleted file mode 100644 index e165c05fc..000000000 --- a/libc/sysv/consts/eth.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef COSMOPOLITAN_LIBC_SYSV_CONSTS_ETH_H_ -#define COSMOPOLITAN_LIBC_SYSV_CONSTS_ETH_H_ -#include "libc/runtime/symbolic.h" - -#define ETH_P_CUST SYMBOLIC(ETH_P_CUST) -#define ETH_P_DDCMP SYMBOLIC(ETH_P_DDCMP) -#define ETH_P_DEC SYMBOLIC(ETH_P_DEC) -#define ETH_P_DIAG SYMBOLIC(ETH_P_DIAG) -#define ETH_P_DNA_DL SYMBOLIC(ETH_P_DNA_DL) -#define ETH_P_DNA_RC SYMBOLIC(ETH_P_DNA_RC) -#define ETH_P_DNA_RT SYMBOLIC(ETH_P_DNA_RT) -#define ETH_P_IEEE802154 SYMBOLIC(ETH_P_IEEE802154) -#define ETH_P_LAT SYMBOLIC(ETH_P_LAT) -#define ETH_P_LOCALTALK SYMBOLIC(ETH_P_LOCALTALK) -#define ETH_P_PPP_MP SYMBOLIC(ETH_P_PPP_MP) -#define ETH_P_RARP SYMBOLIC(ETH_P_RARP) -#define ETH_P_SCA SYMBOLIC(ETH_P_SCA) -#define ETH_P_WAN_PPP SYMBOLIC(ETH_P_WAN_PPP) - -#if !(__ASSEMBLER__ + __LINKER__ + 0) -COSMOPOLITAN_C_START_ - -extern const long ETH_P_CUST; -extern const long ETH_P_DDCMP; -extern const long ETH_P_DEC; -extern const long ETH_P_DIAG; -extern const long ETH_P_DNA_DL; -extern const long ETH_P_DNA_RC; -extern const long ETH_P_DNA_RT; -extern const long ETH_P_IEEE802154; -extern const long ETH_P_LAT; -extern const long ETH_P_LOCALTALK; -extern const long ETH_P_PPP_MP; -extern const long ETH_P_RARP; -extern const long ETH_P_SCA; -extern const long ETH_P_WAN_PPP; - -COSMOPOLITAN_C_END_ -#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ -#endif /* COSMOPOLITAN_LIBC_SYSV_CONSTS_ETH_H_ */ diff --git a/libc/sysv/consts/itimer.h b/libc/sysv/consts/itimer.h index c7847e662..7a50af818 100644 --- a/libc/sysv/consts/itimer.h +++ b/libc/sysv/consts/itimer.h @@ -1,9 +1,8 @@ #ifndef COSMOPOLITAN_LIBC_SYSV_CONSTS_ITIMER_H_ #define COSMOPOLITAN_LIBC_SYSV_CONSTS_ITIMER_H_ -#include "libc/runtime/symbolic.h" -#define ITIMER_REAL 0 +#define ITIMER_REAL 0 #define ITIMER_VIRTUAL 1 -#define ITIMER_PROF 2 +#define ITIMER_PROF 2 #endif /* COSMOPOLITAN_LIBC_SYSV_CONSTS_ITIMER_H_ */ diff --git a/libc/sysv/consts/n.h b/libc/sysv/consts/n.h deleted file mode 100644 index e22b0fe14..000000000 --- a/libc/sysv/consts/n.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef COSMOPOLITAN_LIBC_SYSV_CONSTS_N_H_ -#define COSMOPOLITAN_LIBC_SYSV_CONSTS_N_H_ -#include "libc/runtime/symbolic.h" - -#define N_6PACK SYMBOLIC(N_6PACK) -#define N_AX25 SYMBOLIC(N_AX25) -#define N_HCI SYMBOLIC(N_HCI) -#define N_HDLC SYMBOLIC(N_HDLC) -#define N_IRDA SYMBOLIC(N_IRDA) -#define N_MASC SYMBOLIC(N_MASC) -#define N_MOUSE SYMBOLIC(N_MOUSE) -#define N_PPP SYMBOLIC(N_PPP) -#define N_PROFIBUS_FDL SYMBOLIC(N_PROFIBUS_FDL) -#define N_R3964 SYMBOLIC(N_R3964) -#define N_SLIP SYMBOLIC(N_SLIP) -#define N_SMSBLOCK SYMBOLIC(N_SMSBLOCK) -#define N_STRIP SYMBOLIC(N_STRIP) -#define N_SYNC_PPP SYMBOLIC(N_SYNC_PPP) -#define N_TTY SYMBOLIC(N_TTY) -#define N_X25 SYMBOLIC(N_X25) - -#if !(__ASSEMBLER__ + __LINKER__ + 0) -COSMOPOLITAN_C_START_ - -extern const long N_6PACK; -extern const long N_AX25; -extern const long N_HCI; -extern const long N_HDLC; -extern const long N_IRDA; -extern const long N_MASC; -extern const long N_MOUSE; -extern const long N_PPP; -extern const long N_PROFIBUS_FDL; -extern const long N_R3964; -extern const long N_SLIP; -extern const long N_SMSBLOCK; -extern const long N_STRIP; -extern const long N_SYNC_PPP; -extern const long N_TTY; -extern const long N_X25; - -COSMOPOLITAN_C_END_ -#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ -#endif /* COSMOPOLITAN_LIBC_SYSV_CONSTS_N_H_ */ diff --git a/libc/sysv/consts/nrlinux.h b/libc/sysv/consts/nrlinux.h index 59d6aa8e7..d428b84fd 100644 --- a/libc/sysv/consts/nrlinux.h +++ b/libc/sysv/consts/nrlinux.h @@ -1,7 +1,5 @@ #ifndef COSMOPOLITAN_LIBC_SYSV_CONSTS_NRLINUX_H_ #define COSMOPOLITAN_LIBC_SYSV_CONSTS_NRLINUX_H_ -#if !(__ASSEMBLER__ + __LINKER__ + 0) -COSMOPOLITAN_C_START_ #define __NR_linux_exit 0x003c #define __NR_linux_exit_group 0x00e7 @@ -325,6 +323,4 @@ COSMOPOLITAN_C_START_ #define __NR_linux_io_uring_enter 0x01aa #define __NR_linux_io_uring_register 0x01ab -COSMOPOLITAN_C_END_ -#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_SYSV_CONSTS_NRLINUX_H_ */ diff --git a/libc/sysv/consts/sched.h b/libc/sysv/consts/sched.h index 62ca9452e..b7987b1af 100644 --- a/libc/sysv/consts/sched.h +++ b/libc/sysv/consts/sched.h @@ -2,17 +2,20 @@ #define COSMOPOLITAN_LIBC_SYSV_CONSTS_SCHED_H_ #include "libc/runtime/symbolic.h" -#define SCHED_BATCH SYMBOLIC(SCHED_BATCH) -#define SCHED_FIFO SYMBOLIC(SCHED_FIFO) -#define SCHED_IDLE SYMBOLIC(SCHED_IDLE) -#define SCHED_OTHER SYMBOLIC(SCHED_OTHER) +#define SCHED_BATCH SYMBOLIC(SCHED_BATCH) +#define SCHED_DEADLINE SYMBOLIC(SCHED_DEADLINE) +#define SCHED_FIFO SYMBOLIC(SCHED_FIFO) +#define SCHED_IDLE SYMBOLIC(SCHED_IDLE) +#define SCHED_NORMAL SCHED_OTHER +#define SCHED_OTHER SYMBOLIC(SCHED_OTHER) #define SCHED_RESET_ON_FORK SYMBOLIC(SCHED_RESET_ON_FORK) -#define SCHED_RR SYMBOLIC(SCHED_RR) +#define SCHED_RR SYMBOLIC(SCHED_RR) #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ extern const long SCHED_BATCH; +extern const long SCHED_DEADLINE; extern const long SCHED_FIFO; extern const long SCHED_IDLE; extern const long SCHED_OTHER; diff --git a/libc/sysv/consts/scm.h b/libc/sysv/consts/scm.h new file mode 100644 index 000000000..43e8ea829 --- /dev/null +++ b/libc/sysv/consts/scm.h @@ -0,0 +1,23 @@ +#ifndef COSMOPOLITAN_LIBC_SYSV_CONSTS_SCM_H_ +#define COSMOPOLITAN_LIBC_SYSV_CONSTS_SCM_H_ +#include "libc/runtime/symbolic.h" +#if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ + +extern const long SCM_TIMESTAMP; +extern const long SCM_CREDENTIALS; +extern const long SCM_TIMESTAMPING; +extern const long SCM_TIMESTAMPNS; +extern const long SCM_WIFI_STATUS; + +COSMOPOLITAN_C_END_ +#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ + +#define SCM_RIGHTS LITERALLY(1) +#define SCM_TIMESTAMP SYMBOLIC(SCM_TIMESTAMP) +#define SCM_CREDENTIALS SYMBOLIC(SCM_CREDENTIALS) +#define SCM_TIMESTAMPING SYMBOLIC(SCM_TIMESTAMPING) +#define SCM_TIMESTAMPNS SYMBOLIC(SCM_TIMESTAMPNS) +#define SCM_WIFI_STATUS SYMBOLIC(SCM_WIFI_STATUS) + +#endif /* COSMOPOLITAN_LIBC_SYSV_CONSTS_SCM_H_ */ diff --git a/libc/sysv/consts/tcpopt.h b/libc/sysv/consts/tcpopt.h index 3010aff3f..297b7a078 100644 --- a/libc/sysv/consts/tcpopt.h +++ b/libc/sysv/consts/tcpopt.h @@ -1,26 +1,17 @@ #ifndef COSMOPOLITAN_LIBC_SYSV_CONSTS_TCPOPT_H_ #define COSMOPOLITAN_LIBC_SYSV_CONSTS_TCPOPT_H_ -#include "libc/runtime/symbolic.h" -#define TCPOPT_EOL SYMBOLIC(TCPOPT_EOL) -#define TCPOPT_MAXSEG SYMBOLIC(TCPOPT_MAXSEG) -#define TCPOPT_NOP SYMBOLIC(TCPOPT_NOP) -#define TCPOPT_SACK SYMBOLIC(TCPOPT_SACK) -#define TCPOPT_SACK_PERMITTED SYMBOLIC(TCPOPT_SACK_PERMITTED) -#define TCPOPT_TIMESTAMP SYMBOLIC(TCPOPT_TIMESTAMP) -#define TCPOPT_WINDOW SYMBOLIC(TCPOPT_WINDOW) +#define TCPOPT_EOL 0 +#define TCPOPT_NOP 1 +#define TCPOPT_MAXSEG 2 +#define TCPOPT_WINDOW 3 +#define TCPOPT_SACK_PERMITTED 4 +#define TCPOPT_SACK 5 +#define TCPOPT_TIMESTAMP 8 -#if !(__ASSEMBLER__ + __LINKER__ + 0) -COSMOPOLITAN_C_START_ +#define TCPOLEN_SACK_PERMITTED 2 +#define TCPOLEN_WINDOW 3 +#define TCPOLEN_MAXSEG 4 +#define TCPOLEN_TIMESTAMP 10 -extern const long TCPOPT_EOL; -extern const long TCPOPT_MAXSEG; -extern const long TCPOPT_NOP; -extern const long TCPOPT_SACK; -extern const long TCPOPT_SACK_PERMITTED; -extern const long TCPOPT_TIMESTAMP; -extern const long TCPOPT_WINDOW; - -COSMOPOLITAN_C_END_ -#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_SYSV_CONSTS_TCPOPT_H_ */ diff --git a/libc/sysv/consts/timer.h b/libc/sysv/consts/timer.h new file mode 100644 index 000000000..b76ef13ea --- /dev/null +++ b/libc/sysv/consts/timer.h @@ -0,0 +1,6 @@ +#ifndef COSMOPOLITAN_LIBC_SYSV_CONSTS_TIMER_H_ +#define COSMOPOLITAN_LIBC_SYSV_CONSTS_TIMER_H_ + +#define TIMER_ABSTIME 1 + +#endif /* COSMOPOLITAN_LIBC_SYSV_CONSTS_TIMER_H_ */ diff --git a/libc/sysv/consts/type.h b/libc/sysv/consts/type.h deleted file mode 100644 index 84eb72b31..000000000 --- a/libc/sysv/consts/type.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef COSMOPOLITAN_LIBC_SYSV_CONSTS_TYPE_H_ -#define COSMOPOLITAN_LIBC_SYSV_CONSTS_TYPE_H_ -#include "libc/runtime/symbolic.h" - -#define TYPE_A SYMBOLIC(TYPE_A) -#define TYPE_DISK SYMBOLIC(TYPE_DISK) -#define TYPE_E SYMBOLIC(TYPE_E) -#define TYPE_ENCLOSURE SYMBOLIC(TYPE_ENCLOSURE) -#define TYPE_I SYMBOLIC(TYPE_I) -#define TYPE_L SYMBOLIC(TYPE_L) -#define TYPE_MEDIUM_CHANGER SYMBOLIC(TYPE_MEDIUM_CHANGER) -#define TYPE_MOD SYMBOLIC(TYPE_MOD) -#define TYPE_NO_LUN SYMBOLIC(TYPE_NO_LUN) -#define TYPE_PROCESSOR SYMBOLIC(TYPE_PROCESSOR) -#define TYPE_ROM SYMBOLIC(TYPE_ROM) -#define TYPE_SCANNER SYMBOLIC(TYPE_SCANNER) -#define TYPE_TAPE SYMBOLIC(TYPE_TAPE) -#define TYPE_WORM SYMBOLIC(TYPE_WORM) - -#if !(__ASSEMBLER__ + __LINKER__ + 0) -COSMOPOLITAN_C_START_ - -extern const long TYPE_A; -extern const long TYPE_DISK; -extern const long TYPE_E; -extern const long TYPE_ENCLOSURE; -extern const long TYPE_I; -extern const long TYPE_L; -extern const long TYPE_MEDIUM_CHANGER; -extern const long TYPE_MOD; -extern const long TYPE_NO_LUN; -extern const long TYPE_PROCESSOR; -extern const long TYPE_ROM; -extern const long TYPE_SCANNER; -extern const long TYPE_TAPE; -extern const long TYPE_WORM; - -COSMOPOLITAN_C_END_ -#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ -#endif /* COSMOPOLITAN_LIBC_SYSV_CONSTS_TYPE_H_ */ diff --git a/libc/sysv/machcalls.sh b/libc/sysv/machcalls.sh deleted file mode 100755 index d4a7fced5..000000000 --- a/libc/sysv/machcalls.sh +++ /dev/null @@ -1,89 +0,0 @@ -/*bin/echo ' -*- mode:sh; indent-tabs-mode:nil; tab-width:8; coding:utf-8 -*-│ -│vi: set net ft=sh ts=2 sts=2 sw=2 fenc=utf-8 :vi│ -╞══════════════════════════════════════════════════════════════════════════════╡ -│ Copyright 2020 Justine Alexandra Roberts Tunney │ -│ │ -│ Permission to use, copy, modify, and/or distribute this software for │ -│ any purpose with or without fee is hereby granted, provided that the │ -│ above copyright notice and this permission notice appear in all copies. │ -│ │ -│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ -│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ -│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ -│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ -│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ -│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ -│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ -│ PERFORMANCE OF THIS SOFTWARE. │ -╚────────────────────────────────────────────────────────────────'>/dev/null #*/ -dir=libc/sysv/machcalls -. libc/sysv/gen.sh - -# NeXSTEP Carnegie Melon Mach Microkernel -# » so many context switches -# GNU/Systemd┐ -# 2.6.18+│ -# Mac OS X┐ │ -# 15.6+│ │ -# FreeBSD┐ │ │ -# 12+│ ┌─│──│── XnuClass{1:Mach,2:Unix} -# OpenBSD┐ │ │ │ │ -# 6.4+│ │ │ │ │ -# NetBSD┐ │ │ │ │ │ -# 9.1+│ │ │ │ │ │ -# ┌┴┐┌┴┐┌┴┐│┬┴┐┌┴┐ -scall _kernelrpc_mach_vm_allocate_trap 0xfffffffff100afff globl -scall _kernelrpc_mach_vm_purgable_control_trap 0xfffffffff100bfff globl -scall _kernelrpc_mach_vm_deallocate_trap 0xfffffffff100cfff globl -scall _kernelrpc_mach_vm_protect_trap 0xfffffffff100efff globl -scall _kernelrpc_mach_vm_map_trap 0xfffffffff100ffff globl -scall _kernelrpc_mach_port_allocate_trap 0xfffffffff1010fff globl -scall _kernelrpc_mach_port_destroy_trap 0xfffffffff1011fff globl -scall _kernelrpc_mach_port_deallocate_trap 0xfffffffff1012fff globl -scall _kernelrpc_mach_port_mod_refs_trap 0xfffffffff1013fff globl -scall _kernelrpc_mach_port_move_member_trap 0xfffffffff1014fff globl -scall _kernelrpc_mach_port_insert_right_trap 0xfffffffff1015fff globl -scall _kernelrpc_mach_port_insert_member_trap 0xfffffffff1016fff globl -scall _kernelrpc_mach_port_extract_member_trap 0xfffffffff1017fff globl -scall _kernelrpc_mach_port_construct_trap 0xfffffffff1018fff globl -scall _kernelrpc_mach_port_destruct_trap 0xfffffffff1019fff globl -scall mach_reply_port 0xfffffffff101afff globl -scall thread_self_trap 0xfffffffff101bfff globl -scall task_self_trap 0xfffffffff101cfff globl -scall host_self_trap 0xfffffffff101dfff globl -scall mach_msg_trap 0xfffffffff101ffff globl -scall mach_msg_overwrite_trap 0xfffffffff1020fff globl -scall semaphore_signal_trap 0xfffffffff1021fff globl -scall semaphore_signal_all_trap 0xfffffffff1022fff globl -scall semaphore_signal_thread_trap 0xfffffffff1023fff globl -scall semaphore_wait_trap 0xfffffffff1024fff globl -scall semaphore_wait_signal_trap 0xfffffffff1025fff globl -scall semaphore_timedwait_trap 0xfffffffff1026fff globl -scall semaphore_timedwait_signal_trap 0xfffffffff1027fff globl -scall _kernelrpc_mach_port_guard_trap 0xfffffffff1029fff globl -scall _kernelrpc_mach_port_unguard_trap 0xfffffffff102afff globl -scall mach_generate_activity_id 0xfffffffff102bfff globl -scall task_name_for_pid 0xfffffffff102cfff globl -scall task_for_pid 0xfffffffff102dfff globl -scall pid_for_task 0xfffffffff102efff globl -scall macx_swapon 0xfffffffff1030fff globl -scall macx_swapoff 0xfffffffff1031fff globl -scall thread_get_special_reply_port 0xfffffffff1032fff globl -scall macx_triggers 0xfffffffff1033fff globl -scall macx_backing_store_suspend 0xfffffffff1034fff globl -scall macx_backing_store_recovery 0xfffffffff1035fff globl -scall pfz_exit 0xfffffffff103afff globl -scall swtch_pri 0xfffffffff103bfff globl -scall swtch 0xfffffffff103cfff globl -scall thread_switch 0xfffffffff103dfff globl -scall clock_sleep_trap 0xfffffffff103efff globl -scall host_create_mach_voucher_trap 0xfffffffff1046fff globl -scall mach_voucher_extract_attr_recipe_trap 0xfffffffff1048fff globl -scall mach_timebase_info_trap 0xfffffffff1059fff globl -scall mach_wait_until_trap 0xfffffffff105afff globl -scall mk_timer_create_trap 0xfffffffff105bfff globl -scall mk_timer_destroy_trap 0xfffffffff105cfff globl -scall mk_timer_arm_trap 0xfffffffff105dfff globl -scall mk_timer_cancel_trap 0xfffffffff105efff globl -scall mk_timer_arm_leeway_trap 0xfffffffff105ffff globl -scall iokit_user_client_trap 0xfffffffff1064fff globl diff --git a/libc/sysv/machcalls/_kernelrpc_mach_port_allocate_trap.s b/libc/sysv/machcalls/_kernelrpc_mach_port_allocate_trap.s deleted file mode 100644 index b8b333234..000000000 --- a/libc/sysv/machcalls/_kernelrpc_mach_port_allocate_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall _kernelrpc_mach_port_allocate_trap,0xfffffffff1010fff,globl diff --git a/libc/sysv/machcalls/_kernelrpc_mach_port_construct_trap.s b/libc/sysv/machcalls/_kernelrpc_mach_port_construct_trap.s deleted file mode 100644 index d0f7cb396..000000000 --- a/libc/sysv/machcalls/_kernelrpc_mach_port_construct_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall _kernelrpc_mach_port_construct_trap,0xfffffffff1018fff,globl diff --git a/libc/sysv/machcalls/_kernelrpc_mach_port_deallocate_trap.s b/libc/sysv/machcalls/_kernelrpc_mach_port_deallocate_trap.s deleted file mode 100644 index 1fd9daaa8..000000000 --- a/libc/sysv/machcalls/_kernelrpc_mach_port_deallocate_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall _kernelrpc_mach_port_deallocate_trap,0xfffffffff1012fff,globl diff --git a/libc/sysv/machcalls/_kernelrpc_mach_port_destroy_trap.s b/libc/sysv/machcalls/_kernelrpc_mach_port_destroy_trap.s deleted file mode 100644 index f440e4353..000000000 --- a/libc/sysv/machcalls/_kernelrpc_mach_port_destroy_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall _kernelrpc_mach_port_destroy_trap,0xfffffffff1011fff,globl diff --git a/libc/sysv/machcalls/_kernelrpc_mach_port_destruct_trap.s b/libc/sysv/machcalls/_kernelrpc_mach_port_destruct_trap.s deleted file mode 100644 index f84e97ad4..000000000 --- a/libc/sysv/machcalls/_kernelrpc_mach_port_destruct_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall _kernelrpc_mach_port_destruct_trap,0xfffffffff1019fff,globl diff --git a/libc/sysv/machcalls/_kernelrpc_mach_port_extract_member_trap.s b/libc/sysv/machcalls/_kernelrpc_mach_port_extract_member_trap.s deleted file mode 100644 index b41b77ad1..000000000 --- a/libc/sysv/machcalls/_kernelrpc_mach_port_extract_member_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall _kernelrpc_mach_port_extract_member_trap,0xfffffffff1017fff,globl diff --git a/libc/sysv/machcalls/_kernelrpc_mach_port_guard_trap.s b/libc/sysv/machcalls/_kernelrpc_mach_port_guard_trap.s deleted file mode 100644 index 86631e373..000000000 --- a/libc/sysv/machcalls/_kernelrpc_mach_port_guard_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall _kernelrpc_mach_port_guard_trap,0xfffffffff1029fff,globl diff --git a/libc/sysv/machcalls/_kernelrpc_mach_port_insert_member_trap.s b/libc/sysv/machcalls/_kernelrpc_mach_port_insert_member_trap.s deleted file mode 100644 index 3aab51f40..000000000 --- a/libc/sysv/machcalls/_kernelrpc_mach_port_insert_member_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall _kernelrpc_mach_port_insert_member_trap,0xfffffffff1016fff,globl diff --git a/libc/sysv/machcalls/_kernelrpc_mach_port_insert_right_trap.s b/libc/sysv/machcalls/_kernelrpc_mach_port_insert_right_trap.s deleted file mode 100644 index 83881a86f..000000000 --- a/libc/sysv/machcalls/_kernelrpc_mach_port_insert_right_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall _kernelrpc_mach_port_insert_right_trap,0xfffffffff1015fff,globl diff --git a/libc/sysv/machcalls/_kernelrpc_mach_port_mod_refs_trap.s b/libc/sysv/machcalls/_kernelrpc_mach_port_mod_refs_trap.s deleted file mode 100644 index 1b125debd..000000000 --- a/libc/sysv/machcalls/_kernelrpc_mach_port_mod_refs_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall _kernelrpc_mach_port_mod_refs_trap,0xfffffffff1013fff,globl diff --git a/libc/sysv/machcalls/_kernelrpc_mach_port_move_member_trap.s b/libc/sysv/machcalls/_kernelrpc_mach_port_move_member_trap.s deleted file mode 100644 index e49cbf2bb..000000000 --- a/libc/sysv/machcalls/_kernelrpc_mach_port_move_member_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall _kernelrpc_mach_port_move_member_trap,0xfffffffff1014fff,globl diff --git a/libc/sysv/machcalls/_kernelrpc_mach_port_unguard_trap.s b/libc/sysv/machcalls/_kernelrpc_mach_port_unguard_trap.s deleted file mode 100644 index 4ff8d8a27..000000000 --- a/libc/sysv/machcalls/_kernelrpc_mach_port_unguard_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall _kernelrpc_mach_port_unguard_trap,0xfffffffff102afff,globl diff --git a/libc/sysv/machcalls/_kernelrpc_mach_vm_allocate_trap.s b/libc/sysv/machcalls/_kernelrpc_mach_vm_allocate_trap.s deleted file mode 100644 index d81fc9b53..000000000 --- a/libc/sysv/machcalls/_kernelrpc_mach_vm_allocate_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall _kernelrpc_mach_vm_allocate_trap,0xfffffffff100afff,globl diff --git a/libc/sysv/machcalls/_kernelrpc_mach_vm_deallocate_trap.s b/libc/sysv/machcalls/_kernelrpc_mach_vm_deallocate_trap.s deleted file mode 100644 index 871985276..000000000 --- a/libc/sysv/machcalls/_kernelrpc_mach_vm_deallocate_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall _kernelrpc_mach_vm_deallocate_trap,0xfffffffff100cfff,globl diff --git a/libc/sysv/machcalls/_kernelrpc_mach_vm_map_trap.s b/libc/sysv/machcalls/_kernelrpc_mach_vm_map_trap.s deleted file mode 100644 index e0c865066..000000000 --- a/libc/sysv/machcalls/_kernelrpc_mach_vm_map_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall _kernelrpc_mach_vm_map_trap,0xfffffffff100ffff,globl diff --git a/libc/sysv/machcalls/_kernelrpc_mach_vm_protect_trap.s b/libc/sysv/machcalls/_kernelrpc_mach_vm_protect_trap.s deleted file mode 100644 index 13f522a72..000000000 --- a/libc/sysv/machcalls/_kernelrpc_mach_vm_protect_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall _kernelrpc_mach_vm_protect_trap,0xfffffffff100efff,globl diff --git a/libc/sysv/machcalls/_kernelrpc_mach_vm_purgable_control_trap.s b/libc/sysv/machcalls/_kernelrpc_mach_vm_purgable_control_trap.s deleted file mode 100644 index 411d0d512..000000000 --- a/libc/sysv/machcalls/_kernelrpc_mach_vm_purgable_control_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall _kernelrpc_mach_vm_purgable_control_trap,0xfffffffff100bfff,globl diff --git a/libc/sysv/machcalls/clock_sleep_trap.s b/libc/sysv/machcalls/clock_sleep_trap.s deleted file mode 100644 index f6aaae27a..000000000 --- a/libc/sysv/machcalls/clock_sleep_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall clock_sleep_trap,0xfffffffff103efff,globl diff --git a/libc/sysv/machcalls/host_create_mach_voucher_trap.s b/libc/sysv/machcalls/host_create_mach_voucher_trap.s deleted file mode 100644 index a76758632..000000000 --- a/libc/sysv/machcalls/host_create_mach_voucher_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall host_create_mach_voucher_trap,0xfffffffff1046fff,globl diff --git a/libc/sysv/machcalls/host_self_trap.s b/libc/sysv/machcalls/host_self_trap.s deleted file mode 100644 index 23e77f353..000000000 --- a/libc/sysv/machcalls/host_self_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall host_self_trap,0xfffffffff101dfff,globl diff --git a/libc/sysv/machcalls/iokit_user_client_trap.s b/libc/sysv/machcalls/iokit_user_client_trap.s deleted file mode 100644 index 177ef7fd4..000000000 --- a/libc/sysv/machcalls/iokit_user_client_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall iokit_user_client_trap,0xfffffffff1064fff,globl diff --git a/libc/sysv/machcalls/mach_generate_activity_id.s b/libc/sysv/machcalls/mach_generate_activity_id.s deleted file mode 100644 index 9d1055fce..000000000 --- a/libc/sysv/machcalls/mach_generate_activity_id.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall mach_generate_activity_id,0xfffffffff102bfff,globl diff --git a/libc/sysv/machcalls/mach_msg_overwrite_trap.s b/libc/sysv/machcalls/mach_msg_overwrite_trap.s deleted file mode 100644 index 57c7fe9ee..000000000 --- a/libc/sysv/machcalls/mach_msg_overwrite_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall mach_msg_overwrite_trap,0xfffffffff1020fff,globl diff --git a/libc/sysv/machcalls/mach_msg_trap.s b/libc/sysv/machcalls/mach_msg_trap.s deleted file mode 100644 index 34b71c4ea..000000000 --- a/libc/sysv/machcalls/mach_msg_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall mach_msg_trap,0xfffffffff101ffff,globl diff --git a/libc/sysv/machcalls/mach_reply_port.s b/libc/sysv/machcalls/mach_reply_port.s deleted file mode 100644 index 9cba7e247..000000000 --- a/libc/sysv/machcalls/mach_reply_port.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall mach_reply_port,0xfffffffff101afff,globl diff --git a/libc/sysv/machcalls/mach_timebase_info_trap.s b/libc/sysv/machcalls/mach_timebase_info_trap.s deleted file mode 100644 index ba8e10867..000000000 --- a/libc/sysv/machcalls/mach_timebase_info_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall mach_timebase_info_trap,0xfffffffff1059fff,globl diff --git a/libc/sysv/machcalls/mach_voucher_extract_attr_recipe_trap.s b/libc/sysv/machcalls/mach_voucher_extract_attr_recipe_trap.s deleted file mode 100644 index 3ea5b8270..000000000 --- a/libc/sysv/machcalls/mach_voucher_extract_attr_recipe_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall mach_voucher_extract_attr_recipe_trap,0xfffffffff1048fff,globl diff --git a/libc/sysv/machcalls/mach_wait_until_trap.s b/libc/sysv/machcalls/mach_wait_until_trap.s deleted file mode 100644 index 0d2f27b04..000000000 --- a/libc/sysv/machcalls/mach_wait_until_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall mach_wait_until_trap,0xfffffffff105afff,globl diff --git a/libc/sysv/machcalls/macx_backing_store_recovery.s b/libc/sysv/machcalls/macx_backing_store_recovery.s deleted file mode 100644 index 25eb680fe..000000000 --- a/libc/sysv/machcalls/macx_backing_store_recovery.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall macx_backing_store_recovery,0xfffffffff1035fff,globl diff --git a/libc/sysv/machcalls/macx_backing_store_suspend.s b/libc/sysv/machcalls/macx_backing_store_suspend.s deleted file mode 100644 index 64387f10a..000000000 --- a/libc/sysv/machcalls/macx_backing_store_suspend.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall macx_backing_store_suspend,0xfffffffff1034fff,globl diff --git a/libc/sysv/machcalls/macx_swapoff.s b/libc/sysv/machcalls/macx_swapoff.s deleted file mode 100644 index 4caf26e38..000000000 --- a/libc/sysv/machcalls/macx_swapoff.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall macx_swapoff,0xfffffffff1031fff,globl diff --git a/libc/sysv/machcalls/macx_swapon.s b/libc/sysv/machcalls/macx_swapon.s deleted file mode 100644 index c1c657926..000000000 --- a/libc/sysv/machcalls/macx_swapon.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall macx_swapon,0xfffffffff1030fff,globl diff --git a/libc/sysv/machcalls/macx_triggers.s b/libc/sysv/machcalls/macx_triggers.s deleted file mode 100644 index b3e089114..000000000 --- a/libc/sysv/machcalls/macx_triggers.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall macx_triggers,0xfffffffff1033fff,globl diff --git a/libc/sysv/machcalls/mk_timer_arm_leeway_trap.s b/libc/sysv/machcalls/mk_timer_arm_leeway_trap.s deleted file mode 100644 index 3d1a1a90e..000000000 --- a/libc/sysv/machcalls/mk_timer_arm_leeway_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall mk_timer_arm_leeway_trap,0xfffffffff105ffff,globl diff --git a/libc/sysv/machcalls/mk_timer_arm_trap.s b/libc/sysv/machcalls/mk_timer_arm_trap.s deleted file mode 100644 index b4df37d26..000000000 --- a/libc/sysv/machcalls/mk_timer_arm_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall mk_timer_arm_trap,0xfffffffff105dfff,globl diff --git a/libc/sysv/machcalls/mk_timer_cancel_trap.s b/libc/sysv/machcalls/mk_timer_cancel_trap.s deleted file mode 100644 index e08d0877a..000000000 --- a/libc/sysv/machcalls/mk_timer_cancel_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall mk_timer_cancel_trap,0xfffffffff105efff,globl diff --git a/libc/sysv/machcalls/mk_timer_create_trap.s b/libc/sysv/machcalls/mk_timer_create_trap.s deleted file mode 100644 index 41e71474e..000000000 --- a/libc/sysv/machcalls/mk_timer_create_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall mk_timer_create_trap,0xfffffffff105bfff,globl diff --git a/libc/sysv/machcalls/mk_timer_destroy_trap.s b/libc/sysv/machcalls/mk_timer_destroy_trap.s deleted file mode 100644 index c61270b7c..000000000 --- a/libc/sysv/machcalls/mk_timer_destroy_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall mk_timer_destroy_trap,0xfffffffff105cfff,globl diff --git a/libc/sysv/machcalls/pfz_exit.s b/libc/sysv/machcalls/pfz_exit.s deleted file mode 100644 index 84326b64f..000000000 --- a/libc/sysv/machcalls/pfz_exit.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall pfz_exit,0xfffffffff103afff,globl diff --git a/libc/sysv/machcalls/pid_for_task.s b/libc/sysv/machcalls/pid_for_task.s deleted file mode 100644 index ff9295478..000000000 --- a/libc/sysv/machcalls/pid_for_task.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall pid_for_task,0xfffffffff102efff,globl diff --git a/libc/sysv/machcalls/semaphore_signal_all_trap.s b/libc/sysv/machcalls/semaphore_signal_all_trap.s deleted file mode 100644 index b552e1158..000000000 --- a/libc/sysv/machcalls/semaphore_signal_all_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall semaphore_signal_all_trap,0xfffffffff1022fff,globl diff --git a/libc/sysv/machcalls/semaphore_signal_thread_trap.s b/libc/sysv/machcalls/semaphore_signal_thread_trap.s deleted file mode 100644 index 3f41d020f..000000000 --- a/libc/sysv/machcalls/semaphore_signal_thread_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall semaphore_signal_thread_trap,0xfffffffff1023fff,globl diff --git a/libc/sysv/machcalls/semaphore_signal_trap.s b/libc/sysv/machcalls/semaphore_signal_trap.s deleted file mode 100644 index e6c3dd566..000000000 --- a/libc/sysv/machcalls/semaphore_signal_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall semaphore_signal_trap,0xfffffffff1021fff,globl diff --git a/libc/sysv/machcalls/semaphore_timedwait_signal_trap.s b/libc/sysv/machcalls/semaphore_timedwait_signal_trap.s deleted file mode 100644 index bd917de56..000000000 --- a/libc/sysv/machcalls/semaphore_timedwait_signal_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall semaphore_timedwait_signal_trap,0xfffffffff1027fff,globl diff --git a/libc/sysv/machcalls/semaphore_timedwait_trap.s b/libc/sysv/machcalls/semaphore_timedwait_trap.s deleted file mode 100644 index 396a35b1f..000000000 --- a/libc/sysv/machcalls/semaphore_timedwait_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall semaphore_timedwait_trap,0xfffffffff1026fff,globl diff --git a/libc/sysv/machcalls/semaphore_wait_signal_trap.s b/libc/sysv/machcalls/semaphore_wait_signal_trap.s deleted file mode 100644 index cca3b2039..000000000 --- a/libc/sysv/machcalls/semaphore_wait_signal_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall semaphore_wait_signal_trap,0xfffffffff1025fff,globl diff --git a/libc/sysv/machcalls/semaphore_wait_trap.s b/libc/sysv/machcalls/semaphore_wait_trap.s deleted file mode 100644 index 06baddab5..000000000 --- a/libc/sysv/machcalls/semaphore_wait_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall semaphore_wait_trap,0xfffffffff1024fff,globl diff --git a/libc/sysv/machcalls/swtch.s b/libc/sysv/machcalls/swtch.s deleted file mode 100644 index 58e84b553..000000000 --- a/libc/sysv/machcalls/swtch.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall swtch,0xfffffffff103cfff,globl diff --git a/libc/sysv/machcalls/swtch_pri.s b/libc/sysv/machcalls/swtch_pri.s deleted file mode 100644 index e2dbba85a..000000000 --- a/libc/sysv/machcalls/swtch_pri.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall swtch_pri,0xfffffffff103bfff,globl diff --git a/libc/sysv/machcalls/task_for_pid.s b/libc/sysv/machcalls/task_for_pid.s deleted file mode 100644 index 47c753984..000000000 --- a/libc/sysv/machcalls/task_for_pid.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall task_for_pid,0xfffffffff102dfff,globl diff --git a/libc/sysv/machcalls/task_name_for_pid.s b/libc/sysv/machcalls/task_name_for_pid.s deleted file mode 100644 index ef0b9fc65..000000000 --- a/libc/sysv/machcalls/task_name_for_pid.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall task_name_for_pid,0xfffffffff102cfff,globl diff --git a/libc/sysv/machcalls/task_self_trap.s b/libc/sysv/machcalls/task_self_trap.s deleted file mode 100644 index 9e20070c0..000000000 --- a/libc/sysv/machcalls/task_self_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall task_self_trap,0xfffffffff101cfff,globl diff --git a/libc/sysv/machcalls/thread_get_special_reply_port.s b/libc/sysv/machcalls/thread_get_special_reply_port.s deleted file mode 100644 index 804d21665..000000000 --- a/libc/sysv/machcalls/thread_get_special_reply_port.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall thread_get_special_reply_port,0xfffffffff1032fff,globl diff --git a/libc/sysv/machcalls/thread_self_trap.s b/libc/sysv/machcalls/thread_self_trap.s deleted file mode 100644 index f20732d13..000000000 --- a/libc/sysv/machcalls/thread_self_trap.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall thread_self_trap,0xfffffffff101bfff,globl diff --git a/libc/sysv/machcalls/thread_switch.s b/libc/sysv/machcalls/thread_switch.s deleted file mode 100644 index c5b850d01..000000000 --- a/libc/sysv/machcalls/thread_switch.s +++ /dev/null @@ -1,2 +0,0 @@ -.include "o/libc/sysv/macros.internal.inc" -.scall thread_switch,0xfffffffff103dfff,globl diff --git a/libc/sysv/syscalls.sh b/libc/sysv/syscalls.sh index 6c90cbeef..2fbea762c 100755 --- a/libc/sysv/syscalls.sh +++ b/libc/sysv/syscalls.sh @@ -60,7 +60,7 @@ scall __sys_pipe 0x02a10721e202a016 globl hidden # NOTE: pipe2() on FreeBSD; XN scall sys_select 0x1a104705d205d017 globl hidden scall pselect 0x1b406e20a218afff globl scall pselect6 0xfffffffffffff10e globl -scall sys_sched_yield 0x15e12a14bffff018 globl hidden # swtch on xnu? possibly removed in 12.4 +scall sys_sched_yield 0x15e12a14bf25d018 globl hidden # select() on XNU (previously swtch() but removed in 12.4) scall __sys_mremap 0x19bffffffffff019 globl hidden scall sys_mincore 0x04e04e04e204e01b globl hidden scall sys_madvise 0x04b04b04b204b01c globl hidden @@ -197,12 +197,16 @@ scall sys_sigqueueinfo 0x0f5ffffffffff081 globl hidden # a.k.a. rt_sigqueueinfo scall personality 0xfffffffffffff087 globl scall ustat 0xfffffffffffff088 globl scall sysfs 0xfffffffffffff08b globl -scall sched_setparam 0xffffff147ffff08e globl -scall sched_getparam 0xffffff148ffff08f globl -scall sched_setscheduler 0xffffff149ffff090 globl -scall sched_getscheduler 0xffffff14affff091 globl -scall sched_get_priority_max 0xffffff14cffff092 globl -scall sched_get_priority_min 0xffffff14dffff093 globl +scall sys_sched_setparam 0x15afff147ffff08e globl hidden +scall sys_sched_getparam 0x15bfff148ffff08f globl hidden +scall sys_sched_setscheduler 0xffffff149ffff090 globl hidden +scall sys_sched_getscheduler 0xffffff14affff091 globl hidden +scall sys_sched_setaffinity 0x15cffffffffff0cb globl hidden +scall sys_sched_getaffinity 0x15dffffffffff0cc globl hidden # returns bytes written on success. we polyfill bad posix designs like nice() returning 0, but we won't polyfill a bad unilateral redesign that's just glibc +scall sys_sched_get_priority_max 0xffffff14cffff092 globl hidden +scall sys_sched_get_priority_min 0xffffff14dffff093 globl hidden +scall cpuset_getaffinity 0xffffff1e7fffffff globl +scall cpuset_setaffinity 0xffffff1e8fffffff globl scall sched_rr_get_interval 0xffffff14effff094 globl scall vhangup 0xfffffffffffff099 globl scall modify_ldt 0xfffffffffffff09a globl @@ -233,10 +237,6 @@ scall lsetxattr 0x178ffffffffff0bd globl scall lgetxattr 0x17bffffffffff0c0 globl scall llistxattr 0x17effffffffff0c3 globl scall lremovexattr 0x181ffffffffff0c6 globl -scall sys_sched_setaffinity 0xfffffffffffff0cb globl hidden -scall sys_sched_getaffinity 0xfffffffffffff0cc globl hidden # returns bytes written on success. we polyfill bad posix designs like nice() returning 0, but we won't polyfill a bad unilateral redesign that's just glibc -scall cpuset_getaffinity 0xffffff1e7fffffff globl -scall cpuset_setaffinity 0xffffff1e8fffffff globl scall io_setup 0xfffffffffffff0ce globl scall io_destroy 0xfffffffffffff0cf globl scall io_getevents 0xfffffffffffff0d0 globl @@ -263,7 +263,7 @@ scall ktimer_gettime 0xffffff0eefffffff globl scall ktimer_settime 0xffffff0edfffffff globl scall clock_settime 0x1ac0580e9ffff0e3 globl scall sys_clock_gettime 0x1ab0570e8ffff0e4 globl hidden # Linux 2.6+ (c. 2003); XNU uses magic address -scall clock_getres 0x1ad0590eaffff0e5 globl +scall sys_clock_getres 0x1ad0590eaffff0e5 globl hidden scall clock_nanosleep 0xffffff0f4ffff0e6 globl scall sys_tgkill 0xfffffffffffff0ea globl hidden scall mbind 0xfffffffffffff0ed globl diff --git a/libc/testlib/showerror.c b/libc/testlib/showerror.c index 320e2facc..3b7011c74 100644 --- a/libc/testlib/showerror.c +++ b/libc/testlib/showerror.c @@ -16,11 +16,11 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/bits/atomic.h" #include "libc/bits/safemacros.internal.h" #include "libc/calls/calls.h" #include "libc/fmt/fmt.h" #include "libc/intrin/kprintf.h" -#include "libc/intrin/spinlock.h" #include "libc/log/color.internal.h" #include "libc/log/internal.h" #include "libc/log/libfatal.internal.h" @@ -32,16 +32,12 @@ const char *testlib_showerror_func; const char *testlib_showerror_isfatal; const char *testlib_showerror_macro; const char *testlib_showerror_symbol; -_Alignas(64) static char testlib_showerror_lock; testonly void testlib_showerror(const char *file, int line, const char *func, const char *method, const char *symbol, const char *code, char *v1, char *v2) { char *p; char hostname[128]; - _spinlock(&testlib_showerror_lock); - if (!IsWindows()) __getpid(); /* make strace easier to read */ - if (!IsWindows()) __getpid(); __stpcpy(hostname, "unknown"); gethostname(hostname, sizeof(hostname)); kprintf("%serror%s%s:%s:%d%s: %s() in %s(%s) on %s pid %d tid %d\n" @@ -55,7 +51,6 @@ testonly void testlib_showerror(const char *file, int line, const char *func, SUBTLE, strerror(errno), GetProgramExecutableName(), RESET); free_s(&v1); free_s(&v2); - _spunlock(&testlib_showerror_lock); } /* TODO(jart): Pay off tech debt re duplication */ @@ -65,10 +60,7 @@ testonly void testlib_showerror_(int line, const char *wantcode, int e; va_list va; char hostname[128]; - _spinlock(&testlib_showerror_lock); e = errno; - if (!IsWindows()) __getpid(); - if (!IsWindows()) __getpid(); if (gethostname(hostname, sizeof(hostname))) { __stpcpy(hostname, "unknown"); } @@ -98,6 +90,7 @@ testonly void testlib_showerror_(int line, const char *wantcode, free_s(&FREED_want); free_s(&FREED_got); ++g_testlib_failed; - if (testlib_showerror_isfatal) testlib_abort(); - _spunlock(&testlib_showerror_lock); + if (testlib_showerror_isfatal) { + testlib_abort(); + } } diff --git a/libc/testlib/testlib.h b/libc/testlib/testlib.h index faf264432..001f74ef4 100644 --- a/libc/testlib/testlib.h +++ b/libc/testlib/testlib.h @@ -268,12 +268,11 @@ void TearDownOnce(void); Got = (intptr_t)(GOT); \ Want = (intptr_t)(WANT); \ if (Want != Got) { \ - if (g_testlib_shoulddebugbreak) DebugBreak(); \ - testlib_showerror_file = FILE; \ - testlib_showerror_func = FUNC; \ + testlib_error_enter(FILE, FUNC); \ testlib_showerror_##KIND##_eq(LINE, WANTCODE, GOTCODE, \ testlib_formatint(Want), \ testlib_formatint(Got), "" __VA_ARGS__); \ + testlib_error_leave(); \ } \ (void)0; \ } while (0) @@ -285,12 +284,11 @@ void TearDownOnce(void); Got = (intptr_t)(GOT); \ Want = (intptr_t)(WANT); \ if (Want == Got) { \ - if (g_testlib_shoulddebugbreak) DebugBreak(); \ - testlib_showerror_file = FILE; \ - testlib_showerror_func = FUNC; \ + testlib_error_enter(FILE, FUNC); \ testlib_showerror_##KIND##_ne(LINE, WANTCODE, GOTCODE, \ testlib_formatint(Want), \ testlib_formatint(Got), "" __VA_ARGS__); \ + testlib_error_leave(); \ } \ } while (0) @@ -344,6 +342,8 @@ void testlib_showerror_expect_ne(int, const char *, const char *, char *, void testlib_showerror_expect_true(int, const char *, const char *, char *, char *, const char *, ...); +void testlib_error_leave(void); +void testlib_error_enter(const char *, const char *); void testlib_showerror(const char *, int, const char *, const char *, const char *, const char *, char *, char *); @@ -391,7 +391,9 @@ forceinline void testlib_ontest() { forceinline void testlib_onfail2(bool isfatal) { testlib_incrementfailed(); - if (isfatal) testlib_abort(); + if (isfatal) { + testlib_abort(); + } } forceinline void assertNotEquals(FILIFU_ARGS intptr_t donotwant, intptr_t got, diff --git a/libc/testlib/testrunner.c b/libc/testlib/testrunner.c index d0680fc3c..e32c4a39d 100644 --- a/libc/testlib/testrunner.c +++ b/libc/testlib/testrunner.c @@ -17,6 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" +#include "libc/bits/atomic.h" #include "libc/bits/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/strace.internal.h" @@ -28,6 +29,7 @@ #include "libc/fmt/fmt.h" #include "libc/fmt/itoa.h" #include "libc/intrin/kprintf.h" +#include "libc/intrin/spinlock.h" #include "libc/log/check.h" #include "libc/log/internal.h" #include "libc/macros.internal.h" @@ -49,6 +51,7 @@ static int x; char g_testlib_olddir[PATH_MAX]; char g_testlib_tmpdir[PATH_MAX]; struct sigaction wanthandlers[31]; +static char testlib_error_lock; void testlib_finish(void) { if (g_testlib_failed) { @@ -57,11 +60,29 @@ void testlib_finish(void) { } } +void testlib_error_enter(const char *file, const char *func) { + atomic_fetch_sub_explicit(&__ftrace, 1, memory_order_relaxed); + atomic_fetch_sub_explicit(&__strace, 1, memory_order_relaxed); + _spinlock(&testlib_error_lock); + if (!IsWindows()) sys_getpid(); /* make strace easier to read */ + if (!IsWindows()) sys_getpid(); + if (g_testlib_shoulddebugbreak) { + DebugBreak(); + } + testlib_showerror_file = file; + testlib_showerror_func = func; +} + +void testlib_error_leave(void) { + atomic_fetch_add_explicit(&__ftrace, 1, memory_order_relaxed); + atomic_fetch_add_explicit(&__strace, 1, memory_order_relaxed); + _spunlock(&testlib_error_lock); +} + wontreturn void testlib_abort(void) { testlib_finish(); __restorewintty(); _Exit(MIN(255, g_testlib_failed)); - unreachable; } static void SetupTmpDir(void) { diff --git a/libc/thread/sem.c b/libc/thread/sem.c index e078cfa73..9c75c32c6 100644 --- a/libc/thread/sem.c +++ b/libc/thread/sem.c @@ -23,7 +23,7 @@ STATIC_YOINK("_main_thread_ctor"); #define CTHREAD_THREAD_VAL_BITS 32 -static void pause(int attempt) { +static void Pause(int attempt) { if (attempt < 16) { for (int i = 0; i < (1 << attempt); ++i) { __builtin_ia32_pause(); @@ -108,7 +108,7 @@ int cthread_sem_wait_spin(cthread_sem_t* sem, uint64_t count, int spin, return 0; } } - pause(attempt); + Pause(attempt); } return cthread_sem_wait_futex(sem, timeout); diff --git a/libc/time/time.h b/libc/time/time.h index 510d19ba8..f85c82855 100644 --- a/libc/time/time.h +++ b/libc/time/time.h @@ -26,8 +26,8 @@ int gettimeofday(struct timeval *, struct timezone *); int clock_gettime(int, struct timespec *); int clock_getres(int, struct timespec *); -int sleep(uint32_t); int usleep(uint32_t); +unsigned sleep(unsigned); int nanosleep(const struct timespec *, struct timespec *); unsigned alarm(unsigned); int getitimer(int, struct itimerval *); diff --git a/test/libc/calls/clock_getres_test.c b/test/libc/calls/clock_getres_test.c new file mode 100644 index 000000000..34d055b3d --- /dev/null +++ b/test/libc/calls/clock_getres_test.c @@ -0,0 +1,83 @@ +/*-*- 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/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" +#include "libc/time/time.h" + +struct timespec ts; + +TEST(clock_getres, realtimeHasMillisecondPrecisionOrBetter) { + ASSERT_EQ(0, clock_getres(CLOCK_REALTIME, &ts)); + EXPECT_EQ(0, ts.tv_sec); + EXPECT_LT(ts.tv_nsec, 1000000); + EXPECT_GT(ts.tv_nsec, 0); +} + +TEST(clock_getres, realtimeFastHasMillisecondPrecisionOrBetter) { + ASSERT_EQ(0, clock_getres(CLOCK_REALTIME_FAST, &ts)); + EXPECT_EQ(0, ts.tv_sec); + EXPECT_LT(ts.tv_nsec, 1000000); + EXPECT_GT(ts.tv_nsec, 0); +} + +TEST(clock_getres, realtimeCoarseHasMillisecondPrecisionOrBetter) { + if (clock_getres(CLOCK_REALTIME_COARSE, &ts)) return; + EXPECT_EQ(0, ts.tv_sec); + EXPECT_LT(ts.tv_nsec, 100000000); + EXPECT_GT(ts.tv_nsec, 0); +} + +TEST(clock_getres, realtimePreciseHasMillisecondPrecisionOrBetter) { + if (clock_getres(CLOCK_REALTIME_PRECISE, &ts)) return; + EXPECT_EQ(0, ts.tv_sec); + EXPECT_LT(ts.tv_nsec, 100000000); + EXPECT_GT(ts.tv_nsec, 0); +} + +TEST(clock_getres, monotonicHasMillisecondPrecisionOrBetter) { + ASSERT_EQ(0, clock_getres(CLOCK_MONOTONIC, &ts)); + EXPECT_EQ(0, ts.tv_sec); + EXPECT_LT(ts.tv_nsec, 1000000); + EXPECT_GT(ts.tv_nsec, 0); +} + +TEST(clock_getres, monotonicFastHasMillisecondPrecisionOrBetter) { + ASSERT_EQ(0, clock_getres(CLOCK_MONOTONIC_FAST, &ts)); + EXPECT_EQ(0, ts.tv_sec); + EXPECT_LT(ts.tv_nsec, 1000000); + EXPECT_GT(ts.tv_nsec, 0); +} + +TEST(clock_getres, monotonicCoarseHasMillisecondPrecisionOrBetter) { + if (clock_getres(CLOCK_MONOTONIC_COARSE, &ts)) return; + EXPECT_EQ(0, ts.tv_sec); + EXPECT_LT(ts.tv_nsec, 100000000); + EXPECT_GT(ts.tv_nsec, 0); +} + +TEST(clock_getres, monotonicPreciseHasMillisecondPrecisionOrBetter) { + if (clock_getres(CLOCK_MONOTONIC_PRECISE, &ts)) return; + EXPECT_EQ(0, ts.tv_sec); + EXPECT_LT(ts.tv_nsec, 100000000); + EXPECT_GT(ts.tv_nsec, 0); +} diff --git a/test/libc/calls/clock_gettime_test.c b/test/libc/calls/clock_gettime_test.c index fe279a468..97264ff93 100644 --- a/test/libc/calls/clock_gettime_test.c +++ b/test/libc/calls/clock_gettime_test.c @@ -30,6 +30,10 @@ #include "libc/testlib/testlib.h" #include "libc/time/time.h" +TEST(clock_gettime, fault) { + ASSERT_SYS(EFAULT, -1, clock_gettime(0, 0)); +} + TEST(clock_gettime, test) { bool isfast; struct timespec ts = {0}; diff --git a/test/libc/calls/nanosleep_test.c b/test/libc/calls/nanosleep_test.c new file mode 100644 index 000000000..b70a50825 --- /dev/null +++ b/test/libc/calls/nanosleep_test.c @@ -0,0 +1,64 @@ +/*-*- 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/calls.h" +#include "libc/calls/struct/itimerval.h" +#include "libc/calls/struct/sigaction.h" +#include "libc/calls/struct/timespec.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" +#include "libc/testlib/testlib.h" +#include "libc/time/time.h" + +void OnAlrm(int sig) { + // do nothing +} + +TEST(nanosleep, testFault) { + EXPECT_SYS(EFAULT, -1, nanosleep(0, 0)); +} + +TEST(nanosleep, testInvalid) { + struct timespec ts = {0, -1}; + EXPECT_SYS(EINVAL, -1, nanosleep(&ts, 0)); +} + +TEST(nanosleep, testNoSignalIsDelivered_remIsSetToZero) { + struct timespec ts = {0, 1}; + ASSERT_SYS(0, 0, nanosleep(&ts, &ts)); + EXPECT_EQ(0, ts.tv_sec); + EXPECT_EQ(0, ts.tv_nsec); +} + +TEST(nanosleep, testInterrupt_remIsUpdated) { + struct sigaction sa = { + .sa_handler = OnAlrm, + .sa_flags = SA_RESETHAND, + }; + ASSERT_SYS(0, 0, sigaction(SIGALRM, &sa, 0)); + struct itimerval it = {{0, 0}, {0, 10000}}; // 10ms singleshot + ASSERT_SYS(0, 0, setitimer(ITIMER_REAL, &it, 0)); + struct timespec ts = {500, 0}; + ASSERT_SYS(EINTR, -1, nanosleep(&ts, &ts)); + ASSERT_LT(ts.tv_sec, 500); + ASSERT_GT(ts.tv_sec, 400); + ASSERT_NE(0, ts.tv_nsec); +} diff --git a/test/libc/calls/sched_setscheduler_test.c b/test/libc/calls/sched_setscheduler_test.c new file mode 100644 index 000000000..a1b2f4b8e --- /dev/null +++ b/test/libc/calls/sched_setscheduler_test.c @@ -0,0 +1,66 @@ +/*-*- 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/bits/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/runtime/runtime.h" +#include "libc/sysv/consts/sched.h" +#include "libc/testlib/testlib.h" + +#define DEFAULT_POLICY SCHED_OTHER + +void SetUp(void) { + if (IsXnu() || IsWindows() || IsOpenbsd() || IsWindows()) { + exit(0); + } + int oldpolicy = sched_getscheduler(0); + struct sched_param p = {sched_get_priority_min(DEFAULT_POLICY)}; + EXPECT_SYS(0, oldpolicy, sched_setscheduler(0, DEFAULT_POLICY, &p)); +} + +bool CanTuneRealtimeSchedulers(void) { + int e = errno; + int policy = SCHED_FIFO; + struct sched_param p = {sched_get_priority_min(policy)}; + if (sched_setscheduler(0, policy, &p) != -1) { + struct sched_param p = {sched_get_priority_min(DEFAULT_POLICY)}; + EXPECT_SYS(0, policy, sched_setscheduler(0, DEFAULT_POLICY, &p)); + return true; + } else if (errno == EPERM) { + errno = e; + return false; + } else { + abort(); + } +} + +TEST(sched_setscheduler, test) { + struct sched_param p = {sched_get_priority_min(SCHED_OTHER)}; + EXPECT_SYS(0, DEFAULT_POLICY, sched_setscheduler(0, SCHED_OTHER, &p)); +} + +TEST(sched_setscheduler, testMidpoint) { + if (!CanTuneRealtimeSchedulers()) return; + struct sched_param p = {_midpoint(sched_get_priority_min(SCHED_FIFO), + sched_get_priority_max(SCHED_FIFO))}; + EXPECT_SYS(0, DEFAULT_POLICY, sched_setscheduler(0, SCHED_FIFO, &p)); +} diff --git a/test/libc/intrin/sched_yield_test.c b/test/libc/intrin/sched_yield_test.c new file mode 100644 index 000000000..efe11994d --- /dev/null +++ b/test/libc/intrin/sched_yield_test.c @@ -0,0 +1,24 @@ +/*-*- 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/calls.h" +#include "libc/testlib/testlib.h" + +TEST(sched_yield, test) { + EXPECT_SYS(0, 0, sched_yield()); +} diff --git a/test/libc/mem/pledge_test.c b/test/libc/mem/pledge_test.c index 1709242e2..ae904f4ad 100644 --- a/test/libc/mem/pledge_test.c +++ b/test/libc/mem/pledge_test.c @@ -23,10 +23,12 @@ #include "libc/calls/struct/filter.h" #include "libc/calls/struct/flock.h" #include "libc/calls/struct/seccomp.h" +#include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/stat.h" #include "libc/calls/syscall_support-sysv.internal.h" #include "libc/dce.h" #include "libc/errno.h" +#include "libc/macros.internal.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/sock/sock.h" @@ -47,6 +49,10 @@ char testlib_enable_tmp_setup_teardown; +void OnSig(int sig) { + // do nothing +} + void SetUp(void) { if (!__is_linux_2_6_23() && !IsOpenbsd()) { exit(0); @@ -65,7 +71,8 @@ TEST(pledge, default_allowsExit) { EXPECT_EQ(0, WEXITSTATUS(ws)); } -TEST(pledge, stdio_forbidsOpeningPasswd) { +TEST(pledge, stdio_forbidsOpeningPasswd1) { + if (!IsLinux()) return; int ws, pid; ASSERT_NE(-1, (pid = fork())); if (!pid) { @@ -74,13 +81,70 @@ TEST(pledge, stdio_forbidsOpeningPasswd) { _Exit(0); } EXPECT_NE(-1, wait(&ws)); - if (IsLinux()) { - EXPECT_TRUE(WIFEXITED(ws)); - EXPECT_EQ(0, WEXITSTATUS(ws)); - } else { - EXPECT_TRUE(WIFSIGNALED(ws)); - EXPECT_EQ(SIGABRT, WTERMSIG(ws)); + EXPECT_TRUE(WIFEXITED(ws)); + EXPECT_EQ(0, WEXITSTATUS(ws)); +} + +TEST(pledge, stdio_forbidsOpeningPasswd2) { + if (!IsOpenbsd()) return; + int ws, pid; + ASSERT_NE(-1, (pid = fork())); + if (!pid) { + ASSERT_SYS(0, 0, pledge("stdio", 0)); + ASSERT_SYS(EPERM, -1, open("/etc/passwd", O_RDWR)); + _Exit(0); } + EXPECT_NE(-1, wait(&ws)); + EXPECT_TRUE(WIFSIGNALED(ws)); + EXPECT_EQ(SIGABRT, WTERMSIG(ws)); +} + +TEST(pledge, multipleCalls_canOnlyBecomeMoreRestrictive1) { + if (IsOpenbsd()) return; + int ws, pid; + ASSERT_NE(-1, (pid = fork())); + if (!pid) { + ASSERT_SYS(0, 0, pledge("stdio", 0)); + ASSERT_SYS(0, 0, pledge("stdio unix", 0)); + ASSERT_SYS(0, 3, dup(2)); + ASSERT_SYS(EPERM, -1, socket(AF_UNIX, SOCK_STREAM, 0)); + ASSERT_SYS(EPERM, -1, prctl(PR_SET_NO_NEW_PRIVS, 0, 0, 0, 0)); + ASSERT_SYS(EPERM, -1, prctl(PR_GET_SECCOMP, SECCOMP_MODE_FILTER, 0)); + ASSERT_SYS(EPERM, -1, prctl(PR_SET_SECCOMP, 33, 0)); + _Exit(0); + } + EXPECT_NE(-1, wait(&ws)); + EXPECT_TRUE(WIFEXITED(ws)); + EXPECT_EQ(0, WEXITSTATUS(ws)); +} + +TEST(pledge, multipleCalls_canOnlyBecomeMoreRestrictive2) { + if (!IsOpenbsd()) return; + int ws, pid; + ASSERT_NE(-1, (pid = fork())); + if (!pid) { + ASSERT_SYS(0, 0, pledge("stdio", 0)); + ASSERT_SYS(EPERM, -1, pledge("stdio unix", 0)); + _Exit(0); + } + EXPECT_NE(-1, wait(&ws)); + EXPECT_TRUE(WIFEXITED(ws)); + EXPECT_EQ(0, WEXITSTATUS(ws)); +} + +TEST(pledge, multipleCalls_canOnlyBecomeMoreRestrictive3) { + if (!IsOpenbsd()) return; + int ws, pid; + ASSERT_NE(-1, (pid = fork())); + if (!pid) { + ASSERT_SYS(0, 0, pledge("stdio unix", 0)); + ASSERT_SYS(0, 0, pledge("stdio", 0)); + ASSERT_SYS(0, 3, dup(2)); + _Exit(0); + } + EXPECT_NE(-1, wait(&ws)); + EXPECT_TRUE(WIFEXITED(ws)); + EXPECT_EQ(0, WEXITSTATUS(ws)); } TEST(pledge, stdio_fcntl_allowsSomeFirstArgs) { @@ -89,6 +153,7 @@ TEST(pledge, stdio_fcntl_allowsSomeFirstArgs) { struct flock lk; ASSERT_NE(-1, (pid = fork())); if (!pid) { + ASSERT_SYS(0, 0, pledge("stdio inet", 0)); ASSERT_SYS(0, 0, pledge("stdio", 0)); ASSERT_NE(-1, fcntl(0, F_GETFL)); ASSERT_SYS(0, 0, fcntl(0, F_GETFD)); @@ -108,7 +173,6 @@ TEST(pledge, stdio_fcntl_allowsSomeFirstArgs) { TEST(pledge, stdioTty_sendtoRestricted_requiresNullAddr) { if (IsOpenbsd()) return; // b/c testing linux bpf int ws, pid, sv[2]; - struct sockaddr_in sa = {AF_UNIX}; ASSERT_SYS(0, 0, socketpair(AF_UNIX, SOCK_STREAM, 0, sv)); ASSERT_NE(-1, (pid = fork())); if (!pid) { @@ -118,7 +182,12 @@ TEST(pledge, stdioTty_sendtoRestricted_requiresNullAddr) { isatty(0); ASSERT_NE(EPERM, errno); errno = 0; - ASSERT_SYS(EPERM, -1, sendto(sv[0], "hello", 5, 0, &sa, sizeof(sa))); + // set lower 32-bit word of pointer to zero lool + struct sockaddr_in *sin = + mmap((void *)0x300000000000, FRAMESIZE, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + sin->sin_family = AF_INET; + ASSERT_SYS(EPERM, -1, sendto(sv[0], "hello", 5, 0, sin, sizeof(*sin))); _Exit(0); } close(sv[0]); @@ -134,8 +203,11 @@ TEST(pledge, unix_forbidsInetSockets) { if (!pid) { ASSERT_SYS(0, 0, pledge("stdio unix", 0)); ASSERT_SYS(0, 3, socket(AF_UNIX, SOCK_STREAM, 0)); + ASSERT_SYS(0, 4, socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0)); ASSERT_SYS(EPERM, -1, socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)); ASSERT_SYS(EPERM, -1, socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP)); + ASSERT_SYS(EPERM, -1, socket(AF_UNIX, SOCK_RAW, 0)); + ASSERT_SYS(EPERM, -1, socket(AF_UNIX, SOCK_STREAM, 1)); _Exit(0); } EXPECT_NE(-1, wait(&ws)); @@ -148,10 +220,20 @@ TEST(pledge, inet_forbidsOtherSockets) { ASSERT_NE(-1, (pid = fork())); if (!pid) { ASSERT_SYS(0, 0, pledge("stdio inet", 0)); - ASSERT_SYS(0, 3, socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)); - ASSERT_SYS(0, 4, socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP)); + ASSERT_SYS(0, 3, socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)); + ASSERT_SYS(0, 4, socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)); + ASSERT_SYS(0, 5, socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)); + ASSERT_SYS(0, 6, socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP)); + ASSERT_SYS(0, 7, socket(AF_INET6, SOCK_DGRAM | SOCK_NONBLOCK, IPPROTO_UDP)); ASSERT_SYS(EPERM, -1, socket(AF_UNIX, SOCK_STREAM, 0)); - ASSERT_SYS(EPERM, -1, socket(AF_BLUETOOTH, SOCK_STREAM, 0)); + ASSERT_SYS(EPERM, -1, socket(AF_BLUETOOTH, SOCK_DGRAM, IPPROTO_UDP)); + ASSERT_SYS(EPERM, -1, socket(AF_INET, SOCK_RAW, IPPROTO_UDP)); + ASSERT_SYS(EPERM, -1, socket(AF_INET, SOCK_DGRAM, IPPROTO_RAW)); + struct sockaddr_in sin = {AF_INET, 0, {htonl(0x7f000001)}}; + ASSERT_SYS(0, 0, bind(4, &sin, sizeof(sin))); + uint32_t az = sizeof(sin); + ASSERT_SYS(0, 0, getsockname(4, &sin, &az)); + ASSERT_SYS(0, 5, sendto(3, "hello", 5, 0, &sin, sizeof(sin))); _Exit(0); } EXPECT_NE(-1, wait(&ws)); @@ -179,6 +261,26 @@ TEST(pledge, mmap) { EXPECT_TRUE(WIFEXITED(ws) && !WEXITSTATUS(ws)); } +TEST(pledge, mmapExec) { + if (IsOpenbsd()) return; // b/c testing linux bpf + char *p; + int ws, pid; + ASSERT_NE(-1, (pid = fork())); + if (!pid) { + ASSERT_SYS(0, 0, pledge("stdio exec", 0)); + ASSERT_NE(MAP_FAILED, (p = mmap(0, FRAMESIZE, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0))); + ASSERT_SYS(0, 0, mprotect(p, FRAMESIZE, PROT_READ)); + ASSERT_SYS(EPERM, MAP_FAILED, + mprotect(p, FRAMESIZE, PROT_READ | PROT_EXEC)); + ASSERT_NE(MAP_FAILED, mmap(0, FRAMESIZE, PROT_EXEC | PROT_READ, + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0)); + _Exit(0); + } + EXPECT_NE(-1, wait(&ws)); + EXPECT_TRUE(WIFEXITED(ws) && !WEXITSTATUS(ws)); +} + TEST(pledge, msyscall) { if (IsOpenbsd()) return; // b/c testing linux bpf int ax, ws, pid; @@ -204,7 +306,7 @@ TEST(pledge, chmod_ignoresDangerBits) { ASSERT_SYS(0, 3, creat("foo", 0644)); ASSERT_NE(-1, (pid = fork())); if (!pid) { - ASSERT_SYS(0, 0, pledge("stdio rpath", 0)); + ASSERT_SYS(0, 0, pledge("stdio rpath wpath", 0)); ASSERT_SYS(0, 0, fchmod(3, 00700)); ASSERT_SYS(0, 0, chmod("foo", 00700)); ASSERT_SYS(0, 0, fchmodat(AT_FDCWD, "foo", 00700, 0)); @@ -233,7 +335,6 @@ TEST(pledge, open_rpath) { } EXPECT_NE(-1, wait(&ws)); EXPECT_TRUE(WIFEXITED(ws) && !WEXITSTATUS(ws)); - close(3); } TEST(pledge, open_wpath) { @@ -252,5 +353,20 @@ TEST(pledge, open_wpath) { } EXPECT_NE(-1, wait(&ws)); EXPECT_TRUE(WIFEXITED(ws) && !WEXITSTATUS(ws)); - close(3); +} + +TEST(pledge, sigaction_isFineButForbidsSigsys) { + if (IsOpenbsd()) return; // b/c testing linux bpf + int ws, pid; + struct stat st; + 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)); } diff --git a/test/libc/sock/unix_test.c b/test/libc/sock/unix_test.c index f2febbdc4..0a91692c2 100644 --- a/test/libc/sock/unix_test.c +++ b/test/libc/sock/unix_test.c @@ -66,7 +66,7 @@ TEST(unix, datagram) { alarm(3); while (!fileexists(addr.sun_path)) usleep(10000); ASSERT_SYS(0, 3, socket(AF_UNIX, SOCK_DGRAM, 0)); - ASSERT_SYS(0, 5, sendto(3, "hello", 5, 0, (void *)&addr, len)); + ASSERT_SYS(0, 5, sendto(3, "hello", 5, 0, &addr, len)); ASSERT_SYS(0, 0, close(3)); ASSERT_NE(-1, wait(&ws)); EXPECT_TRUE(WIFEXITED(ws)); diff --git a/third_party/unzip/fileio.c b/third_party/unzip/fileio.c index 84576bafc..63ca99916 100644 --- a/third_party/unzip/fileio.c +++ b/third_party/unzip/fileio.c @@ -2395,13 +2395,13 @@ int do_string(__G__ length, option) /* return PK-type error code */ p = G.outbuf - 1; q = slide; while (*++p) { - int pause = FALSE; + int pause_ = FALSE; if (*p == 0x1B) { /* ASCII escape char */ *q++ = '^'; *q++ = '['; } else if (*p == 0x13) { /* ASCII ^S (pause) */ - pause = TRUE; + pause_ = TRUE; if (p[1] == LF) /* ASCII LF */ *q++ = *++p; else if (p[1] == CR && p[2] == LF) { /* ASCII CR LF */ @@ -2410,10 +2410,10 @@ int do_string(__G__ length, option) /* return PK-type error code */ } } else *q++ = *p; - if ((unsigned)(q-slide) > WSIZE-3 || pause) { /* flush */ + if ((unsigned)(q-slide) > WSIZE-3 || pause_) { /* flush */ (*G.message)((zvoid *)&G, slide, (ulg)(q-slide), 0); q = slide; - if (pause && G.extract_flag) /* don't pause for list/test */ + if (pause_ && G.extract_flag) /* don't pause for list/test */ (*G.mpause)((zvoid *)&G, LoadFarString(QuitPrompt), 0); } } diff --git a/tool/emacs/cosmo-asm-mode.el b/tool/emacs/cosmo-asm-mode.el index c96524f61..17c63d03a 100644 --- a/tool/emacs/cosmo-asm-mode.el +++ b/tool/emacs/cosmo-asm-mode.el @@ -113,6 +113,7 @@ "asyncsignalsafe" "notasyncsignalsafe" "isa" + "norestart" "mayalias" "sideffect") "\\>"])) diff --git a/tool/net/help.txt b/tool/net/help.txt index d0421d35a..4ae91df5a 100644 --- a/tool/net/help.txt +++ b/tool/net/help.txt @@ -1095,7 +1095,7 @@ FUNCTIONS operating system to choose a port, which may be revealed later on by GetServerAddr or the -z flag to stdout. - ProgramMaxPayloadSize(int64) + ProgramMaxPayloadSize(int) Sets the maximum HTTP message payload size in bytes. The default is very conservatively set to 65536 so this is something many people will want to increase. This limit is diff --git a/tool/net/redbean.c b/tool/net/redbean.c index 65d50997c..ca57b7d14 100644 --- a/tool/net/redbean.c +++ b/tool/net/redbean.c @@ -20,7 +20,6 @@ #include "libc/bits/safemacros.internal.h" #include "libc/calls/calls.h" #include "libc/calls/ioctl.h" -#include "libc/calls/math.h" #include "libc/calls/struct/dirent.h" #include "libc/calls/struct/filter.h" #include "libc/calls/struct/flock.h" @@ -410,7 +409,6 @@ static int statuscode; static int shutdownsig; static int sslpskindex; static int oldloglevel; -static int maxpayloadsize; static int messageshandled; static int sslticketlifetime; static uint32_t clientaddrsize; @@ -437,6 +435,7 @@ static const char *zpath; static const char *brand; static char *monitorstack; static char gzip_footer[8]; +static long maxpayloadsize; static const char *pidpath; static const char *logpath; static const char *histpath; @@ -1205,7 +1204,7 @@ static void ReportWorkerResources(int pid, struct rusage *ru) { static void HandleWorkerExit(int pid, int ws, struct rusage *ru) { LockInc(&shared->c.connectionshandled); - AddRusage(&shared->children, ru); + _addrusage(&shared->children, ru); ReportWorkerExit(pid, ws); ReportWorkerResources(pid, ru); if (hasonprocessdestroy) {