From 0ea0d33a770bed044b9001be0df9a413b3843820 Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Sat, 13 Aug 2022 13:11:56 -0700 Subject: [PATCH] Reduce build graph by another eight percent --- dsp/tty/ident.c | 5 +- dsp/tty/ttyraw.c | 1 - examples/ttyaudio.c | 3 +- libc/alg/alg.h | 0 libc/alg/arraylist.internal.h | 0 libc/alg/arraylist2.internal.h | 0 libc/calls/chdir-nt.c | 1 + libc/calls/clock.c | 24 +-- libc/calls/clock_getres.c | 1 + libc/calls/clock_gettime-nt.c | 1 - libc/calls/clock_gettime-xnu.c | 3 +- libc/calls/clock_gettime.c | 6 +- libc/calls/close-nt.c | 2 +- libc/calls/close.c | 3 +- libc/calls/dtime.c | 2 +- libc/calls/dup-nt.c | 3 +- libc/calls/execve-nt.greg.c | 2 +- libc/calls/fcntl-nt.c | 3 + libc/calls/fcntl.c | 2 +- libc/calls/fstat-sysv.c | 1 - libc/calls/fstat.c | 3 +- libc/calls/fstatat-nt.c | 2 +- libc/calls/fstatat-sysv.c | 1 - libc/calls/fstatat.c | 3 +- libc/calls/futimens.c | 2 +- libc/calls/geteuid.c | 2 +- libc/calls/getfiledescriptorsize.c | 3 +- libc/calls/getitimer.c | 2 +- libc/calls/getppid.c | 1 + libc/calls/getpriority.c | 1 + libc/calls/getrlimit.c | 2 +- libc/calls/getrusage-sysv.c | 4 +- libc/calls/getrusage.c | 3 +- libc/calls/gettimeofday-metal.c | 3 +- libc/calls/gettimeofday-nt.c | 1 - libc/calls/gettimeofday-xnu.c | 2 +- libc/calls/gettimeofday.c | 4 +- libc/calls/internal.h | 163 +----------------- libc/calls/interrupts-nt.c | 4 +- libc/calls/ioctl_default.c | 2 +- libc/calls/ioctl_siocgifconf-nt.c | 3 +- libc/calls/ioctl_siocgifconf.c | 5 +- libc/calls/ioctl_tcsets.c | 2 +- libc/calls/ioctl_tiocgwinsz-nt.c | 3 +- libc/calls/ioctl_tiocgwinsz.c | 1 + libc/calls/iovecsize.c | 1 - libc/calls/kemptyfd.c | 1 + libc/calls/lseek.c | 2 +- libc/calls/lutimes.c | 4 +- libc/calls/mremap-sysv.greg.c | 4 +- libc/calls/nanosleep-nt.c | 2 + libc/calls/nanosleep-xnu.c | 2 +- libc/calls/nanosleep.c | 2 +- libc/calls/now.c | 1 - libc/calls/ntaccesscheck.c | 4 +- libc/calls/oldbench.c | 7 +- libc/calls/openat-metal.c | 2 +- libc/calls/openat.c | 2 +- libc/calls/poll-metal.c | 3 +- libc/calls/poll-nt.c | 5 +- libc/calls/poll.c | 4 +- libc/calls/posix_openpt.c | 1 + libc/calls/prctl.c | 1 + libc/calls/pread.c | 3 +- libc/calls/preadv.c | 7 +- libc/calls/printfds.c | 1 + libc/calls/pwrite.c | 1 + libc/calls/pwritev.c | 5 +- libc/calls/raise.c | 1 - libc/calls/read-nt.c | 4 + libc/calls/read.c | 3 +- libc/calls/readansi.c | 1 + libc/calls/readv-metal.c | 4 +- libc/calls/readv-nt.c | 2 +- libc/calls/readv-serial.c | 3 +- libc/calls/readv.c | 6 +- libc/calls/reservefd.c | 2 +- libc/calls/rusage2linux.c | 3 +- libc/calls/sched_rr_get_interval.c | 1 + libc/calls/sched_setscheduler.c | 1 + libc/calls/setfsgid.c | 1 + libc/calls/setfsuid.c | 1 + libc/calls/setgid.c | 1 + libc/calls/setitimer.c | 2 +- libc/calls/setrlimit.c | 2 +- libc/calls/setuid.c | 1 + libc/calls/sig2.c | 2 + libc/calls/sigaction.c | 7 +- libc/calls/sigaltstack.c | 1 + libc/calls/sigchld-nt.c | 2 + libc/calls/sigenter-freebsd.c | 3 +- libc/calls/sigenter-netbsd.c | 3 +- libc/calls/sigenter-openbsd.c | 3 +- libc/calls/sigenter-xnu.c | 3 +- libc/calls/sigprocmask-sysv.greg.c | 3 +- libc/calls/sigprocmask.c | 3 +- libc/calls/sigqueue.c | 4 +- libc/calls/sigsuspend.c | 4 +- libc/calls/sigwinch-nt.c | 3 +- libc/calls/strace.internal.h | 4 - libc/calls/struct/dirent.h | 2 + libc/calls/struct/fd.internal.h | 36 ++++ libc/calls/struct/flock.h | 2 + libc/calls/struct/iovec.h | 7 +- libc/calls/struct/iovec.internal.h | 29 ++++ libc/calls/struct/itimerval.h | 5 + libc/calls/struct/itimerval.internal.h | 17 ++ libc/calls/struct/metastat.internal.h | 2 + libc/calls/struct/rlimit.h | 2 + libc/calls/struct/rlimit.internal.h | 17 ++ libc/calls/struct/rusage.h | 2 + libc/calls/struct/rusage.internal.h | 16 ++ libc/calls/struct/sched_param.internal.h | 13 ++ libc/calls/struct/sigaction.h | 10 +- libc/calls/struct/sigaction.internal.h | 13 ++ libc/calls/struct/sigaltstack.internal.h | 13 ++ libc/calls/struct/siginfo.h | 2 + libc/calls/struct/siginfo.internal.h | 15 ++ libc/calls/struct/sigset.h | 7 +- libc/calls/struct/sigset.internal.h | 18 ++ libc/calls/struct/sigval.h | 2 + libc/calls/struct/sigval.internal.h | 11 ++ libc/calls/struct/stat.h | 2 + libc/calls/struct/stat.internal.h | 20 +++ libc/calls/struct/sysinfo.h | 2 + libc/calls/struct/sysinfo.internal.h | 12 ++ libc/calls/struct/timespec.h | 22 ++- libc/calls/struct/timespec.internal.h | 25 +++ libc/calls/struct/timeval.h | 8 + libc/calls/struct/timeval.internal.h | 20 +++ libc/calls/struct/tms.h | 2 + libc/calls/struct/ucontext.internal.h | 13 ++ libc/calls/struct/utsname.h | 2 + libc/calls/struct/winsize.internal.h | 12 ++ libc/calls/sys_utimes_nt.c | 4 +- libc/calls/sysinfo.c | 2 +- libc/calls/touch.c | 2 +- libc/calls/typedef/sigaction_f.h | 10 -- libc/calls/typedef/sighandler_t.h | 8 - libc/calls/unveil.c | 2 +- libc/calls/utime.c | 2 +- libc/calls/utimensat-sysv.c | 6 +- libc/calls/utimensat-xnu.c | 2 +- libc/calls/utimensat.c | 3 +- libc/calls/utimes.c | 4 +- libc/calls/vdprintf.c | 2 +- libc/calls/vmsplice.c | 2 +- libc/calls/wait4-nt.c | 2 +- libc/calls/wait4-sysv.c | 3 +- libc/calls/wait4.c | 2 +- libc/calls/wincrash.c | 3 +- libc/calls/wincrash.internal.h | 14 ++ libc/calls/write-nt.c | 5 +- libc/calls/write.c | 3 +- libc/calls/writev-metal.c | 3 +- libc/calls/writev-nt.c | 3 +- libc/calls/writev-serial.c | 3 +- libc/calls/writev.c | 5 +- libc/calls/writevuninterruptible.c | 3 +- libc/fmt/fmt.c | 5 +- libc/fmt/vcscanf.c | 12 +- libc/intrin/describeflags.internal.h | 34 ---- libc/intrin/describerlimit.c | 1 + libc/intrin/describesigaction.c | 2 + libc/intrin/describesigset.c | 5 +- libc/intrin/describestat.c | 3 +- libc/intrin/describetimespec.c | 1 + libc/intrin/futex_wait.c | 1 + libc/isystem/time.h | 2 + libc/log/backtrace2.c | 9 +- libc/nt/struct/iovec.h | 2 + libc/nt/struct/securityattributes.h | 2 + libc/runtime/arch_prctl.c | 5 +- libc/runtime/fork-nt.c | 3 +- libc/runtime/getinterpreterexecutablename.c | 1 + libc/runtime/printargs.c | 1 + libc/sock/accept-sysv.c | 1 + libc/sock/accept4-sysv.c | 1 + libc/sock/accept4.c | 3 +- libc/sock/bind-sysv.c | 1 + libc/sock/bind.c | 2 +- libc/sock/connect-sysv.c | 1 + libc/sock/connect.c | 3 +- libc/sock/getpeername-sysv.c | 1 + libc/sock/getpeername.c | 3 +- libc/sock/getsockname-sysv.c | 1 + libc/sock/getsockname.c | 3 +- libc/sock/getsockopt.c | 1 + libc/sock/internal.h | 64 +------ libc/sock/listen-nt.c | 1 - libc/sock/recv-nt.c | 3 +- libc/sock/recv.c | 1 + libc/sock/recvfrom-nt.c | 1 + libc/sock/recvfrom.c | 3 + libc/sock/recvmsg.c | 5 +- libc/sock/select-nt.c | 3 +- libc/sock/send.c | 1 + libc/sock/sendfile.c | 2 +- libc/sock/sendmsg.c | 4 + libc/sock/sendto.c | 2 + libc/sock/sockaddr2bsd.c | 1 + libc/sock/sockaddr2linux.c | 1 + libc/sock/sockdebug.c | 1 + libc/sock/struct/msghdr.internal.h | 22 +++ libc/sock/struct/pollfd.internal.h | 13 ++ libc/sock/struct/sockaddr.internal.h | 51 ++++++ libc/sock/syscall_fd.internal.h | 4 +- libc/sock/syslog.c | 4 +- libc/stdio/dirstream.c | 4 +- libc/stdio/fwrite_unlocked.c | 1 + libc/str/getutf16.ncabi.c | 47 ----- libc/str/oldutf16.internal.h | 51 ------ libc/str/pututf16.ncabi.c | 60 ------- libc/str/str.h | 8 - libc/str/strcasecmp8to16.c | 31 ---- libc/str/strcmp8to16.c | 35 ---- libc/str/strcmp8to16i.internal.h | 30 ---- libc/str/strncasecmp8to16.c | 33 ---- libc/str/strncmp8to16.c | 37 ---- libc/str/strnwidth16.c | 17 +- libc/sysv/errfuns.h | 1 - libc/time/dsleep.c | 1 + libc/time/futimes.c | 3 +- libc/time/futimesat.c | 3 +- libc/time/struct/timezone.h | 2 + libc/time/struct/tm.h | 16 ++ libc/time/struct/utimbuf.h | 2 + libc/time/struct/utimbuf.internal.h | 11 ++ libc/time/time.h | 66 ++----- test/libc/calls/clock_gettime_test.c | 1 + test/libc/calls/read_test.c | 1 + test/libc/calls/setitimer_test.c | 1 + test/libc/calls/write_test.c | 1 + test/libc/intrin/describesigset_test.c | 1 + test/libc/str/getutf16_test.c | 51 ------ test/libc/str/pututf16_test.c | 78 --------- test/libc/str/strcmp_test.c | 15 +- third_party/lua/lunix.c | 3 +- third_party/python/Modules/_lsprof.c | 1 + third_party/python/Modules/_posixsubprocess.c | 1 + third_party/python/Modules/posixmodule.c | 8 +- third_party/python/Python/initstdio.c | 2 + third_party/quickjs/quickjs-libc.c | 3 +- third_party/sqlite3/os_unix.c | 1 + tool/build/blinkenlights.c | 5 +- tool/build/lib/syscall.c | 2 + tool/build/lib/time.c | 1 + tool/build/runit.c | 5 +- tool/scripts/explain-deps.py | 27 +++ 249 files changed, 889 insertions(+), 988 deletions(-) delete mode 100755 libc/alg/alg.h delete mode 100755 libc/alg/arraylist.internal.h delete mode 100755 libc/alg/arraylist2.internal.h create mode 100644 libc/calls/struct/fd.internal.h create mode 100644 libc/calls/struct/iovec.internal.h create mode 100644 libc/calls/struct/itimerval.internal.h create mode 100644 libc/calls/struct/rlimit.internal.h create mode 100644 libc/calls/struct/rusage.internal.h create mode 100644 libc/calls/struct/sched_param.internal.h create mode 100644 libc/calls/struct/sigaction.internal.h create mode 100644 libc/calls/struct/sigaltstack.internal.h create mode 100644 libc/calls/struct/siginfo.internal.h create mode 100644 libc/calls/struct/sigset.internal.h create mode 100644 libc/calls/struct/sigval.internal.h create mode 100644 libc/calls/struct/stat.internal.h create mode 100644 libc/calls/struct/sysinfo.internal.h create mode 100644 libc/calls/struct/timespec.internal.h create mode 100644 libc/calls/struct/timeval.internal.h create mode 100644 libc/calls/struct/ucontext.internal.h create mode 100644 libc/calls/struct/winsize.internal.h delete mode 100644 libc/calls/typedef/sigaction_f.h delete mode 100644 libc/calls/typedef/sighandler_t.h create mode 100644 libc/calls/wincrash.internal.h create mode 100644 libc/sock/struct/msghdr.internal.h create mode 100644 libc/sock/struct/pollfd.internal.h create mode 100644 libc/sock/struct/sockaddr.internal.h delete mode 100644 libc/str/getutf16.ncabi.c mode change 100644 => 100755 libc/str/oldutf16.internal.h delete mode 100644 libc/str/pututf16.ncabi.c delete mode 100644 libc/str/strcasecmp8to16.c delete mode 100644 libc/str/strcmp8to16.c delete mode 100644 libc/str/strcmp8to16i.internal.h delete mode 100644 libc/str/strncasecmp8to16.c delete mode 100644 libc/str/strncmp8to16.c create mode 100644 libc/time/struct/utimbuf.internal.h delete mode 100644 test/libc/str/getutf16_test.c delete mode 100644 test/libc/str/pututf16_test.c create mode 100755 tool/scripts/explain-deps.py diff --git a/dsp/tty/ident.c b/dsp/tty/ident.c index b335408bb..2d6a2dccd 100644 --- a/dsp/tty/ident.c +++ b/dsp/tty/ident.c @@ -17,12 +17,13 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "dsp/tty/tty.h" -#include "libc/intrin/safemacros.internal.h" -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/termios.h" #include "libc/dce.h" +#include "libc/errno.h" #include "libc/fmt/fmt.h" +#include "libc/intrin/safemacros.internal.h" +#include "libc/intrin/weaken.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/sock/sock.h" diff --git a/dsp/tty/ttyraw.c b/dsp/tty/ttyraw.c index 7d8b776bc..33b238a8d 100644 --- a/dsp/tty/ttyraw.c +++ b/dsp/tty/ttyraw.c @@ -22,7 +22,6 @@ #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/siginfo.h" #include "libc/calls/termios.h" -#include "libc/calls/typedef/sigaction_f.h" #include "libc/calls/ucontext.h" #include "libc/log/log.h" #include "libc/macros.internal.h" diff --git a/examples/ttyaudio.c b/examples/ttyaudio.c index 4fd6832f1..b17120b7a 100644 --- a/examples/ttyaudio.c +++ b/examples/ttyaudio.c @@ -8,10 +8,11 @@ ╚─────────────────────────────────────────────────────────────────*/ #endif #include "dsp/core/core.h" -#include "libc/intrin/bits.h" #include "libc/calls/calls.h" +#include "libc/calls/struct/itimerval.h" #include "libc/calls/struct/sigaction.h" #include "libc/fmt/nf32.h" +#include "libc/intrin/bits.h" #include "libc/log/check.h" #include "libc/macros.internal.h" #include "libc/mem/mem.h" diff --git a/libc/alg/alg.h b/libc/alg/alg.h deleted file mode 100755 index e69de29bb..000000000 diff --git a/libc/alg/arraylist.internal.h b/libc/alg/arraylist.internal.h deleted file mode 100755 index e69de29bb..000000000 diff --git a/libc/alg/arraylist2.internal.h b/libc/alg/arraylist2.internal.h deleted file mode 100755 index e69de29bb..000000000 diff --git a/libc/calls/chdir-nt.c b/libc/calls/chdir-nt.c index 3b213b25a..75a3e0ad0 100644 --- a/libc/calls/chdir-nt.c +++ b/libc/calls/chdir-nt.c @@ -17,6 +17,7 @@ │ 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/clock.c b/libc/calls/clock.c index e1094f7b4..9fcec2fa8 100644 --- a/libc/calls/clock.c +++ b/libc/calls/clock.c @@ -17,13 +17,13 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/struct/timespec.h" +#include "libc/dce.h" +#include "libc/fmt/conv.h" +#include "libc/nt/accounting.h" +#include "libc/nt/runtime.h" +#include "libc/nt/synchronization.h" #include "libc/sysv/consts/clock.h" #include "libc/time/time.h" -#include "libc/dce.h" -#include "libc/nt/synchronization.h" -#include "libc/nt/runtime.h" -#include "libc/nt/accounting.h" -#include "libc/fmt/conv.h" /** * Returns how much CPU program has consumed on time-sharing system. @@ -37,13 +37,15 @@ int64_t clock(void) { int64_t proc, total; // polyfill on Windows where CLOCK_PROCESS_CPUTIME_ID may be not available if (IsWindows() && CLOCK_PROCESS_CPUTIME_ID == -1) { - proc = GetCurrentProcess(); - if (!GetProcessTimes(proc, &creation_time, - &exit_time, &kernel_time, &user_time)) return -1; - total = ReadFileTime(kernel_time) + ReadFileTime(user_time); - ts = WindowsDurationToTimeSpec(total); + proc = GetCurrentProcess(); + if (!GetProcessTimes(proc, &creation_time, &exit_time, &kernel_time, + &user_time)) + return -1; + total = ReadFileTime(kernel_time) + ReadFileTime(user_time); + ts = WindowsDurationToTimeSpec(total); + } else if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) == -1) { + return -1; } - else if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) == -1) return -1; return ts.tv_sec * CLOCKS_PER_SEC + ts.tv_nsec / (1000000000 / CLOCKS_PER_SEC); } diff --git a/libc/calls/clock_getres.c b/libc/calls/clock_getres.c index 5258c2a36..9794258a7 100644 --- a/libc/calls/clock_getres.c +++ b/libc/calls/clock_getres.c @@ -18,6 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/asan.internal.h" #include "libc/calls/strace.internal.h" +#include "libc/calls/struct/timespec.internal.h" #include "libc/dce.h" #include "libc/intrin/describeflags.internal.h" #include "libc/sysv/consts/clock.h" diff --git a/libc/calls/clock_gettime-nt.c b/libc/calls/clock_gettime-nt.c index 109886601..3b6891286 100644 --- a/libc/calls/clock_gettime-nt.c +++ b/libc/calls/clock_gettime-nt.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/clock_gettime.internal.h" -#include "libc/calls/internal.h" #include "libc/fmt/conv.h" #include "libc/nt/struct/filetime.h" #include "libc/nt/synchronization.h" diff --git a/libc/calls/clock_gettime-xnu.c b/libc/calls/clock_gettime-xnu.c index 0c154c6bf..774fd9382 100644 --- a/libc/calls/clock_gettime-xnu.c +++ b/libc/calls/clock_gettime-xnu.c @@ -16,9 +16,8 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/calls.h" #include "libc/calls/clock_gettime.internal.h" -#include "libc/calls/internal.h" +#include "libc/calls/struct/timeval.internal.h" #include "libc/sysv/consts/clock.h" #include "libc/sysv/errfuns.h" diff --git a/libc/calls/clock_gettime.c b/libc/calls/clock_gettime.c index ed425cfe4..7a2431914 100644 --- a/libc/calls/clock_gettime.c +++ b/libc/calls/clock_gettime.c @@ -17,18 +17,18 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" -#include "libc/intrin/asmflag.h" -#include "libc/intrin/bits.h" #include "libc/calls/asan.internal.h" #include "libc/calls/clock_gettime.internal.h" -#include "libc/calls/internal.h" #include "libc/calls/state.internal.h" #include "libc/calls/strace.internal.h" +#include "libc/calls/struct/timespec.internal.h" #include "libc/calls/struct/timeval.h" #include "libc/calls/syscall_support-sysv.internal.h" #include "libc/dce.h" #include "libc/fmt/conv.h" #include "libc/intrin/asan.internal.h" +#include "libc/intrin/asmflag.h" +#include "libc/intrin/bits.h" #include "libc/intrin/describeflags.internal.h" #include "libc/mem/alloca.h" #include "libc/nt/synchronization.h" diff --git a/libc/calls/close-nt.c b/libc/calls/close-nt.c index 7b5182aec..0db63759d 100644 --- a/libc/calls/close-nt.c +++ b/libc/calls/close-nt.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/internal.h" +#include "libc/calls/struct/fd.internal.h" #include "libc/errno.h" #include "libc/nt/enum/filetype.h" #include "libc/nt/files.h" diff --git a/libc/calls/close.c b/libc/calls/close.c index 870e55f57..d73a1d86c 100644 --- a/libc/calls/close.c +++ b/libc/calls/close.c @@ -17,14 +17,15 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/state.internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/syscall-nt.internal.h" #include "libc/calls/syscall-sysv.internal.h" +#include "libc/dce.h" #include "libc/intrin/spinlock.h" +#include "libc/intrin/weaken.h" #include "libc/sock/syscall_fd.internal.h" #include "libc/sysv/errfuns.h" #include "libc/zipos/zipos.internal.h" diff --git a/libc/calls/dtime.c b/libc/calls/dtime.c index 685a5989f..7ccc41afa 100644 --- a/libc/calls/dtime.c +++ b/libc/calls/dtime.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/time/time.h" +#include "libc/calls/struct/timespec.h" /** * Returns seconds since epoch w/ high-precision. diff --git a/libc/calls/dup-nt.c b/libc/calls/dup-nt.c index 308a3eeb7..f20f5b90f 100644 --- a/libc/calls/dup-nt.c +++ b/libc/calls/dup-nt.c @@ -16,11 +16,12 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/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/spinlock.h" +#include "libc/intrin/weaken.h" #include "libc/nt/files.h" #include "libc/nt/runtime.h" #include "libc/sock/internal.h" diff --git a/libc/calls/execve-nt.greg.c b/libc/calls/execve-nt.greg.c index b24a06bb7..d7c565197 100644 --- a/libc/calls/execve-nt.greg.c +++ b/libc/calls/execve-nt.greg.c @@ -17,13 +17,13 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #define ShouldUseMsabiAttribute() 1 -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/ntspawn.h" #include "libc/calls/strace.internal.h" #include "libc/calls/syscall-nt.internal.h" #include "libc/intrin/kprintf.h" +#include "libc/intrin/weaken.h" #include "libc/mem/alloca.h" #include "libc/nt/accounting.h" #include "libc/nt/console.h" diff --git a/libc/calls/fcntl-nt.c b/libc/calls/fcntl-nt.c index 3eaf7fb6a..24c7b941e 100644 --- a/libc/calls/fcntl-nt.c +++ b/libc/calls/fcntl-nt.c @@ -18,9 +18,12 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/calls/internal.h" +#include "libc/calls/struct/fd.internal.h" #include "libc/calls/struct/flock.h" #include "libc/calls/syscall-nt.internal.h" #include "libc/calls/syscall_support-nt.internal.h" +#include "libc/calls/wincrash.internal.h" +#include "libc/errno.h" #include "libc/intrin/cmpxchg.h" #include "libc/intrin/kprintf.h" #include "libc/macros.internal.h" diff --git a/libc/calls/fcntl.c b/libc/calls/fcntl.c index ae13e4b19..b840f8552 100644 --- a/libc/calls/fcntl.c +++ b/libc/calls/fcntl.c @@ -16,13 +16,13 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/syscall-nt.internal.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/dce.h" +#include "libc/intrin/weaken.h" #include "libc/sysv/errfuns.h" #include "libc/zipos/zipos.internal.h" diff --git a/libc/calls/fstat-sysv.c b/libc/calls/fstat-sysv.c index 22c4cd7f7..4e24e943b 100644 --- a/libc/calls/fstat-sysv.c +++ b/libc/calls/fstat-sysv.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/internal.h" #include "libc/calls/struct/metastat.internal.h" #include "libc/calls/struct/stat.h" #include "libc/calls/syscall-sysv.internal.h" diff --git a/libc/calls/fstat.c b/libc/calls/fstat.c index ed39ef4ab..b9a11d82b 100644 --- a/libc/calls/fstat.c +++ b/libc/calls/fstat.c @@ -16,13 +16,14 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" +#include "libc/calls/struct/stat.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" #include "libc/intrin/describeflags.internal.h" +#include "libc/intrin/weaken.h" #include "libc/sysv/errfuns.h" #include "libc/zipos/zipos.internal.h" diff --git a/libc/calls/fstatat-nt.c b/libc/calls/fstatat-nt.c index 853744b91..213e30605 100644 --- a/libc/calls/fstatat-nt.c +++ b/libc/calls/fstatat-nt.c @@ -16,8 +16,8 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/internal.h" #include "libc/calls/struct/stat.h" +#include "libc/calls/struct/stat.internal.h" #include "libc/calls/syscall_support-nt.internal.h" #include "libc/nt/createfile.h" #include "libc/nt/enum/accessmask.h" diff --git a/libc/calls/fstatat-sysv.c b/libc/calls/fstatat-sysv.c index 45a9f78f3..fcf2c825f 100644 --- a/libc/calls/fstatat-sysv.c +++ b/libc/calls/fstatat-sysv.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/internal.h" #include "libc/calls/struct/metastat.internal.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/dce.h" diff --git a/libc/calls/fstatat.c b/libc/calls/fstatat.c index 40c491c9b..0f446bf6d 100644 --- a/libc/calls/fstatat.c +++ b/libc/calls/fstatat.c @@ -16,17 +16,18 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/state.internal.h" #include "libc/calls/strace.internal.h" +#include "libc/calls/struct/stat.internal.h" #include "libc/dce.h" #include "libc/errno.h" #include "libc/fmt/itoa.h" #include "libc/intrin/asan.internal.h" #include "libc/intrin/describeflags.internal.h" #include "libc/intrin/kprintf.h" +#include "libc/intrin/weaken.h" #include "libc/log/log.h" #include "libc/mem/alloca.h" #include "libc/str/str.h" diff --git a/libc/calls/futimens.c b/libc/calls/futimens.c index 2341db68e..97dacd518 100644 --- a/libc/calls/futimens.c +++ b/libc/calls/futimens.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/time/time.h" +#include "libc/calls/struct/timespec.h" /** * Sets atime/mtime on file descriptor. diff --git a/libc/calls/geteuid.c b/libc/calls/geteuid.c index 19e829b27..00461f9f6 100644 --- a/libc/calls/geteuid.c +++ b/libc/calls/geteuid.c @@ -19,7 +19,7 @@ #include "libc/calls/calls.h" #include "libc/calls/strace.internal.h" #include "libc/calls/syscall-sysv.internal.h" -#include "libc/runtime/runtime.h" +#include "libc/dce.h" /** * Returns effective user ID of calling process. diff --git a/libc/calls/getfiledescriptorsize.c b/libc/calls/getfiledescriptorsize.c index 5b4e44043..098f6e9eb 100644 --- a/libc/calls/getfiledescriptorsize.c +++ b/libc/calls/getfiledescriptorsize.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" @@ -24,6 +23,8 @@ #include "libc/calls/struct/stat.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/dce.h" +#include "libc/errno.h" +#include "libc/intrin/weaken.h" #include "libc/limits.h" #include "libc/nt/enum/fileinfobyhandleclass.h" #include "libc/nt/files.h" diff --git a/libc/calls/getitimer.c b/libc/calls/getitimer.c index 0467eb522..c2a4612d1 100644 --- a/libc/calls/getitimer.c +++ b/libc/calls/getitimer.c @@ -17,9 +17,9 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/itimerval.h" +#include "libc/calls/struct/itimerval.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" #include "libc/sysv/errfuns.h" diff --git a/libc/calls/getppid.c b/libc/calls/getppid.c index 2d6c24133..a5a30613f 100644 --- a/libc/calls/getppid.c +++ b/libc/calls/getppid.c @@ -19,6 +19,7 @@ #include "libc/calls/strace.internal.h" #include "libc/calls/syscall-nt.internal.h" #include "libc/calls/syscall-sysv.internal.h" +#include "libc/dce.h" /** * Returns parent process id. diff --git a/libc/calls/getpriority.c b/libc/calls/getpriority.c index cdb20e624..0a8565ca8 100644 --- a/libc/calls/getpriority.c +++ b/libc/calls/getpriority.c @@ -20,6 +20,7 @@ #include "libc/calls/strace.internal.h" #include "libc/calls/syscall-nt.internal.h" #include "libc/calls/syscall-sysv.internal.h" +#include "libc/dce.h" /** * Returns nice value of thing. diff --git a/libc/calls/getrlimit.c b/libc/calls/getrlimit.c index ada1a7a04..6676a05c4 100644 --- a/libc/calls/getrlimit.c +++ b/libc/calls/getrlimit.c @@ -17,8 +17,8 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" +#include "libc/calls/struct/rlimit.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" #include "libc/intrin/describeflags.internal.h" diff --git a/libc/calls/getrusage-sysv.c b/libc/calls/getrusage-sysv.c index 4e3261c5e..0c82c5ce9 100644 --- a/libc/calls/getrusage-sysv.c +++ b/libc/calls/getrusage-sysv.c @@ -16,8 +16,8 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/calls.h" -#include "libc/calls/internal.h" +#include "libc/calls/struct/rusage.h" +#include "libc/calls/struct/rusage.internal.h" #include "libc/sysv/errfuns.h" /** diff --git a/libc/calls/getrusage.c b/libc/calls/getrusage.c index 68dc2151b..c15865e5c 100644 --- a/libc/calls/getrusage.c +++ b/libc/calls/getrusage.c @@ -17,8 +17,9 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" +#include "libc/calls/struct/rusage.h" +#include "libc/calls/struct/rusage.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" #include "libc/sysv/errfuns.h" diff --git a/libc/calls/gettimeofday-metal.c b/libc/calls/gettimeofday-metal.c index 0d4ba83a3..f733f0e70 100644 --- a/libc/calls/gettimeofday-metal.c +++ b/libc/calls/gettimeofday-metal.c @@ -16,7 +16,8 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/internal.h" +#include "libc/calls/struct/timeval.internal.h" +#include "libc/time/struct/timezone.h" axdx_t sys_gettimeofday_metal(struct timeval *tv, struct timezone *tz, void *wut) { diff --git a/libc/calls/gettimeofday-nt.c b/libc/calls/gettimeofday-nt.c index 88a28c48f..6432e2ba7 100644 --- a/libc/calls/gettimeofday-nt.c +++ b/libc/calls/gettimeofday-nt.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/internal.h" #include "libc/fmt/conv.h" #include "libc/nt/struct/filetime.h" #include "libc/nt/synchronization.h" diff --git a/libc/calls/gettimeofday-xnu.c b/libc/calls/gettimeofday-xnu.c index b9d07a267..4a6c138bd 100644 --- a/libc/calls/gettimeofday-xnu.c +++ b/libc/calls/gettimeofday-xnu.c @@ -16,7 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/internal.h" +#include "libc/calls/struct/timeval.internal.h" axdx_t sys_gettimeofday_xnu(struct timeval *tv, struct timezone *tz, void *wut) { diff --git a/libc/calls/gettimeofday.c b/libc/calls/gettimeofday.c index 1dee86c96..ab64bf4c5 100644 --- a/libc/calls/gettimeofday.c +++ b/libc/calls/gettimeofday.c @@ -17,17 +17,17 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" -#include "libc/calls/internal.h" #include "libc/calls/state.internal.h" #include "libc/calls/strace.internal.h" +#include "libc/calls/struct/itimerval.internal.h" #include "libc/calls/struct/timeval.h" +#include "libc/calls/struct/timeval.internal.h" #include "libc/calls/syscall_support-sysv.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" #include "libc/intrin/describeflags.internal.h" #include "libc/sysv/errfuns.h" #include "libc/time/struct/timezone.h" -#include "libc/time/time.h" typedef axdx_t gettimeofday_f(struct timeval *, struct timezone *, void *); diff --git a/libc/calls/internal.h b/libc/calls/internal.h index e531146f7..df73d7599 100644 --- a/libc/calls/internal.h +++ b/libc/calls/internal.h @@ -1,34 +1,9 @@ #ifndef COSMOPOLITAN_LIBC_CALLS_INTERNAL_H_ #define COSMOPOLITAN_LIBC_CALLS_INTERNAL_H_ -#include "libc/calls/calls.h" -#include "libc/calls/struct/iovec.h" -#include "libc/calls/struct/itimerval.h" -#include "libc/calls/struct/metastat.internal.h" -#include "libc/calls/struct/rlimit.h" -#include "libc/calls/struct/rusage.h" -#include "libc/calls/struct/sigaction-xnu.internal.h" -#include "libc/calls/struct/siginfo-xnu.internal.h" -#include "libc/calls/struct/siginfo.h" +#include "libc/calls/struct/fd.internal.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" -#include "libc/calls/ucontext.h" #include "libc/dce.h" -#include "libc/limits.h" #include "libc/macros.internal.h" -#include "libc/nt/struct/context.h" -#include "libc/nt/struct/ntexceptionpointers.h" -#include "libc/nt/struct/overlapped.h" -#include "libc/nt/struct/securityattributes.h" -#include "libc/nt/struct/startupinfo.h" -#include "libc/nt/struct/systeminfo.h" -#include "libc/nt/struct/win32fileattributedata.h" -#include "libc/runtime/runtime.h" -#include "libc/time/struct/timezone.h" -#include "libc/time/struct/utimbuf.h" #define kSigactionMinRva 8 /* >SIG_{ERR,DFL,IGN,...} */ @@ -44,34 +19,6 @@ struct IoctlPtmGet { char workername[16]; }; -enum FdKind { - kFdEmpty, - kFdFile, - kFdSocket, - kFdProcess, - kFdConsole, - kFdSerial, - kFdZip, - kFdEpoll, - kFdReserved -}; - -struct Fd { - enum FdKind kind; - unsigned flags; - unsigned mode; - int64_t handle; - int64_t extra; - bool zombie; -}; - -struct Fds { - int f; /* lowest free slot */ - size_t n; /* monotonic capacity */ - struct Fd *p; - struct Fd __init_p[OPEN_MAX]; -}; - hidden extern struct Fds g_fds; hidden extern const struct Fd kEmptyFd; @@ -103,118 +50,10 @@ forceinline size_t _clampio(size_t size) { } } -#define i32 int32_t -#define i64 int64_t -#define u32 uint32_t -#define u64 uint64_t -#define sigset struct sigset - -/*───────────────────────────────────────────────────────────────────────────│─╗ -│ cosmopolitan § syscalls » system five » synthetic jump slots ─╬─│┼ -╚────────────────────────────────────────────────────────────────────────────│*/ - -axdx_t sys_gettimeofday(struct timeval *, struct timezone *, void *) hidden; -i32 __sys_getrusage(i32, struct rusage *) hidden; -i32 __sys_sigprocmask(i32, const sigset *, sigset *, u64) hidden; -i32 __sys_utimensat(i32, const char *, const struct timespec *, i32) hidden; -i32 __sys_wait4(i32, i32 *, i32, struct rusage *) hidden; -i32 sys_clock_gettime(i32, struct timespec *) hidden; -i32 sys_clock_gettime_xnu(i32, struct timespec *) hidden; -i32 sys_fstat(i32, struct stat *) hidden; -i32 sys_fstatat(i32, const char *, struct stat *, i32) hidden; -i32 sys_futimes(i32, const struct timeval *) hidden; -i32 sys_futimens(i32, const struct timespec *) hidden; -i32 sys_futimesat(i32, const char *, const struct timeval *) hidden; -i32 sys_getitimer(i32, struct itimerval *) hidden; -i32 sys_getrlimit(i32, struct rlimit *) hidden; -i32 sys_getrusage(i32, struct rusage *) hidden; -i32 sys_lutimes(const char *, const struct timeval *) hidden; -i32 sys_nanosleep(const struct timespec *, struct timespec *) hidden; -i32 sys_setitimer(i32, const struct itimerval *, struct itimerval *) hidden; -i32 sys_setrlimit(i32, const struct rlimit *) hidden; -i32 sys_sigprocmask(i32, const sigset *, sigset *) hidden; -i32 sys_sigqueue(i32, i32, const union sigval) hidden; -i32 sys_sigqueueinfo(i32, const siginfo_t *) hidden; -i32 sys_sigsuspend(const sigset *, u64) hidden; -i32 sys_sysinfo(struct sysinfo *) hidden; -i32 sys_utime(const char *, const struct utimbuf *) hidden; -i32 sys_utimensat(i32, const char *, const struct timespec *, i32) hidden; -i32 sys_utimes(const char *, const struct timeval *) hidden; -i32 sys_wait4(i32, i32 *, i32, struct rusage *) hidden; -i64 sys_preadv(i32, struct iovec *, i32, i64, i64) hidden; -i64 sys_pwritev(i32, const struct iovec *, i32, i64, i64) hidden; -i64 sys_vmsplice(i32, const struct iovec *, i64, u32) hidden; - -/*───────────────────────────────────────────────────────────────────────────│─╗ -│ cosmopolitan § syscalls » system five » support ─╬─│┼ -╚────────────────────────────────────────────────────────────────────────────│*/ - -int sys_nanosleep_xnu(const struct timespec *, struct timespec *) hidden; -int sys_utimensat_xnu(int, const char *, const struct timespec *, int) hidden; -size_t __iovec_size(const struct iovec *, size_t) hidden; -ssize_t WritevUninterruptible(int, struct iovec *, int); -void __rusage2linux(struct rusage *) hidden; -void __sigenter_xnu(void *, i32, i32, struct siginfo_xnu *, - struct __darwin_ucontext *) hidden; -void __stat2cosmo(struct stat *restrict, const union metastat *) hidden; -axdx_t sys_gettimeofday_xnu(struct timeval *, struct timezone *, void *) hidden; - -/*───────────────────────────────────────────────────────────────────────────│─╗ -│ cosmopolitan § syscalls » windows nt » veneers ─╬─│┼ -╚────────────────────────────────────────────────────────────────────────────│*/ - -axdx_t sys_gettimeofday_nt(struct timeval *, struct timezone *, void *) hidden; -int ioctl_tiocgwinsz_nt(struct Fd *, struct winsize *) hidden; int sys_close_nt(struct Fd *) hidden; -int sys_fstat_nt(i64, struct stat *) hidden; -int sys_fstatat_nt(int, const char *, struct stat *, int) hidden; -int sys_getrusage_nt(int, struct rusage *) hidden; -int sys_lstat_nt(const char *, struct stat *) hidden; -int sys_nanosleep_nt(const struct timespec *, struct timespec *) hidden; -int sys_setitimer_nt(int, const struct itimerval *, struct itimerval *) hidden; -int sys_setrlimit_nt(int, const struct rlimit *) hidden; -int sys_sysinfo_nt(struct sysinfo *) hidden; -int sys_utimensat_nt(int, const char *, const struct timespec *, int) hidden; -int sys_utimes_nt(const char *, const struct timeval[2]) hidden; -ssize_t sys_read_nt(struct Fd *, const struct iovec *, size_t, ssize_t) hidden; -ssize_t sys_write_nt(int, const struct iovec *, size_t, ssize_t) hidden; - -/*───────────────────────────────────────────────────────────────────────────│─╗ -│ cosmopolitan § syscalls » windows nt » support ─╬─│┼ -╚────────────────────────────────────────────────────────────────────────────│*/ - bool _check_interrupts(bool, struct Fd *) hidden; -int sys_clock_gettime_nt(int, struct timespec *) hidden; -ssize_t sys_readv_nt(struct Fd *, const struct iovec *, int) hidden; -ssize_t sys_writev_nt(int, const struct iovec *, int) hidden; -unsigned __wincrash_nt(struct NtExceptionPointers *); -void _ntcontext2linux(struct ucontext *, const struct NtContext *) hidden; -void _ntlinux2context(struct NtContext *, const ucontext_t *) hidden; -struct NtOverlapped *_offset2overlap(int64_t, int64_t, - struct NtOverlapped *) hidden; - -/*───────────────────────────────────────────────────────────────────────────│─╗ -│ cosmopolitan § syscalls » metal ─╬─│┼ -╚────────────────────────────────────────────────────────────────────────────│*/ - -axdx_t sys_gettimeofday_metal(struct timeval *, struct timezone *, void *); -int sys_fstat_metal(int, struct stat *); int sys_openat_metal(int, const char *, int, unsigned); -ssize_t sys_readv_metal(struct Fd *, const struct iovec *, int) hidden; -ssize_t sys_writev_metal(struct Fd *, const struct iovec *, int) hidden; -/*───────────────────────────────────────────────────────────────────────────│─╗ -│ cosmopolitan § syscalls » drivers ─╬─│┼ -╚────────────────────────────────────────────────────────────────────────────│*/ - -ssize_t sys_readv_serial(struct Fd *, const struct iovec *, int) hidden; -ssize_t sys_writev_serial(struct Fd *, const struct iovec *, int) hidden; - -#undef sigset -#undef i32 -#undef i64 -#undef u32 -#undef u64 COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_INTERNAL_H_ */ diff --git a/libc/calls/interrupts-nt.c b/libc/calls/interrupts-nt.c index 5e99ee86d..82ccd8e6e 100644 --- a/libc/calls/interrupts-nt.c +++ b/libc/calls/interrupts-nt.c @@ -17,16 +17,16 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" -#include "libc/calls/internal.h" #include "libc/calls/sig.internal.h" #include "libc/calls/state.internal.h" #include "libc/calls/strace.internal.h" +#include "libc/calls/struct/fd.internal.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/syscall_support-nt.internal.h" #include "libc/dce.h" #include "libc/intrin/lockcmpxchgp.h" +#include "libc/intrin/weaken.h" #include "libc/nexgen32e/threaded.h" textwindows bool _check_interrupts(bool restartable, struct Fd *fd) { diff --git a/libc/calls/ioctl_default.c b/libc/calls/ioctl_default.c index f273d1d93..615f668db 100644 --- a/libc/calls/ioctl_default.c +++ b/libc/calls/ioctl_default.c @@ -16,11 +16,11 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/weaken.h" #include "libc/calls/internal.h" #include "libc/calls/ioctl.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/dce.h" +#include "libc/intrin/weaken.h" #include "libc/nt/winsock.h" #include "libc/sock/internal.h" #include "libc/sysv/errfuns.h" diff --git a/libc/calls/ioctl_siocgifconf-nt.c b/libc/calls/ioctl_siocgifconf-nt.c index 73613bc06..a0fc20a11 100644 --- a/libc/calls/ioctl_siocgifconf-nt.c +++ b/libc/calls/ioctl_siocgifconf-nt.c @@ -17,9 +17,10 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" +#include "libc/errno.h" #include "libc/intrin/cmpxchg.h" +#include "libc/intrin/weaken.h" #include "libc/mem/mem.h" #include "libc/nt/errors.h" #include "libc/nt/iphlpapi.h" diff --git a/libc/calls/ioctl_siocgifconf.c b/libc/calls/ioctl_siocgifconf.c index cc60ce0f7..0b6f6bb2a 100644 --- a/libc/calls/ioctl_siocgifconf.c +++ b/libc/calls/ioctl_siocgifconf.c @@ -17,11 +17,12 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" -#include "libc/intrin/bits.h" -#include "libc/intrin/weaken.h" #include "libc/calls/ioctl.h" #include "libc/calls/strace.internal.h" #include "libc/calls/syscall-sysv.internal.h" +#include "libc/dce.h" +#include "libc/intrin/bits.h" +#include "libc/intrin/weaken.h" #include "libc/macros.internal.h" #include "libc/mem/mem.h" #include "libc/sock/internal.h" diff --git a/libc/calls/ioctl_tcsets.c b/libc/calls/ioctl_tcsets.c index 280a913c3..13fd721d9 100644 --- a/libc/calls/ioctl_tcsets.c +++ b/libc/calls/ioctl_tcsets.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/weaken.h" #include "libc/calls/internal.h" #include "libc/calls/ioctl.h" #include "libc/calls/strace.internal.h" @@ -26,6 +25,7 @@ #include "libc/dce.h" #include "libc/intrin/asan.internal.h" #include "libc/intrin/nomultics.internal.h" +#include "libc/intrin/weaken.h" #include "libc/sysv/consts/termios.h" #include "libc/sysv/errfuns.h" diff --git a/libc/calls/ioctl_tiocgwinsz-nt.c b/libc/calls/ioctl_tiocgwinsz-nt.c index 75b8f3635..cb78168cb 100644 --- a/libc/calls/ioctl_tiocgwinsz-nt.c +++ b/libc/calls/ioctl_tiocgwinsz-nt.c @@ -16,15 +16,16 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/state.internal.h" #include "libc/calls/strace.internal.h" +#include "libc/calls/struct/fd.internal.h" #include "libc/calls/struct/termios.h" #include "libc/calls/struct/winsize.h" #include "libc/calls/syscall_support-nt.internal.h" #include "libc/intrin/spinlock.h" +#include "libc/intrin/weaken.h" #include "libc/log/log.h" #include "libc/nt/console.h" #include "libc/nt/enum/startf.h" diff --git a/libc/calls/ioctl_tiocgwinsz.c b/libc/calls/ioctl_tiocgwinsz.c index 62bc117ae..a6c941dce 100644 --- a/libc/calls/ioctl_tiocgwinsz.c +++ b/libc/calls/ioctl_tiocgwinsz.c @@ -20,6 +20,7 @@ #include "libc/calls/ioctl.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/winsize.h" +#include "libc/calls/struct/winsize.internal.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" diff --git a/libc/calls/iovecsize.c b/libc/calls/iovecsize.c index d4366a32c..810fcb46f 100644 --- a/libc/calls/iovecsize.c +++ b/libc/calls/iovecsize.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/internal.h" #include "libc/calls/struct/iovec.h" size_t __iovec_size(const struct iovec *v, size_t n) { diff --git a/libc/calls/kemptyfd.c b/libc/calls/kemptyfd.c index c32790cc9..01ce8bef0 100644 --- a/libc/calls/kemptyfd.c +++ b/libc/calls/kemptyfd.c @@ -17,5 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/internal.h" +#include "libc/calls/struct/fd.internal.h" hidden const struct Fd kEmptyFd; diff --git a/libc/calls/lseek.c b/libc/calls/lseek.c index b5f1e5bb0..e0c31cd8e 100644 --- a/libc/calls/lseek.c +++ b/libc/calls/lseek.c @@ -16,13 +16,13 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/syscall-nt.internal.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/dce.h" +#include "libc/intrin/weaken.h" #include "libc/log/backtrace.internal.h" #include "libc/zipos/zipos.internal.h" diff --git a/libc/calls/lutimes.c b/libc/calls/lutimes.c index 878782e78..956bf330f 100644 --- a/libc/calls/lutimes.c +++ b/libc/calls/lutimes.c @@ -16,10 +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/timespec.h" +#include "libc/calls/struct/timeval.h" #include "libc/dce.h" #include "libc/sysv/consts/at.h" -#include "libc/time/time.h" /** * Changes file timestamps, the legacy way. diff --git a/libc/calls/mremap-sysv.greg.c b/libc/calls/mremap-sysv.greg.c index bda07dd1b..ef22790a3 100644 --- a/libc/calls/mremap-sysv.greg.c +++ b/libc/calls/mremap-sysv.greg.c @@ -16,9 +16,11 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/asmflag.h" #include "libc/calls/calls.h" #include "libc/calls/strace.internal.h" +#include "libc/dce.h" +#include "libc/errno.h" +#include "libc/intrin/asmflag.h" #include "libc/sysv/consts/map.h" #include "libc/sysv/consts/mremap.h" #include "libc/sysv/errfuns.h" diff --git a/libc/calls/nanosleep-nt.c b/libc/calls/nanosleep-nt.c index dc77434d0..fe260dd2b 100644 --- a/libc/calls/nanosleep-nt.c +++ b/libc/calls/nanosleep-nt.c @@ -21,6 +21,8 @@ #include "libc/calls/sig.internal.h" #include "libc/calls/state.internal.h" #include "libc/calls/strace.internal.h" +#include "libc/calls/struct/timespec.internal.h" +#include "libc/limits.h" #include "libc/macros.internal.h" #include "libc/nexgen32e/rdtsc.h" #include "libc/nt/errors.h" diff --git a/libc/calls/nanosleep-xnu.c b/libc/calls/nanosleep-xnu.c index ce6818c97..bc37cd02e 100644 --- a/libc/calls/nanosleep-xnu.c +++ b/libc/calls/nanosleep-xnu.c @@ -16,8 +16,8 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/internal.h" #include "libc/calls/struct/timespec.h" +#include "libc/calls/struct/timespec.internal.h" #include "libc/calls/struct/timeval.h" #include "libc/errno.h" #include "libc/fmt/conv.h" diff --git a/libc/calls/nanosleep.c b/libc/calls/nanosleep.c index c9ca75452..9c9f4b949 100644 --- a/libc/calls/nanosleep.c +++ b/libc/calls/nanosleep.c @@ -18,9 +18,9 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/asan.internal.h" #include "libc/calls/calls.h" -#include "libc/calls/internal.h" #include "libc/calls/state.internal.h" #include "libc/calls/strace.internal.h" +#include "libc/calls/struct/timespec.internal.h" #include "libc/dce.h" #include "libc/intrin/describeflags.internal.h" #include "libc/sysv/errfuns.h" diff --git a/libc/calls/now.c b/libc/calls/now.c index b3ff3eea0..4a098aae3 100644 --- a/libc/calls/now.c +++ b/libc/calls/now.c @@ -22,7 +22,6 @@ #include "libc/intrin/safemacros.internal.h" #include "libc/calls/calls.h" #include "libc/calls/clock_gettime.internal.h" -#include "libc/calls/internal.h" #include "libc/calls/state.internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/syscall_support-sysv.internal.h" diff --git a/libc/calls/ntaccesscheck.c b/libc/calls/ntaccesscheck.c index a895f470f..05afa9806 100644 --- a/libc/calls/ntaccesscheck.c +++ b/libc/calls/ntaccesscheck.c @@ -16,11 +16,13 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/strace.internal.h" #include "libc/calls/syscall_support-nt.internal.h" +#include "libc/dce.h" +#include "libc/errno.h" #include "libc/fmt/fmt.h" +#include "libc/intrin/weaken.h" #include "libc/mem/mem.h" #include "libc/nt/enum/accessmask.h" #include "libc/nt/enum/securityimpersonationlevel.h" diff --git a/libc/calls/oldbench.c b/libc/calls/oldbench.c index d501f24ab..34eaad6a5 100644 --- a/libc/calls/oldbench.c +++ b/libc/calls/oldbench.c @@ -16,13 +16,14 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/bits.h" -#include "libc/intrin/initializer.internal.h" -#include "libc/intrin/safemacros.internal.h" #include "libc/calls/calls.h" #include "libc/calls/state.internal.h" #include "libc/calls/strace.internal.h" +#include "libc/calls/struct/timespec.h" #include "libc/dce.h" +#include "libc/intrin/bits.h" +#include "libc/intrin/initializer.internal.h" +#include "libc/intrin/safemacros.internal.h" #include "libc/macros.internal.h" #include "libc/nexgen32e/rdtsc.h" #include "libc/nexgen32e/x86feature.h" diff --git a/libc/calls/openat-metal.c b/libc/calls/openat-metal.c index 120e2a278..9fed85fad 100644 --- a/libc/calls/openat-metal.c +++ b/libc/calls/openat-metal.c @@ -16,9 +16,9 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/weaken.h" #include "libc/calls/internal.h" #include "libc/calls/metalfile.internal.h" +#include "libc/intrin/weaken.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/str/str.h" diff --git a/libc/calls/openat.c b/libc/calls/openat.c index 10acd2f73..8b6c6db25 100644 --- a/libc/calls/openat.c +++ b/libc/calls/openat.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/state.internal.h" @@ -26,6 +25,7 @@ #include "libc/dce.h" #include "libc/intrin/asan.internal.h" #include "libc/intrin/describeflags.internal.h" +#include "libc/intrin/weaken.h" #include "libc/log/log.h" #include "libc/str/str.h" #include "libc/sysv/consts/at.h" diff --git a/libc/calls/poll-metal.c b/libc/calls/poll-metal.c index dfc5617ec..07ea98ced 100644 --- a/libc/calls/poll-metal.c +++ b/libc/calls/poll-metal.c @@ -16,12 +16,13 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/safemacros.internal.h" #include "libc/calls/internal.h" +#include "libc/intrin/safemacros.internal.h" #include "libc/nexgen32e/rdtsc.h" #include "libc/nexgen32e/uart.internal.h" #include "libc/runtime/pc.internal.h" #include "libc/sock/internal.h" +#include "libc/sock/struct/pollfd.h" #include "libc/sysv/consts/poll.h" int sys_poll_metal(struct pollfd *fds, size_t nfds, unsigned timeout_ms) { diff --git a/libc/calls/poll-nt.c b/libc/calls/poll-nt.c index 0c2f47a1a..c2fcd8f65 100644 --- a/libc/calls/poll-nt.c +++ b/libc/calls/poll-nt.c @@ -16,8 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/bits.h" -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/sig.internal.h" @@ -25,8 +23,10 @@ #include "libc/calls/strace.internal.h" #include "libc/calls/struct/sigaction.h" #include "libc/errno.h" +#include "libc/intrin/bits.h" #include "libc/intrin/kprintf.h" #include "libc/intrin/spinlock.h" +#include "libc/intrin/weaken.h" #include "libc/macros.internal.h" #include "libc/mem/mem.h" #include "libc/nt/enum/filetype.h" @@ -38,6 +38,7 @@ #include "libc/nt/synchronization.h" #include "libc/nt/winsock.h" #include "libc/sock/internal.h" +#include "libc/sock/struct/pollfd.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/poll.h" #include "libc/sysv/consts/sig.h" diff --git a/libc/calls/poll.c b/libc/calls/poll.c index 65da4ac1b..ffc140c80 100644 --- a/libc/calls/poll.c +++ b/libc/calls/poll.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/likely.h" #include "libc/calls/calls.h" #include "libc/calls/strace.internal.h" #include "libc/dce.h" @@ -24,9 +23,12 @@ #include "libc/intrin/asan.internal.h" #include "libc/intrin/describeflags.internal.h" #include "libc/intrin/kprintf.h" +#include "libc/intrin/likely.h" #include "libc/macros.internal.h" #include "libc/sock/internal.h" #include "libc/sock/sock.h" +#include "libc/sock/struct/pollfd.h" +#include "libc/sock/struct/pollfd.internal.h" #include "libc/sysv/errfuns.h" /** diff --git a/libc/calls/posix_openpt.c b/libc/calls/posix_openpt.c index 93bd3309f..09047ed45 100644 --- a/libc/calls/posix_openpt.c +++ b/libc/calls/posix_openpt.c @@ -16,6 +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/internal.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/calls/termios.h" diff --git a/libc/calls/prctl.c b/libc/calls/prctl.c index f3dd571f1..1d9c9caab 100644 --- a/libc/calls/prctl.c +++ b/libc/calls/prctl.c @@ -18,6 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/calls/strace.internal.h" +#include "libc/dce.h" #include "libc/errno.h" #include "libc/intrin/describeflags.internal.h" #include "libc/sysv/consts/pr.h" diff --git a/libc/calls/pread.c b/libc/calls/pread.c index a96f14f2e..f004744f1 100644 --- a/libc/calls/pread.c +++ b/libc/calls/pread.c @@ -17,14 +17,15 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/iovec.h" +#include "libc/calls/struct/iovec.internal.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" +#include "libc/intrin/weaken.h" #include "libc/macros.internal.h" #include "libc/runtime/runtime.h" #include "libc/sysv/errfuns.h" diff --git a/libc/calls/preadv.c b/libc/calls/preadv.c index fd3a7e13a..25ec37f4c 100644 --- a/libc/calls/preadv.c +++ b/libc/calls/preadv.c @@ -16,20 +16,21 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/bits.h" -#include "libc/intrin/likely.h" -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/state.internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/iovec.h" +#include "libc/calls/struct/iovec.internal.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/dce.h" #include "libc/errno.h" #include "libc/intrin/asan.internal.h" +#include "libc/intrin/bits.h" #include "libc/intrin/describeflags.internal.h" #include "libc/intrin/kprintf.h" +#include "libc/intrin/likely.h" +#include "libc/intrin/weaken.h" #include "libc/macros.internal.h" #include "libc/sysv/consts/iov.h" #include "libc/sysv/errfuns.h" diff --git a/libc/calls/printfds.c b/libc/calls/printfds.c index 9600a43c2..e716f0382 100644 --- a/libc/calls/printfds.c +++ b/libc/calls/printfds.c @@ -18,6 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/internal.h" #include "libc/calls/state.internal.h" +#include "libc/calls/struct/fd.internal.h" #include "libc/intrin/kprintf.h" #include "libc/intrin/spinlock.h" diff --git a/libc/calls/pwrite.c b/libc/calls/pwrite.c index ed3cefd71..dd275ba1b 100644 --- a/libc/calls/pwrite.c +++ b/libc/calls/pwrite.c @@ -21,6 +21,7 @@ #include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/iovec.h" +#include "libc/calls/struct/iovec.internal.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" diff --git a/libc/calls/pwritev.c b/libc/calls/pwritev.c index 00f806912..120da1dba 100644 --- a/libc/calls/pwritev.c +++ b/libc/calls/pwritev.c @@ -16,18 +16,19 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/likely.h" -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/iovec.h" +#include "libc/calls/struct/iovec.internal.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/dce.h" #include "libc/errno.h" #include "libc/intrin/asan.internal.h" #include "libc/intrin/describeflags.internal.h" #include "libc/intrin/kprintf.h" +#include "libc/intrin/likely.h" +#include "libc/intrin/weaken.h" #include "libc/macros.internal.h" #include "libc/sysv/consts/iov.h" #include "libc/sysv/errfuns.h" diff --git a/libc/calls/raise.c b/libc/calls/raise.c index 3feddc9a7..81705058d 100644 --- a/libc/calls/raise.c +++ b/libc/calls/raise.c @@ -18,7 +18,6 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/calls/getconsolectrlevent.internal.h" -#include "libc/calls/internal.h" #include "libc/calls/sig.internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/sigset.h" diff --git a/libc/calls/read-nt.c b/libc/calls/read-nt.c index 6bbc9ded3..9f529b94a 100644 --- a/libc/calls/read-nt.c +++ b/libc/calls/read-nt.c @@ -19,7 +19,11 @@ #include "libc/calls/internal.h" #include "libc/calls/sig.internal.h" #include "libc/calls/strace.internal.h" +#include "libc/calls/struct/fd.internal.h" +#include "libc/calls/struct/iovec.h" +#include "libc/calls/struct/iovec.internal.h" #include "libc/calls/syscall_support-nt.internal.h" +#include "libc/calls/wincrash.internal.h" #include "libc/nt/enum/filetype.h" #include "libc/nt/errors.h" #include "libc/nt/files.h" diff --git a/libc/calls/read.c b/libc/calls/read.c index a15091e80..c09023c64 100644 --- a/libc/calls/read.c +++ b/libc/calls/read.c @@ -16,15 +16,16 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/iovec.h" +#include "libc/calls/struct/iovec.internal.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" #include "libc/intrin/kprintf.h" +#include "libc/intrin/weaken.h" #include "libc/sock/internal.h" #include "libc/sock/sock.h" #include "libc/sysv/errfuns.h" diff --git a/libc/calls/readansi.c b/libc/calls/readansi.c index 854ad59cd..be66fb0d3 100644 --- a/libc/calls/readansi.c +++ b/libc/calls/readansi.c @@ -17,6 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" +#include "libc/errno.h" #include "libc/str/thompike.h" #include "libc/sysv/errfuns.h" diff --git a/libc/calls/readv-metal.c b/libc/calls/readv-metal.c index 4215c95ad..bb2cf19bb 100644 --- a/libc/calls/readv-metal.c +++ b/libc/calls/readv-metal.c @@ -16,8 +16,10 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/internal.h" #include "libc/calls/metalfile.internal.h" +#include "libc/calls/struct/fd.internal.h" +#include "libc/calls/struct/iovec.h" +#include "libc/calls/struct/iovec.internal.h" #include "libc/macros.internal.h" #include "libc/str/str.h" #include "libc/sysv/errfuns.h" diff --git a/libc/calls/readv-nt.c b/libc/calls/readv-nt.c index 9dd2c4adb..a5e627d4b 100644 --- a/libc/calls/readv-nt.c +++ b/libc/calls/readv-nt.c @@ -16,8 +16,8 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/calls/struct/iovec.internal.h" #include "libc/intrin/weaken.h" -#include "libc/calls/internal.h" #include "libc/sock/internal.h" #include "libc/sock/syscall_fd.internal.h" #include "libc/sysv/errfuns.h" diff --git a/libc/calls/readv-serial.c b/libc/calls/readv-serial.c index 15fde98be..e1e9e4a93 100644 --- a/libc/calls/readv-serial.c +++ b/libc/calls/readv-serial.c @@ -16,7 +16,8 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/internal.h" +#include "libc/calls/struct/fd.internal.h" +#include "libc/calls/struct/iovec.internal.h" #include "libc/nexgen32e/uart.internal.h" #include "libc/runtime/pc.internal.h" diff --git a/libc/calls/readv.c b/libc/calls/readv.c index 4df11dcf7..f344ac6bf 100644 --- a/libc/calls/readv.c +++ b/libc/calls/readv.c @@ -16,16 +16,18 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/likely.h" -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/iovec.h" +#include "libc/calls/struct/iovec.internal.h" #include "libc/calls/syscall-sysv.internal.h" +#include "libc/errno.h" #include "libc/intrin/asan.internal.h" #include "libc/intrin/describeflags.internal.h" #include "libc/intrin/kprintf.h" +#include "libc/intrin/likely.h" +#include "libc/intrin/weaken.h" #include "libc/sock/internal.h" #include "libc/sysv/errfuns.h" #include "libc/zipos/zipos.internal.h" diff --git a/libc/calls/reservefd.c b/libc/calls/reservefd.c index 919fba281..a98e44c5c 100644 --- a/libc/calls/reservefd.c +++ b/libc/calls/reservefd.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/state.internal.h" @@ -26,6 +25,7 @@ #include "libc/dce.h" #include "libc/intrin/cmpxchg.h" #include "libc/intrin/spinlock.h" +#include "libc/intrin/weaken.h" #include "libc/macros.internal.h" #include "libc/mem/mem.h" #include "libc/runtime/directmap.internal.h" diff --git a/libc/calls/rusage2linux.c b/libc/calls/rusage2linux.c index d1b62b8e9..1ee4d5ff6 100644 --- a/libc/calls/rusage2linux.c +++ b/libc/calls/rusage2linux.c @@ -16,8 +16,9 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/internal.h" #include "libc/calls/struct/rusage.h" +#include "libc/calls/struct/rusage.internal.h" +#include "libc/dce.h" void __rusage2linux(struct rusage *ru) { if (IsXnu()) { diff --git a/libc/calls/sched_rr_get_interval.c b/libc/calls/sched_rr_get_interval.c index d624a10eb..6ac35aa6a 100644 --- a/libc/calls/sched_rr_get_interval.c +++ b/libc/calls/sched_rr_get_interval.c @@ -18,6 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" #include "libc/calls/strace.internal.h" +#include "libc/calls/struct/timespec.internal.h" #include "libc/intrin/describeflags.internal.h" int sys_sched_rr_get_interval(int, struct timespec *) hidden; diff --git a/libc/calls/sched_setscheduler.c b/libc/calls/sched_setscheduler.c index 33323cda5..211f14326 100644 --- a/libc/calls/sched_setscheduler.c +++ b/libc/calls/sched_setscheduler.c @@ -19,6 +19,7 @@ #include "libc/calls/sched-sysv.internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/sched_param.h" +#include "libc/calls/struct/sched_param.internal.h" #include "libc/dce.h" #include "libc/intrin/describeflags.internal.h" #include "libc/nexgen32e/threaded.h" diff --git a/libc/calls/setfsgid.c b/libc/calls/setfsgid.c index 43c32707c..526683d47 100644 --- a/libc/calls/setfsgid.c +++ b/libc/calls/setfsgid.c @@ -19,6 +19,7 @@ #include "libc/calls/calls.h" #include "libc/calls/strace.internal.h" #include "libc/calls/syscall-sysv.internal.h" +#include "libc/dce.h" /** * Sets user id of current process for file system ops. diff --git a/libc/calls/setfsuid.c b/libc/calls/setfsuid.c index 100b235af..22895680e 100644 --- a/libc/calls/setfsuid.c +++ b/libc/calls/setfsuid.c @@ -19,6 +19,7 @@ #include "libc/calls/calls.h" #include "libc/calls/strace.internal.h" #include "libc/calls/syscall-sysv.internal.h" +#include "libc/dce.h" /** * Sets user id of current process for file system ops. diff --git a/libc/calls/setgid.c b/libc/calls/setgid.c index b149c7803..07980d230 100644 --- a/libc/calls/setgid.c +++ b/libc/calls/setgid.c @@ -19,6 +19,7 @@ #include "libc/calls/calls.h" #include "libc/calls/strace.internal.h" #include "libc/calls/syscall-sysv.internal.h" +#include "libc/dce.h" /** * Sets group id of current process. diff --git a/libc/calls/setitimer.c b/libc/calls/setitimer.c index aa9f72aec..4e5e3dedb 100644 --- a/libc/calls/setitimer.c +++ b/libc/calls/setitimer.c @@ -16,9 +16,9 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/itimerval.h" +#include "libc/calls/struct/itimerval.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" #include "libc/sysv/errfuns.h" diff --git a/libc/calls/setrlimit.c b/libc/calls/setrlimit.c index 2f5e5c81a..853dbf250 100644 --- a/libc/calls/setrlimit.c +++ b/libc/calls/setrlimit.c @@ -18,8 +18,8 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" #include "libc/calls/calls.h" -#include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" +#include "libc/calls/struct/rlimit.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" #include "libc/intrin/describeflags.internal.h" diff --git a/libc/calls/setuid.c b/libc/calls/setuid.c index 8c33a1dae..4921d4169 100644 --- a/libc/calls/setuid.c +++ b/libc/calls/setuid.c @@ -19,6 +19,7 @@ #include "libc/calls/calls.h" #include "libc/calls/strace.internal.h" #include "libc/calls/syscall-sysv.internal.h" +#include "libc/dce.h" /** * Sets user id of current process. diff --git a/libc/calls/sig2.c b/libc/calls/sig2.c index f25858a7e..9ef354223 100644 --- a/libc/calls/sig2.c +++ b/libc/calls/sig2.c @@ -19,6 +19,8 @@ #include "libc/calls/sig.internal.h" #include "libc/calls/state.internal.h" #include "libc/calls/strace.internal.h" +#include "libc/calls/struct/sigaction.h" +#include "libc/calls/struct/siginfo.h" #include "libc/intrin/cmpxchg.h" #include "libc/intrin/lockcmpxchg.h" #include "libc/intrin/spinlock.h" diff --git a/libc/calls/sigaction.c b/libc/calls/sigaction.c index 27f58805d..e40179d45 100644 --- a/libc/calls/sigaction.c +++ b/libc/calls/sigaction.c @@ -17,8 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" -#include "libc/intrin/bits.h" -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/sig.internal.h" @@ -30,13 +28,16 @@ #include "libc/calls/struct/sigaction-openbsd.internal.h" #include "libc/calls/struct/sigaction-xnu.internal.h" #include "libc/calls/struct/sigaction.h" +#include "libc/calls/struct/sigaction.internal.h" +#include "libc/calls/struct/siginfo.internal.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/calls/syscall_support-sysv.internal.h" -#include "libc/calls/typedef/sigaction_f.h" #include "libc/calls/ucontext.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" +#include "libc/intrin/bits.h" #include "libc/intrin/describeflags.internal.h" +#include "libc/intrin/weaken.h" #include "libc/limits.h" #include "libc/log/backtrace.internal.h" #include "libc/log/log.h" diff --git a/libc/calls/sigaltstack.c b/libc/calls/sigaltstack.c index 90826fbd9..bc990c3e5 100644 --- a/libc/calls/sigaltstack.c +++ b/libc/calls/sigaltstack.c @@ -19,6 +19,7 @@ #include "libc/calls/strace.internal.h" #include "libc/calls/struct/metasigaltstack.h" #include "libc/calls/struct/sigaltstack.h" +#include "libc/calls/struct/sigaltstack.internal.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" diff --git a/libc/calls/sigchld-nt.c b/libc/calls/sigchld-nt.c index 427e01200..4ad0ba886 100644 --- a/libc/calls/sigchld-nt.c +++ b/libc/calls/sigchld-nt.c @@ -17,10 +17,12 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" +#include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/sig.internal.h" #include "libc/calls/state.internal.h" #include "libc/calls/strace.internal.h" +#include "libc/calls/struct/siginfo.h" #include "libc/calls/syscall_support-nt.internal.h" #include "libc/dce.h" #include "libc/intrin/spinlock.h" diff --git a/libc/calls/sigenter-freebsd.c b/libc/calls/sigenter-freebsd.c index 4bc1d2aa9..fce6e3af2 100644 --- a/libc/calls/sigenter-freebsd.c +++ b/libc/calls/sigenter-freebsd.c @@ -20,14 +20,15 @@ #include "libc/calls/internal.h" #include "libc/calls/state.internal.h" #include "libc/calls/struct/sigaction-freebsd.internal.h" +#include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/siginfo-freebsd.internal.h" #include "libc/calls/struct/siginfo.h" #include "libc/calls/struct/ucontext-freebsd.internal.h" -#include "libc/calls/typedef/sigaction_f.h" #include "libc/calls/ucontext.h" #include "libc/intrin/kprintf.h" #include "libc/log/libfatal.internal.h" #include "libc/macros.internal.h" +#include "libc/runtime/runtime.h" #include "libc/str/str.h" #include "libc/sysv/consts/sa.h" diff --git a/libc/calls/sigenter-netbsd.c b/libc/calls/sigenter-netbsd.c index b1531596c..873f18bd6 100644 --- a/libc/calls/sigenter-netbsd.c +++ b/libc/calls/sigenter-netbsd.c @@ -20,13 +20,14 @@ #include "libc/calls/internal.h" #include "libc/calls/state.internal.h" #include "libc/calls/struct/sigaction-freebsd.internal.h" +#include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/siginfo-netbsd.internal.h" #include "libc/calls/struct/siginfo.h" #include "libc/calls/struct/ucontext-netbsd.internal.h" -#include "libc/calls/typedef/sigaction_f.h" #include "libc/calls/ucontext.h" #include "libc/log/libfatal.internal.h" #include "libc/macros.internal.h" +#include "libc/runtime/runtime.h" #include "libc/str/str.h" #include "libc/sysv/consts/sa.h" diff --git a/libc/calls/sigenter-openbsd.c b/libc/calls/sigenter-openbsd.c index cd503f4de..534be7221 100644 --- a/libc/calls/sigenter-openbsd.c +++ b/libc/calls/sigenter-openbsd.c @@ -20,13 +20,14 @@ #include "libc/calls/internal.h" #include "libc/calls/state.internal.h" #include "libc/calls/struct/sigaction-freebsd.internal.h" +#include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/siginfo-openbsd.internal.h" #include "libc/calls/struct/siginfo.h" #include "libc/calls/struct/ucontext-openbsd.internal.h" -#include "libc/calls/typedef/sigaction_f.h" #include "libc/calls/ucontext.h" #include "libc/log/libfatal.internal.h" #include "libc/macros.internal.h" +#include "libc/runtime/runtime.h" #include "libc/str/str.h" #include "libc/sysv/consts/sa.h" diff --git a/libc/calls/sigenter-xnu.c b/libc/calls/sigenter-xnu.c index 03fdc9a97..c60ea522b 100644 --- a/libc/calls/sigenter-xnu.c +++ b/libc/calls/sigenter-xnu.c @@ -20,13 +20,14 @@ #include "libc/calls/internal.h" #include "libc/calls/state.internal.h" #include "libc/calls/struct/metasigaltstack.h" +#include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/siginfo-xnu.internal.h" #include "libc/calls/struct/siginfo.h" -#include "libc/calls/typedef/sigaction_f.h" #include "libc/calls/ucontext.h" #include "libc/intrin/kprintf.h" #include "libc/intrin/repstosb.h" #include "libc/log/libfatal.internal.h" +#include "libc/runtime/runtime.h" #include "libc/str/str.h" #include "libc/sysv/consts/sa.h" diff --git a/libc/calls/sigprocmask-sysv.greg.c b/libc/calls/sigprocmask-sysv.greg.c index 738ca5a39..d87c5b39d 100644 --- a/libc/calls/sigprocmask-sysv.greg.c +++ b/libc/calls/sigprocmask-sysv.greg.c @@ -16,8 +16,9 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/internal.h" #include "libc/calls/struct/sigset.h" +#include "libc/calls/struct/sigset.internal.h" +#include "libc/dce.h" #include "libc/str/str.h" int sys_sigprocmask(int how, const sigset_t *opt_set, diff --git a/libc/calls/sigprocmask.c b/libc/calls/sigprocmask.c index df1ff8499..b60bad910 100644 --- a/libc/calls/sigprocmask.c +++ b/libc/calls/sigprocmask.c @@ -16,17 +16,18 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/sig.internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/sigset.h" +#include "libc/calls/struct/sigset.internal.h" #include "libc/dce.h" #include "libc/fmt/itoa.h" #include "libc/intrin/asan.internal.h" #include "libc/intrin/describeflags.internal.h" #include "libc/intrin/kprintf.h" +#include "libc/intrin/weaken.h" #include "libc/log/log.h" #include "libc/str/str.h" #include "libc/sysv/consts/sig.h" diff --git a/libc/calls/sigqueue.c b/libc/calls/sigqueue.c index c7b19cead..a19e63eaf 100644 --- a/libc/calls/sigqueue.c +++ b/libc/calls/sigqueue.c @@ -17,9 +17,11 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/calls/internal.h" #include "libc/calls/struct/siginfo.h" +#include "libc/calls/struct/siginfo.internal.h" #include "libc/calls/struct/sigval.h" +#include "libc/calls/struct/sigval.internal.h" +#include "libc/dce.h" #include "libc/str/str.h" #include "libc/sysv/consts/sicode.h" diff --git a/libc/calls/sigsuspend.c b/libc/calls/sigsuspend.c index e790e93c2..912cf37e4 100644 --- a/libc/calls/sigsuspend.c +++ b/libc/calls/sigsuspend.c @@ -16,18 +16,20 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/sig.internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/sigset.h" +#include "libc/calls/struct/sigset.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" #include "libc/intrin/describeflags.internal.h" +#include "libc/intrin/weaken.h" #include "libc/log/backtrace.internal.h" #include "libc/nt/errors.h" #include "libc/nt/synchronization.h" +#include "libc/sysv/consts/sig.h" #include "libc/sysv/errfuns.h" /** diff --git a/libc/calls/sigwinch-nt.c b/libc/calls/sigwinch-nt.c index c941b7524..0e97b8268 100644 --- a/libc/calls/sigwinch-nt.c +++ b/libc/calls/sigwinch-nt.c @@ -18,11 +18,12 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" #include "libc/calls/calls.h" -#include "libc/calls/internal.h" #include "libc/calls/sig.internal.h" #include "libc/calls/strace.internal.h" +#include "libc/calls/struct/fd.internal.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/winsize.h" +#include "libc/calls/struct/winsize.internal.h" #include "libc/dce.h" #include "libc/errno.h" #include "libc/nt/struct/consolescreenbufferinfoex.h" diff --git a/libc/calls/strace.internal.h b/libc/calls/strace.internal.h index c0e66fe80..a4355370d 100644 --- a/libc/calls/strace.internal.h +++ b/libc/calls/strace.internal.h @@ -1,10 +1,6 @@ #ifndef COSMOPOLITAN_LIBC_CALLS_STRACE_INTERNAL_H_ #define COSMOPOLITAN_LIBC_CALLS_STRACE_INTERNAL_H_ #include "libc/intrin/likely.h" -#include "libc/calls/struct/iovec.h" -#include "libc/calls/struct/rlimit.h" -#include "libc/calls/struct/sigaction.h" -#include "libc/calls/struct/stat.h" #include "libc/runtime/runtime.h" #define _KERNTRACE 0 /* not configurable w/ flag yet */ diff --git a/libc/calls/struct/dirent.h b/libc/calls/struct/dirent.h index 4385bd4ea..ac3605c9a 100644 --- a/libc/calls/struct/dirent.h +++ b/libc/calls/struct/dirent.h @@ -1,6 +1,7 @@ #ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_DIRENT_H_ #define COSMOPOLITAN_LIBC_CALLS_STRUCT_DIRENT_H_ #if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ struct dirent { /* linux getdents64 abi */ uint64_t d_ino; /* inode number */ @@ -22,5 +23,6 @@ struct dirent *readdir(DIR *); void rewinddir(DIR *); void seekdir(DIR *, long); +COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_DIRENT_H_ */ diff --git a/libc/calls/struct/fd.internal.h b/libc/calls/struct/fd.internal.h new file mode 100644 index 000000000..17d586236 --- /dev/null +++ b/libc/calls/struct/fd.internal.h @@ -0,0 +1,36 @@ +#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_FD_INTERNAL_H_ +#define COSMOPOLITAN_LIBC_CALLS_STRUCT_FD_INTERNAL_H_ +#if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ + +enum FdKind { + kFdEmpty, + kFdFile, + kFdSocket, + kFdProcess, + kFdConsole, + kFdSerial, + kFdZip, + kFdEpoll, + kFdReserved +}; + +struct Fd { + enum FdKind kind; + unsigned flags; + unsigned mode; + int64_t handle; + int64_t extra; + bool zombie; +}; + +struct Fds { + int f; /* lowest free slot */ + size_t n; /* monotonic capacity */ + struct Fd *p; + struct Fd __init_p[OPEN_MAX]; +}; + +COSMOPOLITAN_C_END_ +#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ +#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_FD_INTERNAL_H_ */ diff --git a/libc/calls/struct/flock.h b/libc/calls/struct/flock.h index 2a9650579..0cc1e9537 100644 --- a/libc/calls/struct/flock.h +++ b/libc/calls/struct/flock.h @@ -1,6 +1,7 @@ #ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_FLOCK_H_ #define COSMOPOLITAN_LIBC_CALLS_STRUCT_FLOCK_H_ #if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ struct flock { /* cosmopolitan abi */ int16_t l_type; /* F_RDLCK, F_WRLCK, F_UNLCK */ @@ -11,5 +12,6 @@ struct flock { /* cosmopolitan abi */ int32_t l_sysid; /* remote system id or zero for local */ }; +COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_FLOCK_H_ */ diff --git a/libc/calls/struct/iovec.h b/libc/calls/struct/iovec.h index 56537ef2e..97d37fae6 100644 --- a/libc/calls/struct/iovec.h +++ b/libc/calls/struct/iovec.h @@ -1,17 +1,20 @@ #ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_IOVEC_H_ #define COSMOPOLITAN_LIBC_CALLS_STRUCT_IOVEC_H_ #if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ struct iovec { void *iov_base; size_t iov_len; }; -ssize_t readv(int, const struct iovec *, int); -ssize_t writev(int, const struct iovec *, int); ssize_t preadv(int, struct iovec *, int, int64_t); ssize_t pwritev(int, const struct iovec *, int, int64_t); +ssize_t readv(int, const struct iovec *, int); ssize_t vmsplice(int, const struct iovec *, int64_t, uint32_t); +ssize_t writev(int, const struct iovec *, int); +void DescribeIov(const struct iovec *, int, ssize_t); +COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_IOVEC_H_ */ diff --git a/libc/calls/struct/iovec.internal.h b/libc/calls/struct/iovec.internal.h new file mode 100644 index 000000000..3996d3c4d --- /dev/null +++ b/libc/calls/struct/iovec.internal.h @@ -0,0 +1,29 @@ +#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_IOVEC_INTERNAL_H_ +#define COSMOPOLITAN_LIBC_CALLS_STRUCT_IOVEC_INTERNAL_H_ +#include "libc/calls/struct/fd.internal.h" +#include "libc/calls/struct/iovec.h" +#if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ + +int64_t sys_preadv(int, struct iovec *, int, int64_t, int64_t) hidden; +int64_t sys_pwritev(int, const struct iovec *, int, int64_t, int64_t) hidden; +int64_t sys_readv(int32_t, const struct iovec *, int32_t) hidden; +int64_t sys_vmsplice(int, const struct iovec *, int64_t, uint32_t) hidden; +int64_t sys_writev(int32_t, const struct iovec *, int32_t) hidden; +size_t __iovec_size(const struct iovec *, size_t) hidden; +ssize_t WritevUninterruptible(int, struct iovec *, int); +ssize_t sys_read_nt(struct Fd *, const struct iovec *, size_t, ssize_t) hidden; +ssize_t sys_readv_metal(struct Fd *, const struct iovec *, int) hidden; +ssize_t sys_readv_nt(struct Fd *, const struct iovec *, int) hidden; +ssize_t sys_readv_serial(struct Fd *, const struct iovec *, int) hidden; +ssize_t sys_write_nt(int, const struct iovec *, size_t, ssize_t) hidden; +ssize_t sys_writev_metal(struct Fd *, const struct iovec *, int) hidden; +ssize_t sys_writev_nt(int, const struct iovec *, int) hidden; +ssize_t sys_writev_serial(struct Fd *, const struct iovec *, int) hidden; +ssize_t sys_send_nt(int, const struct iovec *, size_t, uint32_t) hidden; +ssize_t sys_sendto_nt(int, const struct iovec *, size_t, uint32_t, void *, + uint32_t) hidden; + +COSMOPOLITAN_C_END_ +#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ +#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_IOVEC_INTERNAL_H_ */ diff --git a/libc/calls/struct/itimerval.h b/libc/calls/struct/itimerval.h index 61d396119..0c8a78b9c 100644 --- a/libc/calls/struct/itimerval.h +++ b/libc/calls/struct/itimerval.h @@ -2,11 +2,16 @@ #define COSMOPOLITAN_LIBC_CALLS_STRUCT_ITIMERVAL_H_ #include "libc/calls/struct/timeval.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ struct itimerval { struct timeval it_interval; /* {0,0} means singleshot */ struct timeval it_value; /* {0,0} means disarm */ }; +int getitimer(int, struct itimerval *); +int setitimer(int, const struct itimerval *, struct itimerval *); + +COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_ITIMERVAL_H_ */ diff --git a/libc/calls/struct/itimerval.internal.h b/libc/calls/struct/itimerval.internal.h new file mode 100644 index 000000000..002124fb0 --- /dev/null +++ b/libc/calls/struct/itimerval.internal.h @@ -0,0 +1,17 @@ +#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_ITIMERVAL_INTERNAL_H_ +#define COSMOPOLITAN_LIBC_CALLS_STRUCT_ITIMERVAL_INTERNAL_H_ +#include "libc/calls/struct/itimerval.h" +#include "libc/mem/alloca.h" +#if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ + +int sys_getitimer(int, struct itimerval *) hidden; +int sys_setitimer(int, const struct itimerval *, struct itimerval *) hidden; +int sys_setitimer_nt(int, const struct itimerval *, struct itimerval *) hidden; + +const char *DescribeTimeval(char[45], int, const struct timeval *); +#define DescribeTimeval(rc, ts) DescribeTimeval(alloca(45), rc, ts) + +COSMOPOLITAN_C_END_ +#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ +#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_ITIMERVAL_INTERNAL_H_ */ diff --git a/libc/calls/struct/metastat.internal.h b/libc/calls/struct/metastat.internal.h index 4c3662071..2e2f71965 100644 --- a/libc/calls/struct/metastat.internal.h +++ b/libc/calls/struct/metastat.internal.h @@ -94,6 +94,8 @@ union metastat { struct stat_netbsd netbsd; }; +void __stat2cosmo(struct stat *restrict, const union metastat *) hidden; + COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_METASTAT_H_ */ diff --git a/libc/calls/struct/rlimit.h b/libc/calls/struct/rlimit.h index a9dcf263b..532ff0a13 100644 --- a/libc/calls/struct/rlimit.h +++ b/libc/calls/struct/rlimit.h @@ -1,6 +1,7 @@ #ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_RLIMIT_H_ #define COSMOPOLITAN_LIBC_CALLS_STRUCT_RLIMIT_H_ #if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ struct rlimit { uint64_t rlim_cur; /* current (soft) limit in bytes */ @@ -10,5 +11,6 @@ struct rlimit { int getrlimit(int, struct rlimit *); int setrlimit(int, const struct rlimit *); +COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_RLIMIT_H_ */ diff --git a/libc/calls/struct/rlimit.internal.h b/libc/calls/struct/rlimit.internal.h new file mode 100644 index 000000000..047cd6ddb --- /dev/null +++ b/libc/calls/struct/rlimit.internal.h @@ -0,0 +1,17 @@ +#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_RLIMIT_INTERNAL_H_ +#define COSMOPOLITAN_LIBC_CALLS_STRUCT_RLIMIT_INTERNAL_H_ +#include "libc/calls/struct/rlimit.h" +#include "libc/mem/alloca.h" +#if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ + +int sys_getrlimit(int, struct rlimit *) hidden; +int sys_setrlimit(int, const struct rlimit *) hidden; +int sys_setrlimit_nt(int, const struct rlimit *) hidden; + +const char *DescribeRlimit(char[64], int, const struct rlimit *); +#define DescribeRlimit(rc, rl) DescribeRlimit(alloca(64), rc, rl) + +COSMOPOLITAN_C_END_ +#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ +#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_RLIMIT_INTERNAL_H_ */ diff --git a/libc/calls/struct/rusage.h b/libc/calls/struct/rusage.h index 64a8c3cb8..343051aad 100644 --- a/libc/calls/struct/rusage.h +++ b/libc/calls/struct/rusage.h @@ -2,6 +2,7 @@ #define COSMOPOLITAN_LIBC_CALLS_STRUCT_RUSAGE_H_ #include "libc/calls/struct/timeval.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ struct rusage { struct timeval ru_utime; /* user CPU time used */ @@ -27,5 +28,6 @@ int wait3(int *, int, struct rusage *); int wait4(int, int *, int, struct rusage *); void _addrusage(struct rusage *, const struct rusage *); +COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_RUSAGE_H_ */ diff --git a/libc/calls/struct/rusage.internal.h b/libc/calls/struct/rusage.internal.h new file mode 100644 index 000000000..50e7394d5 --- /dev/null +++ b/libc/calls/struct/rusage.internal.h @@ -0,0 +1,16 @@ +#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_RUSAGE_INTERNAL_H_ +#define COSMOPOLITAN_LIBC_CALLS_STRUCT_RUSAGE_INTERNAL_H_ +#include "libc/calls/struct/rusage.h" +#if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ + +int __sys_getrusage(int, struct rusage *) hidden; +int __sys_wait4(int, int *, int, struct rusage *) hidden; +int sys_getrusage(int, struct rusage *) hidden; +int sys_wait4(int, int *, int, struct rusage *) hidden; +void __rusage2linux(struct rusage *) hidden; +int sys_getrusage_nt(int, struct rusage *) hidden; + +COSMOPOLITAN_C_END_ +#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ +#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_RUSAGE_INTERNAL_H_ */ diff --git a/libc/calls/struct/sched_param.internal.h b/libc/calls/struct/sched_param.internal.h new file mode 100644 index 000000000..ced36d346 --- /dev/null +++ b/libc/calls/struct/sched_param.internal.h @@ -0,0 +1,13 @@ +#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_SCHED_PARAM_INTERNAL_H_ +#define COSMOPOLITAN_LIBC_CALLS_STRUCT_SCHED_PARAM_INTERNAL_H_ +#include "libc/calls/struct/sched_param.h" +#include "libc/mem/alloca.h" +#if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ + +const char *DescribeSchedParam(char[32], const struct sched_param *); +#define DescribeSchedParam(x) DescribeSchedParam(alloca(32), x) + +COSMOPOLITAN_C_END_ +#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ +#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SCHED_PARAM_INTERNAL_H_ */ diff --git a/libc/calls/struct/sigaction.h b/libc/calls/struct/sigaction.h index ee6a44187..2e97ad114 100644 --- a/libc/calls/struct/sigaction.h +++ b/libc/calls/struct/sigaction.h @@ -1,11 +1,15 @@ #ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGACTION_H_ #define COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGACTION_H_ +#include "libc/calls/struct/siginfo.h" #include "libc/calls/struct/sigset.h" -#include "libc/calls/typedef/sigaction_f.h" -#include "libc/calls/typedef/sighandler_t.h" +#include "libc/calls/ucontext.h" #include "libc/dce.h" #include "libc/sysv/consts/sig.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ + +typedef void (*sighandler_t)(int); +typedef void (*sigaction_f)(int, struct siginfo *, struct ucontext *); struct sigaction { /* cosmo abi */ union { @@ -22,7 +26,6 @@ sighandler_t signal(int, sighandler_t); int sigaction(int, const struct sigaction *, struct sigaction *); #if defined(__GNUC__) && !defined(__STRICT_ANSI__) -COSMOPOLITAN_C_START_ void _init_onntconsoleevent(void); void _init_wincrash(void); @@ -75,6 +78,7 @@ void _check_sigwinch(); }) #endif /* GNU && !ANSI */ + COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGACTION_H_ */ diff --git a/libc/calls/struct/sigaction.internal.h b/libc/calls/struct/sigaction.internal.h new file mode 100644 index 000000000..0443291ec --- /dev/null +++ b/libc/calls/struct/sigaction.internal.h @@ -0,0 +1,13 @@ +#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGACTION_INTERNAL_H_ +#define COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGACTION_INTERNAL_H_ +#include "libc/calls/struct/sigaction.h" +#include "libc/mem/alloca.h" +#if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ + +const char *DescribeSigaction(char[256], int, const struct sigaction *); +#define DescribeSigaction(rc, sa) DescribeSigaction(alloca(256), rc, sa) + +COSMOPOLITAN_C_END_ +#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ +#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGACTION_INTERNAL_H_ */ diff --git a/libc/calls/struct/sigaltstack.internal.h b/libc/calls/struct/sigaltstack.internal.h new file mode 100644 index 000000000..89c50099f --- /dev/null +++ b/libc/calls/struct/sigaltstack.internal.h @@ -0,0 +1,13 @@ +#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGALTSTACK_INTERNAL_H_ +#define COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGALTSTACK_INTERNAL_H_ +#include "libc/calls/struct/sigaltstack.h" +#include "libc/mem/alloca.h" +#if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ + +const char *DescribeSigaltstk(char[128], int, const struct sigaltstack *); +#define DescribeSigaltstk(rc, ss) DescribeSigaltstk(alloca(128), rc, ss) + +COSMOPOLITAN_C_END_ +#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ +#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGALTSTACK_INTERNAL_H_ */ diff --git a/libc/calls/struct/siginfo.h b/libc/calls/struct/siginfo.h index 9c8cd81e7..093952924 100644 --- a/libc/calls/struct/siginfo.h +++ b/libc/calls/struct/siginfo.h @@ -2,6 +2,7 @@ #define COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGINFO_H_ #include "libc/calls/struct/sigval.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ struct siginfo { int32_t si_signo; @@ -54,5 +55,6 @@ struct siginfo { typedef struct siginfo siginfo_t; +COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGINFO_H_ */ diff --git a/libc/calls/struct/siginfo.internal.h b/libc/calls/struct/siginfo.internal.h new file mode 100644 index 000000000..98e725751 --- /dev/null +++ b/libc/calls/struct/siginfo.internal.h @@ -0,0 +1,15 @@ +#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGINFO_INTERNAL_H_ +#define COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGINFO_INTERNAL_H_ +#include "libc/calls/struct/sigaction-xnu.internal.h" +#include "libc/calls/struct/siginfo-xnu.internal.h" +#include "libc/calls/struct/siginfo.h" +#if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ + +int sys_sigqueueinfo(int, const siginfo_t *) hidden; +void __sigenter_xnu(void *, int, int, struct siginfo_xnu *, + struct __darwin_ucontext *) hidden; + +COSMOPOLITAN_C_END_ +#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ +#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGINFO_INTERNAL_H_ */ diff --git a/libc/calls/struct/sigset.h b/libc/calls/struct/sigset.h index a4ad3c343..6434dcd55 100644 --- a/libc/calls/struct/sigset.h +++ b/libc/calls/struct/sigset.h @@ -1,19 +1,20 @@ #ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGSET_H_ #define COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGSET_H_ #if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ 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; +int sigprocmask(int, const sigset_t *, sigset_t *); +int sigsuspend(const sigset_t *); +COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGSET_H_ */ diff --git a/libc/calls/struct/sigset.internal.h b/libc/calls/struct/sigset.internal.h new file mode 100644 index 000000000..1d7545b5e --- /dev/null +++ b/libc/calls/struct/sigset.internal.h @@ -0,0 +1,18 @@ +#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGSET_INTERNAL_H_ +#define COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGSET_INTERNAL_H_ +#include "libc/calls/struct/sigset.h" +#include "libc/mem/alloca.h" +#if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ + +int __sys_sigprocmask(int, const struct sigset *, struct sigset *, + uint64_t) hidden; +int sys_sigprocmask(int, const struct sigset *, struct sigset *) hidden; +int sys_sigsuspend(const struct sigset *, uint64_t) hidden; + +const char *DescribeSigset(char[128], int, const sigset_t *); +#define DescribeSigset(rc, ss) DescribeSigset(alloca(128), rc, ss) + +COSMOPOLITAN_C_END_ +#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ +#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGSET_INTERNAL_H_ */ diff --git a/libc/calls/struct/sigval.h b/libc/calls/struct/sigval.h index e72c6ffa3..fd6e2fe8f 100644 --- a/libc/calls/struct/sigval.h +++ b/libc/calls/struct/sigval.h @@ -1,6 +1,7 @@ #ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGVAL_H_ #define COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGVAL_H_ #if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ union sigval { int32_t sival_int; @@ -9,5 +10,6 @@ union sigval { int sigqueue(int, int, const union sigval); +COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGVAL_H_ */ diff --git a/libc/calls/struct/sigval.internal.h b/libc/calls/struct/sigval.internal.h new file mode 100644 index 000000000..fac03f807 --- /dev/null +++ b/libc/calls/struct/sigval.internal.h @@ -0,0 +1,11 @@ +#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGVAL_INTERNAL_H_ +#define COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGVAL_INTERNAL_H_ +#include "libc/calls/struct/sigval.h" +#if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ + +int sys_sigqueue(int, int, const union sigval) hidden; + +COSMOPOLITAN_C_END_ +#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ +#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGVAL_INTERNAL_H_ */ diff --git a/libc/calls/struct/stat.h b/libc/calls/struct/stat.h index dc15af99e..117448db7 100644 --- a/libc/calls/struct/stat.h +++ b/libc/calls/struct/stat.h @@ -2,6 +2,7 @@ #define COSMOPOLITAN_LIBC_CALLS_STRUCT_STAT_H_ #include "libc/calls/struct/timespec.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ struct stat { /* cosmo abi */ uint64_t st_dev; /* 0: id of device with file */ @@ -27,5 +28,6 @@ int lstat(const char *, struct stat *); int fstat(int, struct stat *); int fstatat(int, const char *, struct stat *, int); +COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_STAT_H_ */ diff --git a/libc/calls/struct/stat.internal.h b/libc/calls/struct/stat.internal.h new file mode 100644 index 000000000..666bd2a55 --- /dev/null +++ b/libc/calls/struct/stat.internal.h @@ -0,0 +1,20 @@ +#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_STAT_INTERNAL_H_ +#define COSMOPOLITAN_LIBC_CALLS_STRUCT_STAT_INTERNAL_H_ +#include "libc/calls/struct/stat.h" +#include "libc/mem/alloca.h" +#if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ + +int sys_fstat(int, struct stat *) hidden; +int sys_fstatat(int, const char *, struct stat *, int) hidden; +int sys_fstat_nt(int64_t, struct stat *) hidden; +int sys_fstatat_nt(int, const char *, struct stat *, int) hidden; +int sys_lstat_nt(const char *, struct stat *) hidden; +int sys_fstat_metal(int, struct stat *); + +const char *DescribeStat(char[300], int, const struct stat *); +#define DescribeStat(rc, st) DescribeStat(alloca(300), rc, st) + +COSMOPOLITAN_C_END_ +#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ +#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_STAT_INTERNAL_H_ */ diff --git a/libc/calls/struct/sysinfo.h b/libc/calls/struct/sysinfo.h index eb1dbf1de..51c78588c 100644 --- a/libc/calls/struct/sysinfo.h +++ b/libc/calls/struct/sysinfo.h @@ -1,6 +1,7 @@ #ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_SYSINFO_H_ #define COSMOPOLITAN_LIBC_CALLS_STRUCT_SYSINFO_H_ #if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ struct sysinfo { int64_t uptime; /* seconds since boot */ @@ -20,5 +21,6 @@ struct sysinfo { int sysinfo(struct sysinfo *); +COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SYSINFO_H_ */ diff --git a/libc/calls/struct/sysinfo.internal.h b/libc/calls/struct/sysinfo.internal.h new file mode 100644 index 000000000..ed728e02d --- /dev/null +++ b/libc/calls/struct/sysinfo.internal.h @@ -0,0 +1,12 @@ +#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_SYSINFO_INTERNAL_H_ +#define COSMOPOLITAN_LIBC_CALLS_STRUCT_SYSINFO_INTERNAL_H_ +#include "libc/calls/struct/sysinfo.h" +#if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ + +int sys_sysinfo(struct sysinfo *) hidden; +int sys_sysinfo_nt(struct sysinfo *) hidden; + +COSMOPOLITAN_C_END_ +#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ +#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SYSINFO_INTERNAL_H_ */ diff --git a/libc/calls/struct/timespec.h b/libc/calls/struct/timespec.h index 75d811200..77c892579 100644 --- a/libc/calls/struct/timespec.h +++ b/libc/calls/struct/timespec.h @@ -1,24 +1,32 @@ #ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMESPEC_H_ #define COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMESPEC_H_ #if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ struct timespec { int64_t tv_sec; int64_t tv_nsec; /* nanoseconds */ }; +int clock_getres(int, struct timespec *); +int clock_gettime(int, struct timespec *); +int futimens(int, const struct timespec[2]); +int nanosleep(const struct timespec *, struct timespec *); int sys_futex(int *, int, int, const struct timespec *, int *); -int64_t _timespec_tonanos(struct timespec) pureconst; -int64_t _timespec_tomicros(struct timespec) pureconst; -int64_t _timespec_tomillis(struct timespec) pureconst; -struct timespec _timespec_frommicros(int64_t) pureconst; -struct timespec _timespec_frommillis(int64_t) pureconst; +int utimensat(int, const char *, const struct timespec[2], int); + bool _timespec_eq(struct timespec, struct timespec) pureconst; bool _timespec_gte(struct timespec, struct timespec) pureconst; +int64_t _timespec_tomicros(struct timespec) pureconst; +int64_t _timespec_tomillis(struct timespec) pureconst; +int64_t _timespec_tonanos(struct timespec) pureconst; struct timespec _timespec_add(struct timespec, struct timespec) pureconst; -struct timespec _timespec_sub(struct timespec, struct timespec) pureconst; -struct timespec _timespec_real(void); +struct timespec _timespec_frommicros(int64_t) pureconst; +struct timespec _timespec_frommillis(int64_t) pureconst; struct timespec _timespec_mono(void); +struct timespec _timespec_real(void); +struct timespec _timespec_sub(struct timespec, struct timespec) pureconst; +COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMESPEC_H_ */ diff --git a/libc/calls/struct/timespec.internal.h b/libc/calls/struct/timespec.internal.h new file mode 100644 index 000000000..329d71c97 --- /dev/null +++ b/libc/calls/struct/timespec.internal.h @@ -0,0 +1,25 @@ +#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMESPEC_INTERNAL_H_ +#define COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMESPEC_INTERNAL_H_ +#include "libc/calls/struct/timespec.h" +#include "libc/mem/alloca.h" +#if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ + +int __sys_utimensat(int, const char *, const struct timespec *, int) hidden; +int sys_clock_gettime(int, struct timespec *) hidden; +int sys_clock_gettime_xnu(int, struct timespec *) hidden; +int sys_futimens(int, const struct timespec *) hidden; +int sys_nanosleep(const struct timespec *, struct timespec *) hidden; +int sys_utimensat(int, const char *, const struct timespec *, int) hidden; +int sys_clock_gettime_nt(int, struct timespec *) hidden; +int sys_nanosleep_nt(const struct timespec *, struct timespec *) hidden; +int sys_nanosleep_xnu(const struct timespec *, struct timespec *) hidden; +int sys_utimensat_nt(int, const char *, const struct timespec *, int) hidden; +int sys_utimensat_xnu(int, const char *, const struct timespec *, int) hidden; + +const char *DescribeTimespec(char[45], int, const struct timespec *); +#define DescribeTimespec(rc, ts) DescribeTimespec(alloca(45), rc, ts) + +COSMOPOLITAN_C_END_ +#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ +#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMESPEC_INTERNAL_H_ */ diff --git a/libc/calls/struct/timeval.h b/libc/calls/struct/timeval.h index 427e346f1..633f05300 100644 --- a/libc/calls/struct/timeval.h +++ b/libc/calls/struct/timeval.h @@ -1,14 +1,22 @@ #ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMEVAL_H_ #define COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMEVAL_H_ +#include "libc/time/struct/timezone.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ struct timeval { int64_t tv_sec; int64_t tv_usec; /* microseconds */ }; +int futimes(int, const struct timeval[2]); +int futimesat(int, const char *, const struct timeval[2]); +int gettimeofday(struct timeval *, struct timezone *); int lutimes(const char *, const struct timeval[2]); +int utimes(const char *, const struct timeval[2]); + struct timeval _timeval_add(struct timeval, struct timeval); +COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMEVAL_H_ */ diff --git a/libc/calls/struct/timeval.internal.h b/libc/calls/struct/timeval.internal.h new file mode 100644 index 000000000..aced4ef43 --- /dev/null +++ b/libc/calls/struct/timeval.internal.h @@ -0,0 +1,20 @@ +#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMEVAL_INTERNAL_H_ +#define COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMEVAL_INTERNAL_H_ +#include "libc/calls/struct/timeval.h" +#include "libc/time/struct/timezone.h" +#if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ + +axdx_t sys_gettimeofday(struct timeval *, struct timezone *, void *) hidden; +int sys_futimes(int, const struct timeval *) hidden; +int sys_futimesat(int, const char *, const struct timeval *) hidden; +int sys_lutimes(const char *, const struct timeval *) hidden; +int sys_utimes(const char *, const struct timeval *) hidden; +axdx_t sys_gettimeofday_xnu(struct timeval *, struct timezone *, void *) hidden; +axdx_t sys_gettimeofday_nt(struct timeval *, struct timezone *, void *) hidden; +int sys_utimes_nt(const char *, const struct timeval[2]) hidden; +axdx_t sys_gettimeofday_metal(struct timeval *, struct timezone *, void *); + +COSMOPOLITAN_C_END_ +#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ +#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMEVAL_INTERNAL_H_ */ diff --git a/libc/calls/struct/tms.h b/libc/calls/struct/tms.h index 0cb957e41..17bd801ff 100644 --- a/libc/calls/struct/tms.h +++ b/libc/calls/struct/tms.h @@ -1,6 +1,7 @@ #ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_TMS_H_ #define COSMOPOLITAN_LIBC_CALLS_STRUCT_TMS_H_ #if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ struct tms { int64_t tms_utime; /* userspace time */ @@ -11,5 +12,6 @@ struct tms { long times(struct tms *); +COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_TMS_H_ */ diff --git a/libc/calls/struct/ucontext.internal.h b/libc/calls/struct/ucontext.internal.h new file mode 100644 index 000000000..1ed5230c8 --- /dev/null +++ b/libc/calls/struct/ucontext.internal.h @@ -0,0 +1,13 @@ +#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_UCONTEXT_INTERNAL_H_ +#define COSMOPOLITAN_LIBC_CALLS_STRUCT_UCONTEXT_INTERNAL_H_ +#include "libc/calls/ucontext.h" +#include "libc/nt/struct/context.h" +#if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ + +void _ntcontext2linux(struct ucontext *, const struct NtContext *) hidden; +void _ntlinux2context(struct NtContext *, const ucontext_t *) hidden; + +COSMOPOLITAN_C_END_ +#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ +#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_UCONTEXT_INTERNAL_H_ */ diff --git a/libc/calls/struct/utsname.h b/libc/calls/struct/utsname.h index 1e8cb318a..2ca96a1c9 100644 --- a/libc/calls/struct/utsname.h +++ b/libc/calls/struct/utsname.h @@ -4,6 +4,7 @@ #define SYS_NMLN 321 #if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ struct utsname { char sysname[SYS_NMLN]; @@ -16,5 +17,6 @@ struct utsname { int uname(struct utsname *); +COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_UTSNAME_H_ */ diff --git a/libc/calls/struct/winsize.internal.h b/libc/calls/struct/winsize.internal.h new file mode 100644 index 000000000..f8e7c9777 --- /dev/null +++ b/libc/calls/struct/winsize.internal.h @@ -0,0 +1,12 @@ +#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_WINSIZE_INTERNAL_H_ +#define COSMOPOLITAN_LIBC_CALLS_STRUCT_WINSIZE_INTERNAL_H_ +#include "libc/calls/struct/fd.internal.h" +#include "libc/calls/struct/winsize.h" +#if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ + +int ioctl_tiocgwinsz_nt(struct Fd *, struct winsize *) hidden; + +COSMOPOLITAN_C_END_ +#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ +#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_WINSIZE_INTERNAL_H_ */ diff --git a/libc/calls/sys_utimes_nt.c b/libc/calls/sys_utimes_nt.c index 225ecd90d..9d1fd71c6 100644 --- a/libc/calls/sys_utimes_nt.c +++ b/libc/calls/sys_utimes_nt.c @@ -16,8 +16,10 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/internal.h" +#include "libc/calls/struct/timespec.h" +#include "libc/calls/struct/timespec.internal.h" #include "libc/calls/struct/timeval.h" +#include "libc/calls/struct/timeval.internal.h" #include "libc/sysv/consts/at.h" textwindows int sys_utimes_nt(const char *path, const struct timeval tv[2]) { diff --git a/libc/calls/sysinfo.c b/libc/calls/sysinfo.c index d04038f10..e47b0a912 100644 --- a/libc/calls/sysinfo.c +++ b/libc/calls/sysinfo.c @@ -16,8 +16,8 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/internal.h" #include "libc/calls/struct/sysinfo.h" +#include "libc/calls/struct/sysinfo.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" #include "libc/macros.internal.h" diff --git a/libc/calls/touch.c b/libc/calls/touch.c index 1106b6321..f3ec453c0 100644 --- a/libc/calls/touch.c +++ b/libc/calls/touch.c @@ -17,9 +17,9 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" +#include "libc/calls/struct/timeval.h" #include "libc/errno.h" #include "libc/sysv/consts/o.h" -#include "libc/time/time.h" /** * Creates new file or changes modified time on existing one. diff --git a/libc/calls/typedef/sigaction_f.h b/libc/calls/typedef/sigaction_f.h deleted file mode 100644 index 34ec6353e..000000000 --- a/libc/calls/typedef/sigaction_f.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef COSMOPOLITAN_LIBC_CALLS_TYPEDEF_SIGACTION_F_H_ -#define COSMOPOLITAN_LIBC_CALLS_TYPEDEF_SIGACTION_F_H_ -#include "libc/calls/struct/siginfo.h" -#include "libc/calls/ucontext.h" -#if !(__ASSEMBLER__ + __LINKER__ + 0) - -typedef void (*sigaction_f)(int, struct siginfo *, struct ucontext *); - -#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ -#endif /* COSMOPOLITAN_LIBC_CALLS_TYPEDEF_SIGACTION_F_H_ */ diff --git a/libc/calls/typedef/sighandler_t.h b/libc/calls/typedef/sighandler_t.h deleted file mode 100644 index ab59767f0..000000000 --- a/libc/calls/typedef/sighandler_t.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef COSMOPOLITAN_LIBC_CALLS_TYPEDEF_SIGHANDLER_T_H_ -#define COSMOPOLITAN_LIBC_CALLS_TYPEDEF_SIGHANDLER_T_H_ -#if !(__ASSEMBLER__ + __LINKER__ + 0) - -typedef void (*sighandler_t)(int); - -#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ -#endif /* COSMOPOLITAN_LIBC_CALLS_TYPEDEF_SIGHANDLER_T_H_ */ diff --git a/libc/calls/unveil.c b/libc/calls/unveil.c index 3e8218b37..f76dc8212 100644 --- a/libc/calls/unveil.c +++ b/libc/calls/unveil.c @@ -18,13 +18,13 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" #include "libc/calls/calls.h" -#include "libc/calls/internal.h" #include "libc/calls/landlock.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/bpf.h" #include "libc/calls/struct/filter.h" #include "libc/calls/struct/seccomp.h" #include "libc/calls/struct/stat.h" +#include "libc/calls/struct/stat.internal.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/calls/syscall_support-sysv.internal.h" #include "libc/errno.h" diff --git a/libc/calls/utime.c b/libc/calls/utime.c index b17f1a388..ac8c97d69 100644 --- a/libc/calls/utime.c +++ b/libc/calls/utime.c @@ -16,10 +16,10 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/calls/struct/timeval.h" #include "libc/str/str.h" #include "libc/sysv/consts/at.h" #include "libc/time/struct/utimbuf.h" -#include "libc/time/time.h" /** * Changes last accessed/modified times on file. diff --git a/libc/calls/utimensat-sysv.c b/libc/calls/utimensat-sysv.c index e8297fd39..4fb0b7753 100644 --- a/libc/calls/utimensat-sysv.c +++ b/libc/calls/utimensat-sysv.c @@ -16,10 +16,12 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/weaken.h" -#include "libc/calls/internal.h" +#include "libc/calls/struct/timespec.internal.h" +#include "libc/calls/struct/timeval.internal.h" +#include "libc/dce.h" #include "libc/errno.h" #include "libc/fmt/conv.h" +#include "libc/intrin/weaken.h" #include "libc/sysv/consts/at.h" #include "libc/time/time.h" #include "libc/zipos/zipos.internal.h" diff --git a/libc/calls/utimensat-xnu.c b/libc/calls/utimensat-xnu.c index cc0b659b3..c9266cad3 100644 --- a/libc/calls/utimensat-xnu.c +++ b/libc/calls/utimensat-xnu.c @@ -16,8 +16,8 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/internal.h" #include "libc/calls/struct/stat.h" +#include "libc/calls/struct/timeval.internal.h" #include "libc/fmt/conv.h" #include "libc/nexgen32e/nexgen32e.h" #include "libc/sysv/consts/at.h" diff --git a/libc/calls/utimensat.c b/libc/calls/utimensat.c index ec4d48b47..5db4e7adc 100644 --- a/libc/calls/utimensat.c +++ b/libc/calls/utimensat.c @@ -16,14 +16,15 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/weaken.h" #include "libc/calls/asan.internal.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" +#include "libc/calls/struct/timespec.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" #include "libc/intrin/describeflags.internal.h" +#include "libc/intrin/weaken.h" #include "libc/sysv/consts/at.h" #include "libc/sysv/errfuns.h" #include "libc/zipos/zipos.internal.h" diff --git a/libc/calls/utimes.c b/libc/calls/utimes.c index 1f4f8edcb..a1544e128 100644 --- a/libc/calls/utimes.c +++ b/libc/calls/utimes.c @@ -16,12 +16,12 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/internal.h" +#include "libc/calls/struct/timeval.h" +#include "libc/calls/struct/timeval.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" #include "libc/sysv/consts/at.h" #include "libc/sysv/errfuns.h" -#include "libc/time/time.h" /** * Changes last accessed/modified times on file. diff --git a/libc/calls/vdprintf.c b/libc/calls/vdprintf.c index 652d9b9dc..045068114 100644 --- a/libc/calls/vdprintf.c +++ b/libc/calls/vdprintf.c @@ -16,8 +16,8 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/internal.h" #include "libc/calls/struct/iovec.h" +#include "libc/calls/struct/iovec.internal.h" #include "libc/dce.h" #include "libc/fmt/fmt.h" #include "libc/limits.h" diff --git a/libc/calls/vmsplice.c b/libc/calls/vmsplice.c index 1f07e1797..922ce5989 100644 --- a/libc/calls/vmsplice.c +++ b/libc/calls/vmsplice.c @@ -17,8 +17,8 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/calls/internal.h" #include "libc/calls/struct/iovec.h" +#include "libc/calls/struct/iovec.internal.h" #include "libc/errno.h" /** diff --git a/libc/calls/wait4-nt.c b/libc/calls/wait4-nt.c index 044dbc127..20b08eee2 100644 --- a/libc/calls/wait4-nt.c +++ b/libc/calls/wait4-nt.c @@ -38,9 +38,9 @@ #include "libc/nt/struct/filetime.h" #include "libc/nt/struct/processmemorycounters.h" #include "libc/nt/synchronization.h" -#include "libc/stdio/lcg.internal.h" #include "libc/runtime/ezmap.internal.h" #include "libc/runtime/runtime.h" +#include "libc/stdio/lcg.internal.h" #include "libc/str/str.h" #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/sig.h" diff --git a/libc/calls/wait4-sysv.c b/libc/calls/wait4-sysv.c index 7e1ebccf8..323c3bc55 100644 --- a/libc/calls/wait4-sysv.c +++ b/libc/calls/wait4-sysv.c @@ -17,7 +17,8 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/calls/internal.h" +#include "libc/calls/struct/rusage.h" +#include "libc/calls/struct/rusage.internal.h" int sys_wait4(int pid, int *opt_out_wstatus, int options, struct rusage *opt_out_rusage) { diff --git a/libc/calls/wait4.c b/libc/calls/wait4.c index a6b48e6f3..6d25d60e7 100644 --- a/libc/calls/wait4.c +++ b/libc/calls/wait4.c @@ -17,8 +17,8 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" -#include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" +#include "libc/calls/struct/rusage.internal.h" #include "libc/calls/wait4.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" diff --git a/libc/calls/wincrash.c b/libc/calls/wincrash.c index 738c99a0c..c1a444132 100644 --- a/libc/calls/wincrash.c +++ b/libc/calls/wincrash.c @@ -16,11 +16,10 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/internal.h" #include "libc/calls/sig.internal.h" #include "libc/calls/state.internal.h" #include "libc/calls/strace.internal.h" -#include "libc/calls/typedef/sigaction_f.h" +#include "libc/calls/struct/ucontext.internal.h" #include "libc/calls/ucontext.h" #include "libc/nt/enum/exceptionhandleractions.h" #include "libc/nt/enum/signal.h" diff --git a/libc/calls/wincrash.internal.h b/libc/calls/wincrash.internal.h new file mode 100644 index 000000000..48d6945f5 --- /dev/null +++ b/libc/calls/wincrash.internal.h @@ -0,0 +1,14 @@ +#ifndef COSMOPOLITAN_LIBC_CALLS_WINCRASH_INTERNAL_H_ +#define COSMOPOLITAN_LIBC_CALLS_WINCRASH_INTERNAL_H_ +#include "libc/nt/struct/ntexceptionpointers.h" +#include "libc/nt/struct/overlapped.h" +#if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ + +unsigned __wincrash_nt(struct NtExceptionPointers *); +struct NtOverlapped *_offset2overlap(int64_t, int64_t, + struct NtOverlapped *) hidden; + +COSMOPOLITAN_C_END_ +#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ +#endif /* COSMOPOLITAN_LIBC_CALLS_WINCRASH_INTERNAL_H_ */ diff --git a/libc/calls/write-nt.c b/libc/calls/write-nt.c index d5462f204..dcbcdd886 100644 --- a/libc/calls/write-nt.c +++ b/libc/calls/write-nt.c @@ -16,12 +16,15 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/weaken.h" #include "libc/calls/internal.h" #include "libc/calls/sig.internal.h" #include "libc/calls/strace.internal.h" +#include "libc/calls/struct/iovec.h" +#include "libc/calls/struct/iovec.internal.h" #include "libc/calls/syscall_support-nt.internal.h" +#include "libc/calls/wincrash.internal.h" #include "libc/errno.h" +#include "libc/intrin/weaken.h" #include "libc/nt/errors.h" #include "libc/nt/runtime.h" #include "libc/runtime/internal.h" diff --git a/libc/calls/write.c b/libc/calls/write.c index 3fd99c10f..2fa3ebd5d 100644 --- a/libc/calls/write.c +++ b/libc/calls/write.c @@ -16,13 +16,14 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/weaken.h" #include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/iovec.h" +#include "libc/calls/struct/iovec.internal.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" +#include "libc/intrin/weaken.h" #include "libc/sock/sock.h" #include "libc/sysv/errfuns.h" #include "libc/zipos/zipos.internal.h" diff --git a/libc/calls/writev-metal.c b/libc/calls/writev-metal.c index 596a564e8..c94263782 100644 --- a/libc/calls/writev-metal.c +++ b/libc/calls/writev-metal.c @@ -16,8 +16,9 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/internal.h" +#include "libc/calls/struct/fd.internal.h" #include "libc/calls/struct/iovec.h" +#include "libc/calls/struct/iovec.internal.h" #include "libc/sysv/errfuns.h" ssize_t sys_writev_metal(struct Fd *fd, const struct iovec *iov, int iovlen) { diff --git a/libc/calls/writev-nt.c b/libc/calls/writev-nt.c index 49a31030f..5050b8e4d 100644 --- a/libc/calls/writev-nt.c +++ b/libc/calls/writev-nt.c @@ -16,8 +16,9 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/weaken.h" #include "libc/calls/internal.h" +#include "libc/calls/struct/iovec.internal.h" +#include "libc/intrin/weaken.h" #include "libc/sock/internal.h" #include "libc/sysv/errfuns.h" diff --git a/libc/calls/writev-serial.c b/libc/calls/writev-serial.c index 022df1d5f..319e78771 100644 --- a/libc/calls/writev-serial.c +++ b/libc/calls/writev-serial.c @@ -16,8 +16,9 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/internal.h" +#include "libc/calls/struct/fd.internal.h" #include "libc/calls/struct/iovec.h" +#include "libc/calls/struct/iovec.internal.h" #include "libc/nexgen32e/uart.internal.h" #include "libc/runtime/pc.internal.h" diff --git a/libc/calls/writev.c b/libc/calls/writev.c index 74d5524e9..9b27fc49a 100644 --- a/libc/calls/writev.c +++ b/libc/calls/writev.c @@ -16,16 +16,17 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/likely.h" -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" +#include "libc/calls/struct/iovec.internal.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/errno.h" #include "libc/intrin/asan.internal.h" #include "libc/intrin/describeflags.internal.h" #include "libc/intrin/kprintf.h" +#include "libc/intrin/likely.h" +#include "libc/intrin/weaken.h" #include "libc/sock/internal.h" #include "libc/sysv/errfuns.h" #include "libc/zipos/zipos.internal.h" diff --git a/libc/calls/writevuninterruptible.c b/libc/calls/writevuninterruptible.c index c1b86340d..5ec7391d6 100644 --- a/libc/calls/writevuninterruptible.c +++ b/libc/calls/writevuninterruptible.c @@ -16,7 +16,8 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/internal.h" +#include "libc/calls/struct/iovec.h" +#include "libc/calls/struct/iovec.internal.h" #include "libc/errno.h" #include "libc/sock/sock.h" diff --git a/libc/fmt/fmt.c b/libc/fmt/fmt.c index 55ddd6b13..b7c5a1153 100644 --- a/libc/fmt/fmt.c +++ b/libc/fmt/fmt.c @@ -17,14 +17,15 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" -#include "libc/intrin/bits.h" -#include "libc/intrin/weaken.h" +#include "libc/errno.h" #include "libc/fmt/conv.h" #include "libc/fmt/fmt.h" #include "libc/fmt/fmt.internal.h" #include "libc/fmt/internal.h" #include "libc/fmt/itoa.h" +#include "libc/intrin/bits.h" #include "libc/intrin/nomultics.internal.h" +#include "libc/intrin/weaken.h" #include "libc/macros.internal.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/bsr.h" diff --git a/libc/fmt/vcscanf.c b/libc/fmt/vcscanf.c index a344e2a55..9fc4df1a7 100644 --- a/libc/fmt/vcscanf.c +++ b/libc/fmt/vcscanf.c @@ -16,14 +16,15 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/weaken.h" #include "libc/fmt/conv.h" #include "libc/fmt/fmt.h" +#include "libc/intrin/weaken.h" #include "libc/mem/mem.h" #include "libc/runtime/runtime.h" #include "libc/str/oldutf16.internal.h" #include "libc/str/str.h" #include "libc/str/tpdecodecb.internal.h" +#include "libc/str/utf16.h" #include "libc/sysv/errfuns.h" /** @@ -254,8 +255,13 @@ int vcscanf(int callback(void *), int unget(int, void *), void *arg, } else if (tpdecodecb((wint_t *)&c, c, (void *)callback, arg) != -1) { if (charbytes == sizeof(char16_t)) { - j += abs(pututf16(&((char16_t *)buf)[j], bufsize - j - 1, c, - false)); + size_t k = 0; + unsigned w = EncodeUtf16(c); + do { + if ((j + 1) * 2 < bufsize) { + ((char16_t *)buf)[j++] = w; + } + } while ((w >>= 16)); } else { ((wchar_t *)buf)[j++] = (wchar_t)c; } diff --git a/libc/intrin/describeflags.internal.h b/libc/intrin/describeflags.internal.h index 290ee8514..aca06fb44 100644 --- a/libc/intrin/describeflags.internal.h +++ b/libc/intrin/describeflags.internal.h @@ -1,18 +1,6 @@ #ifndef COSMOPOLITAN_LIBC_INTRIN_DESCRIBEFLAGS_INTERNAL_H_ #define COSMOPOLITAN_LIBC_INTRIN_DESCRIBEFLAGS_INTERNAL_H_ -#include "libc/calls/struct/iovec.h" -#include "libc/calls/struct/rlimit.h" -#include "libc/calls/struct/sched_param.h" -#include "libc/calls/struct/sigaction.h" -#include "libc/calls/struct/sigaltstack.h" -#include "libc/calls/struct/sigset.h" -#include "libc/calls/struct/stat.h" -#include "libc/calls/struct/timespec.h" -#include "libc/calls/struct/timeval.h" #include "libc/mem/alloca.h" -#include "libc/nt/struct/iovec.h" -#include "libc/nt/struct/securityattributes.h" -#include "libc/sock/struct/sockaddr.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ @@ -45,7 +33,6 @@ const char *DescribeNtPageFlags(char[64], uint32_t); const char *DescribeNtPipeModeFlags(char[64], uint32_t); const char *DescribeNtPipeOpenFlags(char[64], uint32_t); const char *DescribeNtProcAccessFlags(char[256], uint32_t); -const char *DescribeNtSecurityAttributes(struct NtSecurityAttributes *); const char *DescribeNtStartFlags(char[128], uint32_t); const char *DescribeNtSymlinkFlags(char[64], uint32_t); const char *DescribeOpenFlags(char[128], int); @@ -56,26 +43,14 @@ const char *DescribeProtFlags(char[48], int); const char *DescribePtrace(char[12], int); const char *DescribePtraceEvent(char[32], int); const char *DescribeRemapFlags(char[48], int); -const char *DescribeRlimit(char[64], int, const struct rlimit *); const char *DescribeRlimitName(char[20], int); -const char *DescribeSchedParam(char[32], const struct sched_param *); const char *DescribeSchedPolicy(char[48], int); const char *DescribeSeccompOperation(int); -const char *DescribeSigaction(char[256], int, const struct sigaction *); -const char *DescribeSigaltstk(char[128], int, const struct sigaltstack *); -const char *DescribeSigset(char[128], int, const sigset_t *); const char *DescribeSockLevel(char[12], int); const char *DescribeSockOptname(char[32], int, int); -const char *DescribeSockaddr(char[128], const struct sockaddr *, size_t); const char *DescribeSocketFamily(char[12], int); const char *DescribeSocketProtocol(char[12], int); const char *DescribeSocketType(char[64], int); -const char *DescribeStat(char[300], int, const struct stat *); -const char *DescribeTimespec(char[45], int, const struct timespec *); -const char *DescribeTimeval(char[45], int, const struct timeval *); - -void DescribeIov(const struct iovec *, int, ssize_t); -void DescribeIovNt(const struct NtIovec *, uint32_t, ssize_t); #define DescribeCapability(x) DescribeCapability(alloca(20), x) #define DescribeClockName(x) DescribeClockName(alloca(32), x) @@ -106,22 +81,13 @@ void DescribeIovNt(const struct NtIovec *, uint32_t, ssize_t); #define DescribePtrace(i) DescribePtrace(alloca(12), i) #define DescribePtraceEvent(x) DescribePtraceEvent(alloca(32), x) #define DescribeRemapFlags(dirfd) DescribeRemapFlags(alloca(48), dirfd) -#define DescribeRlimit(rc, rl) DescribeRlimit(alloca(64), rc, rl) #define DescribeRlimitName(rl) DescribeRlimitName(alloca(20), rl) -#define DescribeSchedParam(x) DescribeSchedParam(alloca(32), x) #define DescribeSchedPolicy(x) DescribeSchedPolicy(alloca(48), x) -#define DescribeSigaction(rc, sa) DescribeSigaction(alloca(256), rc, sa) -#define DescribeSigaltstk(rc, ss) DescribeSigaltstk(alloca(128), rc, ss) -#define DescribeSigset(rc, ss) DescribeSigset(alloca(128), rc, ss) #define DescribeSockLevel(x) DescribeSockLevel(alloca(12), x) #define DescribeSockOptname(x, y) DescribeSockOptname(alloca(32), x, y) -#define DescribeSockaddr(sa, sz) DescribeSockaddr(alloca(128), sa, sz) #define DescribeSocketFamily(x) DescribeSocketFamily(alloca(12), x) #define DescribeSocketProtocol(x) DescribeSocketProtocol(alloca(12), x) #define DescribeSocketType(x) DescribeSocketType(alloca(64), x) -#define DescribeStat(rc, st) DescribeStat(alloca(300), rc, st) -#define DescribeTimespec(rc, ts) DescribeTimespec(alloca(45), rc, ts) -#define DescribeTimeval(rc, ts) DescribeTimeval(alloca(45), rc, ts) COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/intrin/describerlimit.c b/libc/intrin/describerlimit.c index 0cdbfef48..1d27b600e 100644 --- a/libc/intrin/describerlimit.c +++ b/libc/intrin/describerlimit.c @@ -17,6 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/strace.internal.h" +#include "libc/calls/struct/rlimit.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" #include "libc/intrin/kprintf.h" diff --git a/libc/intrin/describesigaction.c b/libc/intrin/describesigaction.c index f0a0789e0..06d316e9a 100644 --- a/libc/intrin/describesigaction.c +++ b/libc/intrin/describesigaction.c @@ -16,6 +16,8 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/calls/struct/sigaction.h" +#include "libc/calls/struct/sigset.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" #include "libc/intrin/describeflags.internal.h" diff --git a/libc/intrin/describesigset.c b/libc/intrin/describesigset.c index eab234543..b714ac55e 100644 --- a/libc/intrin/describesigset.c +++ b/libc/intrin/describesigset.c @@ -16,11 +16,12 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/popcnt.h" +#include "libc/calls/struct/sigset.h" +#include "libc/calls/struct/sigset.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" -#include "libc/intrin/describeflags.internal.h" #include "libc/intrin/kprintf.h" +#include "libc/intrin/popcnt.h" #include "libc/str/str.h" #define N 128 diff --git a/libc/intrin/describestat.c b/libc/intrin/describestat.c index 6e93e0e32..7c2e72aaf 100644 --- a/libc/intrin/describestat.c +++ b/libc/intrin/describestat.c @@ -16,9 +16,10 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/calls/struct/stat.h" +#include "libc/calls/struct/stat.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" -#include "libc/intrin/describeflags.internal.h" #include "libc/intrin/kprintf.h" const char *(DescribeStat)(char buf[300], int rc, const struct stat *st) { diff --git a/libc/intrin/describetimespec.c b/libc/intrin/describetimespec.c index 2eae307cd..c7f4d77f6 100644 --- a/libc/intrin/describetimespec.c +++ b/libc/intrin/describetimespec.c @@ -16,6 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/calls/struct/timespec.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" #include "libc/intrin/describeflags.internal.h" diff --git a/libc/intrin/futex_wait.c b/libc/intrin/futex_wait.c index f72e7b8e3..6a52d708c 100644 --- a/libc/intrin/futex_wait.c +++ b/libc/intrin/futex_wait.c @@ -18,6 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/strace.internal.h" #include "libc/calls/struct/timespec.h" +#include "libc/calls/struct/timespec.internal.h" #include "libc/dce.h" #include "libc/intrin/describeflags.internal.h" #include "libc/intrin/futex.internal.h" diff --git a/libc/isystem/time.h b/libc/isystem/time.h index c5545b847..89449f24c 100644 --- a/libc/isystem/time.h +++ b/libc/isystem/time.h @@ -1,5 +1,7 @@ #ifndef LIBC_ISYSTEM_TIME_H_ #define LIBC_ISYSTEM_TIME_H_ +#include "libc/calls/struct/timespec.h" +#include "libc/calls/struct/timeval.h" #include "libc/calls/weirdtypes.h" #include "libc/sysv/consts/sched.h" #include "libc/time/struct/tm.h" diff --git a/libc/log/backtrace2.c b/libc/log/backtrace2.c index 7cae490de..52c4794ca 100644 --- a/libc/log/backtrace2.c +++ b/libc/log/backtrace2.c @@ -16,13 +16,10 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/mem/alg.h" -#include "libc/mem/bisectcarleft.internal.h" -#include "libc/intrin/safemacros.internal.h" -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" +#include "libc/calls/struct/rusage.internal.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/calls/syscall_support-sysv.internal.h" #include "libc/dce.h" @@ -32,9 +29,13 @@ #include "libc/fmt/itoa.h" #include "libc/intrin/kprintf.h" #include "libc/intrin/promises.internal.h" +#include "libc/intrin/safemacros.internal.h" +#include "libc/intrin/weaken.h" #include "libc/log/backtrace.internal.h" #include "libc/log/color.internal.h" #include "libc/log/log.h" +#include "libc/mem/alg.h" +#include "libc/mem/bisectcarleft.internal.h" #include "libc/nexgen32e/gc.internal.h" #include "libc/runtime/gc.internal.h" #include "libc/runtime/runtime.h" diff --git a/libc/nt/struct/iovec.h b/libc/nt/struct/iovec.h index 86062bb97..2eaaa6b44 100644 --- a/libc/nt/struct/iovec.h +++ b/libc/nt/struct/iovec.h @@ -8,6 +8,8 @@ struct NtIovec { char *buf; }; +void DescribeIovNt(const struct NtIovec *, uint32_t, ssize_t); + COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_NT_STRUCT_IOVEC_H_ */ diff --git a/libc/nt/struct/securityattributes.h b/libc/nt/struct/securityattributes.h index 2529aa86d..604bd95c3 100644 --- a/libc/nt/struct/securityattributes.h +++ b/libc/nt/struct/securityattributes.h @@ -9,5 +9,7 @@ struct NtSecurityAttributes { bool32 bInheritHandle; }; +const char *DescribeNtSecurityAttributes(struct NtSecurityAttributes *); + #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_NT_STRUCT_SECURITYATTRIBUTES_H_ */ diff --git a/libc/runtime/arch_prctl.c b/libc/runtime/arch_prctl.c index ff0e40bc7..6ee17d98b 100644 --- a/libc/runtime/arch_prctl.c +++ b/libc/runtime/arch_prctl.c @@ -16,11 +16,12 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/asmflag.h" -#include "libc/intrin/bits.h" #include "libc/calls/calls.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/dce.h" +#include "libc/errno.h" +#include "libc/intrin/asmflag.h" +#include "libc/intrin/bits.h" #include "libc/nexgen32e/msr.h" #include "libc/nexgen32e/x86feature.h" #include "libc/runtime/pc.internal.h" diff --git a/libc/runtime/fork-nt.c b/libc/runtime/fork-nt.c index f3cddc83c..5f2735648 100644 --- a/libc/runtime/fork-nt.c +++ b/libc/runtime/fork-nt.c @@ -16,14 +16,15 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/weaken.h" #include "libc/calls/internal.h" #include "libc/calls/ntspawn.h" #include "libc/calls/state.internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/syscall_support-nt.internal.h" +#include "libc/calls/wincrash.internal.h" #include "libc/fmt/itoa.h" #include "libc/intrin/kprintf.h" +#include "libc/intrin/weaken.h" #include "libc/macros.internal.h" #include "libc/mem/alloca.h" #include "libc/mem/mem.h" diff --git a/libc/runtime/getinterpreterexecutablename.c b/libc/runtime/getinterpreterexecutablename.c index f9262f07a..e300623d5 100644 --- a/libc/runtime/getinterpreterexecutablename.c +++ b/libc/runtime/getinterpreterexecutablename.c @@ -19,6 +19,7 @@ #include "libc/calls/calls.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/dce.h" +#include "libc/errno.h" #include "libc/macros.internal.h" #include "libc/runtime/runtime.h" #include "libc/str/str.h" diff --git a/libc/runtime/printargs.c b/libc/runtime/printargs.c index 77cc9ddc6..4337437c1 100644 --- a/libc/runtime/printargs.c +++ b/libc/runtime/printargs.c @@ -48,6 +48,7 @@ #include "libc/runtime/stack.h" #include "libc/sock/internal.h" #include "libc/sock/sock.h" +#include "libc/sock/struct/pollfd.h" #include "libc/str/str.h" #include "libc/sysv/consts/auxv.h" #include "libc/sysv/consts/cap.h" diff --git a/libc/sock/accept-sysv.c b/libc/sock/accept-sysv.c index 084386275..d3137f5fd 100644 --- a/libc/sock/accept-sysv.c +++ b/libc/sock/accept-sysv.c @@ -18,6 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/dce.h" #include "libc/sock/internal.h" +#include "libc/sock/struct/sockaddr.internal.h" int sys_accept(int server, void *addr, uint32_t *addrsize) { int client; diff --git a/libc/sock/accept4-sysv.c b/libc/sock/accept4-sysv.c index 43c5c1e82..33d879c00 100644 --- a/libc/sock/accept4-sysv.c +++ b/libc/sock/accept4-sysv.c @@ -20,6 +20,7 @@ #include "libc/errno.h" #include "libc/sock/internal.h" #include "libc/sock/sock.h" +#include "libc/sock/struct/sockaddr.internal.h" int sys_accept4(int server, void *addr, uint32_t *addrsize, int flags) { if (!flags) return sys_accept(server, addr, addrsize); diff --git a/libc/sock/accept4.c b/libc/sock/accept4.c index 5bd589bb9..c17e72aa8 100644 --- a/libc/sock/accept4.c +++ b/libc/sock/accept4.c @@ -16,12 +16,13 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" -#include "libc/intrin/describeflags.internal.h" #include "libc/sock/internal.h" #include "libc/sock/sock.h" +#include "libc/sock/struct/sockaddr.internal.h" #include "libc/sock/syscall_fd.internal.h" #include "libc/sysv/errfuns.h" diff --git a/libc/sock/bind-sysv.c b/libc/sock/bind-sysv.c index 553005e2c..a53ec73ee 100644 --- a/libc/sock/bind-sysv.c +++ b/libc/sock/bind-sysv.c @@ -18,6 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/dce.h" #include "libc/sock/internal.h" +#include "libc/sock/struct/sockaddr.internal.h" int sys_bind(int fd, const void *addr, uint32_t addrsize) { union sockaddr_storage_bsd bsd; diff --git a/libc/sock/bind.c b/libc/sock/bind.c index b3e73f9d2..3bd93ad83 100644 --- a/libc/sock/bind.c +++ b/libc/sock/bind.c @@ -20,9 +20,9 @@ #include "libc/calls/strace.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" -#include "libc/intrin/describeflags.internal.h" #include "libc/sock/internal.h" #include "libc/sock/sock.h" +#include "libc/sock/struct/sockaddr.internal.h" #include "libc/sock/syscall_fd.internal.h" #include "libc/sysv/errfuns.h" diff --git a/libc/sock/connect-sysv.c b/libc/sock/connect-sysv.c index 24b0f62bc..ccd08a5a0 100644 --- a/libc/sock/connect-sysv.c +++ b/libc/sock/connect-sysv.c @@ -18,6 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/dce.h" #include "libc/sock/internal.h" +#include "libc/sock/struct/sockaddr.internal.h" int sys_connect(int fd, const void *addr, uint32_t addrsize) { union sockaddr_storage_bsd bsd; diff --git a/libc/sock/connect.c b/libc/sock/connect.c index d81be9414..2395ce371 100644 --- a/libc/sock/connect.c +++ b/libc/sock/connect.c @@ -16,13 +16,14 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" -#include "libc/intrin/describeflags.internal.h" #include "libc/intrin/kprintf.h" #include "libc/sock/internal.h" #include "libc/sock/sock.h" +#include "libc/sock/struct/sockaddr.internal.h" #include "libc/sock/syscall_fd.internal.h" #include "libc/sysv/errfuns.h" diff --git a/libc/sock/getpeername-sysv.c b/libc/sock/getpeername-sysv.c index d7993a9bd..81fcd2a75 100644 --- a/libc/sock/getpeername-sysv.c +++ b/libc/sock/getpeername-sysv.c @@ -18,6 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/dce.h" #include "libc/sock/internal.h" +#include "libc/sock/struct/sockaddr.internal.h" int sys_getpeername(int fd, void *out_addr, uint32_t *out_addrsize) { int rc; diff --git a/libc/sock/getpeername.c b/libc/sock/getpeername.c index 6e8825bf9..dda483b2a 100644 --- a/libc/sock/getpeername.c +++ b/libc/sock/getpeername.c @@ -16,12 +16,13 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" -#include "libc/intrin/describeflags.internal.h" #include "libc/sock/internal.h" #include "libc/sock/sock.h" +#include "libc/sock/struct/sockaddr.internal.h" #include "libc/sock/syscall_fd.internal.h" #include "libc/sysv/errfuns.h" diff --git a/libc/sock/getsockname-sysv.c b/libc/sock/getsockname-sysv.c index 19715117a..d37cd2a28 100644 --- a/libc/sock/getsockname-sysv.c +++ b/libc/sock/getsockname-sysv.c @@ -18,6 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/dce.h" #include "libc/sock/internal.h" +#include "libc/sock/struct/sockaddr.internal.h" int sys_getsockname(int fd, void *out_addr, uint32_t *out_addrsize) { int rc; diff --git a/libc/sock/getsockname.c b/libc/sock/getsockname.c index 83ab168d9..56ab5a5a7 100644 --- a/libc/sock/getsockname.c +++ b/libc/sock/getsockname.c @@ -16,12 +16,13 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" -#include "libc/intrin/describeflags.internal.h" #include "libc/sock/internal.h" #include "libc/sock/sock.h" +#include "libc/sock/struct/sockaddr.internal.h" #include "libc/sock/syscall_fd.internal.h" #include "libc/sysv/errfuns.h" diff --git a/libc/sock/getsockopt.c b/libc/sock/getsockopt.c index 991f3c9ed..b8173445a 100644 --- a/libc/sock/getsockopt.c +++ b/libc/sock/getsockopt.c @@ -16,6 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" diff --git a/libc/sock/internal.h b/libc/sock/internal.h index 11a3f7026..7d4438b7c 100644 --- a/libc/sock/internal.h +++ b/libc/sock/internal.h @@ -1,12 +1,12 @@ #ifndef COSMOPOLITAN_LIBC_SOCK_INTERNAL_H_ #define COSMOPOLITAN_LIBC_SOCK_INTERNAL_H_ +#include "libc/calls/struct/iovec.h" #include "libc/nt/struct/overlapped.h" #include "libc/nt/thunk/msabi.h" #include "libc/nt/winsock.h" #include "libc/sock/select.h" #include "libc/sock/sock.h" -#include "libc/sock/struct/msghdr.h" -#include "libc/sock/struct/pollfd.h" +#include "libc/sock/struct/sockaddr.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ @@ -23,49 +23,6 @@ COSMOPOLITAN_C_START_ #define FD_CLOSE (1 << FD_CLOSE_BIT) #define FD_CLOSE_BIT 5 -struct sockaddr_bsd { - uint8_t sa_len; /* « different type */ - uint8_t sa_family; /* « different type */ - char sa_data[14]; -}; - -struct sockaddr_in_bsd { - uint8_t sin_len; /* « different type */ - uint8_t sin_family; /* « different type */ - uint16_t sin_port; - struct in_addr sin_addr; - uint8_t sin_zero[8]; -}; - -struct msghdr_bsd { - void *msg_name; - uint32_t msg_namelen; - struct iovec *msg_iov; - uint32_t msg_iovlen; /* « different type */ - void *msg_control; - uint64_t msg_controllen; - uint32_t msg_flags; /* « different type */ -}; - -struct sockaddr_un_bsd { - uint8_t sun_len; /* sockaddr len including NUL on freebsd but excluding it on - openbsd/xnu */ - uint8_t sun_family; - char sun_path[108]; -}; - -union sockaddr_storage_bsd { - struct sockaddr_bsd sa; - struct sockaddr_in_bsd sin; - struct sockaddr_un_bsd sun; -}; - -union sockaddr_storage_linux { - struct sockaddr sa; - struct sockaddr_in sin; - struct sockaddr_un sun; -}; - /* ------------------------------------------------------------------------------------*/ #define SOCKFD_OVERLAP_BUFSIZ 128 @@ -108,17 +65,12 @@ int32_t sys_getsockopt(int32_t, int32_t, int32_t, void *, uint32_t *) hidden; int32_t sys_listen(int32_t, int32_t) hidden; int32_t sys_getsockname(int32_t, void *, uint32_t *) hidden; int32_t sys_getpeername(int32_t, void *, uint32_t *) hidden; -int32_t sys_poll(struct pollfd *, uint64_t, signed) hidden; int32_t sys_shutdown(int32_t, int32_t) hidden; int32_t sys_socket(int32_t, int32_t, int32_t) hidden; int32_t sys_socketpair(int32_t, int32_t, int32_t, int32_t[2]) hidden; -int64_t sys_readv(int32_t, const struct iovec *, int32_t) hidden; -int64_t sys_writev(int32_t, const struct iovec *, int32_t) hidden; ssize_t sys_recvfrom(int, void *, size_t, int, void *, uint32_t *) hidden; ssize_t sys_sendto(int, const void *, size_t, int, const void *, uint32_t) hidden; -ssize_t sys_sendmsg(int, const struct msghdr *, int) hidden; -ssize_t sys_recvmsg(int, struct msghdr *, int) hidden; int32_t sys_select(int32_t, fd_set *, fd_set *, fd_set *, struct timeval *) hidden; int sys_pselect(int, fd_set *, fd_set *, fd_set *, const struct timespec *, @@ -127,10 +79,9 @@ int sys_setsockopt(int, int, int, const void *, uint32_t) hidden; int32_t sys_epoll_create(int32_t) hidden; int32_t sys_epoll_ctl(int32_t, int32_t, int32_t, void *) hidden; int32_t sys_epoll_wait(int32_t, void *, int32_t, int32_t) hidden; -int sys_poll_metal(struct pollfd *, size_t, unsigned); -int sys_poll_nt(struct pollfd *, uint64_t, uint64_t *) hidden; int sys_socket_nt(int, int, int) hidden; + /* int sys_socketpair_nt_stream(int, int, int, int[2]) hidden; int sys_socketpair_nt_dgram(int, int, int, int[2]) hidden; @@ -138,12 +89,8 @@ int sys_socketpair_nt_dgram(int, int, int, int[2]) hidden; int sys_socketpair_nt(int, int, int, int[2]) hidden; int sys_select_nt(int, fd_set *, fd_set *, fd_set *, struct timeval *) hidden; -bool __asan_is_valid_msghdr(const struct msghdr *); -ssize_t sys_send_nt(int, const struct iovec *, size_t, uint32_t) hidden; size_t __iovec2nt(struct NtIovec[hasatleast 16], const struct iovec *, size_t) hidden; -ssize_t sys_sendto_nt(int, const struct iovec *, size_t, uint32_t, void *, - uint32_t) hidden; void WinSockInit(void) hidden; int64_t __winsockerr(void) nocallback hidden; @@ -155,11 +102,6 @@ struct SockFd *_dupsockfd(struct SockFd *) hidden; int64_t GetNtBaseSocket(int64_t) hidden; int sys_close_epoll(int) hidden; -int sockaddr2bsd(const void *, uint32_t, union sockaddr_storage_bsd *, - uint32_t *); -void sockaddr2linux(const union sockaddr_storage_bsd *, uint32_t, - union sockaddr_storage_linux *, uint32_t *); - COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_SOCK_INTERNAL_H_ */ diff --git a/libc/sock/listen-nt.c b/libc/sock/listen-nt.c index 1816e5223..bb6fbf5d1 100644 --- a/libc/sock/listen-nt.c +++ b/libc/sock/listen-nt.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" -#include "libc/calls/internal.h" #include "libc/nt/winsock.h" #include "libc/sock/internal.h" #include "libc/sock/syscall_fd.internal.h" diff --git a/libc/sock/recv-nt.c b/libc/sock/recv-nt.c index c9fba3f3b..1d62eaaa5 100644 --- a/libc/sock/recv-nt.c +++ b/libc/sock/recv-nt.c @@ -16,11 +16,12 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/likely.h" +#include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/iovec.h" #include "libc/errno.h" #include "libc/intrin/kprintf.h" +#include "libc/intrin/likely.h" #include "libc/nt/struct/overlapped.h" #include "libc/nt/winsock.h" #include "libc/sock/internal.h" diff --git a/libc/sock/recv.c b/libc/sock/recv.c index 79993705f..f07d6953b 100644 --- a/libc/sock/recv.c +++ b/libc/sock/recv.c @@ -18,6 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" +#include "libc/calls/struct/iovec.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" #include "libc/sock/internal.h" diff --git a/libc/sock/recvfrom-nt.c b/libc/sock/recvfrom-nt.c index 6eab61a6a..f13b0153e 100644 --- a/libc/sock/recvfrom-nt.c +++ b/libc/sock/recvfrom-nt.c @@ -16,6 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/calls/internal.h" #include "libc/calls/struct/iovec.h" #include "libc/errno.h" #include "libc/nt/struct/overlapped.h" diff --git a/libc/sock/recvfrom.c b/libc/sock/recvfrom.c index dbad12374..a0d210e25 100644 --- a/libc/sock/recvfrom.c +++ b/libc/sock/recvfrom.c @@ -16,13 +16,16 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/iovec.h" +#include "libc/calls/struct/iovec.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" #include "libc/nt/winsock.h" #include "libc/sock/internal.h" #include "libc/sock/sock.h" +#include "libc/sock/struct/sockaddr.internal.h" #include "libc/sock/syscall_fd.internal.h" #include "libc/sysv/errfuns.h" diff --git a/libc/sock/recvmsg.c b/libc/sock/recvmsg.c index be4798a0a..a2da9a986 100644 --- a/libc/sock/recvmsg.c +++ b/libc/sock/recvmsg.c @@ -19,9 +19,12 @@ #include "libc/assert.h" #include "libc/calls/internal.h" #include "libc/calls/struct/iovec.h" +#include "libc/calls/struct/iovec.internal.h" #include "libc/dce.h" -#include "libc/sock/internal.h" #include "libc/sock/sock.h" +#include "libc/sock/struct/msghdr.h" +#include "libc/sock/struct/msghdr.internal.h" +#include "libc/sock/struct/sockaddr.internal.h" #include "libc/sock/syscall_fd.internal.h" #include "libc/str/str.h" #include "libc/sysv/errfuns.h" diff --git a/libc/sock/select-nt.c b/libc/sock/select-nt.c index dfd1bd08f..bd5da7e13 100644 --- a/libc/sock/select-nt.c +++ b/libc/sock/select-nt.c @@ -19,9 +19,10 @@ #include "libc/calls/internal.h" #include "libc/calls/struct/timeval.h" #include "libc/macros.internal.h" -#include "libc/sock/internal.h" #include "libc/sock/select.h" #include "libc/sock/sock.h" +#include "libc/sock/struct/pollfd.h" +#include "libc/sock/struct/pollfd.internal.h" #include "libc/sysv/consts/poll.h" #include "libc/sysv/errfuns.h" diff --git a/libc/sock/send.c b/libc/sock/send.c index 2fe9ae644..c40dbada0 100644 --- a/libc/sock/send.c +++ b/libc/sock/send.c @@ -19,6 +19,7 @@ #include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/iovec.h" +#include "libc/calls/struct/iovec.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" #include "libc/macros.internal.h" diff --git a/libc/sock/sendfile.c b/libc/sock/sendfile.c index 123228957..ac3910b17 100644 --- a/libc/sock/sendfile.c +++ b/libc/sock/sendfile.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/safemacros.internal.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/sig.internal.h" @@ -25,6 +24,7 @@ #include "libc/calls/syscall_support-nt.internal.h" #include "libc/dce.h" #include "libc/intrin/kprintf.h" +#include "libc/intrin/safemacros.internal.h" #include "libc/nt/enum/wait.h" #include "libc/nt/errors.h" #include "libc/nt/files.h" diff --git a/libc/sock/sendmsg.c b/libc/sock/sendmsg.c index 2c65b9111..d7e4df3b6 100644 --- a/libc/sock/sendmsg.c +++ b/libc/sock/sendmsg.c @@ -20,12 +20,16 @@ #include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/iovec.h" +#include "libc/calls/struct/iovec.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" #include "libc/intrin/describeflags.internal.h" #include "libc/intrin/kprintf.h" #include "libc/sock/internal.h" #include "libc/sock/sock.h" +#include "libc/sock/struct/msghdr.h" +#include "libc/sock/struct/msghdr.internal.h" +#include "libc/sock/struct/sockaddr.internal.h" #include "libc/str/str.h" #include "libc/sysv/errfuns.h" diff --git a/libc/sock/sendto.c b/libc/sock/sendto.c index 506a9b798..b8b0f0631 100644 --- a/libc/sock/sendto.c +++ b/libc/sock/sendto.c @@ -20,11 +20,13 @@ #include "libc/calls/internal.h" #include "libc/calls/strace.internal.h" #include "libc/calls/struct/iovec.h" +#include "libc/calls/struct/iovec.internal.h" #include "libc/dce.h" #include "libc/intrin/asan.internal.h" #include "libc/macros.internal.h" #include "libc/sock/internal.h" #include "libc/sock/sock.h" +#include "libc/sock/struct/sockaddr.internal.h" #include "libc/str/str.h" #include "libc/sysv/errfuns.h" diff --git a/libc/sock/sockaddr2bsd.c b/libc/sock/sockaddr2bsd.c index a6bb2ed53..f2a534f4e 100644 --- a/libc/sock/sockaddr2bsd.c +++ b/libc/sock/sockaddr2bsd.c @@ -17,6 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/sock/internal.h" +#include "libc/sock/struct/sockaddr.internal.h" #include "libc/str/str.h" #include "libc/sysv/consts/af.h" #include "libc/sysv/errfuns.h" diff --git a/libc/sock/sockaddr2linux.c b/libc/sock/sockaddr2linux.c index 244dde623..91fed584d 100644 --- a/libc/sock/sockaddr2linux.c +++ b/libc/sock/sockaddr2linux.c @@ -19,6 +19,7 @@ #include "libc/intrin/kprintf.h" #include "libc/macros.internal.h" #include "libc/sock/internal.h" +#include "libc/sock/struct/sockaddr.internal.h" #include "libc/str/str.h" #include "libc/sysv/consts/af.h" #include "libc/sysv/errfuns.h" diff --git a/libc/sock/sockdebug.c b/libc/sock/sockdebug.c index a9f0b3dcd..970ff4fe6 100644 --- a/libc/sock/sockdebug.c +++ b/libc/sock/sockdebug.c @@ -21,6 +21,7 @@ #include "libc/intrin/describeflags.internal.h" #include "libc/macros.internal.h" #include "libc/sock/sock.h" +#include "libc/sock/struct/sockaddr.h" #include "libc/sock/struct/sockaddr6.h" #include "libc/str/str.h" #include "libc/sysv/consts/af.h" diff --git a/libc/sock/struct/msghdr.internal.h b/libc/sock/struct/msghdr.internal.h new file mode 100644 index 000000000..66d2cff92 --- /dev/null +++ b/libc/sock/struct/msghdr.internal.h @@ -0,0 +1,22 @@ +#ifndef COSMOPOLITAN_LIBC_SOCK_STRUCT_MSGHDR_INTERNAL_H_ +#define COSMOPOLITAN_LIBC_SOCK_STRUCT_MSGHDR_INTERNAL_H_ +#if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ + +struct msghdr_bsd { + void *msg_name; + uint32_t msg_namelen; + struct iovec *msg_iov; + uint32_t msg_iovlen; /* « different type */ + void *msg_control; + uint64_t msg_controllen; + uint32_t msg_flags; /* « different type */ +}; + +ssize_t sys_sendmsg(int, const struct msghdr *, int) hidden; +ssize_t sys_recvmsg(int, struct msghdr *, int) hidden; +bool __asan_is_valid_msghdr(const struct msghdr *); + +COSMOPOLITAN_C_END_ +#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ +#endif /* COSMOPOLITAN_LIBC_SOCK_STRUCT_MSGHDR_INTERNAL_H_ */ diff --git a/libc/sock/struct/pollfd.internal.h b/libc/sock/struct/pollfd.internal.h new file mode 100644 index 000000000..9c6cf2d63 --- /dev/null +++ b/libc/sock/struct/pollfd.internal.h @@ -0,0 +1,13 @@ +#ifndef COSMOPOLITAN_LIBC_SOCK_STRUCT_POLLFD_INTERNAL_H_ +#define COSMOPOLITAN_LIBC_SOCK_STRUCT_POLLFD_INTERNAL_H_ +#include "libc/sock/struct/pollfd.h" +#if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ + +int32_t sys_poll(struct pollfd *, uint64_t, signed) hidden; +int sys_poll_metal(struct pollfd *, size_t, unsigned); +int sys_poll_nt(struct pollfd *, uint64_t, uint64_t *) hidden; + +COSMOPOLITAN_C_END_ +#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ +#endif /* COSMOPOLITAN_LIBC_SOCK_STRUCT_POLLFD_INTERNAL_H_ */ diff --git a/libc/sock/struct/sockaddr.internal.h b/libc/sock/struct/sockaddr.internal.h new file mode 100644 index 000000000..4e9cbb453 --- /dev/null +++ b/libc/sock/struct/sockaddr.internal.h @@ -0,0 +1,51 @@ +#ifndef COSMOPOLITAN_LIBC_SOCK_STRUCT_SOCKADDR_INTERNAL_H_ +#define COSMOPOLITAN_LIBC_SOCK_STRUCT_SOCKADDR_INTERNAL_H_ +#include "libc/mem/alloca.h" +#include "libc/sock/struct/sockaddr.h" +#if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ + +struct sockaddr_bsd { + uint8_t sa_len; /* « different type */ + uint8_t sa_family; /* « different type */ + char sa_data[14]; +}; + +struct sockaddr_in_bsd { + uint8_t sin_len; /* « different type */ + uint8_t sin_family; /* « different type */ + uint16_t sin_port; + struct in_addr sin_addr; + uint8_t sin_zero[8]; +}; + +struct sockaddr_un_bsd { + uint8_t sun_len; /* sockaddr len including NUL on freebsd but excluding it on + openbsd/xnu */ + uint8_t sun_family; + char sun_path[108]; +}; + +union sockaddr_storage_bsd { + struct sockaddr_bsd sa; + struct sockaddr_in_bsd sin; + struct sockaddr_un_bsd sun; +}; + +union sockaddr_storage_linux { + struct sockaddr sa; + struct sockaddr_in sin; + struct sockaddr_un sun; +}; + +const char *DescribeSockaddr(char[128], const struct sockaddr *, size_t); +#define DescribeSockaddr(sa, sz) DescribeSockaddr(alloca(128), sa, sz) + +int sockaddr2bsd(const void *, uint32_t, union sockaddr_storage_bsd *, + uint32_t *); +void sockaddr2linux(const union sockaddr_storage_bsd *, uint32_t, + union sockaddr_storage_linux *, uint32_t *); + +COSMOPOLITAN_C_END_ +#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ +#endif /* COSMOPOLITAN_LIBC_SOCK_STRUCT_SOCKADDR_INTERNAL_H_ */ diff --git a/libc/sock/syscall_fd.internal.h b/libc/sock/syscall_fd.internal.h index 6b5db464e..0a7061b2c 100644 --- a/libc/sock/syscall_fd.internal.h +++ b/libc/sock/syscall_fd.internal.h @@ -1,6 +1,7 @@ #ifndef COSMOPOLITAN_LIBC_SOCK_SYSCALL_INTERNAL_H_ #define COSMOPOLITAN_LIBC_SOCK_SYSCALL_INTERNAL_H_ -#include "libc/calls/internal.h" +#include "libc/calls/struct/fd.internal.h" +#include "libc/calls/struct/iovec.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ @@ -15,7 +16,6 @@ int sys_listen_nt(struct Fd *, int) hidden; int sys_setsockopt_nt(struct Fd *, int, int, const void *, uint32_t) hidden; int sys_shutdown_nt(struct Fd *, int) hidden; ssize_t sys_recv_nt(struct Fd *, const struct iovec *, size_t, uint32_t) hidden; - ssize_t sys_recvfrom_nt(struct Fd *, const struct iovec *, size_t, uint32_t, void *, uint32_t *) hidden; diff --git a/libc/sock/syslog.c b/libc/sock/syslog.c index 52c4d7d29..0308fd326 100644 --- a/libc/sock/syslog.c +++ b/libc/sock/syslog.c @@ -16,13 +16,14 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/safemacros.internal.h" #include "libc/calls/calls.h" #include "libc/calls/dprintf.h" +#include "libc/calls/struct/timespec.h" #include "libc/calls/weirdtypes.h" #include "libc/dce.h" #include "libc/errno.h" #include "libc/fmt/fmt.h" +#include "libc/intrin/safemacros.internal.h" #include "libc/log/internal.h" #include "libc/macros.internal.h" #include "libc/nt/events.h" @@ -38,7 +39,6 @@ #include "libc/sysv/consts/o.h" #include "libc/sysv/consts/sock.h" #include "libc/time/struct/tm.h" -#include "libc/time/time.h" /* Note: log_facility should be initialized with LOG_USER by default, * but since LOG_USER is not a constant value, we cannot initialize it diff --git a/libc/stdio/dirstream.c b/libc/stdio/dirstream.c index 31b60ba00..7e62a735e 100644 --- a/libc/stdio/dirstream.c +++ b/libc/stdio/dirstream.c @@ -17,15 +17,17 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" -#include "libc/intrin/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/struct/stat.h" #include "libc/calls/syscall_support-nt.internal.h" +#include "libc/errno.h" #include "libc/intrin/asan.internal.h" #include "libc/intrin/nopl.h" #include "libc/intrin/pthread.h" +#include "libc/intrin/weaken.h" #include "libc/mem/mem.h" #include "libc/nt/enum/fileflagandattributes.h" #include "libc/nt/enum/filetype.h" diff --git a/libc/stdio/fwrite_unlocked.c b/libc/stdio/fwrite_unlocked.c index bbbbbb1e1..927411a58 100644 --- a/libc/stdio/fwrite_unlocked.c +++ b/libc/stdio/fwrite_unlocked.c @@ -20,6 +20,7 @@ #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/struct/iovec.h" +#include "libc/calls/struct/iovec.internal.h" #include "libc/errno.h" #include "libc/fmt/conv.h" #include "libc/macros.internal.h" diff --git a/libc/str/getutf16.ncabi.c b/libc/str/getutf16.ncabi.c deleted file mode 100644 index d59ae2e19..000000000 --- a/libc/str/getutf16.ncabi.c +++ /dev/null @@ -1,47 +0,0 @@ -/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ -│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ -╞══════════════════════════════════════════════════════════════════════════════╡ -│ Copyright 2020 Justine Alexandra Roberts Tunney │ -│ │ -│ Permission to use, copy, modify, and/or distribute this software for │ -│ any purpose with or without fee is hereby granted, provided that the │ -│ above copyright notice and this permission notice appear in all copies. │ -│ │ -│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ -│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ -│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ -│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ -│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ -│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ -│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ -│ PERFORMANCE OF THIS SOFTWARE. │ -╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/errno.h" -#include "libc/str/str.h" -#include "libc/str/utf16.h" - -/* TODO: DELETE */ - -/** - * Decodes UTF-16 character. - * - * @param s is a NUL-terminated string - * @return number of bytes (NUL counts as 1) or -1 w/ errno - * @note synchronization is performed to skip leading continuations; - * canonicalization and validation are performed to some extent - * @todo delete - */ -forcealignargpointer unsigned(getutf16)(const char16_t *p, wint_t *wc) { - unsigned skip = 0; - while (IsUtf16Cont(p[skip])) skip++; - if (IsUcs2(p[skip])) { - *wc = p[skip]; - return skip + 1; - } else if (!IsUtf16Cont(p[skip + 1])) { - *wc = INVALID_CODEPOINT; - return -1; - } else { - *wc = MergeUtf16(p[skip], p[skip + 1]); - return skip + 2; - } -} diff --git a/libc/str/oldutf16.internal.h b/libc/str/oldutf16.internal.h old mode 100644 new mode 100755 index 3d59dc475..e69de29bb --- a/libc/str/oldutf16.internal.h +++ b/libc/str/oldutf16.internal.h @@ -1,51 +0,0 @@ -#ifndef COSMOPOLITAN_LIBC_STR_OLDUTF16_H_ -#define COSMOPOLITAN_LIBC_STR_OLDUTF16_H_ -#if !(__ASSEMBLER__ + __LINKER__ + 0) -COSMOPOLITAN_C_START_ - -unsigned getutf16(const char16_t *, wint_t *); -int pututf16(char16_t *, size_t, wint_t, bool); - -#if defined(__MNO_RED_ZONE__) && defined(__GNUC__) && !defined(__STRICT_ANSI__) - -#define pututf16(BUF, SIZE, CH, AWESOME) __pututf16(BUF, SIZE, CH, AWESOME) -#define getutf16(BUF, CHPTR) __getutf16(BUF, CHPTR) - -forceinline int __pututf16(char16_t *s, size_t size, wint_t wc, - bool32 awesome) { - if (size >= 1 && (0x00 <= wc && wc <= 0xD7FF)) { - if (wc >= 32 || !awesome) { - s[0] = (char16_t)wc; - return 1; - } else if (size >= 2) { - s[0] = 0xd800; - s[1] = 0xdc00 | (char16_t)wc; - return 2; - } - } - int ax; - asm("call\tpututf16" - : "=a"(ax), "=m"(*(char(*)[size])s) - : "D"(s), "S"(size), "d"(wc) - : "cc"); - return ax; -} - -forceinline unsigned __getutf16(const char16_t *s, wint_t *wc) { - if ((0x00 <= s[0] && s[0] <= 0xD7FF)) { - *wc = s[0]; - return 1; - } - unsigned ax; - asm("call\tgetutf16" - : "=a"(ax), "=m"(*wc) - : "D"(s), "S"(wc), "m"(*s), "m"(*(char(*)[4])s) - : "cc"); - return ax; -} - -#endif - -COSMOPOLITAN_C_END_ -#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ -#endif /* COSMOPOLITAN_LIBC_STR_OLDUTF16_H_ */ diff --git a/libc/str/pututf16.ncabi.c b/libc/str/pututf16.ncabi.c deleted file mode 100644 index 5023c7550..000000000 --- a/libc/str/pututf16.ncabi.c +++ /dev/null @@ -1,60 +0,0 @@ -/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ -│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ -╞══════════════════════════════════════════════════════════════════════════════╡ -│ Copyright 2020 Justine Alexandra Roberts Tunney │ -│ │ -│ Permission to use, copy, modify, and/or distribute this software for │ -│ any purpose with or without fee is hereby granted, provided that the │ -│ above copyright notice and this permission notice appear in all copies. │ -│ │ -│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ -│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ -│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ -│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ -│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ -│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ -│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ -│ PERFORMANCE OF THIS SOFTWARE. │ -╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/str/oldutf16.internal.h" -#include "libc/str/str.h" - -/* TODO(jart): DELETE */ - -/** - * Encodes character to string as UTF-16. - * - * Implementation Details: The header macro should ensure this function - * is only called for truly huge codepoints. Plus this function makes a - * promise to not clobber any registers but %rax. - * - * @param s is what ch gets encoded to - * @param size is the number of shorts available in s - * @param awesome enables numbers the IETF unilaterally banned - * @return number of shorts written or -1 w/ errno - * @todo delete - */ -int(pututf16)(char16_t *s, size_t size, wint_t wc, bool awesome) { - wint_t wc2; - if (size) { - if ((0 <= wc && wc < 32) && awesome && size >= 2) { - s[0] = 0xd800; - s[1] = 0xdc00 | wc; - return 2; - } - if ((0 <= wc && wc <= 0xD7FF) || (0xE000 <= wc && wc <= 0xFFFF)) { - s[0] = wc; - return 1; - } else if (0x10000 <= wc && wc <= 0x10FFFF && size >= 2) { - wc2 = wc - 0x10000; - s[0] = (wc2 >> 10) + 0xd800; - s[1] = (wc2 & 1023) + 0xdc00; - return 2; - } else { - s[0] = INVALID_CODEPOINT; - return -1; - } - } else { - return 0; - } -} diff --git a/libc/str/str.h b/libc/str/str.h index 74a656700..6e9c08eea 100644 --- a/libc/str/str.h +++ b/libc/str/str.h @@ -175,14 +175,6 @@ typedef unsigned mbstate_t; axdx_t tprecode8to16(char16_t *, size_t, const char *); axdx_t tprecode16to8(char *, size_t, const char16_t *); -int strcmp8to16(const char *, const char16_t *) strlenesque; -int strncmp8to16(const char *, const char16_t *, size_t) strlenesque; -int strcasecmp8to16(const char *, const char16_t *) strlenesque; -int strncasecmp8to16(const char *, const char16_t *, size_t) strlenesque; -int strcmp16to8(const char16_t *, const char *) strlenesque; -int strncmp16to8(const char16_t *, const char *, size_t) strlenesque; -int strcasecmp16to8(const char16_t *, const char *) strlenesque; -int strncasecmp16to8(const char16_t *, const char *, size_t) strlenesque; wchar_t *wcsncpy(wchar_t *, const wchar_t *, size_t); int mbtowc(wchar_t *, const char *, size_t); size_t mbrtowc(wchar_t *, const char *, size_t, mbstate_t *); diff --git a/libc/str/strcasecmp8to16.c b/libc/str/strcasecmp8to16.c deleted file mode 100644 index d1fb39150..000000000 --- a/libc/str/strcasecmp8to16.c +++ /dev/null @@ -1,31 +0,0 @@ -/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ -│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ -╞══════════════════════════════════════════════════════════════════════════════╡ -│ Copyright 2020 Justine Alexandra Roberts Tunney │ -│ │ -│ Permission to use, copy, modify, and/or distribute this software for │ -│ any purpose with or without fee is hereby granted, provided that the │ -│ above copyright notice and this permission notice appear in all copies. │ -│ │ -│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ -│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ -│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ -│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ -│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ -│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ -│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ -│ PERFORMANCE OF THIS SOFTWARE. │ -╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/str/internal.h" -#include "libc/str/strcmp8to16i.internal.h" - -/** - * Compares UTF-8 and UTF-16 strings, ignoring case. - */ -int strcasecmp8to16(const char *s1, const char16_t *s2) { - return strcmp8to16i(s1, s2, -1ul, towlower); -} - -int strcasecmp16to8(const char16_t *s1, const char *s2) { - return -strcasecmp8to16(s2, s1); -} diff --git a/libc/str/strcmp8to16.c b/libc/str/strcmp8to16.c deleted file mode 100644 index 5b632375d..000000000 --- a/libc/str/strcmp8to16.c +++ /dev/null @@ -1,35 +0,0 @@ -/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ -│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ -╞══════════════════════════════════════════════════════════════════════════════╡ -│ Copyright 2020 Justine Alexandra Roberts Tunney │ -│ │ -│ Permission to use, copy, modify, and/or distribute this software for │ -│ any purpose with or without fee is hereby granted, provided that the │ -│ above copyright notice and this permission notice appear in all copies. │ -│ │ -│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ -│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ -│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ -│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ -│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ -│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ -│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ -│ PERFORMANCE OF THIS SOFTWARE. │ -╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/str/internal.h" -#include "libc/str/strcmp8to16i.internal.h" - -forceinline unsigned identity32u(unsigned x) { - return x; -} - -/** - * Compares UTF-8 and UTF-16 strings. - */ -int strcmp8to16(const char *s1, const char16_t *s2) { - return strcmp8to16i(s1, s2, -1ul, identity32u); -} - -int strcmp16to8(const char16_t *s1, const char *s2) { - return -strcmp8to16(s2, s1); -} diff --git a/libc/str/strcmp8to16i.internal.h b/libc/str/strcmp8to16i.internal.h deleted file mode 100644 index bf065b6b8..000000000 --- a/libc/str/strcmp8to16i.internal.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef COSMOPOLITAN_LIBC_STR_STRCMP8TO16I_H_ -#define COSMOPOLITAN_LIBC_STR_STRCMP8TO16I_H_ -#include "libc/fmt/conv.h" -#include "libc/macros.internal.h" -#include "libc/str/oldutf16.internal.h" -#include "libc/str/str.h" -#include "libc/str/tpdecode.internal.h" -#if !(__ASSEMBLER__ + __LINKER__ + 0) -COSMOPOLITAN_C_START_ - -forceinline int strcmp8to16i(const char *s1, const char16_t *s2, size_t n, - unsigned xlat(unsigned)) { - int res = 0; - if (n) { - do { - unsigned i, j; - wint_t wc1, wc2; - i = tpdecode(s1, &wc1); - j = getutf16(s2, &wc2); - s1 += ABS(i); - s2 += ABS(j); - if ((res = xlat(wc1) - xlat(wc2)) || !wc1) break; - } while (n == -1ul || --n); - } - return res; -} - -COSMOPOLITAN_C_END_ -#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ -#endif /* COSMOPOLITAN_LIBC_STR_STRCMP8TO16I_H_ */ diff --git a/libc/str/strncasecmp8to16.c b/libc/str/strncasecmp8to16.c deleted file mode 100644 index 44c4ae2d7..000000000 --- a/libc/str/strncasecmp8to16.c +++ /dev/null @@ -1,33 +0,0 @@ -/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ -│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ -╞══════════════════════════════════════════════════════════════════════════════╡ -│ Copyright 2020 Justine Alexandra Roberts Tunney │ -│ │ -│ Permission to use, copy, modify, and/or distribute this software for │ -│ any purpose with or without fee is hereby granted, provided that the │ -│ above copyright notice and this permission notice appear in all copies. │ -│ │ -│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ -│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ -│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ -│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ -│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ -│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ -│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ -│ PERFORMANCE OF THIS SOFTWARE. │ -╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/assert.h" -#include "libc/str/internal.h" -#include "libc/str/strcmp8to16i.internal.h" - -/** - * Compares UTF-8 and UTF-16 strings, ignoring case, with limit. - */ -int strncasecmp8to16(const char *s1, const char16_t *s2, size_t n) { - assert(n != -1ul); - return strcmp8to16i(s1, s2, n, towlower); -} - -int strncasecmp16to8(const char16_t *s1, const char *s2, size_t n) { - return -strncasecmp8to16(s2, s1, n); -} diff --git a/libc/str/strncmp8to16.c b/libc/str/strncmp8to16.c deleted file mode 100644 index c0bf16634..000000000 --- a/libc/str/strncmp8to16.c +++ /dev/null @@ -1,37 +0,0 @@ -/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ -│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ -╞══════════════════════════════════════════════════════════════════════════════╡ -│ Copyright 2020 Justine Alexandra Roberts Tunney │ -│ │ -│ Permission to use, copy, modify, and/or distribute this software for │ -│ any purpose with or without fee is hereby granted, provided that the │ -│ above copyright notice and this permission notice appear in all copies. │ -│ │ -│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ -│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ -│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ -│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ -│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ -│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ -│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ -│ PERFORMANCE OF THIS SOFTWARE. │ -╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/assert.h" -#include "libc/str/internal.h" -#include "libc/str/strcmp8to16i.internal.h" - -forceinline unsigned identity32u(unsigned x) { - return x; -} - -/** - * Compares UTF-8 and UTF-16 strings, with limit. - */ -int strncmp8to16(const char *s1, const char16_t *s2, size_t n) { - assert(n != -1ul); - return strcmp8to16i(s1, s2, n, identity32u); -} - -int strncmp16to8(const char16_t *s1, const char *s2, size_t n) { - return -strncmp8to16(s2, s1, n); -} diff --git a/libc/str/strnwidth16.c b/libc/str/strnwidth16.c index d99f50684..fd3122152 100644 --- a/libc/str/strnwidth16.c +++ b/libc/str/strnwidth16.c @@ -17,21 +17,28 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/intrin/safemacros.internal.h" -#include "libc/str/oldutf16.internal.h" #include "libc/str/str.h" #include "libc/str/unicode.h" +#include "libc/str/utf16.h" /** * Returns monospace display width of UTF-16 or UCS-2 string. */ int strnwidth16(const char16_t *p, size_t n, size_t o) { size_t l; - wint_t wc; + wint_t x, y; l = 0; if (n) { - while (*p) { - p += getutf16(p, &wc); - l += max(0, wcwidth(wc)); + while ((x = *p++)) { + if (!IsUcs2(x)) { + if ((y = *p++)) { + x = MergeUtf16(x, y); + } else { + ++l; + break; + } + } + l += max(0, wcwidth(x)); } } return l; diff --git a/libc/sysv/errfuns.h b/libc/sysv/errfuns.h index efdc02c37..c1582b536 100644 --- a/libc/sysv/errfuns.h +++ b/libc/sysv/errfuns.h @@ -1,6 +1,5 @@ #ifndef COSMOPOLITAN_LIBC_SYSV_ERRFUNS_H_ #define COSMOPOLITAN_LIBC_SYSV_ERRFUNS_H_ -#include "libc/errno.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) /** diff --git a/libc/time/dsleep.c b/libc/time/dsleep.c index c261ffc2e..ca6c5ffe7 100644 --- a/libc/time/dsleep.c +++ b/libc/time/dsleep.c @@ -16,6 +16,7 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/calls/struct/timespec.h" #include "libc/nexgen32e/nexgen32e.h" #include "libc/time/time.h" diff --git a/libc/time/futimes.c b/libc/time/futimes.c index d07c680a6..92c61c47e 100644 --- a/libc/time/futimes.c +++ b/libc/time/futimes.c @@ -16,7 +16,8 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/time/time.h" +#include "libc/calls/struct/timespec.h" +#include "libc/calls/struct/timeval.h" /** * Sets atime/mtime on file descriptor. diff --git a/libc/time/futimesat.c b/libc/time/futimesat.c index 232183c24..215e80450 100644 --- a/libc/time/futimesat.c +++ b/libc/time/futimesat.c @@ -16,7 +16,8 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/time/time.h" +#include "libc/calls/struct/timespec.h" +#include "libc/calls/struct/timeval.h" /** * Changes last accessed/modified times on file. diff --git a/libc/time/struct/timezone.h b/libc/time/struct/timezone.h index c6db7a950..28cfa2186 100644 --- a/libc/time/struct/timezone.h +++ b/libc/time/struct/timezone.h @@ -1,11 +1,13 @@ #ifndef COSMOPOLITAN_LIBC_TIME_STRUCT_TIMEZONE_H_ #define COSMOPOLITAN_LIBC_TIME_STRUCT_TIMEZONE_H_ #if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ struct timezone { int32_t tz_minuteswest; int32_t tz_dsttime; }; +COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_TIME_STRUCT_TIMEZONE_H_ */ diff --git a/libc/time/struct/tm.h b/libc/time/struct/tm.h index 0cdc41668..20bff71bf 100644 --- a/libc/time/struct/tm.h +++ b/libc/time/struct/tm.h @@ -1,6 +1,7 @@ #ifndef COSMOPOLITAN_LIBC_TIME_STRUCT_TM_H_ #define COSMOPOLITAN_LIBC_TIME_STRUCT_TM_H_ #if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ struct tm { int32_t tm_sec; @@ -16,5 +17,20 @@ struct tm { const char *tm_zone; }; +struct tm *gmtime_r(const int64_t *, struct tm *); +struct tm *localtime_r(const int64_t *, struct tm *); +int64_t timegm(struct tm *); +int64_t mktime(struct tm *); +int64_t timelocal(struct tm *); +int64_t timeoff(struct tm *, long); +char *strptime(const char *, const char *, struct tm *); +size_t strftime(char *, size_t, const char *, const struct tm *) + strftimeesque(3); +char *asctime(const struct tm *); +char *asctime_r(const struct tm *, char[hasatleast 64]); +char *iso8601(char[hasatleast 20], struct tm *); +size_t wcsftime(wchar_t *, size_t, const wchar_t *, const struct tm *); + +COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_TIME_STRUCT_TM_H_ */ diff --git a/libc/time/struct/utimbuf.h b/libc/time/struct/utimbuf.h index b5f5e35b5..54d684a6a 100644 --- a/libc/time/struct/utimbuf.h +++ b/libc/time/struct/utimbuf.h @@ -1,11 +1,13 @@ #ifndef COSMOPOLITAN_LIBC_TIME_STRUCT_UTIMBUF_H_ #define COSMOPOLITAN_LIBC_TIME_STRUCT_UTIMBUF_H_ #if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ struct utimbuf { int64_t actime; /* access time */ int64_t modtime; /* modified time */ }; +COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ #endif /* COSMOPOLITAN_LIBC_TIME_STRUCT_UTIMBUF_H_ */ diff --git a/libc/time/struct/utimbuf.internal.h b/libc/time/struct/utimbuf.internal.h new file mode 100644 index 000000000..9e9652a07 --- /dev/null +++ b/libc/time/struct/utimbuf.internal.h @@ -0,0 +1,11 @@ +#ifndef COSMOPOLITAN_LIBC_TIME_STRUCT_UTIMBUF_INTERNAL_H_ +#define COSMOPOLITAN_LIBC_TIME_STRUCT_UTIMBUF_INTERNAL_H_ +#include "libc/time/struct/utimbuf.h" +#if !(__ASSEMBLER__ + __LINKER__ + 0) +COSMOPOLITAN_C_START_ + +int sys_utime(const char *, const struct utimbuf *) hidden; + +COSMOPOLITAN_C_END_ +#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ +#endif /* COSMOPOLITAN_LIBC_TIME_STRUCT_UTIMBUF_INTERNAL_H_ */ diff --git a/libc/time/time.h b/libc/time/time.h index f85c82855..0d8175017 100644 --- a/libc/time/time.h +++ b/libc/time/time.h @@ -1,9 +1,5 @@ #ifndef COSMOPOLITAN_LIBC_TIME_TIME_H_ #define COSMOPOLITAN_LIBC_TIME_TIME_H_ -#include "libc/calls/struct/itimerval.h" -#include "libc/calls/struct/timespec.h" -#include "libc/calls/struct/timeval.h" -#include "libc/time/struct/timezone.h" #include "libc/time/struct/tm.h" #include "libc/time/struct/utimbuf.h" #if !(__ASSEMBLER__ + __LINKER__ + 0) @@ -20,55 +16,25 @@ extern long CLOCKS_PER_SEC; extern long timezone; extern int daylight; -int64_t clock(void); -int64_t time(int64_t *); -int gettimeofday(struct timeval *, struct timezone *); -int clock_gettime(int, struct timespec *); -int clock_getres(int, struct timespec *); - -int usleep(uint32_t); -unsigned sleep(unsigned); -int nanosleep(const struct timespec *, struct timespec *); -unsigned alarm(unsigned); -int getitimer(int, struct itimerval *); -int setitimer(int, const struct itimerval *, struct itimerval *); - -void tzset(void); -struct tm *gmtime(const int64_t *); -struct tm *gmtime_r(const int64_t *, struct tm *); -struct tm *localtime(const int64_t *); -struct tm *localtime_r(const int64_t *, struct tm *); -int64_t timegm(struct tm *); -int64_t mktime(struct tm *); -int64_t timelocal(struct tm *); -int64_t timeoff(struct tm *, long); -int64_t time2posix(int64_t) pureconst; -int64_t posix2time(int64_t) pureconst; - -char *strptime(const char *, const char *, struct tm *); -size_t strftime(char *, size_t, const char *, const struct tm *) - strftimeesque(3); -char *asctime(const struct tm *); char *ctime(const int64_t *); char *ctime_r(const int64_t *, char[hasatleast 64]); -char *asctime_r(const struct tm *, char[hasatleast 64]); - -int futimens(int, const struct timespec[2]); -int utimensat(int, const char *, const struct timespec[2], int); -int utimes(const char *, const struct timeval[2]); -int utime(const char *, const struct utimbuf *); -int futimes(int, const struct timeval[2]); -int futimesat(int, const char *, const struct timeval[2]); - -long double dtime(int); -long double dsleep(long double); -extern long double (*nowl)(void); -long double ConvertTicksToNanos(uint64_t); -void RefreshTime(void); - double difftime(int64_t, int64_t) dontthrow pureconst; -char *iso8601(char[hasatleast 20], struct tm *); -size_t wcsftime(wchar_t *, size_t, const wchar_t *, const struct tm *); +extern long double (*nowl)(void); +int usleep(uint32_t); +int utime(const char *, const struct utimbuf *); +int64_t clock(void); +int64_t posix2time(int64_t) pureconst; +int64_t time(int64_t *); +int64_t time2posix(int64_t) pureconst; +long double ConvertTicksToNanos(uint64_t); +long double dsleep(long double); +long double dtime(int); +struct tm *gmtime(const int64_t *); +struct tm *localtime(const int64_t *); +unsigned alarm(unsigned); +unsigned sleep(unsigned); +void RefreshTime(void); +void tzset(void); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/test/libc/calls/clock_gettime_test.c b/test/libc/calls/clock_gettime_test.c index 8d77d161b..736548d83 100644 --- a/test/libc/calls/clock_gettime_test.c +++ b/test/libc/calls/clock_gettime_test.c @@ -19,6 +19,7 @@ #include "libc/calls/clock_gettime.internal.h" #include "libc/calls/internal.h" #include "libc/calls/struct/timespec.h" +#include "libc/calls/struct/timespec.internal.h" #include "libc/calls/struct/timeval.h" #include "libc/calls/syscall_support-sysv.internal.h" #include "libc/dce.h" diff --git a/test/libc/calls/read_test.c b/test/libc/calls/read_test.c index bbb5bb866..5f5a66897 100644 --- a/test/libc/calls/read_test.c +++ b/test/libc/calls/read_test.c @@ -19,6 +19,7 @@ #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/struct/iovec.h" +#include "libc/calls/struct/iovec.internal.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/sock/internal.h" #include "libc/sysv/consts/nr.h" diff --git a/test/libc/calls/setitimer_test.c b/test/libc/calls/setitimer_test.c index 8fd29aaa6..c568e7541 100644 --- a/test/libc/calls/setitimer_test.c +++ b/test/libc/calls/setitimer_test.c @@ -17,6 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" +#include "libc/calls/struct/itimerval.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/siginfo.h" #include "libc/calls/struct/sigset.h" diff --git a/test/libc/calls/write_test.c b/test/libc/calls/write_test.c index dc443ad00..f6e7cb4a5 100644 --- a/test/libc/calls/write_test.c +++ b/test/libc/calls/write_test.c @@ -19,6 +19,7 @@ #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/struct/iovec.h" +#include "libc/calls/struct/iovec.internal.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/sock/internal.h" #include "libc/sysv/consts/nr.h" diff --git a/test/libc/intrin/describesigset_test.c b/test/libc/intrin/describesigset_test.c index 30167326c..e59b6f576 100644 --- a/test/libc/intrin/describesigset_test.c +++ b/test/libc/intrin/describesigset_test.c @@ -17,6 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/struct/sigset.h" +#include "libc/calls/struct/sigset.internal.h" #include "libc/intrin/describeflags.internal.h" #include "libc/sysv/consts/sig.h" #include "libc/testlib/testlib.h" diff --git a/test/libc/str/getutf16_test.c b/test/libc/str/getutf16_test.c deleted file mode 100644 index a941dc8b7..000000000 --- a/test/libc/str/getutf16_test.c +++ /dev/null @@ -1,51 +0,0 @@ -/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ -│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ -╞══════════════════════════════════════════════════════════════════════════════╡ -│ Copyright 2020 Justine Alexandra Roberts Tunney │ -│ │ -│ Permission to use, copy, modify, and/or distribute this software for │ -│ any purpose with or without fee is hereby granted, provided that the │ -│ above copyright notice and this permission notice appear in all copies. │ -│ │ -│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ -│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ -│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ -│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ -│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ -│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ -│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ -│ PERFORMANCE OF THIS SOFTWARE. │ -╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/bits.h" -#include "libc/str/oldutf16.internal.h" -#include "libc/str/str.h" -#include "libc/str/tpdecode.internal.h" -#include "libc/testlib/testlib.h" - -TEST(getutf16, testNul) { - wint_t wc; - EXPECT_EQ(1, getutf16(u"", &wc)); - EXPECT_EQ('\0', wc); - EXPECT_EQ(1, (getutf16)(u"", &wc)); - EXPECT_EQ('\0', wc); -} - -TEST(getutf16, testBasic) { - wint_t wc; - EXPECT_EQ(1, getutf16(u"h", &wc)); - EXPECT_EQ('h', wc); - EXPECT_EQ(1, (getutf16)(u"h", &wc)); - EXPECT_EQ('h', wc); -} - -TEST(getutf16, testAegeanNumberSupplementaryPlane) { - wint_t wc; - EXPECT_EQ(4, tpdecode("𐄷", &wc)); - EXPECT_EQ(4, tpdecode("\xF0\x90\x84\xB7", &wc)); - EXPECT_EQ(0x10137, wc); - EXPECT_EQ(2, strlen16(u"𐄷")); - EXPECT_EQ(2, getutf16(u"𐄷", &wc)); - EXPECT_EQ(0x10137, wc); - EXPECT_EQ(2, (getutf16)(u"𐄷", &wc)); - EXPECT_EQ(0x10137, wc); -} diff --git a/test/libc/str/pututf16_test.c b/test/libc/str/pututf16_test.c deleted file mode 100644 index 49e1fa5d5..000000000 --- a/test/libc/str/pututf16_test.c +++ /dev/null @@ -1,78 +0,0 @@ -/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│ -│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│ -╞══════════════════════════════════════════════════════════════════════════════╡ -│ Copyright 2020 Justine Alexandra Roberts Tunney │ -│ │ -│ Permission to use, copy, modify, and/or distribute this software for │ -│ any purpose with or without fee is hereby granted, provided that the │ -│ above copyright notice and this permission notice appear in all copies. │ -│ │ -│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ -│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ -│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ -│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ -│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ -│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ -│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ -│ PERFORMANCE OF THIS SOFTWARE. │ -╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/intrin/bits.h" -#include "libc/mem/mem.h" -#include "libc/runtime/gc.internal.h" -#include "libc/str/oldutf16.internal.h" -#include "libc/str/str.h" -#include "libc/testlib/testlib.h" -#include "libc/str/unicode.h" - -unsigned n; -size_t size; -wchar_t *str; -char16_t *b, *buf; - -TEST(pututf16, testEmpty) { - EXPECT_EQ(0, pututf16(NULL, 0, u'j', false)); - EXPECT_EQ(0, (pututf16)(NULL, 0, u'j', false)); -} - -TEST(pututf16, testNul) { - size = 1; - buf = malloc(size * sizeof(char16_t)); - EXPECT_EQ(1, pututf16(buf, size, u'\0', false)); - EXPECT_EQ(u'\0', buf[0]); - buf[0] = '\7'; - EXPECT_EQ(1, (pututf16)(buf, size, u'\0', false)); - EXPECT_EQ(u'\0', buf[0]); - free(buf); -} - -TEST(pututf16, testAscii) { - size = 1; - buf = malloc(size * sizeof(char16_t)); - EXPECT_EQ(1, pututf16(buf, size, u'j', false)); - EXPECT_EQ(u'j', buf[0]); - EXPECT_EQ(1, (pututf16)(buf, size, u't', false)); - EXPECT_EQ(u't', buf[0]); - free(buf); -} - -TEST(pututf16, testGothicSupplementaryPlane) { - size = 2; - buf = malloc(size * sizeof(char16_t)); - EXPECT_EQ(2, pututf16(buf, size, L'𐌰', false)); - EXPECT_STREQN(u"𐌰", buf, 1); - EXPECT_EQ(2, (pututf16)(buf, size, L'𐌱', false)); - EXPECT_STREQN(u"𐌱", buf, 1); - free(buf); -} - -TEST(pututf16, testEmojiAndEmojiPresentationModifier_areBothInAstralPlanes) { - n = 8; - b = gc(malloc(sizeof(char16_t) * n)); - str = L"\U0001F466\U0001F3FF"; - memset(b, 0, n * sizeof(char16_t)); - EXPECT_EQ(2, pututf16(b, n, str[0], false)); - EXPECT_BINEQ(u"=╪f▄    ", b); - memset(b, 0, n * sizeof(char16_t)); - EXPECT_EQ(2, pututf16(b, n, str[1], false)); - EXPECT_BINEQ(u"<╪λ▀    ", b); -} diff --git a/test/libc/str/strcmp_test.c b/test/libc/str/strcmp_test.c index a45e953e7..c17b2a064 100644 --- a/test/libc/str/strcmp_test.c +++ b/test/libc/str/strcmp_test.c @@ -17,14 +17,14 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" -#include "libc/intrin/bits.h" #include "libc/dce.h" +#include "libc/intrin/bits.h" #include "libc/macros.internal.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/cachesize.h" #include "libc/nexgen32e/x86feature.h" -#include "libc/stdio/rand.h" #include "libc/runtime/gc.internal.h" +#include "libc/stdio/rand.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" @@ -319,13 +319,6 @@ TEST(wcscasecmp, testItWorksCase) { EXPECT_NE(0, wcscasecmp(L"hello", L"yello")); } -TEST(strcasecmp8to16, testItWorksCase) { - EXPECT_EQ(0, strcasecmp8to16("hello", u"HELLO")); - EXPECT_EQ(0, strcasecmp8to16("hello", u"Hello")); - EXPECT_EQ(0, strcasecmp8to16("hello", u"hello")); - EXPECT_NE(0, strcasecmp8to16("hello", u"yello")); -} - /*───────────────────────────────────────────────────────────────────────────│─╗ │ test/libc/str/strcmp_test.c § nontrivial length ─╬─│┼ ╚────────────────────────────────────────────────────────────────────────────│*/ @@ -607,6 +600,6 @@ BENCH(memcmp, bench) { EZBENCH2("memcmp big", donothing, EXPROPRIATE(memcmp(kHyperion, copy, kHyperionSize))); copy = gc(strdup("tough little ship")); - EZBENCH2("memcmp 19", donothing, - EXPROPRIATE(memcmp("tough little ship", copy, 19))); + EZBENCH2("memcmp 18", donothing, + EXPROPRIATE(memcmp("tough little ship", copy, 18))); } diff --git a/third_party/lua/lunix.c b/third_party/lua/lunix.c index c3f527011..e341349f9 100644 --- a/third_party/lua/lunix.c +++ b/third_party/lua/lunix.c @@ -17,7 +17,6 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" -#include "libc/intrin/bits.h" #include "libc/calls/calls.h" #include "libc/calls/ioctl.h" #include "libc/calls/makedev.h" @@ -26,6 +25,7 @@ #include "libc/calls/struct/bpf.h" #include "libc/calls/struct/dirent.h" #include "libc/calls/struct/itimerval.h" +#include "libc/calls/struct/rlimit.h" #include "libc/calls/struct/rusage.h" #include "libc/calls/struct/siginfo.h" #include "libc/calls/struct/sigset.h" @@ -39,6 +39,7 @@ #include "libc/fmt/conv.h" #include "libc/fmt/fmt.h" #include "libc/fmt/magnumstrs.internal.h" +#include "libc/intrin/bits.h" #include "libc/log/log.h" #include "libc/macros.internal.h" #include "libc/mem/fmt.h" diff --git a/third_party/python/Modules/_lsprof.c b/third_party/python/Modules/_lsprof.c index 0bb9fd164..17df4187b 100644 --- a/third_party/python/Modules/_lsprof.c +++ b/third_party/python/Modules/_lsprof.c @@ -4,6 +4,7 @@ │ Python 3 │ │ https://docs.python.org/3/license.html │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/calls/struct/timeval.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/Modules/_posixsubprocess.c b/third_party/python/Modules/_posixsubprocess.c index c58fc4323..be7dfcbfb 100644 --- a/third_party/python/Modules/_posixsubprocess.c +++ b/third_party/python/Modules/_posixsubprocess.c @@ -10,6 +10,7 @@ #include "libc/calls/weirdtypes.h" #include "libc/dce.h" #include "libc/errno.h" +#include "libc/runtime/runtime.h" #include "libc/runtime/sysconf.h" #include "libc/sysv/consts/o.h" #include "third_party/python/Include/abstract.h" diff --git a/third_party/python/Modules/posixmodule.c b/third_party/python/Modules/posixmodule.c index 8d05b99ab..fd404f1c1 100644 --- a/third_party/python/Modules/posixmodule.c +++ b/third_party/python/Modules/posixmodule.c @@ -5,15 +5,16 @@ │ https://docs.python.org/3/license.html │ ╚─────────────────────────────────────────────────────────────────────────────*/ #define PY_SSIZE_T_CLEAN -#include "libc/mem/alg.h" #include "libc/assert.h" -#include "libc/intrin/weaken.h" #include "libc/calls/calls.h" #include "libc/calls/internal.h" #include "libc/calls/makedev.h" #include "libc/calls/struct/dirent.h" +#include "libc/calls/struct/iovec.h" #include "libc/calls/struct/sched_param.h" #include "libc/calls/struct/stat.macros.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" @@ -22,7 +23,9 @@ #include "libc/calls/weirdtypes.h" #include "libc/dce.h" #include "libc/errno.h" +#include "libc/intrin/weaken.h" #include "libc/log/log.h" +#include "libc/mem/alg.h" #include "libc/nt/createfile.h" #include "libc/nt/dll.h" #include "libc/nt/enum/creationdisposition.h" @@ -52,6 +55,7 @@ #include "libc/sysv/consts/w.h" #include "libc/sysv/consts/waitid.h" #include "libc/sysv/errfuns.h" +#include "libc/time/struct/utimbuf.h" #include "libc/time/time.h" #include "libc/x/x.h" #include "third_party/musl/passwd.h" diff --git a/third_party/python/Python/initstdio.c b/third_party/python/Python/initstdio.c index 8f7f623a5..42e1a3bcb 100644 --- a/third_party/python/Python/initstdio.c +++ b/third_party/python/Python/initstdio.c @@ -4,7 +4,9 @@ │ Python 3 │ │ https://docs.python.org/3/license.html │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/calls/calls.h" #include "libc/calls/internal.h" +#include "libc/calls/struct/stat.h" #include "libc/str/locale.h" #include "third_party/python/Include/abstract.h" #include "third_party/python/Include/boolobject.h" diff --git a/third_party/quickjs/quickjs-libc.c b/third_party/quickjs/quickjs-libc.c index 1393cf4c3..60123889f 100644 --- a/third_party/quickjs/quickjs-libc.c +++ b/third_party/quickjs/quickjs-libc.c @@ -28,9 +28,9 @@ #include "libc/calls/ioctl.h" #include "libc/calls/struct/dirent.h" #include "libc/calls/struct/sigaction.h" +#include "libc/calls/struct/stat.h" #include "libc/calls/struct/winsize.h" #include "libc/calls/termios.h" -#include "libc/calls/typedef/sighandler_t.h" #include "libc/errno.h" #include "libc/fmt/conv.h" #include "libc/fmt/fmt.h" @@ -38,6 +38,7 @@ #include "libc/mem/mem.h" #include "libc/nt/synchronization.h" #include "libc/runtime/dlfcn.h" +#include "libc/runtime/runtime.h" #include "libc/runtime/sysconf.h" #include "libc/sock/select.h" #include "libc/stdio/temp.h" diff --git a/third_party/sqlite3/os_unix.c b/third_party/sqlite3/os_unix.c index a194f2539..4c4be88c7 100644 --- a/third_party/sqlite3/os_unix.c +++ b/third_party/sqlite3/os_unix.c @@ -49,6 +49,7 @@ #include "libc/calls/struct/stat.h" #include "libc/sysv/consts/s.h" #include "libc/runtime/runtime.h" +#include "libc/calls/struct/timeval.h" #include "third_party/sqlite3/sqliteInt.inc" #if SQLITE_OS_UNIX /* This file is used on unix only */ diff --git a/tool/build/blinkenlights.c b/tool/build/blinkenlights.c index 579bb965d..615738d0a 100644 --- a/tool/build/blinkenlights.c +++ b/tool/build/blinkenlights.c @@ -18,11 +18,11 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "dsp/scale/cdecimate2xuint8x8.h" #include "dsp/tty/tty.h" -#include "libc/mem/arraylist2.internal.h" #include "libc/assert.h" #include "libc/calls/calls.h" #include "libc/calls/ioctl.h" #include "libc/calls/struct/iovec.h" +#include "libc/calls/struct/itimerval.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/stat.h" #include "libc/calls/struct/termios.h" @@ -46,6 +46,7 @@ #include "libc/log/log.h" #include "libc/macros.internal.h" #include "libc/math.h" +#include "libc/mem/arraylist2.internal.h" #include "libc/mem/mem.h" #include "libc/runtime/gc.internal.h" #include "libc/runtime/runtime.h" @@ -58,6 +59,7 @@ #include "libc/str/tpdecode.internal.h" #include "libc/str/tpenc.h" #include "libc/str/tpencode.internal.h" +#include "libc/str/unicode.h" #include "libc/sysv/consts/auxv.h" #include "libc/sysv/consts/ex.h" #include "libc/sysv/consts/exit.h" @@ -72,7 +74,6 @@ #include "libc/sysv/consts/termios.h" #include "libc/sysv/errfuns.h" #include "libc/time/time.h" -#include "libc/str/unicode.h" #include "libc/x/x.h" #include "third_party/gdtoa/gdtoa.h" #include "third_party/getopt/getopt.h" diff --git a/tool/build/lib/syscall.c b/tool/build/lib/syscall.c index d1a78e5b6..9a6bb4a3c 100644 --- a/tool/build/lib/syscall.c +++ b/tool/build/lib/syscall.c @@ -22,10 +22,12 @@ #include "libc/calls/sig.internal.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-linux.internal.h" #include "libc/calls/struct/sigaction.h" #include "libc/calls/struct/stat.h" +#include "libc/calls/struct/sysinfo.h" #include "libc/calls/struct/termios.h" #include "libc/calls/struct/timespec.h" #include "libc/calls/struct/timeval.h" diff --git a/tool/build/lib/time.c b/tool/build/lib/time.c index d856638ab..70bdd59fd 100644 --- a/tool/build/lib/time.c +++ b/tool/build/lib/time.c @@ -17,6 +17,7 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/calls.h" +#include "libc/calls/struct/timespec.h" #include "libc/nexgen32e/rdtsc.h" #include "libc/sock/sock.h" #include "libc/sysv/consts/clock.h" diff --git a/tool/build/runit.c b/tool/build/runit.c index badec0d79..626a31b2e 100644 --- a/tool/build/runit.c +++ b/tool/build/runit.c @@ -17,12 +17,13 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/assert.h" -#include "libc/intrin/bits.h" -#include "libc/intrin/safemacros.internal.h" #include "libc/calls/calls.h" +#include "libc/calls/struct/itimerval.h" #include "libc/calls/struct/stat.h" #include "libc/dns/dns.h" #include "libc/fmt/conv.h" +#include "libc/intrin/bits.h" +#include "libc/intrin/safemacros.internal.h" #include "libc/limits.h" #include "libc/log/check.h" #include "libc/log/log.h" diff --git a/tool/scripts/explain-deps.py b/tool/scripts/explain-deps.py new file mode 100755 index 000000000..66d32bb59 --- /dev/null +++ b/tool/scripts/explain-deps.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python.com + +import os +import re +import sys + +def GetDeps(path): + deps = set() + def Dive(path, depth): + if path in deps: + return + deps.add(path) + sys.stdout.write('%s%s\n' % ('\t' * depth, path)) + with open(path) as f: + code = f.read() + for dep in re.findall(r'[.#]include "([^"]+)"', code): + Dive(dep, depth + 1) + Dive(path, 0) + sys.stdout.write('\n') + +for arg in sys.argv[1:]: + if os.path.isdir(arg): + for dirpath, dirs, files in os.walk(arg): + for filepath in files: + GetDeps(os.path.join(dirpath, filepath)) + else: + GetDeps(arg)