From adac64a52b574a491ac6f6266fe776ff1a021be2 Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Wed, 8 Jun 2022 20:01:28 -0700 Subject: [PATCH] Reduce makefile dependencies by 10% The includes in libc/calls/calls.h have now been refactored so that functions with struct parameters are declared in libc/calls/struct/ --- dsp/tty/ttyraw.c | 1 - examples/cosh.c | 2 +- examples/exec.c | 1 - examples/greenbean.c | 2 +- examples/ls.c | 1 + examples/rusage.c | 1 - examples/unbourne.c | 2 +- examples/walk.c | 1 + libc/calls/calls.h | 67 ------------------- libc/calls/chdir-nt.c | 1 - libc/calls/close-nt.c | 3 +- libc/calls/close.c | 5 +- libc/calls/copyfile.c | 1 + libc/calls/describesigset.greg.c | 1 - libc/calls/directmap-nt.c | 5 +- libc/calls/dprintf.c | 2 +- libc/calls/dprintf.h | 18 +++++ libc/calls/dup-nt.c | 18 ++--- libc/calls/execve-sysv.c | 1 + libc/calls/fadvise-nt.c | 22 +++--- libc/calls/getprogramexecutablename.greg.c | 1 + libc/calls/internal.h | 1 + libc/calls/ioctl_siocgifconf-nt.c | 1 + libc/calls/ioctl_tiocgwinsz-nt.c | 4 +- libc/calls/ischardev.c | 1 + libc/calls/isdirectory.c | 1 + libc/calls/isregularfile.c | 1 + libc/calls/issymlink.c | 1 + libc/calls/lstat.c | 2 +- libc/calls/open-nt.c | 6 +- libc/calls/pipe-nt.c | 14 ++-- libc/calls/poll-nt.c | 5 +- libc/calls/printfds.c | 4 +- libc/calls/ptsname_r.c | 1 + libc/calls/reservefd.c | 16 ++--- libc/calls/setpriority.c | 1 + libc/calls/sig2.c | 2 +- libc/calls/sigaction.c | 1 - libc/calls/sigaddset.c | 2 +- libc/calls/sigbits.h | 15 ----- libc/calls/sigchld-nt.c | 8 +-- libc/calls/sigdelset.c | 2 +- libc/calls/sigemptyset.c | 2 +- libc/calls/sigfillset.c | 2 +- libc/calls/sigismember.c | 2 +- libc/calls/sigprocmask-sysv.greg.c | 1 + libc/calls/sigprocmask.c | 1 - libc/calls/sigsuspend.c | 1 - libc/calls/stat.c | 2 +- libc/calls/state.internal.h | 5 +- libc/calls/struct/dirent.h | 8 +++ libc/calls/struct/iovec.h | 4 ++ libc/calls/struct/rlimit.h | 3 + libc/calls/struct/rusage.h | 41 ++++++------ libc/calls/struct/sigaction.h | 1 + libc/calls/struct/sigset.h | 9 +++ libc/calls/struct/sigval.h | 2 + libc/calls/struct/stat.h | 5 ++ libc/calls/struct/sysinfo.h | 2 + libc/calls/struct/timespec.h | 2 + libc/calls/struct/timeval.h | 2 + libc/calls/struct/tms.h | 2 + libc/calls/struct/utsname.h | 2 + libc/calls/wait.c | 2 +- libc/calls/wait3.c | 3 +- libc/calls/wait4-nt.c | 11 ++- libc/calls/waitpid.c | 2 +- libc/calls/wincrash.c | 1 - libc/intrin/_spinlock_gettid.S | 24 +++++++ libc/intrin/_spinlock_yield.S | 24 +++++++ libc/intrin/_trylock_debug_4.c | 2 +- libc/intrin/g_fds.c | 11 ++- libc/intrin/releasefd.c | 4 +- libc/intrin/spinlock.h | 12 ++-- libc/isystem/signal.h | 1 - libc/isystem/sys/utsname.h | 1 - libc/log/backtrace2.c | 1 - libc/log/leaks.c | 1 + libc/log/meminfo.c | 1 + libc/log/memsummary.c | 1 + libc/log/oncrash.c | 2 +- libc/log/onkill.c | 1 - libc/log/showcrashreports.c | 1 - libc/log/vflogf.c | 1 + libc/nexgen32e/rdtscp.h | 1 + libc/rand/rand64.c | 7 +- libc/runtime/abort.greg.c | 1 - libc/runtime/clktck.c | 1 + libc/runtime/clone.c | 1 + libc/runtime/closesymboltable.c | 2 +- libc/runtime/fork-nt.c | 1 + libc/runtime/getinterpreterexecutablename.c | 1 + libc/runtime/getresourcelimit.c | 3 +- libc/runtime/hook.greg.c | 1 - libc/runtime/morph.greg.c | 1 - libc/runtime/printargs.greg.c | 1 + libc/runtime/sysconf.c | 6 +- libc/sock/accept-nt.c | 6 +- libc/sock/epoll.c | 4 +- libc/sock/socket-nt.c | 4 +- libc/sock/socketpair-nt.c | 8 +-- libc/sock/syslog.c | 5 +- libc/stdio/dirstream.c | 9 +-- libc/stdio/pclose.c | 1 + libc/stdio/spawn.c | 1 - libc/stdio/spawna.c | 1 - libc/stdio/system.c | 1 - libc/str/strsignal.greg.c | 14 ++-- libc/sysv/consts/s.h | 8 +++ libc/testlib/quota.c | 1 - libc/testlib/testmain.c | 1 - libc/testlib/testrunner.c | 1 - libc/x/filecmp.c | 1 + libc/x/rmrf.c | 1 + libc/x/xspawn.c | 1 - libc/x/xvspawn.c | 1 - libc/zipos/get.c | 1 - libc/zipos/open.c | 4 +- libc/zipos/stat-impl.c | 3 +- test/dsp/core/alaw_test.c | 2 + test/libc/calls/chdir_test.c | 1 + test/libc/calls/pipe_test.c | 1 + test/libc/calls/readlinkat_test.c | 7 +- test/libc/calls/setitimer_test.c | 1 - test/libc/calls/setrlimit_test.c | 1 - test/libc/calls/sigaction_test.c | 2 +- test/libc/calls/sigprocmask_test.c | 1 - test/libc/calls/sigsuspend_test.c | 1 - test/libc/calls/symlinkat_test.c | 1 + test/libc/calls/writev_test.c | 1 + test/libc/mem/pledge_test.c | 1 + test/libc/rand/rand64_test.c | 2 +- test/libc/rand/rand_test.c | 2 + test/libc/runtime/ape_test.c | 1 - test/libc/runtime/fork_test.c | 1 - test/libc/sock/poll_test.c | 1 - test/libc/sock/sendrecvmsg_test.c | 11 ++- test/libc/stdio/dumphexc_test.c | 1 + test/libc/str/blake2_test.c | 1 + test/libc/str/longsort_test.c | 1 + test/libc/str/regex_test.c | 2 + test/libc/str/sigset_test.c | 2 +- test/libc/str/strsignal_test.c | 1 + test/libc/str/undeflate_test.c | 1 + test/net/http/decodelatin1_test.c | 1 + test/net/http/underlong_test.c | 1 + test/tool/args/args_test.c | 1 + test/tool/net/redbean_test.c | 1 - test/tool/plinko/plinko_test.c | 1 - third_party/chibicc/as.c | 1 + third_party/compiler_rt/divmodti4.c | 1 - third_party/linenoise/linenoise.c | 2 +- third_party/lua/lrepl.c | 2 +- third_party/lua/lua.main.c | 1 - third_party/lua/luac.main.c | 1 - third_party/lz4cli/util.h | 1 + third_party/make/dir.c | 1 + third_party/make/makeint.inc | 1 - third_party/mbedtls/x509_crt.c | 1 + third_party/musl/glob.c | 1 + third_party/musl/nftw.c | 1 + third_party/python/Modules/_io/fileio.c | 1 + third_party/python/Modules/_posixsubprocess.c | 1 + third_party/python/Modules/_testcapimodule.c | 1 + third_party/python/Modules/faulthandler.c | 1 - third_party/python/Modules/getpath.c | 1 + third_party/python/Modules/main.c | 1 + third_party/python/Modules/mmapmodule.c | 1 + third_party/python/Modules/posixmodule.c | 3 + third_party/python/Modules/zipimport.c | 1 + third_party/python/Python/getsig.c | 1 - third_party/python/Python/pylifecycle.c | 1 - third_party/python/Python/sysmodule.c | 1 + third_party/python/runpythonmodule.c | 1 - third_party/quickjs/quickjs-libc.c | 2 + third_party/sqlite3/os_unix.c | 2 + third_party/sqlite3/shell.c | 6 +- third_party/zip/tailor.h | 1 + third_party/zip/unix.c | 1 + third_party/zlib/gz/gzread.c | 1 + tool/build/ar.c | 1 + tool/build/compile.c | 3 +- tool/build/cp.c | 1 + tool/build/deltaify.c | 1 - tool/build/jail.c | 1 - tool/build/lib/elfwriter_zip.c | 1 + tool/build/lib/syscall.c | 2 + tool/build/pstrace.c | 1 - tool/build/runit.c | 2 +- tool/build/runitd.c | 2 +- tool/build/strace.c | 1 - tool/build/unbundle.c | 1 + tool/build/zipobj.c | 1 + tool/decode/zip2.c | 1 + tool/net/echo.c | 1 + tool/net/lunix.c | 1 - tool/net/redbean.c | 3 +- tool/viz/basicidea.c | 1 + tool/viz/bf.c | 1 + tool/viz/lib/ycbcr2rgb3.c | 1 - tool/viz/printimage.c | 14 +--- tool/viz/printvideo.c | 1 - 202 files changed, 372 insertions(+), 319 deletions(-) create mode 100644 libc/calls/dprintf.h delete mode 100644 libc/calls/sigbits.h create mode 100644 libc/intrin/_spinlock_gettid.S create mode 100644 libc/intrin/_spinlock_yield.S diff --git a/dsp/tty/ttyraw.c b/dsp/tty/ttyraw.c index a6f7b8c2a..7d8b776bc 100644 --- a/dsp/tty/ttyraw.c +++ b/dsp/tty/ttyraw.c @@ -19,7 +19,6 @@ #include "dsp/tty/tty.h" #include "libc/assert.h" #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/siginfo.h" #include "libc/calls/termios.h" diff --git a/examples/cosh.c b/examples/cosh.c index 9e0126ab5..1ebee1ed0 100644 --- a/examples/cosh.c +++ b/examples/cosh.c @@ -8,7 +8,7 @@ ╚─────────────────────────────────────────────────────────────────*/ #endif #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" +#include "libc/calls/struct/dirent.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/sigset.h" #include "libc/calls/struct/timespec.h" diff --git a/examples/exec.c b/examples/exec.c index f844bf645..8ad300d1b 100644 --- a/examples/exec.c +++ b/examples/exec.c @@ -8,7 +8,6 @@ ╚─────────────────────────────────────────────────────────────────*/ #endif #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/sigset.h" #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" diff --git a/examples/greenbean.c b/examples/greenbean.c index 0d475bd85..d91cac665 100644 --- a/examples/greenbean.c +++ b/examples/greenbean.c @@ -10,7 +10,7 @@ #include "libc/assert.h" #include "libc/bits/atomic.h" #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" +#include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/sigset.h" #include "libc/calls/struct/timespec.h" #include "libc/calls/struct/timeval.h" diff --git a/examples/ls.c b/examples/ls.c index 7d1f98d00..f4a647cb9 100644 --- a/examples/ls.c +++ b/examples/ls.c @@ -15,6 +15,7 @@ #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/dt.h" +#include "libc/sysv/consts/s.h" #include "libc/x/x.h" struct stat st; diff --git a/examples/rusage.c b/examples/rusage.c index 969bba592..e28b6b467 100644 --- a/examples/rusage.c +++ b/examples/rusage.c @@ -8,7 +8,6 @@ ╚─────────────────────────────────────────────────────────────────*/ #endif #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/rusage.h" #include "libc/calls/struct/sigaction.h" #include "libc/errno.h" diff --git a/examples/unbourne.c b/examples/unbourne.c index 973d1a074..2f2bcd520 100644 --- a/examples/unbourne.c +++ b/examples/unbourne.c @@ -114,7 +114,6 @@ #include "libc/assert.h" #include "libc/bits/safemacros.internal.h" #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/dirent.h" #include "libc/calls/struct/rlimit.h" #include "libc/calls/struct/sigaction.h" @@ -142,6 +141,7 @@ #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/ok.h" #include "libc/sysv/consts/rlim.h" +#include "libc/sysv/consts/s.h" #include "libc/sysv/consts/sig.h" #include "libc/sysv/consts/w.h" #include "third_party/gdtoa/gdtoa.h" diff --git a/examples/walk.c b/examples/walk.c index c55296189..b9eca8eba 100644 --- a/examples/walk.c +++ b/examples/walk.c @@ -15,6 +15,7 @@ #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/exit.h" +#include "libc/sysv/consts/s.h" #include "libc/x/x.h" #include "third_party/musl/ftw.h" diff --git a/libc/calls/calls.h b/libc/calls/calls.h index 03868e354..5775c0ecc 100644 --- a/libc/calls/calls.h +++ b/libc/calls/calls.h @@ -1,21 +1,5 @@ #ifndef COSMOPOLITAN_LIBC_CALLS_SYSCALLS_H_ #define COSMOPOLITAN_LIBC_CALLS_SYSCALLS_H_ -#include "libc/calls/struct/dirent.h" -#include "libc/calls/struct/iovec.h" -#include "libc/calls/struct/rlimit.h" -#include "libc/calls/struct/rusage.h" -#include "libc/calls/struct/sigaction.h" -#include "libc/calls/struct/sigset.h" -#include "libc/calls/struct/sigval.h" -#include "libc/calls/struct/stat.h" -#include "libc/calls/struct/sysinfo.h" -#include "libc/calls/struct/timespec.h" -#include "libc/calls/struct/tms.h" -#include "libc/calls/struct/utsname.h" -#include "libc/dce.h" -#include "libc/fmt/pflink.h" -#include "libc/sysv/consts/s.h" -#include "libc/sysv/consts/sig.h" #define _POSIX_VERSION 200809L #define _POSIX2_VERSION _POSIX_VERSION @@ -46,14 +30,6 @@ #define MAP_HUGE_2MB (21 << MAP_HUGE_SHIFT) #define MAP_HUGE_1GB (30 << MAP_HUGE_SHIFT) -#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR) -#define S_ISCHR(mode) (((mode)&S_IFMT) == S_IFCHR) -#define S_ISBLK(mode) (((mode)&S_IFMT) == S_IFBLK) -#define S_ISREG(mode) (((mode)&S_IFMT) == S_IFREG) -#define S_ISFIFO(mode) (((mode)&S_IFMT) == S_IFIFO) -#define S_ISLNK(mode) (((mode)&S_IFMT) == S_IFLNK) -#define S_ISSOCK(mode) (((mode)&S_IFMT) == S_IFSOCK) - #define WCOREDUMP(s) (0x80 & (s)) #define WEXITSTATUS(s) ((0xff00 & (s)) >> 8) #define WIFCONTINUED(s) ((s) == 0xffff) @@ -72,8 +48,6 @@ COSMOPOLITAN_C_START_ typedef int sig_atomic_t; -DIR *fdopendir(int) dontdiscard; -DIR *opendir(const char *) dontdiscard; bool fileexists(const char *); bool isdirectory(const char *); bool isexecutable(const char *); @@ -94,9 +68,7 @@ int chmod(const char *, uint32_t); int chown(const char *, uint32_t, uint32_t); int chroot(const char *); int close(int); -int closedir(DIR *); int creat(const char *, uint32_t); -int dirfd(DIR *); int dup(int); int dup2(int, int); int dup3(int, int, int); @@ -119,8 +91,6 @@ int fdatasync(int); int filecmp(const char *, const char *); int flock(int, int); int fork(void); -int fstat(int, struct stat *); -int fstatat(int, const char *, struct stat *, int); int fsync(int); int ftruncate(int, int64_t); int getdents(unsigned, void *, unsigned, long *); @@ -137,8 +107,6 @@ int getppid(void); int getpriority(int, unsigned); int getresgid(uint32_t *, uint32_t *, uint32_t *); int getresuid(uint32_t *, uint32_t *, uint32_t *); -int getrlimit(int, struct rlimit *); -int getrusage(int, struct rusage *); int getsid(int) nosideeffect libcesque; int gettid(void) libcesque; int getuid(void) nosideeffect libcesque; @@ -146,8 +114,6 @@ int kill(int, int); int killpg(int, int); int link(const char *, const char *) dontthrow; int linkat(int, const char *, int, const char *, int); -int lstat(const char *, struct stat *); -int lutimes(const char *, const struct timeval[2]); int madvise(void *, uint64_t, int); int mincore(void *, size_t, unsigned char *); int mkdir(const char *, uint32_t); @@ -193,79 +159,46 @@ int setregid(uint32_t, uint32_t); int setresgid(uint32_t, uint32_t, uint32_t); int setresuid(uint32_t, uint32_t, uint32_t); int setreuid(uint32_t, uint32_t); -int setrlimit(int, const struct rlimit *); int setsid(void); int setuid(int); int sigignore(int); int siginterrupt(int, int); -int sigprocmask(int, const struct sigset *, struct sigset *); -int sigqueue(int, int, const union sigval); -int sigsuspend(const struct sigset *); -int stat(const char *, struct stat *); int symlink(const char *, const char *); int symlinkat(const char *, int, const char *); int sync_file_range(int, int64_t, int64_t, unsigned); int sysctl(const int *, unsigned, void *, size_t *, void *, size_t); -int sysinfo(struct sysinfo *); int tgkill(int, int, int); int tkill(int, int); int touch(const char *, uint32_t); int truncate(const char *, uint64_t); int ttyname_r(int, char *, size_t); int umask(int); -int uname(struct utsname *); int unlink(const char *); int unlink_s(const char **); int unlinkat(int, const char *, int); int vfork(void) returnstwice; int wait(int *); -int wait3(int *, int, struct rusage *); -int wait4(int, int *, int, struct rusage *); int waitpid(int, int *, int); intptr_t syscall(int, ...); long ptrace(int, ...); -long telldir(DIR *); -long times(struct tms *); size_t GetFileSize(const char *); ssize_t copy_file_range(int, long *, int, long *, size_t, uint32_t); ssize_t copyfd(int, int64_t *, int, int64_t *, size_t, uint32_t); ssize_t getfiledescriptorsize(int); ssize_t lseek(int, int64_t, unsigned); ssize_t pread(int, void *, size_t, int64_t); -ssize_t preadv(int, struct iovec *, int, int64_t); ssize_t pwrite(int, const void *, size_t, int64_t); -ssize_t pwritev(int, const struct iovec *, int, int64_t); ssize_t read(int, void *, size_t); ssize_t readansi(int, char *, size_t); ssize_t readlink(const char *, char *, size_t); ssize_t readlinkat(int, const char *, char *, size_t); ssize_t splice(int, int64_t *, int, int64_t *, size_t, uint32_t); -ssize_t vmsplice(int, const struct iovec *, int64_t, uint32_t); ssize_t write(int, const void *, size_t); -struct dirent *readdir(DIR *); -void rewinddir(DIR *); void sync(void); int clone(int (*)(void *), void *, size_t, int, void *, int *, void *, size_t, int *); -int futex(uint32_t *, int, int, const struct timespec *, uint32_t *); -/*───────────────────────────────────────────────────────────────────────────│─╗ -│ cosmopolitan § system calls » formatting ─╬─│┼ -╚────────────────────────────────────────────────────────────────────────────│*/ - -int dprintf(int, const char *, ...) printfesque(2) paramsnonnull((2)); -int vdprintf(int, const char *, va_list) paramsnonnull(); - -/*───────────────────────────────────────────────────────────────────────────│─╗ -│ cosmopolitan § system calls » link-time optimizations ─╬─│┼ -╚────────────────────────────────────────────────────────────────────────────│*/ -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) - -#define dprintf(FD, FMT, ...) (dprintf)(FD, PFLINK(FMT), ##__VA_ARGS__) -#define vdprintf(FD, FMT, VA) (vdprintf)(FD, PFLINK(FMT), VA) - -#endif /* GNU && !ANSI */ COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_SYSCALLS_H_ */ diff --git a/libc/calls/chdir-nt.c b/libc/calls/chdir-nt.c index 75a3e0ad0..3b213b25a 100644 --- a/libc/calls/chdir-nt.c +++ b/libc/calls/chdir-nt.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/syscall_support-nt.internal.h" -#include "libc/errno.h" #include "libc/macros.internal.h" #include "libc/nt/errors.h" #include "libc/nt/files.h" diff --git a/libc/calls/close-nt.c b/libc/calls/close-nt.c index ef9bfe2fd..7b5182aec 100644 --- a/libc/calls/close-nt.c +++ b/libc/calls/close-nt.c @@ -16,13 +16,12 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/bits/weaken.h" #include "libc/calls/internal.h" +#include "libc/errno.h" #include "libc/nt/enum/filetype.h" #include "libc/nt/files.h" #include "libc/nt/runtime.h" #include "libc/sysv/consts/o.h" -#include "libc/sysv/errfuns.h" textwindows int sys_close_nt(struct Fd *fd) { int e; diff --git a/libc/calls/close.c b/libc/calls/close.c index c03d92f75..3db9bb566 100644 --- a/libc/calls/close.c +++ b/libc/calls/close.c @@ -17,6 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/bits/weaken.h" +#include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/state.internal.h" #include "libc/calls/strace.internal.h" @@ -48,7 +49,7 @@ */ int close(int fd) { int rc; - _spinlock(&__fds_lock); + __fds_lock(); if (fd == -1) { rc = 0; } else if (fd < 0) { @@ -80,7 +81,7 @@ int close(int fd) { __releasefd_unlocked(fd); } } - _spunlock(&__fds_lock); + __fds_unlock(); STRACE("%s(%d) → %d% m", "close", fd, rc); return rc; } diff --git a/libc/calls/copyfile.c b/libc/calls/copyfile.c index 31cd2422f..e1f034f86 100644 --- a/libc/calls/copyfile.c +++ b/libc/calls/copyfile.c @@ -30,6 +30,7 @@ #include "libc/nt/files.h" #include "libc/nt/runtime.h" #include "libc/nt/struct/filetime.h" +#include "libc/str/str.h" #include "libc/sysv/consts/at.h" #include "libc/sysv/consts/madv.h" #include "libc/sysv/consts/o.h" diff --git a/libc/calls/describesigset.greg.c b/libc/calls/describesigset.greg.c index e72078e1f..ad194d44e 100644 --- a/libc/calls/describesigset.greg.c +++ b/libc/calls/describesigset.greg.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/bits/popcnt.h" -#include "libc/calls/sigbits.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" #include "libc/intrin/describeflags.internal.h" diff --git a/libc/calls/directmap-nt.c b/libc/calls/directmap-nt.c index fb4921776..3b5f44f1e 100644 --- a/libc/calls/directmap-nt.c +++ b/libc/calls/directmap-nt.c @@ -19,18 +19,15 @@ #include "libc/assert.h" #include "libc/calls/internal.h" #include "libc/calls/state.internal.h" -#include "libc/intrin/kprintf.h" #include "libc/nt/enum/filemapflags.h" #include "libc/nt/enum/pageflags.h" #include "libc/nt/memory.h" -#include "libc/nt/process.h" #include "libc/nt/runtime.h" #include "libc/nt/struct/processmemorycounters.h" +#include "libc/nt/struct/securityattributes.h" #include "libc/runtime/directmap.internal.h" -#include "libc/runtime/runtime.h" #include "libc/sysv/consts/map.h" #include "libc/sysv/consts/o.h" -#include "libc/sysv/consts/prot.h" textwindows struct DirectMap sys_mmap_nt(void *addr, size_t size, int prot, int flags, int fd, int64_t off) { diff --git a/libc/calls/dprintf.c b/libc/calls/dprintf.c index f2092b9c6..e5fb62544 100644 --- a/libc/calls/dprintf.c +++ b/libc/calls/dprintf.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/calls.h" +#include "libc/calls/dprintf.h" /** * Formats string directly to file descriptor. diff --git a/libc/calls/dprintf.h b/libc/calls/dprintf.h new file mode 100644 index 000000000..a327e0481 --- /dev/null +++ b/libc/calls/dprintf.h @@ -0,0 +1,18 @@ +#ifndef COSMOPOLITAN_LIBC_CALLS_DPRINTF_H_ +#define COSMOPOLITAN_LIBC_CALLS_DPRINTF_H_ +#include "libc/fmt/pflink.h" +#if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ + +int dprintf(int, const char *, ...) printfesque(2) paramsnonnull((2)); +int vdprintf(int, const char *, va_list) paramsnonnull(); + +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) + +#define dprintf(FD, FMT, ...) (dprintf)(FD, PFLINK(FMT), ##__VA_ARGS__) +#define vdprintf(FD, FMT, VA) (vdprintf)(FD, PFLINK(FMT), VA) + +#endif /* GNU && !ANSI */ +COSMOPOLITAN_C_END_ +#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ +#endif /* COSMOPOLITAN_LIBC_CALLS_DPRINTF_H_ */ diff --git a/libc/calls/dup-nt.c b/libc/calls/dup-nt.c index b3da0954d..cc84c453a 100644 --- a/libc/calls/dup-nt.c +++ b/libc/calls/dup-nt.c @@ -16,15 +16,11 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/bits/bits.h" #include "libc/bits/weaken.h" -#include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/state.internal.h" #include "libc/calls/syscall_support-nt.internal.h" -#include "libc/intrin/kprintf.h" #include "libc/intrin/spinlock.h" -#include "libc/mem/mem.h" #include "libc/nt/files.h" #include "libc/nt/runtime.h" #include "libc/sock/internal.h" @@ -41,12 +37,12 @@ textwindows int sys_dup_nt(int oldfd, int newfd, int flags, int start) { if (oldfd < 0) return ebadf(); if (flags & ~O_CLOEXEC) return einval(); - _spinlock(&__fds_lock); + __fds_lock(); if (oldfd >= g_fds.n || (g_fds.p[oldfd].kind != kFdFile && g_fds.p[oldfd].kind != kFdSocket && g_fds.p[oldfd].kind != kFdConsole)) { - _spunlock(&__fds_lock); + __fds_unlock(); return ebadf(); } @@ -54,19 +50,19 @@ textwindows int sys_dup_nt(int oldfd, int newfd, int flags, int start) { for (;;) { if (newfd == -1) { if ((newfd = __reservefd_unlocked(start)) == -1) { - _spunlock(&__fds_lock); + __fds_unlock(); return -1; } break; } else { if (__ensurefds_unlocked(newfd) == -1) { - _spunlock(&__fds_lock); + __fds_unlock(); return -1; } if (g_fds.p[newfd].kind) { - _spunlock(&__fds_lock); + __fds_unlock(); close(newfd); - _spinlock(&__fds_lock); + __fds_lock(); } if (!g_fds.p[newfd].kind) { g_fds.p[newfd].kind = kFdReserved; @@ -96,6 +92,6 @@ textwindows int sys_dup_nt(int oldfd, int newfd, int flags, int start) { rc = __winerr(); } - _spunlock(&__fds_lock); + __fds_unlock(); return rc; } diff --git a/libc/calls/execve-sysv.c b/libc/calls/execve-sysv.c index bcf848537..50dcf9088 100644 --- a/libc/calls/execve-sysv.c +++ b/libc/calls/execve-sysv.c @@ -20,6 +20,7 @@ #include "libc/bits/safemacros.internal.h" #include "libc/calls/calls.h" #include "libc/calls/syscall-sysv.internal.h" +#include "libc/dce.h" #include "libc/errno.h" #include "libc/mem/alloca.h" #include "libc/paths.h" diff --git a/libc/calls/fadvise-nt.c b/libc/calls/fadvise-nt.c index 9c8cae641..2c0ec8c28 100644 --- a/libc/calls/fadvise-nt.c +++ b/libc/calls/fadvise-nt.c @@ -17,18 +17,12 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/internal.h" +#include "libc/calls/state.internal.h" #include "libc/calls/syscall_support-nt.internal.h" +#include "libc/intrin/spinlock.h" #include "libc/nt/createfile.h" -#include "libc/nt/enum/fileflagandattributes.h" -#include "libc/nt/enum/filesharemode.h" -#include "libc/nt/enum/status.h" #include "libc/nt/files.h" -#include "libc/nt/nt/file.h" #include "libc/nt/runtime.h" -#include "libc/nt/struct/fileaccessinformation.h" -#include "libc/nt/struct/filebasicinformation.h" -#include "libc/nt/struct/iostatusblock.h" -#include "libc/runtime/runtime.h" #include "libc/sysv/consts/madv.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/errfuns.h" @@ -36,7 +30,7 @@ textwindows int sys_fadvise_nt(int fd, uint64_t offset, uint64_t len, int advice) { int64_t h1, h2; - int flags, mode; + int rc, flags, mode; uint32_t perm, share, attr; if (!__isfdkind(fd, kFdFile)) return ebadf(); h1 = g_fds.p[fd].handle; @@ -49,6 +43,7 @@ textwindows int sys_fadvise_nt(int fd, uint64_t offset, uint64_t len, case MADV_RANDOM: flags |= O_RANDOM; break; + case MADV_WILLNEED: case MADV_SEQUENTIAL: flags |= O_SEQUENTIAL; break; @@ -56,14 +51,19 @@ textwindows int sys_fadvise_nt(int fd, uint64_t offset, uint64_t len, return einval(); } if (GetNtOpenFlags(flags, mode, &perm, &share, 0, &attr) == -1) return -1; + + __fds_lock(); if ((h2 = ReOpenFile(h1, perm, share, attr)) != -1) { if (h2 != h1) { CloseHandle(h1); g_fds.p[fd].handle = h2; } g_fds.p[fd].flags = flags; - return 0; + rc = 0; } else { - return __winerr(); + rc = __winerr(); } + __fds_unlock(); + + return rc; } diff --git a/libc/calls/getprogramexecutablename.greg.c b/libc/calls/getprogramexecutablename.greg.c index 7a516ebb8..58840a714 100644 --- a/libc/calls/getprogramexecutablename.greg.c +++ b/libc/calls/getprogramexecutablename.greg.c @@ -23,6 +23,7 @@ #include "libc/macros.internal.h" #include "libc/nt/runtime.h" #include "libc/runtime/runtime.h" +#include "libc/str/str.h" #include "libc/sysv/consts/at.h" #include "libc/sysv/consts/ok.h" diff --git a/libc/calls/internal.h b/libc/calls/internal.h index 84d6cb098..2357116fa 100644 --- a/libc/calls/internal.h +++ b/libc/calls/internal.h @@ -11,6 +11,7 @@ #include "libc/calls/struct/siginfo.h" #include "libc/calls/struct/sigval.h" #include "libc/calls/struct/stat.h" +#include "libc/calls/struct/sysinfo.h" #include "libc/calls/struct/timespec.h" #include "libc/calls/struct/timeval.h" #include "libc/calls/struct/winsize.h" diff --git a/libc/calls/ioctl_siocgifconf-nt.c b/libc/calls/ioctl_siocgifconf-nt.c index 05ef547a0..db75446c4 100644 --- a/libc/calls/ioctl_siocgifconf-nt.c +++ b/libc/calls/ioctl_siocgifconf-nt.c @@ -20,6 +20,7 @@ #include "libc/bits/weaken.h" #include "libc/calls/calls.h" #include "libc/intrin/cmpxchg.h" +#include "libc/mem/mem.h" #include "libc/nt/errors.h" #include "libc/nt/iphlpapi.h" #include "libc/nt/runtime.h" diff --git a/libc/calls/ioctl_tiocgwinsz-nt.c b/libc/calls/ioctl_tiocgwinsz-nt.c index c6805d11b..91575dae5 100644 --- a/libc/calls/ioctl_tiocgwinsz-nt.c +++ b/libc/calls/ioctl_tiocgwinsz-nt.c @@ -42,7 +42,7 @@ textwindows int ioctl_tiocgwinsz_nt(struct Fd *fd, struct winsize *ws) { rc = -1; e = errno; if (ws) { - _spinlock(&__fds_lock); + __fds_lock(); fds[0] = fd, fds[1] = g_fds.p + 1, fds[2] = g_fds.p + 0; GetStartupInfo(&startinfo); for (i = 0; i < ARRAYLEN(fds); ++i) { @@ -76,7 +76,7 @@ textwindows int ioctl_tiocgwinsz_nt(struct Fd *fd, struct winsize *ws) { ebadf(); } } - _spunlock(&__fds_lock); + __fds_unlock(); } else { efault(); } diff --git a/libc/calls/ischardev.c b/libc/calls/ischardev.c index 9e51bf4c8..6d460d7f4 100644 --- a/libc/calls/ischardev.c +++ b/libc/calls/ischardev.c @@ -24,6 +24,7 @@ #include "libc/errno.h" #include "libc/nt/enum/filetype.h" #include "libc/nt/files.h" +#include "libc/sysv/consts/s.h" /** * Returns true if file descriptor is backed by character i/o. diff --git a/libc/calls/isdirectory.c b/libc/calls/isdirectory.c index 84262b49d..e73f84e62 100644 --- a/libc/calls/isdirectory.c +++ b/libc/calls/isdirectory.c @@ -28,6 +28,7 @@ #include "libc/intrin/asan.internal.h" #include "libc/nt/files.h" #include "libc/sysv/consts/at.h" +#include "libc/sysv/consts/s.h" #include "libc/sysv/errfuns.h" #include "libc/zipos/zipos.internal.h" diff --git a/libc/calls/isregularfile.c b/libc/calls/isregularfile.c index b7112bced..8e00446ae 100644 --- a/libc/calls/isregularfile.c +++ b/libc/calls/isregularfile.c @@ -26,6 +26,7 @@ #include "libc/errno.h" #include "libc/intrin/asan.internal.h" #include "libc/sysv/consts/at.h" +#include "libc/sysv/consts/s.h" #include "libc/sysv/errfuns.h" #include "libc/zipos/zipos.internal.h" diff --git a/libc/calls/issymlink.c b/libc/calls/issymlink.c index 9ff983f40..2a59b0298 100644 --- a/libc/calls/issymlink.c +++ b/libc/calls/issymlink.c @@ -28,6 +28,7 @@ #include "libc/intrin/asan.internal.h" #include "libc/nt/files.h" #include "libc/sysv/consts/at.h" +#include "libc/sysv/consts/s.h" #include "libc/sysv/errfuns.h" #include "libc/zipos/zipos.internal.h" diff --git a/libc/calls/lstat.c b/libc/calls/lstat.c index 9889bc41a..cb2aa1a98 100644 --- a/libc/calls/lstat.c +++ b/libc/calls/lstat.c @@ -16,7 +16,7 @@ │ 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/stat.h" #include "libc/sysv/consts/at.h" /** diff --git a/libc/calls/open-nt.c b/libc/calls/open-nt.c index f2b6001d3..051e51562 100644 --- a/libc/calls/open-nt.c +++ b/libc/calls/open-nt.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/internal.h" #include "libc/calls/ntmagicpaths.internal.h" #include "libc/calls/state.internal.h" @@ -25,6 +26,7 @@ #include "libc/nt/createfile.h" #include "libc/nt/enum/filetype.h" #include "libc/nt/files.h" +#include "libc/str/str.h" #include "libc/sysv/consts/fileno.h" #include "libc/sysv/consts/o.h" @@ -79,7 +81,7 @@ textwindows int sys_open_nt(int dirfd, const char *file, uint32_t flags, int32_t mode) { int fd; ssize_t rc; - _spinlock(&__fds_lock); + __fds_lock(); if ((rc = fd = __reservefd_unlocked(-1)) != -1) { if ((flags & O_ACCMODE) == O_RDWR && !strcmp(file, kNtMagicPaths.devtty)) { rc = sys_open_nt_console(dirfd, &kNtMagicPaths, flags, mode, fd); @@ -89,7 +91,7 @@ textwindows int sys_open_nt(int dirfd, const char *file, uint32_t flags, if (rc == -1) { __releasefd_unlocked(fd); } - _spunlock(&__fds_lock); + __fds_unlock(); } return rc; } diff --git a/libc/calls/pipe-nt.c b/libc/calls/pipe-nt.c index c38e6c8c7..caa125ed9 100644 --- a/libc/calls/pipe-nt.c +++ b/libc/calls/pipe-nt.c @@ -36,14 +36,14 @@ textwindows int sys_pipe_nt(int pipefd[2], unsigned flags) { int reader, writer; char16_t pipename[64]; CreatePipeName(pipename); - _spinlock(&__fds_lock); + __fds_lock(); if ((reader = __reservefd_unlocked(-1)) == -1) { - _spunlock(&__fds_lock); + __fds_unlock(); return -1; } if ((writer = __reservefd_unlocked(-1)) == -1) { __releasefd_unlocked(reader); - _spunlock(&__fds_lock); + __fds_unlock(); return -1; } if (~flags & O_DIRECT) { @@ -51,10 +51,10 @@ textwindows int sys_pipe_nt(int pipefd[2], unsigned flags) { } else { mode = kNtPipeTypeMessage | kNtPipeReadmodeMessage; } - _spunlock(&__fds_lock); + __fds_unlock(); hin = CreateNamedPipe(pipename, kNtPipeAccessInbound | kNtFileFlagOverlapped, mode, 1, PIPE_BUF, PIPE_BUF, 0, &kNtIsInheritable); - _spinlock(&__fds_lock); + __fds_lock(); if (hin != -1) { if ((hout = CreateFile(pipename, kNtGenericWrite, 0, &kNtIsInheritable, kNtOpenExisting, kNtFileFlagOverlapped, 0)) != -1) { @@ -68,7 +68,7 @@ textwindows int sys_pipe_nt(int pipefd[2], unsigned flags) { g_fds.p[writer].handle = hout; pipefd[0] = reader; pipefd[1] = writer; - _spunlock(&__fds_lock); + __fds_unlock(); return 0; } else { CloseHandle(hin); @@ -76,6 +76,6 @@ textwindows int sys_pipe_nt(int pipefd[2], unsigned flags) { } __releasefd_unlocked(writer); __releasefd_unlocked(reader); - _spunlock(&__fds_lock); + __fds_unlock(); return -1; } diff --git a/libc/calls/poll-nt.c b/libc/calls/poll-nt.c index c6b575f88..a6abe1eee 100644 --- a/libc/calls/poll-nt.c +++ b/libc/calls/poll-nt.c @@ -21,7 +21,6 @@ #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/sig.internal.h" -#include "libc/calls/sigbits.h" #include "libc/calls/state.internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/sigaction.h" @@ -69,7 +68,7 @@ textwindows int sys_poll_nt(struct pollfd *fds, uint64_t nfds, uint64_t *ms) { // we need to read static variables // we might need to spawn threads and open pipes _spinlock(&poll_lock); - _spinlock(&__fds_lock); + __fds_lock(); for (gotinvals = failed = sn = pn = i = 0; i < nfds; ++i) { if (fds[i].fd < 0) continue; if (__isfdopen(fds[i].fd)) { @@ -115,7 +114,7 @@ textwindows int sys_poll_nt(struct pollfd *fds, uint64_t nfds, uint64_t *ms) { ++gotinvals; } } - _spunlock(&__fds_lock); + __fds_unlock(); _spunlock(&poll_lock); if (failed) { // failed to create a polling solution diff --git a/libc/calls/printfds.c b/libc/calls/printfds.c index f3a45a039..9600a43c2 100644 --- a/libc/calls/printfds.c +++ b/libc/calls/printfds.c @@ -46,7 +46,7 @@ static const char *__fdkind2str(int x) { void __printfds(void) { int i; - _spinlock(&__fds_lock); + __fds_lock(); for (i = 0; i < g_fds.n; ++i) { if (!g_fds.p[i].kind) continue; kprintf("%3d %s", i, __fdkind2str(g_fds.p[i].kind)); @@ -57,5 +57,5 @@ void __printfds(void) { if (g_fds.p[i].extra) kprintf(" extra=%ld", g_fds.p[i].extra); kprintf("\n"); } - _spunlock(&__fds_lock); + __fds_unlock(); } diff --git a/libc/calls/ptsname_r.c b/libc/calls/ptsname_r.c index 49fefdb0a..baa0ea8e7 100644 --- a/libc/calls/ptsname_r.c +++ b/libc/calls/ptsname_r.c @@ -20,6 +20,7 @@ #include "libc/calls/termios.h" #include "libc/errno.h" #include "libc/fmt/itoa.h" +#include "libc/str/str.h" #include "libc/sysv/consts/termios.h" #include "libc/sysv/errfuns.h" diff --git a/libc/calls/reservefd.c b/libc/calls/reservefd.c index 528b25e4b..003fadae2 100644 --- a/libc/calls/reservefd.c +++ b/libc/calls/reservefd.c @@ -69,9 +69,9 @@ int __ensurefds_unlocked(int fd) { * Grows file descriptor array memory if needed. */ int __ensurefds(int fd) { - _spinlock(&__fds_lock); + __fds_lock(); fd = __ensurefds_unlocked(fd); - _spunlock(&__fds_lock); + __fds_unlock(); return fd; } @@ -96,9 +96,9 @@ int __reservefd_unlocked(int start) { */ int __reservefd(int start) { int fd; - _spinlock(&__fds_lock); + __fds_lock(); fd = __reservefd_unlocked(start); - _spunlock(&__fds_lock); + __fds_unlock(); return fd; } @@ -108,12 +108,12 @@ int __reservefd(int start) { static void FreeFds(void) { int i, keep = 3; STRACE("FreeFds()"); - _spinlock(&__fds_lock); + __fds_lock(); for (i = keep; i < g_fds.n; ++i) { if (g_fds.p[i].kind) { - _spunlock(&__fds_lock); + __fds_unlock(); close(i); - _spinlock(&__fds_lock); + __fds_lock(); } } if (g_fds.p != g_fds.__init_p) { @@ -125,7 +125,7 @@ static void FreeFds(void) { g_fds.p = g_fds.__init_p; g_fds.n = ARRAYLEN(g_fds.__init_p); } - _spunlock(&__fds_lock); + __fds_unlock(); } static textstartup void FreeFdsInit(void) { diff --git a/libc/calls/setpriority.c b/libc/calls/setpriority.c index 10d8bd26a..005d8dac7 100644 --- a/libc/calls/setpriority.c +++ b/libc/calls/setpriority.c @@ -19,6 +19,7 @@ #include "libc/calls/calls.h" #include "libc/calls/syscall-nt.internal.h" #include "libc/calls/syscall-sysv.internal.h" +#include "libc/dce.h" /** * Sets nice value of thing. diff --git a/libc/calls/sig2.c b/libc/calls/sig2.c index fb59bae12..8404ebe31 100644 --- a/libc/calls/sig2.c +++ b/libc/calls/sig2.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/sig.internal.h" -#include "libc/calls/sigbits.h" #include "libc/calls/state.internal.h" #include "libc/calls/strace.internal.h" #include "libc/intrin/cmpxchg.h" @@ -28,6 +27,7 @@ #include "libc/runtime/internal.h" #include "libc/runtime/runtime.h" #include "libc/sysv/consts/sa.h" +#include "libc/sysv/consts/sig.h" #include "libc/sysv/errfuns.h" /** diff --git a/libc/calls/sigaction.c b/libc/calls/sigaction.c index 9806ce460..9ed0f535d 100644 --- a/libc/calls/sigaction.c +++ b/libc/calls/sigaction.c @@ -22,7 +22,6 @@ #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/sig.internal.h" -#include "libc/calls/sigbits.h" #include "libc/calls/state.internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/sigaction-freebsd.internal.h" diff --git a/libc/calls/sigaddset.c b/libc/calls/sigaddset.c index 260b80304..0437293bd 100644 --- a/libc/calls/sigaddset.c +++ b/libc/calls/sigaddset.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/sigbits.h" +#include "libc/calls/struct/sigset.h" #include "libc/sysv/errfuns.h" /** diff --git a/libc/calls/sigbits.h b/libc/calls/sigbits.h deleted file mode 100644 index da837a231..000000000 --- a/libc/calls/sigbits.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef COSMOPOLITAN_LIBC_CALLS_SIGBITS_H_ -#define COSMOPOLITAN_LIBC_CALLS_SIGBITS_H_ -#include "libc/calls/struct/sigset.h" -#if !(__ASSEMBLER__ + __LINKER__ + 0) -COSMOPOLITAN_C_START_ - -int sigaddset(sigset_t *, int) paramsnonnull(); -int sigdelset(sigset_t *, int) paramsnonnull(); -int sigemptyset(sigset_t *) paramsnonnull(); -int sigfillset(sigset_t *) paramsnonnull(); -int sigismember(const sigset_t *, int) paramsnonnull() nosideeffect; - -COSMOPOLITAN_C_END_ -#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ -#endif /* COSMOPOLITAN_LIBC_CALLS_SIGBITS_H_ */ diff --git a/libc/calls/sigchld-nt.c b/libc/calls/sigchld-nt.c index 14c278bcc..427e01200 100644 --- a/libc/calls/sigchld-nt.c +++ b/libc/calls/sigchld-nt.c @@ -41,9 +41,9 @@ void _check_sigchld(void) { int pids[64]; uint32_t i, n; int64_t handles[64]; - _spinlock(&__fds_lock); + __fds_lock(); n = __sample_pids(pids, handles, true); - _spunlock(&__fds_lock); + __fds_unlock(); if (!n) return; i = WaitForMultipleObjects(n, handles, false, 0); if (i == kNtWaitTimeout) return; @@ -61,8 +61,8 @@ void _check_sigchld(void) { CloseHandle(handles[i]); __releasefd(pids[i]); } - _spinlock(&__fds_lock); + __fds_lock(); g_fds.p[pids[i]].zombie = true; - _spunlock(&__fds_lock); + __fds_unlock(); __sig_add(SIGCHLD, CLD_EXITED); } diff --git a/libc/calls/sigdelset.c b/libc/calls/sigdelset.c index 84ca3129b..1ab470193 100644 --- a/libc/calls/sigdelset.c +++ b/libc/calls/sigdelset.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/sigbits.h" +#include "libc/calls/struct/sigset.h" #include "libc/sysv/errfuns.h" /** diff --git a/libc/calls/sigemptyset.c b/libc/calls/sigemptyset.c index 676a6422d..e08281593 100644 --- a/libc/calls/sigemptyset.c +++ b/libc/calls/sigemptyset.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/sigbits.h" +#include "libc/calls/struct/sigset.h" #include "libc/str/str.h" /** diff --git a/libc/calls/sigfillset.c b/libc/calls/sigfillset.c index e455ffc36..7870d1bd7 100644 --- a/libc/calls/sigfillset.c +++ b/libc/calls/sigfillset.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/sigbits.h" +#include "libc/calls/struct/sigset.h" #include "libc/str/str.h" /** diff --git a/libc/calls/sigismember.c b/libc/calls/sigismember.c index 246ac55db..279abedbb 100644 --- a/libc/calls/sigismember.c +++ b/libc/calls/sigismember.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/sigbits.h" +#include "libc/calls/struct/sigset.h" #include "libc/sysv/errfuns.h" /** diff --git a/libc/calls/sigprocmask-sysv.greg.c b/libc/calls/sigprocmask-sysv.greg.c index 625808d8e..738ca5a39 100644 --- a/libc/calls/sigprocmask-sysv.greg.c +++ b/libc/calls/sigprocmask-sysv.greg.c @@ -18,6 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/internal.h" #include "libc/calls/struct/sigset.h" +#include "libc/str/str.h" int sys_sigprocmask(int how, const sigset_t *opt_set, sigset_t *opt_out_oldset) { diff --git a/libc/calls/sigprocmask.c b/libc/calls/sigprocmask.c index 26bea2137..2b2a3020f 100644 --- a/libc/calls/sigprocmask.c +++ b/libc/calls/sigprocmask.c @@ -20,7 +20,6 @@ #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/sig.internal.h" -#include "libc/calls/sigbits.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/sigset.h" #include "libc/dce.h" diff --git a/libc/calls/sigsuspend.c b/libc/calls/sigsuspend.c index acd2ae612..e1682df38 100644 --- a/libc/calls/sigsuspend.c +++ b/libc/calls/sigsuspend.c @@ -20,7 +20,6 @@ #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/sig.internal.h" -#include "libc/calls/sigbits.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/sigset.h" #include "libc/dce.h" diff --git a/libc/calls/stat.c b/libc/calls/stat.c index 19c89ce45..6378934ae 100644 --- a/libc/calls/stat.c +++ b/libc/calls/stat.c @@ -16,7 +16,7 @@ │ 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/stat.h" #include "libc/sysv/consts/at.h" /** diff --git a/libc/calls/state.internal.h b/libc/calls/state.internal.h index 0a5d03ccf..ed8ef1437 100644 --- a/libc/calls/state.internal.h +++ b/libc/calls/state.internal.h @@ -4,13 +4,16 @@ COSMOPOLITAN_C_START_ hidden extern int __vforked; -hidden extern int __fds_lock; +hidden extern int __fds_lock_obj; hidden extern int __sig_lock_obj; hidden extern bool __time_critical; hidden extern unsigned __sighandrvas[NSIG]; hidden extern unsigned __sighandflags[NSIG]; hidden extern const struct NtSecurityAttributes kNtIsInheritable; +void __fds_lock(void); +void __fds_unlock(void); + COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STATE_INTERNAL_H_ */ diff --git a/libc/calls/struct/dirent.h b/libc/calls/struct/dirent.h index 4107c5722..cb94f580d 100644 --- a/libc/calls/struct/dirent.h +++ b/libc/calls/struct/dirent.h @@ -13,5 +13,13 @@ struct dirent { /* linux getdents64 abi */ struct dirstream; typedef struct dirstream DIR; +DIR *fdopendir(int) dontdiscard; +DIR *opendir(const char *) dontdiscard; +int closedir(DIR *); +int dirfd(DIR *); +long telldir(DIR *); +struct dirent *readdir(DIR *); +void rewinddir(DIR *); + #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_DIRENT_H_ */ diff --git a/libc/calls/struct/iovec.h b/libc/calls/struct/iovec.h index 33c413da2..f7d8b431b 100644 --- a/libc/calls/struct/iovec.h +++ b/libc/calls/struct/iovec.h @@ -7,5 +7,9 @@ struct iovec { size_t iov_len; }; +ssize_t preadv(int, struct iovec *, int, int64_t); +ssize_t pwritev(int, const struct iovec *, int, int64_t); +ssize_t vmsplice(int, const struct iovec *, int64_t, uint32_t); + #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_IOVEC_H_ */ diff --git a/libc/calls/struct/rlimit.h b/libc/calls/struct/rlimit.h index edbe0dfb5..a9dcf263b 100644 --- a/libc/calls/struct/rlimit.h +++ b/libc/calls/struct/rlimit.h @@ -7,5 +7,8 @@ struct rlimit { uint64_t rlim_max; /* maximum limit in bytes */ }; +int getrlimit(int, struct rlimit *); +int setrlimit(int, const struct rlimit *); + #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_RLIMIT_H_ */ diff --git a/libc/calls/struct/rusage.h b/libc/calls/struct/rusage.h index ed08ebc71..d3902d037 100644 --- a/libc/calls/struct/rusage.h +++ b/libc/calls/struct/rusage.h @@ -4,28 +4,27 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) struct rusage { - union { - struct { - struct timeval ru_utime; /* user CPU time used */ - struct timeval ru_stime; /* system CPU time used */ - int64_t ru_maxrss; /* maximum resident set size in (kb) */ - int64_t ru_ixrss; /* shared memory size (integral kb CLK_TCK) */ - int64_t ru_idrss; /* unshared data size (integral kb CLK_TCK) */ - int64_t ru_isrss; /* unshared stack size (integral kb CLK_TCK) */ - int64_t ru_minflt; /* page reclaims */ - int64_t ru_majflt; /* page faults */ - int64_t ru_nswap; /* swaps */ - int64_t ru_inblock; /* block input operations */ - int64_t ru_oublock; /* block output operations */ - int64_t ru_msgsnd; /* IPC messages sent */ - int64_t ru_msgrcv; /* IPC messages received */ - int64_t ru_nsignals; /* signals received */ - int64_t ru_nvcsw; /* voluntary context switches */ - int64_t ru_nivcsw; /* involuntary context switches */ - }; - uint8_t __conservatism[1024]; - }; + struct timeval ru_utime; /* user CPU time used */ + struct timeval ru_stime; /* system CPU time used */ + int64_t ru_maxrss; /* maximum resident set size in (kb) */ + int64_t ru_ixrss; /* shared memory size (integral kb CLK_TCK) */ + int64_t ru_idrss; /* unshared data size (integral kb CLK_TCK) */ + int64_t ru_isrss; /* unshared stack size (integral kb CLK_TCK) */ + int64_t ru_minflt; /* page reclaims */ + int64_t ru_majflt; /* page faults */ + int64_t ru_nswap; /* swaps */ + int64_t ru_inblock; /* block input operations */ + int64_t ru_oublock; /* block output operations */ + int64_t ru_msgsnd; /* IPC messages sent */ + int64_t ru_msgrcv; /* IPC messages received */ + int64_t ru_nsignals; /* signals received */ + int64_t ru_nvcsw; /* voluntary context switches */ + int64_t ru_nivcsw; /* involuntary context switches */ }; +int getrusage(int, struct rusage *); +int wait3(int *, int, struct rusage *); +int wait4(int, int *, int, struct rusage *); + #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_RUSAGE_H_ */ diff --git a/libc/calls/struct/sigaction.h b/libc/calls/struct/sigaction.h index 23bec2ee0..ee6a44187 100644 --- a/libc/calls/struct/sigaction.h +++ b/libc/calls/struct/sigaction.h @@ -4,6 +4,7 @@ #include "libc/calls/typedef/sigaction_f.h" #include "libc/calls/typedef/sighandler_t.h" #include "libc/dce.h" +#include "libc/sysv/consts/sig.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) struct sigaction { /* cosmo abi */ diff --git a/libc/calls/struct/sigset.h b/libc/calls/struct/sigset.h index 7f1fb1f91..a4ad3c343 100644 --- a/libc/calls/struct/sigset.h +++ b/libc/calls/struct/sigset.h @@ -6,5 +6,14 @@ typedef struct sigset { uint64_t __bits[2]; } sigset_t; +int sigprocmask(int, const sigset_t *, sigset_t *); +int sigsuspend(const sigset_t *); + +int sigaddset(sigset_t *, int) paramsnonnull(); +int sigdelset(sigset_t *, int) paramsnonnull(); +int sigemptyset(sigset_t *) paramsnonnull(); +int sigfillset(sigset_t *) paramsnonnull(); +int sigismember(const sigset_t *, int) paramsnonnull() nosideeffect; + #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGSET_H_ */ diff --git a/libc/calls/struct/sigval.h b/libc/calls/struct/sigval.h index 504e6e5ef..e72c6ffa3 100644 --- a/libc/calls/struct/sigval.h +++ b/libc/calls/struct/sigval.h @@ -7,5 +7,7 @@ union sigval { void *sival_ptr; }; +int sigqueue(int, int, const union sigval); + #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGVAL_H_ */ diff --git a/libc/calls/struct/stat.h b/libc/calls/struct/stat.h index b744420cd..dc15af99e 100644 --- a/libc/calls/struct/stat.h +++ b/libc/calls/struct/stat.h @@ -22,5 +22,10 @@ struct stat { /* cosmo abi */ uint64_t st_gen; /* xnu/bsd only */ }; +int stat(const char *, struct stat *); +int lstat(const char *, struct stat *); +int fstat(int, struct stat *); +int fstatat(int, const char *, struct stat *, int); + #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_STAT_H_ */ diff --git a/libc/calls/struct/sysinfo.h b/libc/calls/struct/sysinfo.h index 72a7c3fb1..eb1dbf1de 100644 --- a/libc/calls/struct/sysinfo.h +++ b/libc/calls/struct/sysinfo.h @@ -18,5 +18,7 @@ struct sysinfo { uint32_t mem_unit; /* ram stuff above is multiples of this */ }; +int sysinfo(struct sysinfo *); + #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SYSINFO_H_ */ diff --git a/libc/calls/struct/timespec.h b/libc/calls/struct/timespec.h index f7b3094b0..1ac1f0aec 100644 --- a/libc/calls/struct/timespec.h +++ b/libc/calls/struct/timespec.h @@ -7,5 +7,7 @@ struct timespec { int64_t tv_nsec; /* nanoseconds */ }; +int futex(uint32_t *, int, int, const struct timespec *, uint32_t *); + #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMESPEC_H_ */ diff --git a/libc/calls/struct/timeval.h b/libc/calls/struct/timeval.h index e6dc06061..00b6ce22e 100644 --- a/libc/calls/struct/timeval.h +++ b/libc/calls/struct/timeval.h @@ -7,5 +7,7 @@ struct timeval { int64_t tv_usec; /* microseconds */ }; +int lutimes(const char *, const struct timeval[2]); + #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMEVAL_H_ */ diff --git a/libc/calls/struct/tms.h b/libc/calls/struct/tms.h index 5ea0f93a2..0cb957e41 100644 --- a/libc/calls/struct/tms.h +++ b/libc/calls/struct/tms.h @@ -9,5 +9,7 @@ struct tms { int64_t tms_cstime; /* children kernelspace time */ }; +long times(struct tms *); + #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_TMS_H_ */ diff --git a/libc/calls/struct/utsname.h b/libc/calls/struct/utsname.h index e18e72ce6..1e8cb318a 100644 --- a/libc/calls/struct/utsname.h +++ b/libc/calls/struct/utsname.h @@ -14,5 +14,7 @@ struct utsname { char domainname[SYS_NMLN]; }; +int uname(struct utsname *); + #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_UTSNAME_H_ */ diff --git a/libc/calls/wait.c b/libc/calls/wait.c index a20a9b773..f322cb9f5 100644 --- a/libc/calls/wait.c +++ b/libc/calls/wait.c @@ -16,7 +16,7 @@ │ 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/rusage.h" /** * Waits for status to change on any child process. diff --git a/libc/calls/wait3.c b/libc/calls/wait3.c index 2f9e44c3d..9932081c4 100644 --- a/libc/calls/wait3.c +++ b/libc/calls/wait3.c @@ -16,8 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/calls.h" -#include "libc/dce.h" +#include "libc/calls/struct/rusage.h" #include "libc/sysv/errfuns.h" /** diff --git a/libc/calls/wait4-nt.c b/libc/calls/wait4-nt.c index 7bd1990b6..f7c4edaeb 100644 --- a/libc/calls/wait4-nt.c +++ b/libc/calls/wait4-nt.c @@ -20,7 +20,6 @@ #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/sig.internal.h" -#include "libc/calls/sigbits.h" #include "libc/calls/state.internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/rusage.h" @@ -60,7 +59,7 @@ static textwindows int sys_wait4_nt_impl(int pid, int *opt_out_wstatus, struct NtProcessMemoryCountersEx memcount; struct NtFileTime createfiletime, exitfiletime, kernelfiletime, userfiletime; if (_check_interrupts(true, g_fds.p)) return eintr(); - _spinlock(&__fds_lock); + __fds_lock(); if (pid != -1 && pid != 0) { if (pid < 0) { /* XXX: this is sloppy */ @@ -76,12 +75,12 @@ static textwindows int sys_wait4_nt_impl(int pid, int *opt_out_wstatus, g_fds.p[pid].handle = handle; g_fds.p[pid].flags = O_CLOEXEC; } else { - _spunlock(&__fds_lock); + __fds_unlock(); CloseHandle(handle); return echild(); } } else { - _spunlock(&__fds_lock); + __fds_unlock(); return echild(); } } @@ -91,11 +90,11 @@ static textwindows int sys_wait4_nt_impl(int pid, int *opt_out_wstatus, } else { count = __sample_pids(pids, handles, false); if (!count) { - _spunlock(&__fds_lock); + __fds_unlock(); return echild(); } } - _spunlock(&__fds_lock); + __fds_unlock(); for (;;) { if (_check_interrupts(true, 0)) return eintr(); dwExitCode = kNtStillActive; diff --git a/libc/calls/waitpid.c b/libc/calls/waitpid.c index a0d0ea510..9f457f066 100644 --- a/libc/calls/waitpid.c +++ b/libc/calls/waitpid.c @@ -16,7 +16,7 @@ │ 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/rusage.h" /** * Waits for status to change on process. diff --git a/libc/calls/wincrash.c b/libc/calls/wincrash.c index d79500212..738c99a0c 100644 --- a/libc/calls/wincrash.c +++ b/libc/calls/wincrash.c @@ -18,7 +18,6 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/internal.h" #include "libc/calls/sig.internal.h" -#include "libc/calls/sigbits.h" #include "libc/calls/state.internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/typedef/sigaction_f.h" diff --git a/libc/intrin/_spinlock_gettid.S b/libc/intrin/_spinlock_gettid.S new file mode 100644 index 000000000..8eab7b541 --- /dev/null +++ b/libc/intrin/_spinlock_gettid.S @@ -0,0 +1,24 @@ +/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│ +│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│ +╞══════════════════════════════════════════════════════════════════════════════╡ +│ Copyright 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/macros.internal.h" +.privileged + +_spinlock_gettid: + jmp gettid + .endfn _spinlock_gettid,globl diff --git a/libc/intrin/_spinlock_yield.S b/libc/intrin/_spinlock_yield.S new file mode 100644 index 000000000..b90bccd15 --- /dev/null +++ b/libc/intrin/_spinlock_yield.S @@ -0,0 +1,24 @@ +/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│ +│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│ +╞══════════════════════════════════════════════════════════════════════════════╡ +│ Copyright 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/macros.internal.h" +.privileged + +_spinlock_yield: + jmp sched_yield + .endfn _spinlock_yield,globl diff --git a/libc/intrin/_trylock_debug_4.c b/libc/intrin/_trylock_debug_4.c index 901548ce3..6af0d5608 100644 --- a/libc/intrin/_trylock_debug_4.c +++ b/libc/intrin/_trylock_debug_4.c @@ -27,7 +27,7 @@ privileged int _trylock_debug_4(int *lock, const char *lockname, const char *file, int line, const char *func) { int owner = 0; - int me = gettid(); + int me = _spinlock_gettid(); if (_lockcmpxchgp(lock, &owner, me)) { return 0; } else if (owner != me) { diff --git a/libc/intrin/g_fds.c b/libc/intrin/g_fds.c index 9f575dcd6..c0bb4e73f 100644 --- a/libc/intrin/g_fds.c +++ b/libc/intrin/g_fds.c @@ -19,13 +19,22 @@ #include "libc/bits/pushpop.h" #include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" +#include "libc/intrin/spinlock.h" #include "libc/nt/runtime.h" #include "libc/sysv/consts/o.h" STATIC_YOINK("_init_g_fds"); struct Fds g_fds; -_Alignas(64) int __fds_lock; +_Alignas(64) int __fds_lock_obj; + +void __fds_lock(void) { + _spinlock(&__fds_lock_obj); +} + +void __fds_unlock(void) { + _spunlock(&__fds_lock_obj); +} textstartup void InitializeFileDescriptors(void) { struct Fds *fds; diff --git a/libc/intrin/releasefd.c b/libc/intrin/releasefd.c index 48124c3cb..6b4b7e03b 100644 --- a/libc/intrin/releasefd.c +++ b/libc/intrin/releasefd.c @@ -22,7 +22,7 @@ #include "libc/macros.internal.h" void __releasefd(int fd) { - _spinlock(&__fds_lock); + __fds_lock(); __releasefd_unlocked(fd); - _spunlock(&__fds_lock); + __fds_unlock(); } diff --git a/libc/intrin/spinlock.h b/libc/intrin/spinlock.h index b1df648dc..dd3d39b0c 100644 --- a/libc/intrin/spinlock.h +++ b/libc/intrin/spinlock.h @@ -1,15 +1,11 @@ #ifndef COSMOPOLITAN_LIBC_INTRIN_SPINLOCK_H_ #define COSMOPOLITAN_LIBC_INTRIN_SPINLOCK_H_ -#include "libc/assert.h" -#include "libc/calls/calls.h" -#include "libc/intrin/lockcmpxchg.h" -#include "libc/intrin/lockcmpxchgp.h" /*───────────────────────────────────────────────────────────────────────────│─╗ │ cosmopolitan § spinlocks ─╬─│┼ ╚────────────────────────────────────────────────────────────────────────────│─╝ privileged unsophisticated locking subroutines */ -#if IsModeDbg() && !defined(_SPINLOCK_DEBUG) +#if defined(MODE_DBG) && !defined(_SPINLOCK_DEBUG) #define _SPINLOCK_DEBUG #endif @@ -17,7 +13,7 @@ #define _spinlock(lock) _spinlock_ndebug(lock) #define _spinlock_ndebug(lock) _spinlock_cooperative(lock) #define _trylock(lock) _trylock_debug(lock) -#define _seizelock(lock) _seizelock_impl(lock, gettid()) +#define _seizelock(lock) _seizelock_impl(lock, _spinlock_gettid()) #elif defined(TINY) #define _spinlock(lock) _spinlock_tiny(lock) #define _spinlock_ndebug(lock) _spinlock_tiny(lock) @@ -72,12 +68,14 @@ } else if (++__tries & 7) { \ __builtin_ia32_pause(); \ } else { \ - sched_yield(); \ + _spinlock_yield(); \ } \ } \ } while (0) +int _spinlock_gettid(void); int _trylock_debug_4(int *, const char *, const char *, int, const char *); void _spinlock_debug_4(int *, const char *, const char *, int, const char *); +void _spinlock_yield(void); #endif /* COSMOPOLITAN_LIBC_INTRIN_SPINLOCK_H_ */ diff --git a/libc/isystem/signal.h b/libc/isystem/signal.h index cb41528f6..fd442ad13 100644 --- a/libc/isystem/signal.h +++ b/libc/isystem/signal.h @@ -1,7 +1,6 @@ #ifndef LIBC_ISYSTEM_SIGNAL_H_ #define LIBC_ISYSTEM_SIGNAL_H_ #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/siginfo.h" #include "libc/sysv/consts/sicode.h" diff --git a/libc/isystem/sys/utsname.h b/libc/isystem/sys/utsname.h index 5d26809e0..9af6170bc 100644 --- a/libc/isystem/sys/utsname.h +++ b/libc/isystem/sys/utsname.h @@ -1,5 +1,4 @@ #ifndef LIBC_ISYSTEM_SYS_UTSNAME_H_ #define LIBC_ISYSTEM_SYS_UTSNAME_H_ -#include "libc/calls/calls.h" #include "libc/calls/struct/utsname.h" #endif diff --git a/libc/log/backtrace2.c b/libc/log/backtrace2.c index 9e98224fc..42606fc8b 100644 --- a/libc/log/backtrace2.c +++ b/libc/log/backtrace2.c @@ -21,7 +21,6 @@ #include "libc/bits/safemacros.internal.h" #include "libc/bits/weaken.h" #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/strace.internal.h" #include "libc/calls/syscall_support-sysv.internal.h" #include "libc/dce.h" diff --git a/libc/log/leaks.c b/libc/log/leaks.c index 16c65ceee..e3879eff8 100644 --- a/libc/log/leaks.c +++ b/libc/log/leaks.c @@ -21,6 +21,7 @@ #include "libc/intrin/asan.internal.h" #include "libc/intrin/kprintf.h" #include "libc/intrin/lockcmpxchg.h" +#include "libc/mem/mem.h" #include "libc/runtime/internal.h" #include "libc/runtime/memtrack.internal.h" #include "libc/runtime/runtime.h" diff --git a/libc/log/meminfo.c b/libc/log/meminfo.c index 5fbe6bee9..253987c21 100644 --- a/libc/log/meminfo.c +++ b/libc/log/meminfo.c @@ -17,6 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" +#include "libc/calls/dprintf.h" #include "libc/fmt/fmt.h" #include "libc/log/log.h" #include "libc/mem/mem.h" diff --git a/libc/log/memsummary.c b/libc/log/memsummary.c index 5b3a5bef3..755719c99 100644 --- a/libc/log/memsummary.c +++ b/libc/log/memsummary.c @@ -17,6 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" +#include "libc/calls/dprintf.h" #include "libc/log/log.h" #include "libc/mem/mem.h" diff --git a/libc/log/oncrash.c b/libc/log/oncrash.c index b83fbc8bf..967d93d69 100644 --- a/libc/log/oncrash.c +++ b/libc/log/oncrash.c @@ -18,10 +18,10 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/bits/weaken.h" #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/state.internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/sigaction.h" +#include "libc/calls/struct/utsname.h" #include "libc/errno.h" #include "libc/intrin/asan.internal.h" #include "libc/intrin/kprintf.h" diff --git a/libc/log/onkill.c b/libc/log/onkill.c index 971a0c94d..addcdea41 100644 --- a/libc/log/onkill.c +++ b/libc/log/onkill.c @@ -18,7 +18,6 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/bits/bits.h" #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/siginfo.h" #include "libc/calls/ucontext.h" diff --git a/libc/log/showcrashreports.c b/libc/log/showcrashreports.c index b7fec5f62..b7f4e81c9 100644 --- a/libc/log/showcrashreports.c +++ b/libc/log/showcrashreports.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/sigaltstack.h" #include "libc/log/internal.h" diff --git a/libc/log/vflogf.c b/libc/log/vflogf.c index c67a7d8ff..b6026ef4b 100644 --- a/libc/log/vflogf.c +++ b/libc/log/vflogf.c @@ -19,6 +19,7 @@ #include "libc/bits/bits.h" #include "libc/bits/safemacros.internal.h" #include "libc/calls/calls.h" +#include "libc/calls/dprintf.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/stat.h" #include "libc/calls/struct/timeval.h" diff --git a/libc/nexgen32e/rdtscp.h b/libc/nexgen32e/rdtscp.h index 4c5ecbbd2..33868c540 100644 --- a/libc/nexgen32e/rdtscp.h +++ b/libc/nexgen32e/rdtscp.h @@ -1,6 +1,7 @@ #ifndef COSMOPOLITAN_LIBC_NEXGEN32E_RDTSCP_H_ #define COSMOPOLITAN_LIBC_NEXGEN32E_RDTSCP_H_ #include "libc/bits/asmflag.h" +#include "libc/dce.h" #include "libc/nexgen32e/x86feature.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ diff --git a/libc/rand/rand64.c b/libc/rand/rand64.c index b69469181..ea036440f 100644 --- a/libc/rand/rand64.c +++ b/libc/rand/rand64.c @@ -16,16 +16,11 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/assert.h" -#include "libc/bits/bits.h" -#include "libc/bits/weaken.h" -#include "libc/calls/calls.h" #include "libc/intrin/spinlock.h" #include "libc/nexgen32e/rdtsc.h" -#include "libc/nt/thread.h" -#include "libc/rand/rand.h" #include "libc/runtime/internal.h" #include "libc/runtime/runtime.h" +#include "libc/str/str.h" #include "libc/sysv/consts/auxv.h" static int thepid; diff --git a/libc/runtime/abort.greg.c b/libc/runtime/abort.greg.c index 883542945..ebef9c846 100644 --- a/libc/runtime/abort.greg.c +++ b/libc/runtime/abort.greg.c @@ -18,7 +18,6 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/calls/sig.internal.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/sigset.h" #include "libc/dce.h" #include "libc/runtime/internal.h" diff --git a/libc/runtime/clktck.c b/libc/runtime/clktck.c index 6bb6d02f5..3617f430e 100644 --- a/libc/runtime/clktck.c +++ b/libc/runtime/clktck.c @@ -20,6 +20,7 @@ #include "libc/dce.h" #include "libc/fmt/conv.h" #include "libc/runtime/clktck.h" +#include "libc/runtime/runtime.h" #include "libc/sysv/consts/auxv.h" struct clockinfo_netbsd { diff --git a/libc/runtime/clone.c b/libc/runtime/clone.c index 886c2ad2d..6836dbc11 100644 --- a/libc/runtime/clone.c +++ b/libc/runtime/clone.c @@ -31,6 +31,7 @@ #include "libc/nt/thread.h" #include "libc/nt/thunk/msabi.h" #include "libc/runtime/runtime.h" +#include "libc/str/str.h" #include "libc/sysv/consts/clone.h" #include "libc/sysv/consts/futex.h" #include "libc/sysv/consts/nr.h" diff --git a/libc/runtime/closesymboltable.c b/libc/runtime/closesymboltable.c index d23f0fb7d..d91beb0bc 100644 --- a/libc/runtime/closesymboltable.c +++ b/libc/runtime/closesymboltable.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/calls.h" +#include "libc/runtime/runtime.h" #include "libc/runtime/symbols.internal.h" /** diff --git a/libc/runtime/fork-nt.c b/libc/runtime/fork-nt.c index 8d9549992..d3d9f827c 100644 --- a/libc/runtime/fork-nt.c +++ b/libc/runtime/fork-nt.c @@ -47,6 +47,7 @@ #include "libc/runtime/internal.h" #include "libc/runtime/memtrack.internal.h" #include "libc/runtime/runtime.h" +#include "libc/str/str.h" #include "libc/sysv/consts/map.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/prot.h" diff --git a/libc/runtime/getinterpreterexecutablename.c b/libc/runtime/getinterpreterexecutablename.c index f31ec9c7b..51aa209e3 100644 --- a/libc/runtime/getinterpreterexecutablename.c +++ b/libc/runtime/getinterpreterexecutablename.c @@ -21,6 +21,7 @@ #include "libc/dce.h" #include "libc/macros.internal.h" #include "libc/runtime/runtime.h" +#include "libc/str/str.h" #include "libc/sysv/consts/at.h" #include "libc/sysv/errfuns.h" diff --git a/libc/runtime/getresourcelimit.c b/libc/runtime/getresourcelimit.c index 362e7adfd..a10160ac5 100644 --- a/libc/runtime/getresourcelimit.c +++ b/libc/runtime/getresourcelimit.c @@ -16,10 +16,9 @@ │ 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/rlimit.h" #include "libc/limits.h" #include "libc/macros.internal.h" -#include "libc/runtime/runtime.h" #include "libc/sysv/consts/rlim.h" long GetResourceLimit(int resource) { diff --git a/libc/runtime/hook.greg.c b/libc/runtime/hook.greg.c index 8ba9cda96..05d20b987 100644 --- a/libc/runtime/hook.greg.c +++ b/libc/runtime/hook.greg.c @@ -18,7 +18,6 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/bits/bits.h" #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/sigset.h" #include "libc/dce.h" #include "libc/errno.h" diff --git a/libc/runtime/morph.greg.c b/libc/runtime/morph.greg.c index 1f11a7f31..350481d2a 100644 --- a/libc/runtime/morph.greg.c +++ b/libc/runtime/morph.greg.c @@ -19,7 +19,6 @@ #define ShouldUseMsabiAttribute() 1 #include "libc/bits/asmflag.h" #include "libc/calls/internal.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/sigset.h" #include "libc/dce.h" #include "libc/errno.h" diff --git a/libc/runtime/printargs.greg.c b/libc/runtime/printargs.greg.c index 55e2f98f1..807a8297c 100644 --- a/libc/runtime/printargs.greg.c +++ b/libc/runtime/printargs.greg.c @@ -20,6 +20,7 @@ #include "libc/calls/strace.internal.h" #include "libc/calls/struct/sigset.h" #include "libc/calls/struct/termios.h" +#include "libc/calls/struct/utsname.h" #include "libc/calls/termios.h" #include "libc/calls/ttydefaults.h" #include "libc/dce.h" diff --git a/libc/runtime/sysconf.c b/libc/runtime/sysconf.c index 6c685d528..a17085baa 100644 --- a/libc/runtime/sysconf.c +++ b/libc/runtime/sysconf.c @@ -16,14 +16,10 @@ │ 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/rlimit.h" -#include "libc/limits.h" -#include "libc/macros.internal.h" #include "libc/runtime/clktck.h" +#include "libc/runtime/runtime.h" #include "libc/runtime/sysconf.h" #include "libc/sysv/consts/limits.h" -#include "libc/sysv/consts/rlim.h" #include "libc/sysv/consts/rlimit.h" /** diff --git a/libc/sock/accept-nt.c b/libc/sock/accept-nt.c index e0c667bd8..d1c805a5f 100644 --- a/libc/sock/accept-nt.c +++ b/libc/sock/accept-nt.c @@ -52,7 +52,7 @@ textwindows int sys_accept_nt(struct Fd *fd, void *addr, uint32_t *addrsize, if ((!(flags & SOCK_NONBLOCK) || __sys_ioctlsocket_nt(h, FIONBIO, (uint32_t[]){1}) != -1) && (sockfd2 = calloc(1, sizeof(struct SockFd)))) { - _spinlock(&__fds_lock); + __fds_lock(); if ((client = __reservefd_unlocked(-1)) != -1) { sockfd2->family = sockfd->family; sockfd2->type = sockfd->type; @@ -62,10 +62,10 @@ textwindows int sys_accept_nt(struct Fd *fd, void *addr, uint32_t *addrsize, g_fds.p[client].mode = 0140666; g_fds.p[client].handle = h; g_fds.p[client].extra = (uintptr_t)sockfd2; - _spunlock(&__fds_lock); + __fds_unlock(); return client; } - _spunlock(&__fds_lock); + __fds_unlock(); free(sockfd2); } __sys_closesocket_nt(h); diff --git a/libc/sock/epoll.c b/libc/sock/epoll.c index 14112e1a8..8168446d8 100644 --- a/libc/sock/epoll.c +++ b/libc/sock/epoll.c @@ -1342,12 +1342,12 @@ static textwindows dontinline int sys_epoll_create1_nt(uint32_t flags) { __releasefd(fd); return -1; } - _spinlock(&__fds_lock); + __fds_lock(); g_fds.p[fd].kind = kFdEpoll; g_fds.p[fd].handle = ephnd; g_fds.p[fd].flags = flags; g_fds.p[fd].mode = 0140666; - _spunlock(&__fds_lock); + __fds_unlock(); return fd; } diff --git a/libc/sock/socket-nt.c b/libc/sock/socket-nt.c index ab043b905..10c06eebc 100644 --- a/libc/sock/socket-nt.c +++ b/libc/sock/socket-nt.c @@ -64,13 +64,13 @@ textwindows int sys_socket_nt(int family, int type, int protocol) { sockfd->family = family; sockfd->type = truetype; sockfd->protocol = protocol; - _spinlock(&__fds_lock); + __fds_lock(); g_fds.p[fd].kind = kFdSocket; g_fds.p[fd].flags = oflags; g_fds.p[fd].mode = 0140666; g_fds.p[fd].handle = h; g_fds.p[fd].extra = (uintptr_t)sockfd; - _spunlock(&__fds_lock); + __fds_unlock(); return fd; } else { __releasefd(fd); diff --git a/libc/sock/socketpair-nt.c b/libc/sock/socketpair-nt.c index f490916db..153d09e46 100644 --- a/libc/sock/socketpair-nt.c +++ b/libc/sock/socketpair-nt.c @@ -56,10 +56,10 @@ textwindows int sys_socketpair_nt(int family, int type, int proto, int sv[2]) { } CreatePipeName(pipename); - _spinlock(&__fds_lock); + __fds_lock(); reader = __reservefd_unlocked(-1); writer = __reservefd_unlocked(-1); - _spunlock(&__fds_lock); + __fds_unlock(); if (reader == -1 || writer == -1) { if (reader != -1) __releasefd(reader); if (writer != -1) __releasefd(writer); @@ -76,7 +76,7 @@ textwindows int sys_socketpair_nt(int family, int type, int proto, int sv[2]) { h1 = CreateFile(pipename, kNtGenericWrite | kNtGenericRead, 0, &kNtIsInheritable, kNtOpenExisting, kNtFileFlagOverlapped, 0); - _spinlock(&__fds_lock); + __fds_lock(); if (h1 != -1) { @@ -101,7 +101,7 @@ textwindows int sys_socketpair_nt(int family, int type, int proto, int sv[2]) { rc = -1; } - _spunlock(&__fds_lock); + __fds_unlock(); return rc; } diff --git a/libc/sock/syslog.c b/libc/sock/syslog.c index 9c879aae1..5bb1eec61 100644 --- a/libc/sock/syslog.c +++ b/libc/sock/syslog.c @@ -18,6 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/bits/safemacros.internal.h" #include "libc/calls/calls.h" +#include "libc/calls/dprintf.h" #include "libc/calls/weirdtypes.h" #include "libc/dce.h" #include "libc/errno.h" @@ -229,7 +230,9 @@ void vsyslog(int priority, const char *message, va_list ap) { ++log_id; } - if (log_opt & LOG_PERROR) dprintf(2, "%.*s", l - hlen, buf + hlen); + if (log_opt & LOG_PERROR) { + dprintf(2, "%.*s", l - hlen, buf + hlen); + } } } diff --git a/libc/stdio/dirstream.c b/libc/stdio/dirstream.c index 364c0bf08..ba44952e1 100644 --- a/libc/stdio/dirstream.c +++ b/libc/stdio/dirstream.c @@ -17,28 +17,21 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" -#include "libc/bits/bits.h" #include "libc/bits/weaken.h" -#include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/dirent.h" #include "libc/calls/syscall_support-nt.internal.h" -#include "libc/dce.h" #include "libc/intrin/asan.internal.h" -#include "libc/intrin/kprintf.h" -#include "libc/macros.internal.h" #include "libc/mem/mem.h" #include "libc/nt/enum/fileflagandattributes.h" #include "libc/nt/enum/filetype.h" #include "libc/nt/files.h" -#include "libc/nt/runtime.h" #include "libc/nt/struct/win32finddata.h" -#include "libc/nt/synchronization.h" -#include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/dt.h" #include "libc/sysv/consts/o.h" +#include "libc/sysv/consts/s.h" #include "libc/sysv/errfuns.h" #include "libc/zip.h" #include "libc/zipos/zipos.internal.h" diff --git a/libc/stdio/pclose.c b/libc/stdio/pclose.c index 911855ad1..e9047cd1a 100644 --- a/libc/stdio/pclose.c +++ b/libc/stdio/pclose.c @@ -18,6 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" #include "libc/calls/calls.h" +#include "libc/calls/struct/rusage.h" #include "libc/errno.h" #include "libc/stdio/stdio.h" #include "libc/sysv/errfuns.h" diff --git a/libc/stdio/spawn.c b/libc/stdio/spawn.c index de6cfa921..4f0ec0f97 100644 --- a/libc/stdio/spawn.c +++ b/libc/stdio/spawn.c @@ -18,7 +18,6 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/calls/scheduler.h" -#include "libc/calls/sigbits.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 125738ed2..f5dc634b7 100644 --- a/libc/stdio/spawna.c +++ b/libc/stdio/spawna.c @@ -18,7 +18,6 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/calls/scheduler.h" -#include "libc/calls/sigbits.h" #include "libc/stdio/spawn.h" #include "libc/stdio/spawna.internal.h" diff --git a/libc/stdio/system.c b/libc/stdio/system.c index ee88289a5..55543aa57 100644 --- a/libc/stdio/system.c +++ b/libc/stdio/system.c @@ -18,7 +18,6 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/bits/weaken.h" #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/sigaction.h" #include "libc/dce.h" #include "libc/errno.h" diff --git a/libc/str/strsignal.greg.c b/libc/str/strsignal.greg.c index b169c1264..6339d9da3 100644 --- a/libc/str/strsignal.greg.c +++ b/libc/str/strsignal.greg.c @@ -16,14 +16,20 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/bits/bits.h" #include "libc/fmt/magnumstrs.internal.h" -#include "libc/log/libfatal.internal.h" -#include "libc/macros.internal.h" #include "libc/str/str.h" static char g_strsignal[12]; +static inline char *StpCpy(char *d, const char *s) { + size_t i; + for (i = 0;; ++i) { + if (!(d[i] = s[i])) { + return d + i; + } + } +} + /** * Returns string describing signal code. * @@ -47,7 +53,7 @@ privileged char *strsignal(int sig) { p[3] = 0; if (sig) { if ((s = GetMagnumStr(kSignalNames, sig))) { - __stpcpy(p + 3, s); + StpCpy(p + 3, s); return p; } } diff --git a/libc/sysv/consts/s.h b/libc/sysv/consts/s.h index 0a6cb1284..0ce29235e 100644 --- a/libc/sysv/consts/s.h +++ b/libc/sysv/consts/s.h @@ -29,4 +29,12 @@ #define S_IEXEC 0000100 /* just use octal */ #define S_IWRITE 0000200 /* just use octal */ +#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR) +#define S_ISCHR(mode) (((mode)&S_IFMT) == S_IFCHR) +#define S_ISBLK(mode) (((mode)&S_IFMT) == S_IFBLK) +#define S_ISREG(mode) (((mode)&S_IFMT) == S_IFREG) +#define S_ISFIFO(mode) (((mode)&S_IFMT) == S_IFIFO) +#define S_ISLNK(mode) (((mode)&S_IFMT) == S_IFLNK) +#define S_ISSOCK(mode) (((mode)&S_IFMT) == S_IFSOCK) + #endif /* COSMOPOLITAN_LIBC_SYSV_CONSTS_S_H_ */ diff --git a/libc/testlib/quota.c b/libc/testlib/quota.c index d454d141c..1302482f0 100644 --- a/libc/testlib/quota.c +++ b/libc/testlib/quota.c @@ -18,7 +18,6 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/bits/bits.h" #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/errno.h" #include "libc/intrin/kprintf.h" #include "libc/log/backtrace.internal.h" diff --git a/libc/testlib/testmain.c b/libc/testlib/testmain.c index c29258e57..1e5b8f65e 100644 --- a/libc/testlib/testmain.c +++ b/libc/testlib/testmain.c @@ -20,7 +20,6 @@ #include "libc/bits/safemacros.internal.h" #include "libc/bits/weaken.h" #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/rlimit.h" #include "libc/calls/struct/sigaction.h" diff --git a/libc/testlib/testrunner.c b/libc/testlib/testrunner.c index 526ec817d..d0680fc3c 100644 --- a/libc/testlib/testrunner.c +++ b/libc/testlib/testrunner.c @@ -19,7 +19,6 @@ #include "libc/assert.h" #include "libc/bits/weaken.h" #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/sigset.h" diff --git a/libc/x/filecmp.c b/libc/x/filecmp.c index be074b2a8..1c37aa3da 100644 --- a/libc/x/filecmp.c +++ b/libc/x/filecmp.c @@ -20,6 +20,7 @@ #include "libc/calls/calls.h" #include "libc/errno.h" #include "libc/macros.internal.h" +#include "libc/runtime/runtime.h" #include "libc/str/str.h" #include "libc/sysv/consts/madv.h" #include "libc/sysv/consts/map.h" diff --git a/libc/x/rmrf.c b/libc/x/rmrf.c index 8d55f6c71..bb3ae0cd2 100644 --- a/libc/x/rmrf.c +++ b/libc/x/rmrf.c @@ -25,6 +25,7 @@ #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/dt.h" +#include "libc/sysv/consts/s.h" #include "libc/x/x.h" static int rmrfdir(const char *dirpath) { diff --git a/libc/x/xspawn.c b/libc/x/xspawn.c index b46bd052b..60f2ddd39 100644 --- a/libc/x/xspawn.c +++ b/libc/x/xspawn.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/rusage.h" #include "libc/calls/struct/sigaction.h" #include "libc/errno.h" diff --git a/libc/x/xvspawn.c b/libc/x/xvspawn.c index 6cf8f30a7..b2801bdc7 100644 --- a/libc/x/xvspawn.c +++ b/libc/x/xvspawn.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/errno.h" #include "libc/sysv/consts/sig.h" #include "libc/x/x.h" diff --git a/libc/zipos/get.c b/libc/zipos/get.c index de5f4e14c..ca2d56a8c 100644 --- a/libc/zipos/get.c +++ b/libc/zipos/get.c @@ -19,7 +19,6 @@ #include "libc/bits/safemacros.internal.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" -#include "libc/calls/sigbits.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/stat.h" #include "libc/dce.h" diff --git a/libc/zipos/open.c b/libc/zipos/open.c index 72dbff789..3869274fc 100644 --- a/libc/zipos/open.c +++ b/libc/zipos/open.c @@ -84,14 +84,14 @@ static int __zipos_load(struct Zipos *zipos, size_t cf, unsigned flags, if (h->mem) { if ((fd = IsWindows() ? __reservefd(-1) : dup(2)) != -1) { if (__ensurefds(fd) != -1) { - _spinlock(&__fds_lock); + __fds_lock(); h->handle = g_fds.p[fd].handle; g_fds.p[fd].kind = kFdZip; g_fds.p[fd].handle = (intptr_t)h; g_fds.p[fd].flags = flags | O_CLOEXEC; g_fds.p[fd].mode = mode; g_fds.p[fd].extra = 0; - _spunlock(&__fds_lock); + __fds_unlock(); return fd; } close(fd); diff --git a/libc/zipos/stat-impl.c b/libc/zipos/stat-impl.c index a9d9558a3..ff4e01ac4 100644 --- a/libc/zipos/stat-impl.c +++ b/libc/zipos/stat-impl.c @@ -17,8 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/bits/safemacros.internal.h" -#include "libc/calls/calls.h" -#include "libc/fmt/conv.h" +#include "libc/calls/struct/stat.h" #include "libc/str/str.h" #include "libc/sysv/errfuns.h" #include "libc/zip.h" diff --git a/test/dsp/core/alaw_test.c b/test/dsp/core/alaw_test.c index 504662b4c..c9d35f69d 100644 --- a/test/dsp/core/alaw_test.c +++ b/test/dsp/core/alaw_test.c @@ -18,6 +18,8 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "dsp/core/core.h" #include "libc/macros.internal.h" +#include "libc/mem/mem.h" +#include "libc/runtime/gc.internal.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" #include "libc/testlib/testlib.h" diff --git a/test/libc/calls/chdir_test.c b/test/libc/calls/chdir_test.c index 4fa925296..a495ec7e9 100644 --- a/test/libc/calls/chdir_test.c +++ b/test/libc/calls/chdir_test.c @@ -17,6 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" +#include "libc/dce.h" #include "libc/errno.h" #include "libc/sysv/consts/o.h" #include "libc/testlib/testlib.h" diff --git a/test/libc/calls/pipe_test.c b/test/libc/calls/pipe_test.c index c88c5d0f2..913f9d7b4 100644 --- a/test/libc/calls/pipe_test.c +++ b/test/libc/calls/pipe_test.c @@ -17,6 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" +#include "libc/calls/struct/rlimit.h" #include "libc/dce.h" #include "libc/errno.h" #include "libc/sysv/consts/rlimit.h" diff --git a/test/libc/calls/readlinkat_test.c b/test/libc/calls/readlinkat_test.c index 86ecd4465..09b37b24f 100644 --- a/test/libc/calls/readlinkat_test.c +++ b/test/libc/calls/readlinkat_test.c @@ -26,6 +26,7 @@ #include "libc/str/str.h" #include "libc/sysv/consts/at.h" #include "libc/sysv/consts/o.h" +#include "libc/sysv/consts/s.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" @@ -83,8 +84,10 @@ TEST(readlinkat, frootloop) { ASSERT_SYS(0, 0, symlink("froot", "froot")); ASSERT_SYS(ELOOP, -1, readlink("froot/loop", buf, sizeof(buf))); if (O_NOFOLLOW) { - ASSERT_SYS(IsFreebsd() ? EMLINK : IsNetbsd() ? EFTYPE : ELOOP, -1, - open("froot", O_RDONLY | O_NOFOLLOW)); + ASSERT_SYS(IsFreebsd() ? EMLINK + : IsNetbsd() ? EFTYPE + : ELOOP, + -1, open("froot", O_RDONLY | O_NOFOLLOW)); if (0 && O_PATH) { /* need rhel5 test */ ASSERT_NE(-1, (fd = open("froot", O_RDONLY | O_NOFOLLOW | O_PATH))); ASSERT_NE(-1, close(fd)); diff --git a/test/libc/calls/setitimer_test.c b/test/libc/calls/setitimer_test.c index d858c22c4..46084a20b 100644 --- a/test/libc/calls/setitimer_test.c +++ b/test/libc/calls/setitimer_test.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/siginfo.h" #include "libc/calls/struct/sigset.h" diff --git a/test/libc/calls/setrlimit_test.c b/test/libc/calls/setrlimit_test.c index c0f0aafb6..f761c49d0 100644 --- a/test/libc/calls/setrlimit_test.c +++ b/test/libc/calls/setrlimit_test.c @@ -19,7 +19,6 @@ #include "dsp/core/core.h" #include "libc/bits/safemacros.internal.h" #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/rlimit.h" #include "libc/calls/struct/sigaction.h" #include "libc/dce.h" diff --git a/test/libc/calls/sigaction_test.c b/test/libc/calls/sigaction_test.c index 4f09954e0..c77c456ea 100644 --- a/test/libc/calls/sigaction_test.c +++ b/test/libc/calls/sigaction_test.c @@ -17,7 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" +#include "libc/calls/struct/rusage.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/siginfo.h" #include "libc/calls/ucontext.h" diff --git a/test/libc/calls/sigprocmask_test.c b/test/libc/calls/sigprocmask_test.c index 51836565e..a0504cb19 100644 --- a/test/libc/calls/sigprocmask_test.c +++ b/test/libc/calls/sigprocmask_test.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/siginfo.h" #include "libc/calls/struct/sigset.h" diff --git a/test/libc/calls/sigsuspend_test.c b/test/libc/calls/sigsuspend_test.c index 0772c8ef9..17fd8fa06 100644 --- a/test/libc/calls/sigsuspend_test.c +++ b/test/libc/calls/sigsuspend_test.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/sigset.h" #include "libc/dce.h" #include "libc/errno.h" diff --git a/test/libc/calls/symlinkat_test.c b/test/libc/calls/symlinkat_test.c index c8d06f68e..366d68d19 100644 --- a/test/libc/calls/symlinkat_test.c +++ b/test/libc/calls/symlinkat_test.c @@ -23,6 +23,7 @@ #include "libc/rand/rand.h" #include "libc/runtime/runtime.h" #include "libc/sysv/consts/at.h" +#include "libc/sysv/consts/s.h" #include "libc/testlib/testlib.h" char testlib_enable_tmp_setup_teardown; diff --git a/test/libc/calls/writev_test.c b/test/libc/calls/writev_test.c index 8d256b4f5..56f829eb0 100644 --- a/test/libc/calls/writev_test.c +++ b/test/libc/calls/writev_test.c @@ -21,6 +21,7 @@ #include "libc/dce.h" #include "libc/errno.h" #include "libc/macros.internal.h" +#include "libc/mem/mem.h" #include "libc/runtime/gc.internal.h" #include "libc/runtime/runtime.h" #include "libc/sock/sock.h" diff --git a/test/libc/mem/pledge_test.c b/test/libc/mem/pledge_test.c index 10fb53463..e7be82722 100644 --- a/test/libc/mem/pledge_test.c +++ b/test/libc/mem/pledge_test.c @@ -24,6 +24,7 @@ #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/sysv/consts/o.h" +#include "libc/sysv/consts/sig.h" #include "libc/testlib/testlib.h" void SetUp(void) { diff --git a/test/libc/rand/rand64_test.c b/test/libc/rand/rand64_test.c index 97ea38a63..9f3dd3d6a 100644 --- a/test/libc/rand/rand64_test.c +++ b/test/libc/rand/rand64_test.c @@ -18,7 +18,6 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/bits/atomic.h" #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/sigset.h" #include "libc/dce.h" @@ -27,6 +26,7 @@ #include "libc/intrin/spinlock.h" #include "libc/limits.h" #include "libc/macros.internal.h" +#include "libc/mem/mem.h" #include "libc/nexgen32e/threaded.h" #include "libc/rand/rand.h" #include "libc/runtime/stack.h" diff --git a/test/libc/rand/rand_test.c b/test/libc/rand/rand_test.c index db75b9188..3969cdd10 100644 --- a/test/libc/rand/rand_test.c +++ b/test/libc/rand/rand_test.c @@ -17,7 +17,9 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/bits/bits.h" +#include "libc/mem/mem.h" #include "libc/rand/rand.h" +#include "libc/str/str.h" #include "libc/testlib/hyperion.h" #include "libc/testlib/testlib.h" diff --git a/test/libc/runtime/ape_test.c b/test/libc/runtime/ape_test.c index bfee9dd8c..704950cf2 100644 --- a/test/libc/runtime/ape_test.c +++ b/test/libc/runtime/ape_test.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/sigaction.h" #include "libc/errno.h" #include "libc/intrin/kprintf.h" diff --git a/test/libc/runtime/fork_test.c b/test/libc/runtime/fork_test.c index 688d4cd04..2cf08400b 100644 --- a/test/libc/runtime/fork_test.c +++ b/test/libc/runtime/fork_test.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/sigaction.h" #include "libc/dce.h" #include "libc/log/check.h" diff --git a/test/libc/sock/poll_test.c b/test/libc/sock/poll_test.c index 9a6271de1..f0fa863c2 100644 --- a/test/libc/sock/poll_test.c +++ b/test/libc/sock/poll_test.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/dce.h" #include "libc/intrin/kprintf.h" #include "libc/log/libfatal.internal.h" diff --git a/test/libc/sock/sendrecvmsg_test.c b/test/libc/sock/sendrecvmsg_test.c index 41bcfc0b0..74f6d9002 100644 --- a/test/libc/sock/sendrecvmsg_test.c +++ b/test/libc/sock/sendrecvmsg_test.c @@ -17,13 +17,14 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" +#include "libc/calls/struct/iovec.h" #include "libc/dce.h" +#include "libc/runtime/gc.internal.h" #include "libc/sock/sock.h" #include "libc/sysv/consts/af.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/sock.h" #include "libc/testlib/testlib.h" -#include "libc/runtime/gc.internal.h" #include "libc/x/x.h" TEST(sendrecvmsg, testPingPong) { @@ -32,7 +33,7 @@ TEST(sendrecvmsg, testPingPong) { const char world[] = "WORLD"; struct msghdr msg; struct iovec data[2]; - const uint32_t hwLen = strlen(hello)+strlen(world); + const uint32_t hwLen = strlen(hello) + strlen(world); memset(&msg, 0, sizeof(msg)); memset(&data[0], 0, sizeof(data)); @@ -40,14 +41,14 @@ TEST(sendrecvmsg, testPingPong) { data[0].iov_base = hello; data[0].iov_len = strlen(hello); data[1].iov_base = world; - data[1].iov_len = strlen(world); /* Don't send the '\0' */ + data[1].iov_len = strlen(world); /* Don't send the '\0' */ msg.msg_iov = &data[0]; msg.msg_iovlen = 2; ASSERT_NE(-1, socketpair(AF_UNIX, SOCK_STREAM, 0, fd)); ASSERT_EQ(hwLen, sendmsg(fd[0], &msg, 0)); - + data[0].iov_base = gc(xcalloc(20, 1)); data[0].iov_len = 20; msg.msg_iovlen = 1; @@ -58,5 +59,3 @@ TEST(sendrecvmsg, testPingPong) { ASSERT_NE(-1, close(fd[0])); ASSERT_NE(-1, close(fd[1])); } - - diff --git a/test/libc/stdio/dumphexc_test.c b/test/libc/stdio/dumphexc_test.c index c648f7c99..10f8d06e9 100644 --- a/test/libc/stdio/dumphexc_test.c +++ b/test/libc/stdio/dumphexc_test.c @@ -16,6 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/mem/mem.h" #include "libc/stdio/hex.internal.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" diff --git a/test/libc/str/blake2_test.c b/test/libc/str/blake2_test.c index 4c02081a2..22381049b 100644 --- a/test/libc/str/blake2_test.c +++ b/test/libc/str/blake2_test.c @@ -17,6 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" +#include "libc/mem/mem.h" #include "libc/rand/rand.h" #include "libc/str/blake2.h" #include "libc/str/str.h" diff --git a/test/libc/str/longsort_test.c b/test/libc/str/longsort_test.c index 3eb8d6131..48174f17d 100644 --- a/test/libc/str/longsort_test.c +++ b/test/libc/str/longsort_test.c @@ -17,6 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/alg/alg.h" +#include "libc/mem/mem.h" #include "libc/rand/rand.h" #include "libc/runtime/runtime.h" #include "libc/str/str.h" diff --git a/test/libc/str/regex_test.c b/test/libc/str/regex_test.c index ab92eb74c..6342eeb98 100644 --- a/test/libc/str/regex_test.c +++ b/test/libc/str/regex_test.c @@ -16,6 +16,8 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/mem/mem.h" +#include "libc/runtime/gc.internal.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" diff --git a/test/libc/str/sigset_test.c b/test/libc/str/sigset_test.c index 7cb0d58ed..10171e6d1 100644 --- a/test/libc/str/sigset_test.c +++ b/test/libc/str/sigset_test.c @@ -19,7 +19,7 @@ #include "libc/bits/bits.h" #include "libc/bits/safemacros.internal.h" #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" +#include "libc/calls/struct/sigset.h" #include "libc/str/str.h" #include "libc/testlib/testlib.h" diff --git a/test/libc/str/strsignal_test.c b/test/libc/str/strsignal_test.c index 12c90a0c9..0a00bd4c0 100644 --- a/test/libc/str/strsignal_test.c +++ b/test/libc/str/strsignal_test.c @@ -17,6 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/str/str.h" +#include "libc/sysv/consts/sig.h" #include "libc/testlib/testlib.h" TEST(strsignal, test) { diff --git a/test/libc/str/undeflate_test.c b/test/libc/str/undeflate_test.c index 0b018c67d..651b29218 100644 --- a/test/libc/str/undeflate_test.c +++ b/test/libc/str/undeflate_test.c @@ -34,6 +34,7 @@ #include "libc/sysv/consts/map.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/prot.h" +#include "libc/sysv/consts/s.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" #include "libc/testlib/testlib.h" diff --git a/test/net/http/decodelatin1_test.c b/test/net/http/decodelatin1_test.c index 27c395c43..dbd2a340b 100644 --- a/test/net/http/decodelatin1_test.c +++ b/test/net/http/decodelatin1_test.c @@ -17,6 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/errno.h" +#include "libc/mem/mem.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" #include "libc/testlib/testlib.h" diff --git a/test/net/http/underlong_test.c b/test/net/http/underlong_test.c index 043084956..3c7221a8f 100644 --- a/test/net/http/underlong_test.c +++ b/test/net/http/underlong_test.c @@ -16,6 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/mem/mem.h" #include "libc/runtime/gc.internal.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" diff --git a/test/tool/args/args_test.c b/test/tool/args/args_test.c index 71cb52b0f..5ff53051e 100644 --- a/test/tool/args/args_test.c +++ b/test/tool/args/args_test.c @@ -16,6 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/mem/mem.h" #include "libc/testlib/testlib.h" #include "tool/args/args.h" diff --git a/test/tool/net/redbean_test.c b/test/tool/net/redbean_test.c index 177ee4294..77f8094eb 100644 --- a/test/tool/net/redbean_test.c +++ b/test/tool/net/redbean_test.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/fmt/conv.h" #include "libc/runtime/gc.internal.h" #include "libc/runtime/runtime.h" diff --git a/test/tool/plinko/plinko_test.c b/test/tool/plinko/plinko_test.c index b4349fd1b..dfd438767 100644 --- a/test/tool/plinko/plinko_test.c +++ b/test/tool/plinko/plinko_test.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/sigaction.h" #include "libc/errno.h" #include "libc/intrin/kprintf.h" diff --git a/third_party/chibicc/as.c b/third_party/chibicc/as.c index 17a21cdb0..dbc9bc6be 100644 --- a/third_party/chibicc/as.c +++ b/third_party/chibicc/as.c @@ -32,6 +32,7 @@ #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/o.h" +#include "libc/sysv/consts/s.h" #include "libc/x/x.h" #include "third_party/chibicc/file.h" #include "third_party/gdtoa/gdtoa.h" diff --git a/third_party/compiler_rt/divmodti4.c b/third_party/compiler_rt/divmodti4.c index 643ce06f6..e92fc7cdc 100644 --- a/third_party/compiler_rt/divmodti4.c +++ b/third_party/compiler_rt/divmodti4.c @@ -7,7 +7,6 @@ │ • http://creativecommons.org/publicdomain/zero/1.0/ │ ╚─────────────────────────────────────────────────────────────────*/ #endif -#include "libc/calls/calls.h" #include "third_party/compiler_rt/int_lib.h" /** diff --git a/third_party/linenoise/linenoise.c b/third_party/linenoise/linenoise.c index c28852c1a..79943497d 100644 --- a/third_party/linenoise/linenoise.c +++ b/third_party/linenoise/linenoise.c @@ -129,7 +129,6 @@ #include "libc/bits/bits.h" #include "libc/calls/calls.h" #include "libc/calls/sig.internal.h" -#include "libc/calls/sigbits.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/stat.h" @@ -159,6 +158,7 @@ #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/poll.h" #include "libc/sysv/consts/prot.h" +#include "libc/sysv/consts/s.h" #include "libc/sysv/consts/sa.h" #include "libc/sysv/consts/sig.h" #include "libc/sysv/consts/termios.h" diff --git a/third_party/lua/lrepl.c b/third_party/lua/lrepl.c index b8c01462a..9378b2d43 100644 --- a/third_party/lua/lrepl.c +++ b/third_party/lua/lrepl.c @@ -28,7 +28,7 @@ #define lua_c #include "libc/alg/alg.h" #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" +#include "libc/calls/struct/sigaction.h" #include "libc/errno.h" #include "libc/intrin/nomultics.internal.h" #include "libc/log/check.h" diff --git a/third_party/lua/lua.main.c b/third_party/lua/lua.main.c index 214e9f51f..a81bb1554 100644 --- a/third_party/lua/lua.main.c +++ b/third_party/lua/lua.main.c @@ -27,7 +27,6 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #define lua_c #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/sigaction.h" #include "libc/dce.h" #include "libc/errno.h" diff --git a/third_party/lua/luac.main.c b/third_party/lua/luac.main.c index 83b11dcbc..1226785b2 100644 --- a/third_party/lua/luac.main.c +++ b/third_party/lua/luac.main.c @@ -28,7 +28,6 @@ #define luac_c #define LUA_CORE #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/sigaction.h" #include "libc/errno.h" #include "libc/sysv/consts/exit.h" diff --git a/third_party/lz4cli/util.h b/third_party/lz4cli/util.h index e94380c2f..3526c91cd 100644 --- a/third_party/lz4cli/util.h +++ b/third_party/lz4cli/util.h @@ -42,6 +42,7 @@ extern "C" { #include "libc/time/struct/utimbuf.h" #include "libc/calls/struct/stat.h" #include "libc/calls/struct/dirent.h" +#include "libc/sysv/consts/s.h" #include "libc/calls/weirdtypes.h" diff --git a/third_party/make/dir.c b/third_party/make/dir.c index 9a828158b..37e22820f 100644 --- a/third_party/make/dir.c +++ b/third_party/make/dir.c @@ -16,6 +16,7 @@ this program. If not, see . */ #include "third_party/make/makeint.inc" /**/ +#include "libc/calls/struct/dirent.h" #include "third_party/make/dep.h" #include "third_party/make/filedef.h" #include "third_party/make/hash.h" diff --git a/third_party/make/makeint.inc b/third_party/make/makeint.inc index 7720228a1..7acb12a0f 100644 --- a/third_party/make/makeint.inc +++ b/third_party/make/makeint.inc @@ -18,7 +18,6 @@ this program. If not, see . */ #include "libc/assert.h" #include "libc/calls/calls.h" #include "libc/calls/makedev.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/rlimit.h" #include "libc/calls/struct/rusage.h" #include "libc/calls/struct/sigaction.h" diff --git a/third_party/mbedtls/x509_crt.c b/third_party/mbedtls/x509_crt.c index 28616f4b9..5805eadde 100644 --- a/third_party/mbedtls/x509_crt.c +++ b/third_party/mbedtls/x509_crt.c @@ -24,6 +24,7 @@ #include "libc/log/log.h" #include "libc/mem/mem.h" #include "libc/stdio/stdio.h" +#include "libc/sysv/consts/s.h" #include "net/http/http.h" #include "third_party/mbedtls/common.h" #include "third_party/mbedtls/error.h" diff --git a/third_party/musl/glob.c b/third_party/musl/glob.c index 15ba60203..b0882473d 100644 --- a/third_party/musl/glob.c +++ b/third_party/musl/glob.c @@ -33,6 +33,7 @@ #include "libc/mem/mem.h" #include "libc/str/str.h" #include "libc/sysv/consts/dt.h" +#include "libc/sysv/consts/s.h" #include "third_party/musl/fnmatch.h" #include "third_party/musl/glob.h" diff --git a/third_party/musl/nftw.c b/third_party/musl/nftw.c index bafb1f4dd..159a3144c 100644 --- a/third_party/musl/nftw.c +++ b/third_party/musl/nftw.c @@ -31,6 +31,7 @@ #include "libc/errno.h" #include "libc/str/str.h" #include "libc/sysv/consts/o.h" +#include "libc/sysv/consts/s.h" #include "third_party/musl/ftw.h" asm(".ident\t\"\\n\\n\ diff --git a/third_party/python/Modules/_io/fileio.c b/third_party/python/Modules/_io/fileio.c index 361666eb8..741dc5770 100644 --- a/third_party/python/Modules/_io/fileio.c +++ b/third_party/python/Modules/_io/fileio.c @@ -8,6 +8,7 @@ #include "libc/calls/calls.h" #include "libc/errno.h" #include "libc/sysv/consts/o.h" +#include "libc/sysv/consts/s.h" #include "third_party/python/Include/abstract.h" #include "third_party/python/Include/boolobject.h" #include "third_party/python/Include/bytesobject.h" diff --git a/third_party/python/Modules/_posixsubprocess.c b/third_party/python/Modules/_posixsubprocess.c index 3dbc042d2..c58fc4323 100644 --- a/third_party/python/Modules/_posixsubprocess.c +++ b/third_party/python/Modules/_posixsubprocess.c @@ -6,6 +6,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/calls/internal.h" +#include "libc/calls/struct/dirent.h" #include "libc/calls/weirdtypes.h" #include "libc/dce.h" #include "libc/errno.h" diff --git a/third_party/python/Modules/_testcapimodule.c b/third_party/python/Modules/_testcapimodule.c index 8761a8038..834697484 100644 --- a/third_party/python/Modules/_testcapimodule.c +++ b/third_party/python/Modules/_testcapimodule.c @@ -12,6 +12,7 @@ #include "libc/fmt/fmt.h" #include "libc/limits.h" #include "libc/math.h" +#include "libc/sysv/consts/sig.h" #include "libc/time/time.h" #include "third_party/python/Include/abstract.h" #include "third_party/python/Include/boolobject.h" diff --git a/third_party/python/Modules/faulthandler.c b/third_party/python/Modules/faulthandler.c index c2f35e6c7..6c4b12196 100644 --- a/third_party/python/Modules/faulthandler.c +++ b/third_party/python/Modules/faulthandler.c @@ -5,7 +5,6 @@ │ https://docs.python.org/3/license.html │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/sigaction.h" #include "libc/errno.h" #include "libc/sysv/consts/rlimit.h" diff --git a/third_party/python/Modules/getpath.c b/third_party/python/Modules/getpath.c index 59178a01c..04c096279 100644 --- a/third_party/python/Modules/getpath.c +++ b/third_party/python/Modules/getpath.c @@ -15,6 +15,7 @@ #include "libc/runtime/runtime.h" #include "libc/str/str.h" #include "libc/sysv/consts/auxv.h" +#include "libc/sysv/consts/s.h" #include "libc/x/x.h" #include "third_party/python/Include/fileutils.h" #include "third_party/python/Include/osdefs.h" diff --git a/third_party/python/Modules/main.c b/third_party/python/Modules/main.c index bfaf906d2..44563a5d6 100644 --- a/third_party/python/Modules/main.c +++ b/third_party/python/Modules/main.c @@ -8,6 +8,7 @@ #include "libc/dce.h" #include "libc/errno.h" #include "libc/stdio/stdio.h" +#include "libc/sysv/consts/s.h" #include "libc/unicode/locale.h" #include "third_party/python/Include/abstract.h" #include "third_party/python/Include/bytesobject.h" diff --git a/third_party/python/Modules/mmapmodule.c b/third_party/python/Modules/mmapmodule.c index 028017a36..df3017f1b 100644 --- a/third_party/python/Modules/mmapmodule.c +++ b/third_party/python/Modules/mmapmodule.c @@ -12,6 +12,7 @@ #include "libc/sysv/consts/map.h" #include "libc/sysv/consts/msync.h" #include "libc/sysv/consts/prot.h" +#include "libc/sysv/consts/s.h" #include "third_party/python/Include/abstract.h" #include "third_party/python/Include/boolobject.h" #include "third_party/python/Include/ceval.h" diff --git a/third_party/python/Modules/posixmodule.c b/third_party/python/Modules/posixmodule.c index e352fd3cb..85f31a901 100644 --- a/third_party/python/Modules/posixmodule.c +++ b/third_party/python/Modules/posixmodule.c @@ -13,6 +13,8 @@ #include "libc/calls/makedev.h" #include "libc/calls/struct/dirent.h" #include "libc/calls/struct/stat.macros.h" +#include "libc/calls/struct/tms.h" +#include "libc/calls/struct/utsname.h" #include "libc/calls/struct/winsize.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/calls/termios.h" @@ -41,6 +43,7 @@ #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/posix.h" #include "libc/sysv/consts/prio.h" +#include "libc/sysv/consts/s.h" #include "libc/sysv/consts/sched.h" #include "libc/sysv/consts/sf.h" #include "libc/sysv/consts/sicode.h" diff --git a/third_party/python/Modules/zipimport.c b/third_party/python/Modules/zipimport.c index aa9658b29..dfcf8d8f4 100644 --- a/third_party/python/Modules/zipimport.c +++ b/third_party/python/Modules/zipimport.c @@ -7,6 +7,7 @@ #include "libc/bits/bits.h" #include "libc/calls/calls.h" #include "libc/calls/weirdtypes.h" +#include "libc/sysv/consts/s.h" #include "libc/time/struct/tm.h" #include "libc/time/time.h" #include "third_party/python/Include/abstract.h" diff --git a/third_party/python/Python/getsig.c b/third_party/python/Python/getsig.c index f9c153134..c93dcfe74 100644 --- a/third_party/python/Python/getsig.c +++ b/third_party/python/Python/getsig.c @@ -5,7 +5,6 @@ │ https://docs.python.org/3/license.html │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/sigaction.h" #include "third_party/python/Include/pydebug.h" #include "third_party/python/Include/pylifecycle.h" diff --git a/third_party/python/Python/pylifecycle.c b/third_party/python/Python/pylifecycle.c index cdc0abdfa..546c9361e 100644 --- a/third_party/python/Python/pylifecycle.c +++ b/third_party/python/Python/pylifecycle.c @@ -7,7 +7,6 @@ #include "libc/assert.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" -#include "libc/calls/sigbits.h" #include "libc/dce.h" #include "libc/fmt/conv.h" #include "libc/log/check.h" diff --git a/third_party/python/Python/sysmodule.c b/third_party/python/Python/sysmodule.c index 12852cac9..512de60b4 100644 --- a/third_party/python/Python/sysmodule.c +++ b/third_party/python/Python/sysmodule.c @@ -13,6 +13,7 @@ #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" #include "libc/sysv/consts/exit.h" +#include "libc/sysv/consts/s.h" #include "libc/unicode/locale.h" #include "libc/x/x.h" #include "third_party/python/Include/abstract.h" diff --git a/third_party/python/runpythonmodule.c b/third_party/python/runpythonmodule.c index 52f4e5f46..22c139eb7 100644 --- a/third_party/python/runpythonmodule.c +++ b/third_party/python/runpythonmodule.c @@ -10,7 +10,6 @@ #include "libc/bits/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/siginfo.h" #include "libc/calls/struct/sigset.h" #include "libc/calls/ucontext.h" diff --git a/third_party/quickjs/quickjs-libc.c b/third_party/quickjs/quickjs-libc.c index de6269ab5..9428b29c6 100644 --- a/third_party/quickjs/quickjs-libc.c +++ b/third_party/quickjs/quickjs-libc.c @@ -26,6 +26,7 @@ #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/ioctl.h" +#include "libc/calls/struct/dirent.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/winsize.h" #include "libc/calls/termios.h" @@ -42,6 +43,7 @@ #include "libc/str/str.h" #include "libc/sysv/consts/clock.h" #include "libc/sysv/consts/o.h" +#include "libc/sysv/consts/s.h" #include "libc/sysv/consts/termios.h" #include "libc/sysv/consts/w.h" #include "libc/time/time.h" diff --git a/third_party/sqlite3/os_unix.c b/third_party/sqlite3/os_unix.c index e84cb8e1d..48d01a1ef 100644 --- a/third_party/sqlite3/os_unix.c +++ b/third_party/sqlite3/os_unix.c @@ -46,6 +46,8 @@ */ #include "libc/rand/rand.h" #include "libc/sysv/consts/lock.h" +#include "libc/calls/struct/stat.h" +#include "libc/sysv/consts/s.h" #include "third_party/sqlite3/sqliteInt.inc" #if SQLITE_OS_UNIX /* This file is used on unix only */ diff --git a/third_party/sqlite3/shell.c b/third_party/sqlite3/shell.c index b49460ef6..9424f7c5f 100644 --- a/third_party/sqlite3/shell.c +++ b/third_party/sqlite3/shell.c @@ -94,6 +94,10 @@ #include "libc/calls/struct/stat.macros.h" #include "tool/args/args.h" #include "tool/args/args.h" +#include "libc/calls/struct/rusage.h" +#include "libc/sysv/consts/rusage.h" +#include "libc/calls/struct/stat.h" +#include "libc/sysv/consts/s.h" #include "third_party/sqlite3/sqlite3.h" typedef sqlite3_int64 i64; @@ -105,7 +109,6 @@ typedef unsigned char u8; #include "libc/str/str.h" #if !defined(_WIN32) && !defined(WIN32) -#include "libc/calls/sigbits.h" #if !defined(__RTP__) && !defined(_WRS_KERNEL) #include "third_party/musl/passwd.h" #endif @@ -1795,7 +1798,6 @@ SQLITE_EXTENSION_INIT1 #include "libc/calls/weirdtypes.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" -#include "libc/calls/sigbits.h" #include "libc/isystem/unistd.h" #include "libc/time/time.h" #include "libc/errno.h" diff --git a/third_party/zip/tailor.h b/third_party/zip/tailor.h index 0f6c62af9..b259295d2 100644 --- a/third_party/zip/tailor.h +++ b/third_party/zip/tailor.h @@ -37,6 +37,7 @@ #endif #include "libc/str/str.h" +#include "libc/calls/struct/stat.h" #include "third_party/zip/osdep.h" diff --git a/third_party/zip/unix.c b/third_party/zip/unix.c index 7bc237579..df40bf4fc 100644 --- a/third_party/zip/unix.c +++ b/third_party/zip/unix.c @@ -16,6 +16,7 @@ #include "libc/time/time.h" #include "libc/calls/struct/stat.macros.h" #include "libc/calls/calls.h" +#include "third_party/zip/osdep.h" #include "libc/sysv/consts/dt.h" #ifndef UTIL /* the companion #endif is a bit of ways down ... */ diff --git a/third_party/zlib/gz/gzread.c b/third_party/zlib/gz/gzread.c index c514a81af..7855a5149 100644 --- a/third_party/zlib/gz/gzread.c +++ b/third_party/zlib/gz/gzread.c @@ -1,6 +1,7 @@ #include "libc/calls/calls.h" #include "libc/errno.h" #include "libc/limits.h" +#include "libc/mem/mem.h" #include "libc/str/str.h" #include "third_party/zlib/gz/gzguts.inc" #include "third_party/zlib/zlib.h" diff --git a/tool/build/ar.c b/tool/build/ar.c index c33da4e07..9df2dc982 100644 --- a/tool/build/ar.c +++ b/tool/build/ar.c @@ -41,6 +41,7 @@ #include "libc/sysv/consts/map.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/prot.h" +#include "libc/sysv/consts/s.h" #include "libc/x/x.h" #include "tool/build/lib/getargs.h" diff --git a/tool/build/compile.c b/tool/build/compile.c index a0a2d891e..43229b237 100644 --- a/tool/build/compile.c +++ b/tool/build/compile.c @@ -22,8 +22,8 @@ #include "libc/calls/calls.h" #include "libc/calls/copyfile.h" #include "libc/calls/ioctl.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/itimerval.h" +#include "libc/calls/struct/rlimit.h" #include "libc/calls/struct/rusage.h" #include "libc/calls/struct/sigset.h" #include "libc/calls/struct/stat.h" @@ -51,6 +51,7 @@ #include "libc/sysv/consts/itimer.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/rlimit.h" +#include "libc/sysv/consts/s.h" #include "libc/sysv/consts/sa.h" #include "libc/sysv/consts/sig.h" #include "libc/sysv/consts/termios.h" diff --git a/tool/build/cp.c b/tool/build/cp.c index f8c41dac7..1431301f2 100644 --- a/tool/build/cp.c +++ b/tool/build/cp.c @@ -31,6 +31,7 @@ #include "libc/sysv/consts/ex.h" #include "libc/sysv/consts/exit.h" #include "libc/sysv/consts/ok.h" +#include "libc/sysv/consts/s.h" #include "libc/x/x.h" #include "third_party/getopt/getopt.h" #include "third_party/musl/ftw.h" diff --git a/tool/build/deltaify.c b/tool/build/deltaify.c index c2d420525..f9384a894 100644 --- a/tool/build/deltaify.c +++ b/tool/build/deltaify.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/siginfo.h" #include "libc/calls/ucontext.h" diff --git a/tool/build/jail.c b/tool/build/jail.c index f00ff37e0..f0a008d4a 100644 --- a/tool/build/jail.c +++ b/tool/build/jail.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/filter.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/siginfo.h" diff --git a/tool/build/lib/elfwriter_zip.c b/tool/build/lib/elfwriter_zip.c index 79e2e7971..9edf233de 100644 --- a/tool/build/lib/elfwriter_zip.c +++ b/tool/build/lib/elfwriter_zip.c @@ -28,6 +28,7 @@ #include "libc/nt/enum/fileflagandattributes.h" #include "libc/rand/rand.h" #include "libc/runtime/gc.internal.h" +#include "libc/sysv/consts/s.h" #include "libc/time/struct/tm.h" #include "libc/time/time.h" #include "libc/x/x.h" diff --git a/tool/build/lib/syscall.c b/tool/build/lib/syscall.c index 3960cfd31..50ce1f1c7 100644 --- a/tool/build/lib/syscall.c +++ b/tool/build/lib/syscall.c @@ -28,6 +28,8 @@ #include "libc/calls/struct/termios.h" #include "libc/calls/struct/timespec.h" #include "libc/calls/struct/timeval.h" +#include "libc/calls/struct/tms.h" +#include "libc/calls/struct/utsname.h" #include "libc/calls/struct/winsize.h" #include "libc/errno.h" #include "libc/fmt/fmt.h" diff --git a/tool/build/pstrace.c b/tool/build/pstrace.c index a9fde0694..c7efc8edd 100644 --- a/tool/build/pstrace.c +++ b/tool/build/pstrace.c @@ -18,7 +18,6 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/bits/bits.h" #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/sigset.h" #include "libc/errno.h" diff --git a/tool/build/runit.c b/tool/build/runit.c index 7ab830fed..41cf9f71b 100644 --- a/tool/build/runit.c +++ b/tool/build/runit.c @@ -20,8 +20,8 @@ #include "libc/bits/bits.h" #include "libc/bits/safemacros.internal.h" #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/flock.h" +#include "libc/calls/struct/stat.h" #include "libc/dce.h" #include "libc/dns/dns.h" #include "libc/fmt/conv.h" diff --git a/tool/build/runitd.c b/tool/build/runitd.c index 7bd594dc7..588446d11 100644 --- a/tool/build/runitd.c +++ b/tool/build/runitd.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/bits/bits.h" #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" +#include "libc/calls/struct/stat.h" #include "libc/calls/struct/timeval.h" #include "libc/dce.h" #include "libc/errno.h" diff --git a/tool/build/strace.c b/tool/build/strace.c index f5d59a59d..383950e9a 100644 --- a/tool/build/strace.c +++ b/tool/build/strace.c @@ -19,7 +19,6 @@ #include "libc/assert.h" #include "libc/bits/bits.h" #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/iovec.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/siginfo.h" diff --git a/tool/build/unbundle.c b/tool/build/unbundle.c index 7614af4ac..b3b1bb874 100644 --- a/tool/build/unbundle.c +++ b/tool/build/unbundle.c @@ -24,6 +24,7 @@ #include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" +#include "libc/sysv/consts/s.h" #include "libc/x/x.h" #include "third_party/musl/ftw.h" diff --git a/tool/build/zipobj.c b/tool/build/zipobj.c index 1d92c2c1f..b4c1a1192 100644 --- a/tool/build/zipobj.c +++ b/tool/build/zipobj.c @@ -33,6 +33,7 @@ #include "libc/sysv/consts/map.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/prot.h" +#include "libc/sysv/consts/s.h" #include "libc/time/time.h" #include "libc/x/x.h" #include "libc/zip.h" diff --git a/tool/decode/zip2.c b/tool/decode/zip2.c index dcc88ada5..56c9eae35 100644 --- a/tool/decode/zip2.c +++ b/tool/decode/zip2.c @@ -18,6 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/bits/safemacros.internal.h" #include "libc/calls/calls.h" +#include "libc/calls/struct/stat.h" #include "libc/fmt/conv.h" #include "libc/log/check.h" #include "libc/log/log.h" diff --git a/tool/net/echo.c b/tool/net/echo.c index a1e36161c..a2c164966 100644 --- a/tool/net/echo.c +++ b/tool/net/echo.c @@ -23,6 +23,7 @@ #include "libc/rand/rand.h" #include "libc/runtime/runtime.h" #include "libc/sock/sock.h" +#include "libc/str/str.h" #include "libc/sysv/consts/af.h" #include "libc/sysv/consts/ipproto.h" #include "libc/sysv/consts/sock.h" diff --git a/tool/net/lunix.c b/tool/net/lunix.c index 51031d56b..4474c2542 100644 --- a/tool/net/lunix.c +++ b/tool/net/lunix.c @@ -21,7 +21,6 @@ #include "libc/calls/calls.h" #include "libc/calls/ioctl.h" #include "libc/calls/makedev.h" -#include "libc/calls/sigbits.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/bpf.h" #include "libc/calls/struct/dirent.h" diff --git a/tool/net/redbean.c b/tool/net/redbean.c index 8f329da0f..80fdf4354 100644 --- a/tool/net/redbean.c +++ b/tool/net/redbean.c @@ -21,7 +21,7 @@ #include "libc/calls/calls.h" #include "libc/calls/ioctl.h" #include "libc/calls/math.h" -#include "libc/calls/sigbits.h" +#include "libc/calls/struct/dirent.h" #include "libc/calls/struct/filter.h" #include "libc/calls/struct/flock.h" #include "libc/calls/struct/iovec.h" @@ -75,6 +75,7 @@ #include "libc/sysv/consts/pr.h" #include "libc/sysv/consts/prot.h" #include "libc/sysv/consts/rusage.h" +#include "libc/sysv/consts/s.h" #include "libc/sysv/consts/sa.h" #include "libc/sysv/consts/sig.h" #include "libc/sysv/consts/sock.h" diff --git a/tool/viz/basicidea.c b/tool/viz/basicidea.c index 009ee68f4..754f1b63b 100644 --- a/tool/viz/basicidea.c +++ b/tool/viz/basicidea.c @@ -19,6 +19,7 @@ #include "dsp/scale/scale.h" #include "libc/calls/calls.h" #include "libc/calls/ioctl.h" +#include "libc/calls/struct/stat.h" #include "libc/fmt/fmt.h" #include "libc/log/log.h" #include "libc/runtime/runtime.h" diff --git a/tool/viz/bf.c b/tool/viz/bf.c index 2b8433a9a..fa1a46eef 100644 --- a/tool/viz/bf.c +++ b/tool/viz/bf.c @@ -26,6 +26,7 @@ #include "libc/str/str.h" #include "libc/str/tpenc.h" #include "libc/sysv/consts/o.h" +#include "libc/sysv/consts/s.h" /** * @fileoverview BingFold - A Hexdump Tool diff --git a/tool/viz/lib/ycbcr2rgb3.c b/tool/viz/lib/ycbcr2rgb3.c index 9d1df4c04..dd157bfba 100644 --- a/tool/viz/lib/ycbcr2rgb3.c +++ b/tool/viz/lib/ycbcr2rgb3.c @@ -27,7 +27,6 @@ #include "dsp/scale/scale.h" #include "libc/bits/xmmintrin.internal.h" #include "libc/calls/calls.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/sigset.h" #include "libc/intrin/pmulhrsw.h" #include "libc/log/check.h" diff --git a/tool/viz/printimage.c b/tool/viz/printimage.c index 3bc47b4ed..53052a604 100644 --- a/tool/viz/printimage.c +++ b/tool/viz/printimage.c @@ -21,25 +21,16 @@ #include "dsp/scale/scale.h" #include "dsp/tty/quant.h" #include "dsp/tty/tty.h" -#include "libc/assert.h" -#include "libc/bits/bits.h" -#include "libc/bits/safemacros.internal.h" -#include "libc/calls/calls.h" #include "libc/calls/ioctl.h" #include "libc/calls/struct/stat.h" #include "libc/calls/struct/winsize.h" #include "libc/dce.h" #include "libc/fmt/conv.h" -#include "libc/limits.h" #include "libc/log/check.h" #include "libc/log/log.h" -#include "libc/macros.internal.h" -#include "libc/math.h" -#include "libc/mem/mem.h" -#include "libc/rand/rand.h" #include "libc/runtime/gc.internal.h" +#include "libc/runtime/runtime.h" #include "libc/stdio/stdio.h" -#include "libc/str/str.h" #include "libc/sysv/consts/ex.h" #include "libc/sysv/consts/exit.h" #include "libc/sysv/consts/fileno.h" @@ -48,7 +39,6 @@ #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/prot.h" #include "libc/sysv/consts/termios.h" -#include "libc/x/x.h" #include "third_party/getopt/getopt.h" #include "third_party/stb/stb_image.h" #include "tool/viz/lib/graphic.h" @@ -378,7 +368,7 @@ void WithImageFile(const char *path, CHECK_NE(-1, fstat(fd, &st)); CHECK_GT(st.st_size, 0); CHECK_LE(st.st_size, INT_MAX); - fadvise(fd, 0, 0, MADV_WILLNEED | MADV_SEQUENTIAL); + fadvise(fd, 0, st.st_size, MADV_WILLNEED | MADV_SEQUENTIAL); CHECK_NE(MAP_FAILED, (map = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0))); CHECK_NOTNULL( diff --git a/tool/viz/printvideo.c b/tool/viz/printvideo.c index 4f332b2dd..7c495cc67 100644 --- a/tool/viz/printvideo.c +++ b/tool/viz/printvideo.c @@ -32,7 +32,6 @@ #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/ioctl.h" -#include "libc/calls/sigbits.h" #include "libc/calls/struct/framebufferfixedscreeninfo.h" #include "libc/calls/struct/framebuffervirtualscreeninfo.h" #include "libc/calls/struct/iovec.h"