From e0c2b91b3ec6f88d060d6059210a993a0ef46b08 Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Mon, 24 Jul 2023 08:31:54 -0700 Subject: [PATCH] Remove _Hide keyword It never did anything and isn't worthwhile as documentation. --- examples/showdown.c | 26 +++ libc/calls/clock_gettime.c | 2 +- libc/calls/clock_gettime.internal.h | 6 +- libc/calls/close-nt.c | 2 +- libc/calls/execve-sysv.internal.h | 2 +- libc/calls/fcntl-nt.c | 2 +- libc/calls/gettemppatha-flunk.S | 27 --- libc/calls/internal.h | 20 +- libc/calls/iovecsize.c | 27 --- libc/calls/kemptyfd.c | 2 +- libc/calls/ntmagicpaths.c | 2 +- libc/calls/ntmagicpaths.internal.h | 2 +- libc/calls/ntspawn.h | 6 +- libc/calls/pledge.internal.h | 6 +- libc/calls/sched-sysv.internal.h | 6 +- libc/calls/sched_rr_get_interval.c | 2 +- libc/calls/sig.internal.h | 16 +- libc/calls/sigtimedwait.internal.h | 2 +- libc/calls/state.internal.h | 14 +- libc/calls/struct/iovec.internal.h | 33 ++- libc/calls/struct/itimerval.internal.h | 6 +- libc/calls/struct/metastat.internal.h | 2 +- libc/calls/struct/rlimit.internal.h | 6 +- libc/calls/struct/rusage.internal.h | 12 +- libc/calls/struct/sigaction.internal.h | 10 +- libc/calls/struct/siginfo-meta.internal.h | 2 +- libc/calls/struct/siginfo.internal.h | 2 +- libc/calls/struct/sigset.internal.h | 9 +- libc/calls/struct/sigval.internal.h | 2 +- libc/calls/struct/stat.internal.h | 10 +- libc/calls/struct/statfs-meta.internal.h | 2 +- libc/calls/struct/sysinfo.internal.h | 4 +- libc/calls/struct/timespec.internal.h | 38 +-- libc/calls/struct/timeval.internal.h | 18 +- libc/calls/struct/ucontext.internal.h | 4 +- libc/calls/struct/winsize.internal.h | 2 +- libc/calls/syscall-nt.internal.h | 69 +++--- libc/calls/syscall-sysv.internal.h | 258 ++++++++++----------- libc/calls/syscall_support-nt.internal.h | 34 +-- libc/calls/syscall_support-sysv.internal.h | 34 +-- libc/calls/wait4.h | 2 +- libc/calls/writevuninterruptible.c | 3 +- libc/fmt/fmt.h | 2 +- libc/fmt/magnumstrs.internal.h | 22 +- libc/integral/c.inc | 9 - libc/intrin/_getenv.internal.h | 2 +- libc/intrin/kntisinheritable.greg.c | 2 +- libc/intrin/kprintf.greg.c | 4 +- libc/isystem/cosmo.h | 4 +- libc/log/gdbsync.c | 2 +- libc/log/internal.h | 8 +- libc/log/logkprintftofile.c | 2 +- libc/mem/internal.h | 2 +- libc/nexgen32e/kompressor.h | 12 +- libc/runtime/__sigsetjmp_tail.c | 2 +- libc/runtime/enable_threads.c | 9 +- libc/runtime/getsymbol.c | 2 +- libc/runtime/getsymboltable.c | 2 +- libc/runtime/hook.greg.c | 7 +- libc/runtime/internal.h | 28 +-- libc/runtime/isdynamicexecutable.c | 81 ------- libc/runtime/metalprintf.greg.c | 2 +- libc/runtime/{morph.greg.c => morph.c} | 41 ++-- libc/runtime/morph.h | 12 - libc/runtime/morph_tls.c | 9 +- libc/runtime/runtime.h | 4 +- libc/runtime/runtime.mk | 4 +- libc/runtime/winmain.greg.c | 2 +- libc/sock/internal.h | 83 ++++--- libc/sock/kntwsadata.c | 2 +- libc/sock/sendfile.internal.h | 4 +- libc/sock/struct/msghdr.internal.h | 4 +- libc/sock/struct/pollfd.internal.h | 6 +- libc/sock/syscall_fd.internal.h | 25 +- libc/sock/xinet_ntop.c | 41 ---- libc/stdio/dirstream.c | 2 + libc/stdio/fflush.internal.h | 4 +- libc/stdio/fmt.c | 2 +- libc/stdio/fread_unlocked.c | 5 - libc/stdio/fwrite_unlocked.c | 10 +- libc/stdio/internal.h | 14 +- libc/stdio/posix_spawn.c | 9 +- libc/stdio/readdir64.S | 31 --- libc/stdio/stdbuf.c | 4 +- libc/stdio/strlist.internal.h | 8 +- libc/stdio/temp.h | 2 +- libc/stdio/vdprintf.c | 5 +- libc/str/internal.h | 27 --- libc/str/kmonthyearday.c | 2 +- libc/str/kx86processormodels.c | 4 +- libc/thread/posixthread.internal.h | 22 +- libc/thread/spawn.h | 6 +- libc/thread/wait0.internal.h | 2 +- libc/time/struct/utimbuf.internal.h | 2 +- libc/time/time.h | 10 +- libc/tinymath/atan_data.internal.h | 2 +- libc/tinymath/atanf_data.internal.h | 2 +- libc/tinymath/complex.internal.h | 4 +- libc/tinymath/exp2f_data.internal.h | 2 +- libc/tinymath/exp_data.internal.h | 2 +- libc/tinymath/freebsd.internal.h | 2 +- libc/tinymath/internal.h | 28 +-- libc/tinymath/invtrigl.internal.h | 4 +- libc/tinymath/kernel.internal.h | 26 +-- libc/tinymath/log1pf_data.internal.h | 4 +- libc/tinymath/log2_data.internal.h | 2 +- libc/tinymath/log2f_data.internal.h | 2 +- libc/tinymath/log_data.internal.h | 2 +- libc/tinymath/logf_data.internal.h | 2 +- libc/tinymath/pow_data.internal.h | 2 +- libc/tinymath/powf_data.internal.h | 2 +- libc/tinymath/sincosf.internal.h | 4 +- libc/zipos/zipos.internal.h | 34 +-- test/dsp/tty/windex_test.c | 6 +- test/libc/str/memmem_test.c | 5 +- test/libc/str/strcasestr_test.c | 2 +- test/libc/str/strstr_test.c | 8 +- third_party/dlmalloc/dlmalloc.h | 4 +- third_party/gdtoa/gdtoa.internal.h | 14 +- third_party/musl/crypt_des.internal.h | 4 +- third_party/regex/tre.inc | 20 +- third_party/zlib/cpu_features.internal.h | 6 +- third_party/zlib/inffast.internal.h | 2 +- third_party/zlib/internal.h | 22 +- third_party/zlib/treeconst.c | 4 +- third_party/zlib/zutil.internal.h | 6 +- tool/build/pledge.c | 52 ++++- tool/build/runit.c | 2 +- tool/emacs/c.lang | 1 - tool/emacs/cosmo-c-keywords.el | 1 - tool/emacs/key.py | 2 - 131 files changed, 716 insertions(+), 917 deletions(-) create mode 100644 examples/showdown.c delete mode 100644 libc/calls/gettemppatha-flunk.S delete mode 100644 libc/calls/iovecsize.c delete mode 100644 libc/runtime/isdynamicexecutable.c rename libc/runtime/{morph.greg.c => morph.c} (76%) delete mode 100644 libc/runtime/morph.h delete mode 100644 libc/sock/xinet_ntop.c delete mode 100644 libc/stdio/readdir64.S delete mode 100644 libc/str/internal.h diff --git a/examples/showdown.c b/examples/showdown.c new file mode 100644 index 000000000..a56f18a50 --- /dev/null +++ b/examples/showdown.c @@ -0,0 +1,26 @@ +#if 0 +/*─────────────────────────────────────────────────────────────────╗ +│ To the extent possible under law, Justine Tunney has waived │ +│ all copyright and related or neighboring rights to this file, │ +│ as it is written in the following disclaimers: │ +│ • http://unlicense.org/ │ +│ • http://creativecommons.org/publicdomain/zero/1.0/ │ +╚─────────────────────────────────────────────────────────────────*/ +#endif +#include "libc/calls/calls.h" +#include "libc/calls/struct/iovec.h" +#include "libc/errno.h" +#include "libc/stdio/stdio.h" +#include "libc/str/str.h" + +int main(int argc, char *argv[]) { + char buf[65536]; + memset(buf, '\n', sizeof(buf)); + for (;;) { + ssize_t rc = writev(1, &(struct iovec){buf, sizeof(buf)}, 1); + if (rc != sizeof(buf)) { + printf("got %ld (%s)\n", rc, strerror(errno)); + return 1; + } + } +} diff --git a/libc/calls/clock_gettime.c b/libc/calls/clock_gettime.c index 09b18ca7a..b99b02e2f 100644 --- a/libc/calls/clock_gettime.c +++ b/libc/calls/clock_gettime.c @@ -131,7 +131,7 @@ clock_gettime_f *__clock_gettime_get(bool *opt_out_isfast) { return res; } -_Hide int __clock_gettime_init(int clockid, struct timespec *ts) { +int __clock_gettime_init(int clockid, struct timespec *ts) { clock_gettime_f *gettime; __clock_gettime = gettime = __clock_gettime_get(0); return gettime(clockid, ts); diff --git a/libc/calls/clock_gettime.internal.h b/libc/calls/clock_gettime.internal.h index 277899fc4..a260257fc 100644 --- a/libc/calls/clock_gettime.internal.h +++ b/libc/calls/clock_gettime.internal.h @@ -7,9 +7,9 @@ COSMOPOLITAN_C_START_ typedef int clock_gettime_f(int, struct timespec *); extern clock_gettime_f *__clock_gettime; -clock_gettime_f *__clock_gettime_get(bool *) _Hide; -int __clock_gettime_init(int, struct timespec *) _Hide; -int sys_clock_gettime_mono(struct timespec *) _Hide; +clock_gettime_f *__clock_gettime_get(bool *); +int __clock_gettime_init(int, struct timespec *); +int sys_clock_gettime_mono(struct timespec *); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/calls/close-nt.c b/libc/calls/close-nt.c index e63eeb179..7076f1ec9 100644 --- a/libc/calls/close-nt.c +++ b/libc/calls/close-nt.c @@ -24,7 +24,7 @@ #include "libc/nt/runtime.h" #include "libc/sysv/consts/o.h" -void sys_fcntl_nt_lock_cleanup(int) _Hide; +void sys_fcntl_nt_lock_cleanup(int); textwindows int sys_close_nt(struct Fd *fd, int fildes) { int e; diff --git a/libc/calls/execve-sysv.internal.h b/libc/calls/execve-sysv.internal.h index b9148c5e4..50c2d95a0 100644 --- a/libc/calls/execve-sysv.internal.h +++ b/libc/calls/execve-sysv.internal.h @@ -3,7 +3,7 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -bool IsAPEMagic(char[8]) _Hide; +bool IsAPEMagic(char[8]); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/calls/fcntl-nt.c b/libc/calls/fcntl-nt.c index b5dbe2aa8..2004e73bc 100644 --- a/libc/calls/fcntl-nt.c +++ b/libc/calls/fcntl-nt.c @@ -102,7 +102,7 @@ static textwindows bool EqualsFileLock(struct FileLock *fl, int64_t off, return fl->off == off && off + len == fl->off + fl->len; } -_Hide textwindows void sys_fcntl_nt_lock_cleanup(int fd) { +textwindows void sys_fcntl_nt_lock_cleanup(int fd) { struct FileLock *fl, *ft, **flp; pthread_mutex_lock(&g_locks.mu); for (flp = &g_locks.list, fl = *flp; fl;) { diff --git a/libc/calls/gettemppatha-flunk.S b/libc/calls/gettemppatha-flunk.S deleted file mode 100644 index d75ee846f..000000000 --- a/libc/calls/gettemppatha-flunk.S +++ /dev/null @@ -1,27 +0,0 @@ -/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│ -│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│ -╞══════════════════════════════════════════════════════════════════════════════╡ -│ Copyright 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/macros.internal.h" - -// Calls GetTempPathA() w/ different API. -// -// @see GetSystemDirectoryA(), GetWindowsDirectoryA() -GetTempPathA_flunk: - xchg %rcx,%rdx - jmp *__imp_GetTempPathA(%rip) - .endfn GetTempPathA_flunk,globl,hidden diff --git a/libc/calls/internal.h b/libc/calls/internal.h index d6a44a5d8..7025c6ccb 100644 --- a/libc/calls/internal.h +++ b/libc/calls/internal.h @@ -12,15 +12,15 @@ COSMOPOLITAN_C_START_ #define kIoMotion ((const int8_t[3]){1, 0, 0}) -_Hide extern struct Fds g_fds; -_Hide extern const struct Fd kEmptyFd; +extern struct Fds g_fds; +extern const struct Fd kEmptyFd; -int __reservefd(int) _Hide; -int __reservefd_unlocked(int) _Hide; -void __releasefd(int) _Hide; -int __ensurefds(int) _Hide; -int __ensurefds_unlocked(int) _Hide; -void __printfds(void) _Hide; +int __reservefd(int); +int __reservefd_unlocked(int); +void __releasefd(int); +int __ensurefds(int); +int __ensurefds_unlocked(int); +void __printfds(void); forceinline int64_t __getfdhandleactual(int fd) { return g_fds.p[fd].handle; @@ -34,8 +34,8 @@ forceinline bool __isfdkind(int fd, int kind) { return 0 <= fd && fd < g_fds.n && g_fds.p[fd].kind == kind; } -int sys_close_nt(struct Fd *, int) _Hide; -int _check_interrupts(bool, struct Fd *) _Hide; +int sys_close_nt(struct Fd *, int); +int _check_interrupts(bool, struct Fd *); int sys_openat_metal(int, const char *, int, unsigned); COSMOPOLITAN_C_END_ diff --git a/libc/calls/iovecsize.c b/libc/calls/iovecsize.c deleted file mode 100644 index 810fcb46f..000000000 --- a/libc/calls/iovecsize.c +++ /dev/null @@ -1,27 +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 2021 Justine Alexandra Roberts Tunney │ -│ │ -│ Permission to use, copy, modify, and/or distribute this software for │ -│ any purpose with or without fee is hereby granted, provided that the │ -│ above copyright notice and this permission notice appear in all copies. │ -│ │ -│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ -│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ -│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ -│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ -│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ -│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ -│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ -│ PERFORMANCE OF THIS SOFTWARE. │ -╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/struct/iovec.h" - -size_t __iovec_size(const struct iovec *v, size_t n) { - size_t i, sum; - for (sum = i = 0; i < n; ++i) { - sum += v[i].iov_len; - } - return sum; -} diff --git a/libc/calls/kemptyfd.c b/libc/calls/kemptyfd.c index 69f227ca9..375a88cbd 100644 --- a/libc/calls/kemptyfd.c +++ b/libc/calls/kemptyfd.c @@ -19,4 +19,4 @@ #include "libc/calls/internal.h" #include "libc/calls/struct/fd.internal.h" -_Hide const struct Fd kEmptyFd; +const struct Fd kEmptyFd; diff --git a/libc/calls/ntmagicpaths.c b/libc/calls/ntmagicpaths.c index fd9218889..30269b7c9 100644 --- a/libc/calls/ntmagicpaths.c +++ b/libc/calls/ntmagicpaths.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/calls/ntmagicpaths.internal.h" -_Hide const struct NtMagicPaths kNtMagicPaths = { +const struct NtMagicPaths kNtMagicPaths = { #define TAB(NAME, STRING) STRING, #include "libc/calls/ntmagicpaths.inc" #undef TAB diff --git a/libc/calls/ntmagicpaths.internal.h b/libc/calls/ntmagicpaths.internal.h index 18624e918..20b2be0fd 100644 --- a/libc/calls/ntmagicpaths.internal.h +++ b/libc/calls/ntmagicpaths.internal.h @@ -9,7 +9,7 @@ struct NtMagicPaths { #undef TAB }; -_Hide extern const struct NtMagicPaths kNtMagicPaths; +extern const struct NtMagicPaths kNtMagicPaths; COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/calls/ntspawn.h b/libc/calls/ntspawn.h index 05b0fd193..c583b6e88 100644 --- a/libc/calls/ntspawn.h +++ b/libc/calls/ntspawn.h @@ -6,13 +6,13 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -int mkntcmdline(char16_t[ARG_MAX / 2], char *const[]) _Hide; +int mkntcmdline(char16_t[ARG_MAX / 2], char *const[]); int mkntenvblock(char16_t[ARG_MAX / 2], char *const[], const char *, - char[ARG_MAX]) _Hide; + char[ARG_MAX]); int ntspawn(const char *, char *const[], char *const[], const char *, struct NtSecurityAttributes *, struct NtSecurityAttributes *, bool32, uint32_t, const char16_t *, const struct NtStartupInfo *, - struct NtProcessInformation *) _Hide; + struct NtProcessInformation *); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/calls/pledge.internal.h b/libc/calls/pledge.internal.h index 182963ab2..b79498b59 100644 --- a/libc/calls/pledge.internal.h +++ b/libc/calls/pledge.internal.h @@ -11,10 +11,10 @@ struct Pledges { const size_t len; }; -_Hide extern const struct Pledges kPledge[PROMISE_LEN_]; +extern const struct Pledges kPledge[PROMISE_LEN_]; -int sys_pledge_linux(unsigned long, int) _Hide; -int ParsePromises(const char *, unsigned long *) _Hide; +int sys_pledge_linux(unsigned long, int); +int ParsePromises(const char *, unsigned long *); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/calls/sched-sysv.internal.h b/libc/calls/sched-sysv.internal.h index 145df5fde..f5a69e9ad 100644 --- a/libc/calls/sched-sysv.internal.h +++ b/libc/calls/sched-sysv.internal.h @@ -18,11 +18,11 @@ int sys_sched_get_priority_max(int); int sys_sched_get_priority_min(int); int sys_sched_getparam(int, struct sched_param *); int sys_sched_getscheduler(int); -int sys_sched_setaffinity(int, uint64_t, const void *) _Hide; +int sys_sched_setaffinity(int, uint64_t, const void *); int sys_sched_setparam(int, const struct sched_param *); int sys_sched_setscheduler(int, int, const struct sched_param *); -int sys_sched_yield(void) _Hide; -int64_t sys_sched_getaffinity(int, uint64_t, void *) _Hide; +int sys_sched_yield(void); +int64_t sys_sched_getaffinity(int, uint64_t, void *); int sys_sched_getscheduler_netbsd(int, struct sched_param *); int sys_sched_setparam_netbsd(int, int, int, const struct sched_param *) // diff --git a/libc/calls/sched_rr_get_interval.c b/libc/calls/sched_rr_get_interval.c index 4b7fcf234..813a5e53d 100644 --- a/libc/calls/sched_rr_get_interval.c +++ b/libc/calls/sched_rr_get_interval.c @@ -21,7 +21,7 @@ #include "libc/intrin/describeflags.internal.h" #include "libc/intrin/strace.internal.h" -int sys_sched_rr_get_interval(int, struct timespec *) _Hide; +int sys_sched_rr_get_interval(int, struct timespec *); /** * Returns round-robin `SCHED_RR` quantum for `pid`. diff --git a/libc/calls/sig.internal.h b/libc/calls/sig.internal.h index f680772aa..508e8568b 100644 --- a/libc/calls/sig.internal.h +++ b/libc/calls/sig.internal.h @@ -28,14 +28,14 @@ struct Signals { extern struct Signals __sig; extern atomic_long __sig_count; -bool __sig_check(bool) _Hide; -bool __sig_handle(bool, int, int, ucontext_t *) _Hide; -int __sig_add(int, int, int) _Hide; -int __sig_mask(int, const sigset_t *, sigset_t *) _Hide; -int __sig_raise(int, int) _Hide; -void __sig_check_ignore(const int, const unsigned) _Hide; -void __sig_pending(sigset_t *) _Hide; -int __sig_is_applicable(struct Signal *) _Hide; +bool __sig_check(bool); +bool __sig_handle(bool, int, int, ucontext_t *); +int __sig_add(int, int, int); +int __sig_mask(int, const sigset_t *, sigset_t *); +int __sig_raise(int, int); +void __sig_check_ignore(const int, const unsigned); +void __sig_pending(sigset_t *); +int __sig_is_applicable(struct Signal *); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/calls/sigtimedwait.internal.h b/libc/calls/sigtimedwait.internal.h index e9db2f4f8..a75b51929 100644 --- a/libc/calls/sigtimedwait.internal.h +++ b/libc/calls/sigtimedwait.internal.h @@ -7,7 +7,7 @@ COSMOPOLITAN_C_START_ int sys_sigtimedwait(const sigset_t *, union siginfo_meta *, - const struct timespec *, size_t) _Hide; + const struct timespec *, size_t); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/calls/state.internal.h b/libc/calls/state.internal.h index 0c5be6f63..7616c1e85 100644 --- a/libc/calls/state.internal.h +++ b/libc/calls/state.internal.h @@ -6,13 +6,13 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -_Hide extern int __vforked; -_Hide extern bool __time_critical; -_Hide extern unsigned __sighandrvas[NSIG]; -_Hide extern unsigned __sighandflags[NSIG]; -_Hide extern pthread_mutex_t __fds_lock_obj; -_Hide extern pthread_mutex_t __sig_lock_obj; -_Hide extern const struct NtSecurityAttributes kNtIsInheritable; +extern int __vforked; +extern bool __time_critical; +extern unsigned __sighandrvas[NSIG]; +extern unsigned __sighandflags[NSIG]; +extern pthread_mutex_t __fds_lock_obj; +extern pthread_mutex_t __sig_lock_obj; +extern const struct NtSecurityAttributes kNtIsInheritable; void __fds_lock(void); void __fds_unlock(void); diff --git a/libc/calls/struct/iovec.internal.h b/libc/calls/struct/iovec.internal.h index a5048940a..4bb8a2f1f 100644 --- a/libc/calls/struct/iovec.internal.h +++ b/libc/calls/struct/iovec.internal.h @@ -6,24 +6,23 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -int64_t sys_preadv(int, struct iovec *, int, int64_t, int64_t) _Hide; -int64_t sys_pwritev(int, const struct iovec *, int, int64_t, int64_t) _Hide; -int64_t sys_readv(int32_t, const struct iovec *, int32_t) _Hide; -int64_t sys_vmsplice(int, const struct iovec *, int64_t, uint32_t) _Hide; -int64_t sys_writev(int32_t, const struct iovec *, int32_t) _Hide; -size_t __iovec_size(const struct iovec *, size_t) _Hide; -ssize_t WritevUninterruptible(int, struct iovec *, int); -ssize_t sys_read_nt(struct Fd *, const struct iovec *, size_t, int64_t) _Hide; -ssize_t sys_readv_metal(struct Fd *, const struct iovec *, int) _Hide; -ssize_t sys_readv_nt(struct Fd *, const struct iovec *, int) _Hide; -ssize_t sys_readv_serial(struct Fd *, const struct iovec *, int) _Hide; -ssize_t sys_write_nt(int, const struct iovec *, size_t, ssize_t) _Hide; -ssize_t sys_writev_metal(struct Fd *, const struct iovec *, int) _Hide; -ssize_t sys_writev_nt(int, const struct iovec *, int) _Hide; -ssize_t sys_writev_serial(struct Fd *, const struct iovec *, int) _Hide; -ssize_t sys_send_nt(int, const struct iovec *, size_t, uint32_t) _Hide; +ssize_t __robust_writev(int, struct iovec *, int); +int64_t sys_preadv(int, struct iovec *, int, int64_t, int64_t); +int64_t sys_pwritev(int, const struct iovec *, int, int64_t, int64_t); +int64_t sys_readv(int32_t, const struct iovec *, int32_t); +int64_t sys_vmsplice(int, const struct iovec *, int64_t, uint32_t); +int64_t sys_writev(int32_t, const struct iovec *, int32_t); +ssize_t sys_read_nt(struct Fd *, const struct iovec *, size_t, int64_t); +ssize_t sys_readv_metal(struct Fd *, const struct iovec *, int); +ssize_t sys_readv_nt(struct Fd *, const struct iovec *, int); +ssize_t sys_readv_serial(struct Fd *, const struct iovec *, int); +ssize_t sys_write_nt(int, const struct iovec *, size_t, ssize_t); +ssize_t sys_writev_metal(struct Fd *, const struct iovec *, int); +ssize_t sys_writev_nt(int, const struct iovec *, int); +ssize_t sys_writev_serial(struct Fd *, const struct iovec *, int); +ssize_t sys_send_nt(int, const struct iovec *, size_t, uint32_t); ssize_t sys_sendto_nt(int, const struct iovec *, size_t, uint32_t, void *, - uint32_t) _Hide; + uint32_t); const char *DescribeIovec(char[300], ssize_t, const struct iovec *, int); #define DescribeIovec(x, y, z) DescribeIovec(alloca(300), x, y, z) diff --git a/libc/calls/struct/itimerval.internal.h b/libc/calls/struct/itimerval.internal.h index b3a50084c..96119e98d 100644 --- a/libc/calls/struct/itimerval.internal.h +++ b/libc/calls/struct/itimerval.internal.h @@ -5,9 +5,9 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -int sys_getitimer(int, struct itimerval *) _Hide; -int sys_setitimer(int, const struct itimerval *, struct itimerval *) _Hide; -int sys_setitimer_nt(int, const struct itimerval *, struct itimerval *) _Hide; +int sys_getitimer(int, struct itimerval *); +int sys_setitimer(int, const struct itimerval *, struct itimerval *); +int sys_setitimer_nt(int, const struct itimerval *, struct itimerval *); const char *DescribeItimerval(char[90], int, const struct itimerval *); #define DescribeItimerval(rc, ts) DescribeItimerval(alloca(90), rc, ts) diff --git a/libc/calls/struct/metastat.internal.h b/libc/calls/struct/metastat.internal.h index 027e3d4e3..e9086fd1a 100644 --- a/libc/calls/struct/metastat.internal.h +++ b/libc/calls/struct/metastat.internal.h @@ -112,7 +112,7 @@ union metastat { struct stat_netbsd netbsd; }; -void __stat2cosmo(struct stat *restrict, const union metastat *) _Hide; +void __stat2cosmo(struct stat *restrict, const union metastat *); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/calls/struct/rlimit.internal.h b/libc/calls/struct/rlimit.internal.h index 895c717db..8a7235c73 100644 --- a/libc/calls/struct/rlimit.internal.h +++ b/libc/calls/struct/rlimit.internal.h @@ -5,9 +5,9 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -int sys_getrlimit(int, struct rlimit *) _Hide; -int sys_setrlimit(int, const struct rlimit *) _Hide; -int sys_setrlimit_nt(int, const struct rlimit *) _Hide; +int sys_getrlimit(int, struct rlimit *); +int sys_setrlimit(int, const struct rlimit *); +int sys_setrlimit_nt(int, const struct rlimit *); const char *DescribeRlimit(char[64], int, const struct rlimit *); #define DescribeRlimit(rc, rl) DescribeRlimit(alloca(64), rc, rl) diff --git a/libc/calls/struct/rusage.internal.h b/libc/calls/struct/rusage.internal.h index 7038721d3..50432fb9c 100644 --- a/libc/calls/struct/rusage.internal.h +++ b/libc/calls/struct/rusage.internal.h @@ -4,12 +4,12 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -int __sys_getrusage(int, struct rusage *) _Hide; -int __sys_wait4(int, int *, int, struct rusage *) _Hide; -int sys_getrusage(int, struct rusage *) _Hide; -int sys_wait4(int, int *, int, struct rusage *) _Hide; -void __rusage2linux(struct rusage *) _Hide; -int sys_getrusage_nt(int, struct rusage *) _Hide; +int __sys_getrusage(int, struct rusage *); +int __sys_wait4(int, int *, int, struct rusage *); +int sys_getrusage(int, struct rusage *); +int sys_wait4(int, int *, int, struct rusage *); +void __rusage2linux(struct rusage *); +int sys_getrusage_nt(int, struct rusage *); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/calls/struct/sigaction.internal.h b/libc/calls/struct/sigaction.internal.h index 509769d8f..82aad5a59 100644 --- a/libc/calls/struct/sigaction.internal.h +++ b/libc/calls/struct/sigaction.internal.h @@ -54,11 +54,11 @@ union metasigaction { struct sigaction_xnu_out xnu_out; }; -void __sigenter_xnu(int, struct siginfo *, void *) _Hide; -void __sigenter_wsl(int, struct siginfo *, void *) _Hide; -void __sigenter_netbsd(int, struct siginfo *, void *) _Hide; -void __sigenter_freebsd(int, struct siginfo *, void *) _Hide; -void __sigenter_openbsd(int, struct siginfo *, void *) _Hide; +void __sigenter_xnu(int, struct siginfo *, void *); +void __sigenter_wsl(int, struct siginfo *, void *); +void __sigenter_netbsd(int, struct siginfo *, void *); +void __sigenter_freebsd(int, struct siginfo *, void *); +void __sigenter_openbsd(int, struct siginfo *, void *); const char *DescribeSigaction(char[256], int, const struct sigaction *); #define DescribeSigaction(rc, sa) DescribeSigaction(alloca(256), rc, sa) diff --git a/libc/calls/struct/siginfo-meta.internal.h b/libc/calls/struct/siginfo-meta.internal.h index 9ae0a9fc7..45c751876 100644 --- a/libc/calls/struct/siginfo-meta.internal.h +++ b/libc/calls/struct/siginfo-meta.internal.h @@ -16,7 +16,7 @@ union siginfo_meta { struct siginfo_netbsd netbsd; }; -void __siginfo2cosmo(struct siginfo *, const union siginfo_meta *) _Hide; +void __siginfo2cosmo(struct siginfo *, const union siginfo_meta *); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/calls/struct/siginfo.internal.h b/libc/calls/struct/siginfo.internal.h index 931a8cfce..06134b9e9 100644 --- a/libc/calls/struct/siginfo.internal.h +++ b/libc/calls/struct/siginfo.internal.h @@ -5,7 +5,7 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -int sys_sigqueueinfo(int, const siginfo_t *) _Hide; +int sys_sigqueueinfo(int, const siginfo_t *); const char *DescribeSiginfo(char[300], int, const siginfo_t *); #define DescribeSiginfo(x, y) DescribeSiginfo(alloca(300), x, y) diff --git a/libc/calls/struct/sigset.internal.h b/libc/calls/struct/sigset.internal.h index 05b5674d7..fc80ffcb9 100644 --- a/libc/calls/struct/sigset.internal.h +++ b/libc/calls/struct/sigset.internal.h @@ -5,11 +5,10 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -int __sys_sigprocmask(int, const struct sigset *, struct sigset *, - uint64_t) _Hide; -int sys_sigprocmask(int, const struct sigset *, struct sigset *) _Hide; -int sys_sigsuspend(const struct sigset *, uint64_t) _Hide; -int sys_sigpending(struct sigset *, size_t) _Hide; +int __sys_sigprocmask(int, const struct sigset *, struct sigset *, uint64_t); +int sys_sigprocmask(int, const struct sigset *, struct sigset *); +int sys_sigsuspend(const struct sigset *, uint64_t); +int sys_sigpending(struct sigset *, size_t); const char *DescribeSigset(char[128], int, const sigset_t *); #define DescribeSigset(rc, ss) DescribeSigset(alloca(128), rc, ss) diff --git a/libc/calls/struct/sigval.internal.h b/libc/calls/struct/sigval.internal.h index 45e704b39..ee87d1dcb 100644 --- a/libc/calls/struct/sigval.internal.h +++ b/libc/calls/struct/sigval.internal.h @@ -4,7 +4,7 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -int sys_sigqueue(int, int, const union sigval) _Hide; +int sys_sigqueue(int, int, const union sigval); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/calls/struct/stat.internal.h b/libc/calls/struct/stat.internal.h index 6b4766793..29861e85b 100644 --- a/libc/calls/struct/stat.internal.h +++ b/libc/calls/struct/stat.internal.h @@ -5,11 +5,11 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -int sys_fstat(int, struct stat *) _Hide; -int sys_fstatat(int, const char *, struct stat *, int) _Hide; -int sys_fstat_nt(int64_t, struct stat *) _Hide; -int sys_fstatat_nt(int, const char *, struct stat *, int) _Hide; -int sys_lstat_nt(const char *, struct stat *) _Hide; +int sys_fstat(int, struct stat *); +int sys_fstatat(int, const char *, struct stat *, int); +int sys_fstat_nt(int64_t, struct stat *); +int sys_fstatat_nt(int, const char *, struct stat *, int); +int sys_lstat_nt(const char *, struct stat *); int sys_fstat_metal(int, struct stat *); const char *DescribeStat(char[300], int, const struct stat *); diff --git a/libc/calls/struct/statfs-meta.internal.h b/libc/calls/struct/statfs-meta.internal.h index 2443cb4c9..26d767570 100644 --- a/libc/calls/struct/statfs-meta.internal.h +++ b/libc/calls/struct/statfs-meta.internal.h @@ -17,7 +17,7 @@ union statfs_meta { struct statfs_netbsd netbsd; }; -void statfs2cosmo(struct statfs *, const union statfs_meta *) _Hide; +void statfs2cosmo(struct statfs *, const union statfs_meta *); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/calls/struct/sysinfo.internal.h b/libc/calls/struct/sysinfo.internal.h index 2c2fcef24..b4d992db4 100644 --- a/libc/calls/struct/sysinfo.internal.h +++ b/libc/calls/struct/sysinfo.internal.h @@ -4,8 +4,8 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -int sys_sysinfo(struct sysinfo *) _Hide; -int sys_sysinfo_nt(struct sysinfo *) _Hide; +int sys_sysinfo(struct sysinfo *); +int sys_sysinfo_nt(struct sysinfo *); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/calls/struct/timespec.internal.h b/libc/calls/struct/timespec.internal.h index ba8475651..199dd5bbe 100644 --- a/libc/calls/struct/timespec.internal.h +++ b/libc/calls/struct/timespec.internal.h @@ -6,26 +6,26 @@ COSMOPOLITAN_C_START_ /* clang-format off */ -int __sys_clock_nanosleep(int, int, const struct timespec *, struct timespec *) _Hide; -int __sys_utimensat(int, const char *, const struct timespec[2], int) _Hide; -int __utimens(int, const char *, const struct timespec[2], int) _Hide; -int sys_clock_getres(int, struct timespec *) _Hide; +int __sys_clock_nanosleep(int, int, const struct timespec *, struct timespec *); +int __sys_utimensat(int, const char *, const struct timespec[2], int); +int __utimens(int, const char *, const struct timespec[2], int); +int sys_clock_getres(int, struct timespec *); int sys_clock_settime(int, const struct timespec *); -int sys_clock_gettime(int, struct timespec *) _Hide; -int sys_clock_gettime_nt(int, struct timespec *) _Hide; -int sys_clock_gettime_m1(int, struct timespec *) _Hide; -int sys_clock_gettime_xnu(int, struct timespec *) _Hide; -int sys_clock_nanosleep_nt(int, int, const struct timespec *, struct timespec *) _Hide; -int sys_clock_nanosleep_openbsd(int, int, const struct timespec *, struct timespec *) _Hide; -int sys_clock_nanosleep_xnu(int, int, const struct timespec *, struct timespec *) _Hide; -int sys_futimens(int, const struct timespec[2]) _Hide; -int sys_nanosleep(const struct timespec *, struct timespec *) _Hide; -int sys_nanosleep_nt(const struct timespec *, struct timespec *) _Hide; -int sys_nanosleep_xnu(const struct timespec *, struct timespec *) _Hide; -int sys_sem_timedwait(int64_t, const struct timespec *) _Hide; -int sys_utimensat(int, const char *, const struct timespec[2], int) _Hide; -int sys_utimensat_nt(int, const char *, const struct timespec[2], int) _Hide; -int sys_utimensat_xnu(int, const char *, const struct timespec[2], int) _Hide; +int sys_clock_gettime(int, struct timespec *); +int sys_clock_gettime_nt(int, struct timespec *); +int sys_clock_gettime_m1(int, struct timespec *); +int sys_clock_gettime_xnu(int, struct timespec *); +int sys_clock_nanosleep_nt(int, int, const struct timespec *, struct timespec *); +int sys_clock_nanosleep_openbsd(int, int, const struct timespec *, struct timespec *); +int sys_clock_nanosleep_xnu(int, int, const struct timespec *, struct timespec *); +int sys_futimens(int, const struct timespec[2]); +int sys_nanosleep(const struct timespec *, struct timespec *); +int sys_nanosleep_nt(const struct timespec *, struct timespec *); +int sys_nanosleep_xnu(const struct timespec *, struct timespec *); +int sys_sem_timedwait(int64_t, const struct timespec *); +int sys_utimensat(int, const char *, const struct timespec[2], int); +int sys_utimensat_nt(int, const char *, const struct timespec[2], int); +int sys_utimensat_xnu(int, const char *, const struct timespec[2], int); const char *DescribeTimespec(char[45], int, const struct timespec *); #define DescribeTimespec(rc, ts) DescribeTimespec(alloca(45), rc, ts) diff --git a/libc/calls/struct/timeval.internal.h b/libc/calls/struct/timeval.internal.h index ce0f086c6..aaa2e5fa0 100644 --- a/libc/calls/struct/timeval.internal.h +++ b/libc/calls/struct/timeval.internal.h @@ -6,15 +6,15 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -axdx_t sys_gettimeofday(struct timeval *, struct timezone *, void *) _Hide; -int sys_settimeofday(const struct timeval *, const struct timezone *) _Hide; -int sys_futimes(int, const struct timeval *) _Hide; -int sys_lutimes(const char *, const struct timeval *) _Hide; -int sys_utimes(const char *, const struct timeval *) _Hide; -axdx_t sys_gettimeofday_m1(struct timeval *, struct timezone *, void *) _Hide; -axdx_t sys_gettimeofday_xnu(struct timeval *, struct timezone *, void *) _Hide; -axdx_t sys_gettimeofday_nt(struct timeval *, struct timezone *, void *) _Hide; -int sys_utimes_nt(const char *, const struct timeval[2]) _Hide; +axdx_t sys_gettimeofday(struct timeval *, struct timezone *, void *); +int sys_settimeofday(const struct timeval *, const struct timezone *); +int sys_futimes(int, const struct timeval *); +int sys_lutimes(const char *, const struct timeval *); +int sys_utimes(const char *, const struct timeval *); +axdx_t sys_gettimeofday_m1(struct timeval *, struct timezone *, void *); +axdx_t sys_gettimeofday_xnu(struct timeval *, struct timezone *, void *); +axdx_t sys_gettimeofday_nt(struct timeval *, struct timezone *, void *); +int sys_utimes_nt(const char *, const struct timeval[2]); axdx_t sys_gettimeofday_metal(struct timeval *, struct timezone *, void *); const char *DescribeTimeval(char[45], int, const struct timeval *); diff --git a/libc/calls/struct/ucontext.internal.h b/libc/calls/struct/ucontext.internal.h index 35e189f96..613fdfb1f 100644 --- a/libc/calls/struct/ucontext.internal.h +++ b/libc/calls/struct/ucontext.internal.h @@ -29,8 +29,8 @@ COSMOPOLITAN_C_START_ #error "unsupported architecture" #endif -void _ntcontext2linux(struct ucontext *, const struct NtContext *) _Hide; -void _ntlinux2context(struct NtContext *, const ucontext_t *) _Hide; +void _ntcontext2linux(struct ucontext *, const struct NtContext *); +void _ntlinux2context(struct NtContext *, const ucontext_t *); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/calls/struct/winsize.internal.h b/libc/calls/struct/winsize.internal.h index 91d1b4d47..2558b874c 100644 --- a/libc/calls/struct/winsize.internal.h +++ b/libc/calls/struct/winsize.internal.h @@ -6,7 +6,7 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -int tcgetwinsize_nt(struct Fd *, struct winsize *) _Hide; +int tcgetwinsize_nt(struct Fd *, struct winsize *); const char *DescribeWinsize(char[64], int, struct winsize *); #define DescribeWinsize(rc, ws) DescribeWinsize(alloca(12), rc, ws) diff --git a/libc/calls/syscall-nt.internal.h b/libc/calls/syscall-nt.internal.h index c752eecdc..c2e7310f7 100644 --- a/libc/calls/syscall-nt.internal.h +++ b/libc/calls/syscall-nt.internal.h @@ -3,41 +3,40 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -bool32 sys_isatty_nt(int) _Hide; -char *sys_getcwd_nt(char *, size_t) _Hide; -int sys_chdir_nt(const char *) _Hide; -int sys_close_epoll_nt(int) _Hide; -int sys_dup_nt(int, int, int, int) _Hide; -int sys_execve_nt(const char *, char *const[], char *const[]) _Hide; -int sys_faccessat_nt(int, const char *, int, uint32_t) _Hide; -int sys_fadvise_nt(int, uint64_t, uint64_t, int) _Hide; -int sys_fchdir_nt(int) _Hide; -int sys_fchmodat_nt(int, const char *, uint32_t, int) _Hide; -int sys_fcntl_nt(int, int, uintptr_t) _Hide; -int sys_fdatasync_nt(int) _Hide; -int sys_flock_nt(int, int) _Hide; -int sys_fork_nt(uint32_t) _Hide; -int sys_ftruncate_nt(int64_t, uint64_t) _Hide; -int sys_getloadavg_nt(double *, int) _Hide; -int sys_getppid_nt(void) _Hide; -int sys_getpriority_nt(int, unsigned) _Hide; -int sys_kill_nt(int, int) _Hide; -int sys_linkat_nt(int, const char *, int, const char *) _Hide; -int sys_madvise_nt(void *, size_t, int) _Hide; -int sys_mkdirat_nt(int, const char *, uint32_t) _Hide; -int sys_msync_nt(char *, size_t, int) _Hide; -int sys_open_nt(int, const char *, uint32_t, int32_t) -dontdiscard _Hide; -int sys_pipe_nt(int[hasatleast 2], unsigned) _Hide; -int sys_renameat_nt(int, const char *, int, const char *) _Hide; -int sys_sched_yield_nt(void) _Hide; -int sys_setpriority_nt(int, unsigned, int) _Hide; -int sys_symlinkat_nt(const char *, int, const char *) _Hide; -int sys_sync_nt(void) _Hide; -int sys_truncate_nt(const char *, uint64_t) _Hide; -int sys_unlinkat_nt(int, const char *, int) _Hide; -int64_t sys_lseek_nt(int, int64_t, int) _Hide; -ssize_t sys_readlinkat_nt(int, const char *, char *, size_t) _Hide; +bool32 sys_isatty_nt(int); +char *sys_getcwd_nt(char *, size_t); +int sys_chdir_nt(const char *); +int sys_close_epoll_nt(int); +int sys_dup_nt(int, int, int, int); +int sys_execve_nt(const char *, char *const[], char *const[]); +int sys_faccessat_nt(int, const char *, int, uint32_t); +int sys_fadvise_nt(int, uint64_t, uint64_t, int); +int sys_fchdir_nt(int); +int sys_fchmodat_nt(int, const char *, uint32_t, int); +int sys_fcntl_nt(int, int, uintptr_t); +int sys_fdatasync_nt(int); +int sys_flock_nt(int, int); +int sys_fork_nt(uint32_t); +int sys_ftruncate_nt(int64_t, uint64_t); +int sys_getloadavg_nt(double *, int); +int sys_getppid_nt(void); +int sys_getpriority_nt(int, unsigned); +int sys_kill_nt(int, int); +int sys_linkat_nt(int, const char *, int, const char *); +int sys_madvise_nt(void *, size_t, int); +int sys_mkdirat_nt(int, const char *, uint32_t); +int sys_msync_nt(char *, size_t, int); +int sys_open_nt(int, const char *, uint32_t, int32_t) dontdiscard; +int sys_pipe_nt(int[hasatleast 2], unsigned); +int sys_renameat_nt(int, const char *, int, const char *); +int sys_sched_yield_nt(void); +int sys_setpriority_nt(int, unsigned, int); +int sys_symlinkat_nt(const char *, int, const char *); +int sys_sync_nt(void); +int sys_truncate_nt(const char *, uint64_t); +int sys_unlinkat_nt(int, const char *, int); +int64_t sys_lseek_nt(int, int64_t, int); +ssize_t sys_readlinkat_nt(int, const char *, char *, size_t); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/calls/syscall-sysv.internal.h b/libc/calls/syscall-sysv.internal.h index 3c3bcd609..f33b4b970 100644 --- a/libc/calls/syscall-sysv.internal.h +++ b/libc/calls/syscall-sysv.internal.h @@ -10,135 +10,135 @@ COSMOPOLITAN_C_START_ │ cosmopolitan § syscalls » system five » structless synthetic jump slots ─╬─│┼ ╚────────────────────────────────────────────────────────────────────────────│*/ -axdx_t __sys_fork(void) _Hide; -axdx_t __sys_pipe(i32[hasatleast 2], i32) _Hide; -axdx_t sys_getpid(void) _Hide; -char *sys_getcwd(char *, u64) _Hide; -char *sys_getcwd_xnu(char *, u64) _Hide; -i32 __sys_dup3(i32, i32, i32) _Hide; -i32 __sys_execve(const char *, char *const[], char *const[]) _Hide; -i32 __sys_fcntl(i32, i32, ...) _Hide; -i32 __sys_fcntl_cp(i32, i32, ...) _Hide; -i32 __sys_fstat(i32, void *) _Hide; -i32 __sys_fstatat(i32, const char *, void *, i32) _Hide; -i32 __sys_gettid(i64 *) _Hide; -i32 __sys_munmap(void *, u64) _Hide; -i32 __sys_openat(i32, const char *, i32, u32) _Hide; -i32 __sys_openat_nc(i32, const char *, i32, u32) _Hide; -i32 __sys_pipe2(i32[hasatleast 2], u32) _Hide; -i32 sys_arch_prctl(i32, i64) _Hide; -i32 sys_chdir(const char *) _Hide; -i32 sys_chroot(const char *) _Hide; -i32 sys_close(i32) _Hide; -i32 sys_close_range(u32, u32, u32) _Hide; -i32 sys_closefrom(i32) _Hide; -i32 sys_dup(i32) _Hide; -i32 sys_dup2(i32, i32, i32) _Hide; -i32 sys_dup3(i32, i32, i32) _Hide; -i32 sys_execve(const char *, char *const[], char *const[]) _Hide; -i32 sys_execveat(i32, const char *, char *const[], char *const[], i32) _Hide; -i32 sys_faccessat(i32, const char *, i32, u32) _Hide; -i32 sys_faccessat2(i32, const char *, i32, u32) _Hide; -i32 sys_fadvise(i32, i64, i64, i32) _Hide; -i32 sys_fchdir(i32) _Hide; -i32 sys_fchmod(i32, u32) _Hide; -i32 sys_fchmodat(i32, const char *, u32, u32) _Hide; -i32 sys_fchown(i64, u32, u32) _Hide; -i32 sys_fchownat(i32, const char *, u32, u32, u32) _Hide; -i32 sys_fcntl(i32, i32, u64, i32 (*)(i32, i32, ...)) _Hide; -i32 sys_fdatasync(i32) _Hide; -i32 sys_fexecve(i32, char *const[], char *const[]) _Hide; -i32 sys_flock(i32, i32) _Hide; -i32 sys_fork(void) _Hide; -i32 sys_fsync(i32) _Hide; -i32 sys_ftruncate(i32, i64, i64) _Hide; -i32 sys_getcontext(void *) _Hide; -i32 sys_getpgid(i32) _Hide; -i32 sys_getppid(void) _Hide; -i32 sys_getpriority(i32, u32) _Hide; -i32 sys_getresgid(u32 *, u32 *, u32 *) _Hide; -i32 sys_getresuid(u32 *, u32 *, u32 *) _Hide; -i32 sys_getsid(i32) _Hide; -i32 sys_gettid(void) _Hide; -i32 sys_ioctl(i32, u64, ...) _Hide; -i32 sys_ioctl_cp(i32, u64, ...) _Hide; -i32 sys_issetugid(void) _Hide; -i32 sys_kill(i32, i32, i32) _Hide; -i32 sys_linkat(i32, const char *, i32, const char *, i32) _Hide; -i32 sys_madvise(void *, size_t, i32) _Hide; -i32 sys_memfd_create(const char *, u32) _Hide; -i32 sys_mincore(void *, u64, unsigned char *) _Hide; -i32 sys_mkdirat(i32, const char *, u32) _Hide; -i32 sys_mkfifo(const char *, u32) _Hide; -i32 sys_mknod(const char *, u32, u64) _Hide; -i32 sys_mknodat(i32, const char *, u32, u64) _Hide; -i32 sys_mprotect(void *, u64, i32) _Hide; -i32 sys_msync(void *, u64, i32) _Hide; -i32 sys_munmap(void *, u64) _Hide; -i32 sys_openat(i32, const char *, i32, u32) _Hide; -i32 sys_pause(void) _Hide; -i32 sys_pipe(i32[hasatleast 2]) _Hide; -i32 sys_pipe2(i32[hasatleast 2], u32) _Hide; -i32 sys_pivot_root(const char *, const char *) _Hide; -i32 sys_pledge(const char *, const char *) _Hide; -i32 sys_posix_openpt(i32) _Hide; -i32 sys_renameat(i32, const char *, i32, const char *) _Hide; -i32 sys_sem_close(i64) _Hide; -i32 sys_sem_destroy(i64) _Hide; -i32 sys_sem_getvalue(i64, u32 *) _Hide; -i32 sys_sem_init(u32, i64 *) _Hide; -i32 sys_sem_open(const char *, int, u32, i64 *) _Hide; -i32 sys_sem_post(i64) _Hide; -i32 sys_sem_trywait(i64) _Hide; -i32 sys_sem_unlink(const char *) _Hide; -i32 sys_sem_wait(i64) _Hide; -i32 sys_setfsgid(i32) _Hide; -i32 sys_setfsuid(i32) _Hide; -i32 sys_setgid(i32) _Hide; -i32 sys_setpgid(i32, i32) _Hide; -i32 sys_setpriority(i32, u32, i32) _Hide; -i32 sys_setregid(u32, u32) _Hide; -i32 sys_setresgid(u32, u32, u32) _Hide; -i32 sys_setresuid(u32, u32, u32) _Hide; -i32 sys_setreuid(u32, u32) _Hide; -i32 sys_setsid(void) _Hide; -i32 sys_setuid(i32) _Hide; -i32 sys_shm_open(const char *, i32, u32) _Hide; -i32 sys_sigaction(i32, const void *, void *, i64, i64) _Hide; -i32 sys_sigaltstack(const void *, void *) _Hide; -i32 sys_symlinkat(const char *, i32, const char *) _Hide; -i32 sys_sync(void) _Hide; -i32 sys_sync_file_range(i32, i64, i64, u32) _Hide; -i32 sys_syslog(i32, char *, i32) _Hide; -i32 sys_tgkill(i32, i32, i32) _Hide; -i32 sys_tkill(i32, i32, void *) _Hide; -i32 sys_truncate(const char *, u64, u64) _Hide; -i32 sys_uname(void *) _Hide; -i32 sys_unlink(const char *) _Hide; -i32 sys_unlinkat(i32, const char *, i32) _Hide; -i32 sys_unmount(const char *, i32) _Hide; -i32 sys_unveil(const char *, const char *) _Hide; -i64 __sys_ptrace(i32, i32, i64, long *) _Hide; -i64 sys_copy_file_range(i32, long *, i32, long *, u64, u32) _Hide; -i64 sys_getrandom(void *, u64, u32) _Hide; -i64 sys_lseek(i32, i64, i64, i64) _Hide; -i64 sys_pread(i32, void *, u64, i64, i64) _Hide; -i64 sys_pwrite(i32, const void *, u64, i64, i64) _Hide; -i64 sys_read(i32, void *, u64) _Hide; -i64 sys_readlinkat(i32, const char *, char *, u64) _Hide; -i64 sys_sendfile(i32, i32, i64 *, u64) _Hide; -i64 sys_splice(i32, i64 *, i32, i64 *, u64, u32) _Hide; -i64 sys_write(i32, const void *, u64) _Hide; -u32 sys_getegid(void) _Hide; -u32 sys_geteuid(void) _Hide; -u32 sys_getgid(void) _Hide; -u32 sys_getuid(void) _Hide; -u32 sys_umask(u32) _Hide; -unsigned long _sysret(unsigned long) _Hide; -void *__sys_mmap(void *, u64, u32, u32, i64, i64, i64) _Hide; -void *__sys_mremap(void *, u64, u64, i32, void *) _Hide; -void *sys_mremap(void *, u64, u64, i32, void *) _Hide; -void sys_exit(i32) _Hide; +axdx_t __sys_fork(void); +axdx_t __sys_pipe(i32[hasatleast 2], i32); +axdx_t sys_getpid(void); +char *sys_getcwd(char *, u64); +char *sys_getcwd_xnu(char *, u64); +i32 __sys_dup3(i32, i32, i32); +i32 __sys_execve(const char *, char *const[], char *const[]); +i32 __sys_fcntl(i32, i32, ...); +i32 __sys_fcntl_cp(i32, i32, ...); +i32 __sys_fstat(i32, void *); +i32 __sys_fstatat(i32, const char *, void *, i32); +i32 __sys_gettid(i64 *); +i32 __sys_munmap(void *, u64); +i32 __sys_openat(i32, const char *, i32, u32); +i32 __sys_openat_nc(i32, const char *, i32, u32); +i32 __sys_pipe2(i32[hasatleast 2], u32); +i32 sys_arch_prctl(i32, i64); +i32 sys_chdir(const char *); +i32 sys_chroot(const char *); +i32 sys_close(i32); +i32 sys_close_range(u32, u32, u32); +i32 sys_closefrom(i32); +i32 sys_dup(i32); +i32 sys_dup2(i32, i32, i32); +i32 sys_dup3(i32, i32, i32); +i32 sys_execve(const char *, char *const[], char *const[]); +i32 sys_execveat(i32, const char *, char *const[], char *const[], i32); +i32 sys_faccessat(i32, const char *, i32, u32); +i32 sys_faccessat2(i32, const char *, i32, u32); +i32 sys_fadvise(i32, i64, i64, i32); +i32 sys_fchdir(i32); +i32 sys_fchmod(i32, u32); +i32 sys_fchmodat(i32, const char *, u32, u32); +i32 sys_fchown(i64, u32, u32); +i32 sys_fchownat(i32, const char *, u32, u32, u32); +i32 sys_fcntl(i32, i32, u64, i32 (*)(i32, i32, ...)); +i32 sys_fdatasync(i32); +i32 sys_fexecve(i32, char *const[], char *const[]); +i32 sys_flock(i32, i32); +i32 sys_fork(void); +i32 sys_fsync(i32); +i32 sys_ftruncate(i32, i64, i64); +i32 sys_getcontext(void *); +i32 sys_getpgid(i32); +i32 sys_getppid(void); +i32 sys_getpriority(i32, u32); +i32 sys_getresgid(u32 *, u32 *, u32 *); +i32 sys_getresuid(u32 *, u32 *, u32 *); +i32 sys_getsid(i32); +i32 sys_gettid(void); +i32 sys_ioctl(i32, u64, ...); +i32 sys_ioctl_cp(i32, u64, ...); +i32 sys_issetugid(void); +i32 sys_kill(i32, i32, i32); +i32 sys_linkat(i32, const char *, i32, const char *, i32); +i32 sys_madvise(void *, size_t, i32); +i32 sys_memfd_create(const char *, u32); +i32 sys_mincore(void *, u64, unsigned char *); +i32 sys_mkdirat(i32, const char *, u32); +i32 sys_mkfifo(const char *, u32); +i32 sys_mknod(const char *, u32, u64); +i32 sys_mknodat(i32, const char *, u32, u64); +i32 sys_mprotect(void *, u64, i32); +i32 sys_msync(void *, u64, i32); +i32 sys_munmap(void *, u64); +i32 sys_openat(i32, const char *, i32, u32); +i32 sys_pause(void); +i32 sys_pipe(i32[hasatleast 2]); +i32 sys_pipe2(i32[hasatleast 2], u32); +i32 sys_pivot_root(const char *, const char *); +i32 sys_pledge(const char *, const char *); +i32 sys_posix_openpt(i32); +i32 sys_renameat(i32, const char *, i32, const char *); +i32 sys_sem_close(i64); +i32 sys_sem_destroy(i64); +i32 sys_sem_getvalue(i64, u32 *); +i32 sys_sem_init(u32, i64 *); +i32 sys_sem_open(const char *, int, u32, i64 *); +i32 sys_sem_post(i64); +i32 sys_sem_trywait(i64); +i32 sys_sem_unlink(const char *); +i32 sys_sem_wait(i64); +i32 sys_setfsgid(i32); +i32 sys_setfsuid(i32); +i32 sys_setgid(i32); +i32 sys_setpgid(i32, i32); +i32 sys_setpriority(i32, u32, i32); +i32 sys_setregid(u32, u32); +i32 sys_setresgid(u32, u32, u32); +i32 sys_setresuid(u32, u32, u32); +i32 sys_setreuid(u32, u32); +i32 sys_setsid(void); +i32 sys_setuid(i32); +i32 sys_shm_open(const char *, i32, u32); +i32 sys_sigaction(i32, const void *, void *, i64, i64); +i32 sys_sigaltstack(const void *, void *); +i32 sys_symlinkat(const char *, i32, const char *); +i32 sys_sync(void); +i32 sys_sync_file_range(i32, i64, i64, u32); +i32 sys_syslog(i32, char *, i32); +i32 sys_tgkill(i32, i32, i32); +i32 sys_tkill(i32, i32, void *); +i32 sys_truncate(const char *, u64, u64); +i32 sys_uname(void *); +i32 sys_unlink(const char *); +i32 sys_unlinkat(i32, const char *, i32); +i32 sys_unmount(const char *, i32); +i32 sys_unveil(const char *, const char *); +i64 __sys_ptrace(i32, i32, i64, long *); +i64 sys_copy_file_range(i32, long *, i32, long *, u64, u32); +i64 sys_getrandom(void *, u64, u32); +i64 sys_lseek(i32, i64, i64, i64); +i64 sys_pread(i32, void *, u64, i64, i64); +i64 sys_pwrite(i32, const void *, u64, i64, i64); +i64 sys_read(i32, void *, u64); +i64 sys_readlinkat(i32, const char *, char *, u64); +i64 sys_sendfile(i32, i32, i64 *, u64); +i64 sys_splice(i32, i64 *, i32, i64 *, u64, u32); +i64 sys_write(i32, const void *, u64); +u32 sys_getegid(void); +u32 sys_geteuid(void); +u32 sys_getgid(void); +u32 sys_getuid(void); +u32 sys_umask(u32); +unsigned long _sysret(unsigned long); +void *__sys_mmap(void *, u64, u32, u32, i64, i64, i64); +void *__sys_mremap(void *, u64, u64, i32, void *); +void *sys_mremap(void *, u64, u64, i32, void *); +void sys_exit(i32); #undef i32 #undef i64 diff --git a/libc/calls/syscall_support-nt.internal.h b/libc/calls/syscall_support-nt.internal.h index 7aaf1379f..5c2e5554e 100644 --- a/libc/calls/syscall_support-nt.internal.h +++ b/libc/calls/syscall_support-nt.internal.h @@ -3,25 +3,25 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -bool isdirectory_nt(const char *) _Hide; -bool isregularfile_nt(const char *) _Hide; -bool issymlink_nt(const char *) _Hide; -bool32 ntsetprivilege(int64_t, const char16_t *, uint32_t) _Hide; -char16_t *CreatePipeName(char16_t *) _Hide; -int __mkntpath(const char *, char16_t[hasatleast PATH_MAX]) _Hide; -int __mkntpath2(const char *, char16_t[hasatleast PATH_MAX], int) _Hide; -int __mkntpathat(int, const char *, int, char16_t[hasatleast PATH_MAX]) _Hide; -int __sample_pids(int[hasatleast 64], int64_t[hasatleast 64], bool) _Hide; -int ntaccesscheck(const char16_t *, uint32_t) paramsnonnull() _Hide; -int sys_pause_nt(void) _Hide; -int64_t __fix_enotdir(int64_t, char16_t *) _Hide; -int64_t __fix_enotdir3(int64_t, char16_t *, char16_t *) _Hide; +bool isdirectory_nt(const char *); +bool isregularfile_nt(const char *); +bool issymlink_nt(const char *); +bool32 ntsetprivilege(int64_t, const char16_t *, uint32_t); +char16_t *CreatePipeName(char16_t *); +int __mkntpath(const char *, char16_t[hasatleast PATH_MAX]); +int __mkntpath2(const char *, char16_t[hasatleast PATH_MAX], int); +int __mkntpathat(int, const char *, int, char16_t[hasatleast PATH_MAX]); +int __sample_pids(int[hasatleast 64], int64_t[hasatleast 64], bool); +int ntaccesscheck(const char16_t *, uint32_t) paramsnonnull(); +int sys_pause_nt(void); +int64_t __fix_enotdir(int64_t, char16_t *); +int64_t __fix_enotdir3(int64_t, char16_t *, char16_t *); int64_t __winerr(void) nocallback privileged; int64_t ntreturn(uint32_t); -void *GetProcAddressModule(const char *, const char *) _Hide; -void WinMainForked(void) _Hide; -void _check_sigalrm(void) _Hide; -void _check_sigchld(void) _Hide; +void *GetProcAddressModule(const char *, const char *); +void WinMainForked(void); +void _check_sigalrm(void); +void _check_sigchld(void); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/calls/syscall_support-sysv.internal.h b/libc/calls/syscall_support-sysv.internal.h index 75e87a28f..3543933ce 100644 --- a/libc/calls/syscall_support-sysv.internal.h +++ b/libc/calls/syscall_support-sysv.internal.h @@ -6,27 +6,27 @@ COSMOPOLITAN_C_START_ │ cosmopolitan § syscalls » system five » structless support ─╬─│┼ ╚────────────────────────────────────────────────────────────────────────────│*/ -bool __is_linux_2_6_23(void) _Hide; +bool __is_linux_2_6_23(void); bool32 sys_isatty_metal(int); -int __fixupnewfd(int, int) _Hide; +int __fixupnewfd(int, int); int __notziposat(int, const char *); -int __tkill(int, int, void *) _Hide; -int _fork(uint32_t) _Hide; -int _isptmaster(int) _Hide; -int _ptsname(int, char *, size_t) _Hide; -int getdomainname_linux(char *, size_t) _Hide; -int gethostname_bsd(char *, size_t, int) _Hide; -int gethostname_linux(char *, size_t) _Hide; -int gethostname_nt(char *, size_t, int) _Hide; +int __tkill(int, int, void *); +int _fork(uint32_t); +int _isptmaster(int); +int _ptsname(int, char *, size_t); +int getdomainname_linux(char *, size_t); +int gethostname_bsd(char *, size_t, int); +int gethostname_linux(char *, size_t); +int gethostname_nt(char *, size_t, int); int sys_msyscall(void *, size_t); long sys_bogus(void); -ssize_t __getrandom(void *, size_t, unsigned) _Hide; -void *__vdsosym(const char *, const char *) _Hide; -void __onfork(void) _Hide; -void __restore_rt() _Hide; -void __restore_rt_netbsd(void) _Hide; -void cosmo2flock(uintptr_t) _Hide; -void flock2cosmo(uintptr_t) _Hide; +ssize_t __getrandom(void *, size_t, unsigned); +void *__vdsosym(const char *, const char *); +void __onfork(void); +void __restore_rt(); +void __restore_rt_netbsd(void); +void cosmo2flock(uintptr_t); +void flock2cosmo(uintptr_t); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/calls/wait4.h b/libc/calls/wait4.h index e26633a7c..5a532d225 100644 --- a/libc/calls/wait4.h +++ b/libc/calls/wait4.h @@ -4,7 +4,7 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -int sys_wait4_nt(int, int *, int, struct rusage *) _Hide; +int sys_wait4_nt(int, int *, int, struct rusage *); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/calls/writevuninterruptible.c b/libc/calls/writevuninterruptible.c index 5ec7391d6..5ee305848 100644 --- a/libc/calls/writevuninterruptible.c +++ b/libc/calls/writevuninterruptible.c @@ -19,9 +19,8 @@ #include "libc/calls/struct/iovec.h" #include "libc/calls/struct/iovec.internal.h" #include "libc/errno.h" -#include "libc/sock/sock.h" -ssize_t WritevUninterruptible(int fd, struct iovec *iov, int iovlen) { +ssize_t __robust_writev(int fd, struct iovec *iov, int iovlen) { ssize_t rc; size_t wrote; do { diff --git a/libc/fmt/fmt.h b/libc/fmt/fmt.h index 91efc5602..9a5cfb0a3 100644 --- a/libc/fmt/fmt.h +++ b/libc/fmt/fmt.h @@ -29,7 +29,7 @@ char *gcvt(double, int, char *); #ifdef COSMO int __vcscanf(int (*)(void *), int (*)(int, void *), void *, const char *, va_list); -int __fmt(void *, void *, const char *, va_list) _Hide; +int __fmt(void *, void *, const char *, va_list); #endif COSMOPOLITAN_C_END_ diff --git a/libc/fmt/magnumstrs.internal.h b/libc/fmt/magnumstrs.internal.h index 1d4c1c188..b8338a1de 100644 --- a/libc/fmt/magnumstrs.internal.h +++ b/libc/fmt/magnumstrs.internal.h @@ -16,17 +16,17 @@ struct MagnumStr { int x, s; }; -_Hide extern const struct MagnumStr kClockNames[]; -_Hide extern const struct MagnumStr kErrnoDocs[]; -_Hide extern const struct MagnumStr kErrnoNames[]; -_Hide extern const struct MagnumStr kFcntlCmds[]; -_Hide extern const struct MagnumStr kIpOptnames[]; -_Hide extern const struct MagnumStr kOpenFlags[]; -_Hide extern const struct MagnumStr kRlimitNames[]; -_Hide extern const struct MagnumStr kSignalNames[]; -_Hide extern const struct MagnumStr kSockOptnames[]; -_Hide extern const struct MagnumStr kTcpOptnames[]; -_Hide extern const struct MagnumStr kPollNames[]; +extern const struct MagnumStr kClockNames[]; +extern const struct MagnumStr kErrnoDocs[]; +extern const struct MagnumStr kErrnoNames[]; +extern const struct MagnumStr kFcntlCmds[]; +extern const struct MagnumStr kIpOptnames[]; +extern const struct MagnumStr kOpenFlags[]; +extern const struct MagnumStr kRlimitNames[]; +extern const struct MagnumStr kSignalNames[]; +extern const struct MagnumStr kSockOptnames[]; +extern const struct MagnumStr kTcpOptnames[]; +extern const struct MagnumStr kPollNames[]; char *DescribeMagnum(char *, const struct MagnumStr *, const char *, int); diff --git a/libc/integral/c.inc b/libc/integral/c.inc index a7195f1af..5a67eee7f 100644 --- a/libc/integral/c.inc +++ b/libc/integral/c.inc @@ -193,15 +193,6 @@ typedef struct { #define strftimeesque(n) #endif -#ifndef _Hide -#if !defined(__STRICT_ANSI__) && \ - (__has_attribute(__visibility__) || defined(__GNUC__)) && !defined(_WIN32) -#define _Hide __attribute__((__visibility__("hidden"))) -#else -#define _Hide -#endif -#endif - #ifndef privileged #if !defined(__STRICT_ANSI__) && \ (__has_attribute(__visibility__) || defined(__GNUC__)) diff --git a/libc/intrin/_getenv.internal.h b/libc/intrin/_getenv.internal.h index c28e06993..e700d4d0c 100644 --- a/libc/intrin/_getenv.internal.h +++ b/libc/intrin/_getenv.internal.h @@ -8,7 +8,7 @@ struct Env { int i; }; -struct Env _getenv(char **, const char *) _Hide; +struct Env _getenv(char **, const char *); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/intrin/kntisinheritable.greg.c b/libc/intrin/kntisinheritable.greg.c index 9fcabf913..a871e6813 100644 --- a/libc/intrin/kntisinheritable.greg.c +++ b/libc/intrin/kntisinheritable.greg.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/nt/struct/securityattributes.h" -_Hide const struct NtSecurityAttributes kNtIsInheritable = { +const struct NtSecurityAttributes kNtIsInheritable = { sizeof(struct NtSecurityAttributes), NULL, true, diff --git a/libc/intrin/kprintf.greg.c b/libc/intrin/kprintf.greg.c index 275eeb6ac..b6f9d8a11 100644 --- a/libc/intrin/kprintf.greg.c +++ b/libc/intrin/kprintf.greg.c @@ -106,8 +106,8 @@ break; \ } -_Hide long __klog_handle; -extern _Hide struct SymbolTable *__symtab; +long __klog_handle; +extern struct SymbolTable *__symtab; privileged static inline char *kadvance(char *p, char *e, long n) { intptr_t t = (intptr_t)p; diff --git a/libc/isystem/cosmo.h b/libc/isystem/cosmo.h index 5bf582d7d..b7c59d184 100644 --- a/libc/isystem/cosmo.h +++ b/libc/isystem/cosmo.h @@ -12,10 +12,9 @@ * * Users of the `cosmocc` toolchain can say, for example: * -#include "tool/args/args.h" * #include * - * int main(int argc, char *argv[]) { + * main() { * ShowCrashReports(); * kprintf("hello world\n"); * } @@ -46,7 +45,6 @@ #include "libc/nexgen32e/rdtsc.h" #include "libc/nexgen32e/stackframe.h" #include "libc/nexgen32e/x86feature.h" -#include "libc/runtime/morph.h" #include "libc/runtime/runtime.h" #include "libc/runtime/stack.h" #include "libc/runtime/symbols.internal.h" diff --git a/libc/log/gdbsync.c b/libc/log/gdbsync.c index b0444fda6..5d2a5032b 100644 --- a/libc/log/gdbsync.c +++ b/libc/log/gdbsync.c @@ -18,4 +18,4 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/log/gdb.h" -volatile int g_gdbsync _Hide; +volatile int g_gdbsync; diff --git a/libc/log/internal.h b/libc/log/internal.h index 2bef0ed00..9f69f3cde 100644 --- a/libc/log/internal.h +++ b/libc/log/internal.h @@ -4,11 +4,11 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -extern _Hide bool __nocolor; -extern _Hide bool _wantcrashreports; -extern _Hide bool g_isrunningundermake; +extern bool __nocolor; +extern bool _wantcrashreports; +extern bool g_isrunningundermake; -void __start_fatal(const char *, int) _Hide; +void __start_fatal(const char *, int); void __restore_tty(void); void RestoreDefaultCrashSignalHandlers(void); void __oncrash_amd64(int, struct siginfo *, void *) relegated; diff --git a/libc/log/logkprintftofile.c b/libc/log/logkprintftofile.c index 778e1fab8..38cdd8dc5 100644 --- a/libc/log/logkprintftofile.c +++ b/libc/log/logkprintftofile.c @@ -24,7 +24,7 @@ #include "libc/sysv/consts/o.h" static int __klog_fd; -extern _Hide long __klog_handle; +extern long __klog_handle; /** * Redirects kprintf(), `--strace`, etc. output to file. diff --git a/libc/mem/internal.h b/libc/mem/internal.h index 6147d35ac..076649f54 100644 --- a/libc/mem/internal.h +++ b/libc/mem/internal.h @@ -9,7 +9,7 @@ struct CritbitNode { unsigned otherbits; }; -int PutEnvImpl(char *, bool) _Hide; +int PutEnvImpl(char *, bool); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/nexgen32e/kompressor.h b/libc/nexgen32e/kompressor.h index aef5a9b1e..e1800208c 100644 --- a/libc/nexgen32e/kompressor.h +++ b/libc/nexgen32e/kompressor.h @@ -13,12 +13,12 @@ struct RlDecode { uint8_t byte; }; -void rldecode(void *dest, const struct RlDecode *) _Hide; -void rldecode2(void *dest, const struct RlDecode *) _Hide; -const uint8_t *lz4check(const void *data) _Hide; -void *lz4cpy(void *dest, const void *blockdata, size_t blocksize) _Hide; -size_t lz4len(const void *blockdata, size_t blocksize) _Hide; -void *lz4decode(void *dest, const void *src) _Hide; +void rldecode(void *dest, const struct RlDecode *); +void rldecode2(void *dest, const struct RlDecode *); +const uint8_t *lz4check(const void *data); +void *lz4cpy(void *dest, const void *blockdata, size_t blocksize); +size_t lz4len(const void *blockdata, size_t blocksize); +void *lz4decode(void *dest, const void *src); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/runtime/__sigsetjmp_tail.c b/libc/runtime/__sigsetjmp_tail.c index c3d8f5f61..c564416bc 100644 --- a/libc/runtime/__sigsetjmp_tail.c +++ b/libc/runtime/__sigsetjmp_tail.c @@ -23,7 +23,7 @@ #ifdef __x86_64__ // kudos rich felker for the brilliant design -_Hide int __sigsetjmp_tail(sigjmp_buf jb, int rc) { +int __sigsetjmp_tail(sigjmp_buf jb, int rc) { _Static_assert( sizeof(sigjmp_buf) == sizeof(jmp_buf) + 8 + 8 + sizeof(sigset_t), "please recompute sigjmp_buf w.r.t. sigset_t"); diff --git a/libc/runtime/enable_threads.c b/libc/runtime/enable_threads.c index 8bce9b1dc..177a67207 100644 --- a/libc/runtime/enable_threads.c +++ b/libc/runtime/enable_threads.c @@ -17,12 +17,8 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "ape/sections.internal.h" -#include "libc/assert.h" -#include "libc/calls/calls.h" -#include "libc/calls/struct/sigset.h" #include "libc/calls/syscall-sysv.internal.h" #include "libc/intrin/strace.internal.h" -#include "libc/runtime/morph.h" #include "libc/runtime/runtime.h" #include "libc/thread/tls.h" @@ -30,8 +26,7 @@ extern int __threadcalls_end[] __attribute__((__weak__)); extern int __threadcalls_start[] __attribute__((__weak__)); static privileged dontinline void FixupLockNops(void) { - sigset_t mask; - __morph_begin(&mask); + __morph_begin(); /* * _NOPL("__threadcalls", func) * @@ -55,7 +50,7 @@ static privileged dontinline void FixupLockNops(void) { __executable_start[*p + 1] = 0x67; __executable_start[*p + 2] = 0xe8; } - __morph_end(&mask); + __morph_end(); } void __enable_threads(void) { diff --git a/libc/runtime/getsymbol.c b/libc/runtime/getsymbol.c index 87d3c8a00..8852b2200 100644 --- a/libc/runtime/getsymbol.c +++ b/libc/runtime/getsymbol.c @@ -19,7 +19,7 @@ #include "libc/runtime/runtime.h" #include "libc/runtime/symbols.internal.h" -extern _Hide struct SymbolTable *__symtab; +extern struct SymbolTable *__symtab; /** * Returns low index into symbol table for address. diff --git a/libc/runtime/getsymboltable.c b/libc/runtime/getsymboltable.c index 2480af9cc..6639c5101 100644 --- a/libc/runtime/getsymboltable.c +++ b/libc/runtime/getsymboltable.c @@ -35,7 +35,7 @@ STATIC_YOINK("__get_symbol"); static pthread_spinlock_t g_lock; -_Hide struct SymbolTable *__symtab; // for kprintf +struct SymbolTable *__symtab; // for kprintf /** * Looks for `.symtab` in zip central directory. diff --git a/libc/runtime/hook.greg.c b/libc/runtime/hook.greg.c index 6c828e9df..4dacb9c38 100644 --- a/libc/runtime/hook.greg.c +++ b/libc/runtime/hook.greg.c @@ -20,7 +20,7 @@ #include "libc/calls/struct/sigset.h" #include "libc/limits.h" #include "libc/macros.internal.h" -#include "libc/runtime/morph.h" +#include "libc/runtime/runtime.h" #include "libc/runtime/symbols.internal.h" #ifdef __x86_64__ @@ -109,11 +109,10 @@ static privileged void HookFunction(code_t *func, void *dest) { privileged dontinstrument noasan int __hook(void *dest, struct SymbolTable *st) { long i; - sigset_t mask; code_t *p, *pe; intptr_t lowest; if (!st) return -1; - __morph_begin(&mask); + __morph_begin(); lowest = MAX((intptr_t)__executable_start, (intptr_t)_ereal); for (i = 0; i < st->count; ++i) { if (st->symbols[i].x < 9) continue; @@ -129,6 +128,6 @@ privileged dontinstrument noasan int __hook(void *dest, // kprintf("can't hook %t at %lx\n", p, p); } } - __morph_end(&mask); + __morph_end(); return 0; } diff --git a/libc/runtime/internal.h b/libc/runtime/internal.h index 870ebcfc5..44cba05a2 100644 --- a/libc/runtime/internal.h +++ b/libc/runtime/internal.h @@ -31,25 +31,25 @@ extern unsigned char _tbss_offset[] __attribute__((__weak__)); extern unsigned char _tls_size[] __attribute__((__weak__)); extern unsigned char _tls_content[] __attribute__((__weak__)); -void _init(void) _Hide; -int ftrace_init(void) _Hide; -void ftrace_hook(void) _Hide; -void __morph_tls(void) _Hide; -void __enable_tls(void) _Hide; -void __enable_threads(void) _Hide; -void *__cxa_finalize(void *) _Hide; +void _init(void); +int ftrace_init(void); +void ftrace_hook(void); +void __morph_tls(void); +void __enable_tls(void); +void __enable_threads(void); +void *__cxa_finalize(void *); void __stack_chk_fail(void) wontreturn relegated; -void __stack_chk_fail_local(void) wontreturn relegated _Hide; -void __asan_init(int, char **, char **, intptr_t *) _Hide; -void _jmpstack(void *, void *, ...) _Hide wontreturn; -long _setstack(void *, void *, ...) _Hide; +void __stack_chk_fail_local(void) wontreturn relegated; +void __asan_init(int, char **, char **, intptr_t *); +void _jmpstack(void *, void *, ...) wontreturn; +long _setstack(void *, void *, ...); int GetDosArgv(const char16_t *, char *, size_t, char **, size_t); int GetDosEnviron(const char16_t *, char *, size_t, char **, size_t); bool __intercept_flag(int *, char *[], const char *); -int sys_mprotect_nt(void *, size_t, int) _Hide; +int sys_mprotect_nt(void *, size_t, int); int __inflate(void *, size_t, const void *, size_t); -noasan void *_Mmap(void *, size_t, int, int, int, int64_t) _Hide; -noasan int _Munmap(char *, size_t) _Hide; +noasan void *_Mmap(void *, size_t, int, int, int, int64_t); +noasan int _Munmap(char *, size_t); void __on_arithmetic_overflow(void); void __init_fds(void); diff --git a/libc/runtime/isdynamicexecutable.c b/libc/runtime/isdynamicexecutable.c deleted file mode 100644 index b2b33f190..000000000 --- a/libc/runtime/isdynamicexecutable.c +++ /dev/null @@ -1,81 +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 2022 Justine Alexandra Roberts Tunney │ -│ │ -│ Permission to use, copy, modify, and/or distribute this software for │ -│ any purpose with or without fee is hereby granted, provided that the │ -│ above copyright notice and this permission notice appear in all copies. │ -│ │ -│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │ -│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │ -│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │ -│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │ -│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │ -│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │ -│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ -│ PERFORMANCE OF THIS SOFTWARE. │ -╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/blockcancel.internal.h" -#include "libc/calls/calls.h" -#include "libc/calls/struct/stat.h" -#include "libc/elf/def.h" -#include "libc/elf/elf.h" -#include "libc/elf/struct/ehdr.h" -#include "libc/elf/struct/phdr.h" -#include "libc/errno.h" -#include "libc/intrin/bits.h" -#include "libc/runtime/runtime.h" -#include "libc/sysv/consts/map.h" -#include "libc/sysv/consts/o.h" -#include "libc/sysv/consts/prot.h" - -/** - * Returns true if ELF executable uses dynamic loading magic. - */ -bool _IsDynamicExecutable(const char *prog) { - bool res; - Elf64_Ehdr *e; - Elf64_Phdr *p; - struct stat st; - int i, fd, err; - BLOCK_CANCELLATIONS; - fd = -1; - err = errno; - e = MAP_FAILED; - if ((fd = open(prog, O_RDONLY)) == -1) { - res = false; - goto Finish; - } - if (fstat(fd, &st) == -1 || st.st_size < 64) { - res = false; - goto Finish; - } - if ((e = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0)) == MAP_FAILED) { - res = false; - goto Finish; - } - if (READ32LE(e->e_ident) != READ32LE(ELFMAG)) { - res = false; - goto Finish; - } - if (e->e_type == ET_DYN) { - res = true; - goto Finish; - } - for (i = 0; i < e->e_phnum; ++i) { - p = GetElfProgramHeaderAddress(e, st.st_size, i); - if (p->p_type == PT_INTERP || p->p_type == PT_DYNAMIC) { - res = true; - goto Finish; - } - } - res = false; - goto Finish; -Finish: - if (e != MAP_FAILED) munmap(e, st.st_size); - if (fd != -1) close(fd); - errno = err; - ALLOW_CANCELLATIONS; - return res; -} diff --git a/libc/runtime/metalprintf.greg.c b/libc/runtime/metalprintf.greg.c index b14878bd2..c8823807c 100644 --- a/libc/runtime/metalprintf.greg.c +++ b/libc/runtime/metalprintf.greg.c @@ -36,7 +36,7 @@ * This only supports %d and %s. It'll will work even if .rodata hasn't * been loaded into memory yet. */ -_Hide textreal void(MetalPrintf)(const char *fmt, ...) { +textreal void(MetalPrintf)(const char *fmt, ...) { int i; char c; unsigned u; diff --git a/libc/runtime/morph.greg.c b/libc/runtime/morph.c similarity index 76% rename from libc/runtime/morph.greg.c rename to libc/runtime/morph.c index 538b91ba7..d9a1c9ed0 100644 --- a/libc/runtime/morph.greg.c +++ b/libc/runtime/morph.c @@ -18,22 +18,16 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #define ShouldUseMsabiAttribute() 1 #include "ape/sections.internal.h" -#include "libc/calls/calls.h" -#include "libc/calls/internal.h" -#include "libc/calls/struct/sigset.h" #include "libc/dce.h" #include "libc/errno.h" #include "libc/intrin/asmflag.h" #include "libc/intrin/kprintf.h" #include "libc/nt/enum/pageflags.h" #include "libc/nt/memory.h" -#include "libc/nt/runtime.h" #include "libc/nt/thunk/msabi.h" -#include "libc/runtime/internal.h" #include "libc/runtime/runtime.h" #include "libc/sysv/consts/nr.h" #include "libc/sysv/consts/prot.h" -#include "libc/sysv/consts/sig.h" __msabi extern typeof(VirtualProtect) *const __imp_VirtualProtect; @@ -77,24 +71,37 @@ __funline void __morph_mprotect(void *addr, size_t size, int prot, int ntprot) { /** * Begins code morphing executable. * - * @return 0 on success, or -1 w/ errno + * The following example + * + * #include + * #include + * + * privileged int main() { // privileged code is unmodifiable + * ShowCrashReports(); // print report if trapped + * __morph_begin(0); // make executable code R+W + * *(char *)exit = 0xCC; // turn exit() into an INT3 trap + * __morph_end(); // make executable code R+X + * exit(0); // won't actually exit + * } + * + * shows how the exit() function can be recompiled at runtime to become + * an int3 (x86-64) debugger trap. What makes it tricky is Cosmopolitan + * maintains a R^X invariant, in order to support OpenBSD. So when code + * wants to modify some part of the executable image in memory the vast + * majority of the code stops being executable during that time, unless + * it's been linked into a special privileged section of the binary. It + * is only possible to code morph from privileged functions. Privileged + * functions are also only allowed to call other privileged functions. */ -privileged void __morph_begin(sigset_t *save) { - int ax; - bool cf; - intptr_t dx; - sigset_t ss = {{-1, -1}}; +privileged void __morph_begin(void) { __morph_mprotect(__executable_start, __privileged_start - __executable_start, PROT_READ | PROT_WRITE, kNtPageWritecopy); } /** - * Begins code morphing executable. + * Finishes code morphing executable. */ -privileged void __morph_end(sigset_t *save) { - int ax; - long dx; - bool cf; +privileged void __morph_end(void) { __morph_mprotect(__executable_start, __privileged_start - __executable_start, PROT_READ | PROT_EXEC, kNtPageExecuteRead); } diff --git a/libc/runtime/morph.h b/libc/runtime/morph.h deleted file mode 100644 index 813140317..000000000 --- a/libc/runtime/morph.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef COSMOPOLITAN_LIBC_RUNTIME_MORPH_H_ -#define COSMOPOLITAN_LIBC_RUNTIME_MORPH_H_ -#include "libc/calls/struct/sigset.h" -#if !(__ASSEMBLER__ + __LINKER__ + 0) -COSMOPOLITAN_C_START_ - -void __morph_begin(sigset_t *); -void __morph_end(sigset_t *); - -COSMOPOLITAN_C_END_ -#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ -#endif /* COSMOPOLITAN_LIBC_RUNTIME_MORPH_H_ */ diff --git a/libc/runtime/morph_tls.c b/libc/runtime/morph_tls.c index 04fbebb0a..8e4afb067 100644 --- a/libc/runtime/morph_tls.c +++ b/libc/runtime/morph_tls.c @@ -17,11 +17,9 @@ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "ape/sections.internal.h" -#include "libc/dce.h" #include "libc/intrin/bits.h" -#include "libc/intrin/kprintf.h" #include "libc/runtime/internal.h" -#include "libc/runtime/morph.h" +#include "libc/runtime/runtime.h" #include "libc/thread/tls.h" typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(1))); @@ -47,10 +45,9 @@ privileged void __morph_tls(void) { // have actually been linked into this program. int n; uint64_t w; - sigset_t mask; unsigned m, dis; unsigned char *p; - __morph_begin(&mask); + __morph_begin(); if (IsXnu()) { // Apple is quite straightforward to patch. We basically @@ -114,6 +111,6 @@ privileged void __morph_tls(void) { } } - __morph_end(&mask); + __morph_end(); #endif } diff --git a/libc/runtime/runtime.h b/libc/runtime/runtime.h index c580c7db1..621f79bf9 100644 --- a/libc/runtime/runtime.h +++ b/libc/runtime/runtime.h @@ -103,7 +103,6 @@ int _cocmd(int, char **, char **); char *GetProgramExecutableName(void); char *GetInterpreterExecutableName(char *, size_t); int _OpenExecutable(void); -bool _IsDynamicExecutable(const char *); /* execution control */ int verynice(void); axdx_t setlongerjmp(jmp_buf) @@ -121,6 +120,9 @@ void *_mapanon(size_t) attributeallocsize((1)) mallocesque; void *_mapshared(size_t) attributeallocsize((1)) mallocesque; void __oom_hook(size_t); bool _isheap(void *); +/* code morphing */ +void __morph_begin(void); +void __morph_end(void); /* portability */ int NtGetVersion(void) pureconst; bool IsGenuineBlink(void); diff --git a/libc/runtime/runtime.mk b/libc/runtime/runtime.mk index 78fcef9e2..0c73ec109 100644 --- a/libc/runtime/runtime.mk +++ b/libc/runtime/runtime.mk @@ -123,13 +123,15 @@ o/$(MODE)/libc/runtime/enable_tls.o: private \ endif # privileged functions +o/$(MODE)/libc/runtime/morph.o \ o/$(MODE)/libc/runtime/getsymbol.o \ o/$(MODE)/libc/runtime/enable_threads.o \ o/$(MODE)/libc/runtime/morph_tls.o: private \ CFLAGS += \ -ffreestanding \ -fno-sanitize=all \ - -fno-stack-protector + -fno-stack-protector \ + -fpatchable-function-entry=0,0 # TODO(jart): We need a way to avoid WinThreadEntry() being hooked. o/$(MODE)/libc/runtime/clone.o: private \ diff --git a/libc/runtime/winmain.greg.c b/libc/runtime/winmain.greg.c index 3ac00dff6..c77b519e0 100644 --- a/libc/runtime/winmain.greg.c +++ b/libc/runtime/winmain.greg.c @@ -67,7 +67,7 @@ __msabi extern typeof(VirtualProtect) *const __imp_VirtualProtect; extern int64_t __wincrashearly; extern const char kConsoleHandles[3]; -extern void cosmo(int, char **, char **, long (*)[2]) _Hide wontreturn; +extern void cosmo(int, char **, char **, long (*)[2]) wontreturn; static const short kConsoleModes[3] = { kNtEnableProcessedInput | kNtEnableLineInput | kNtEnableEchoInput | diff --git a/libc/sock/internal.h b/libc/sock/internal.h index 97e1173fa..22287ae86 100644 --- a/libc/sock/internal.h +++ b/libc/sock/internal.h @@ -34,61 +34,58 @@ struct SockFd { uint32_t sndtimeo; }; -errno_t __dos2errno(uint32_t) _Hide; +errno_t __dos2errno(uint32_t); -int32_t __sys_accept(int32_t, void *, uint32_t *, int) dontdiscard _Hide; -int32_t __sys_accept4(int32_t, void *, uint32_t *, int) dontdiscard _Hide; -int32_t __sys_bind(int32_t, const void *, uint32_t) _Hide; -int32_t __sys_connect(int32_t, const void *, uint32_t) _Hide; -int32_t __sys_getpeername(int32_t, void *, uint32_t *) _Hide; -int32_t __sys_getsockname(int32_t, void *, uint32_t *) _Hide; -int32_t __sys_socket(int32_t, int32_t, int32_t) _Hide; -int32_t __sys_socketpair(int32_t, int32_t, int32_t, int32_t[2]) _Hide; +int32_t __sys_accept(int32_t, void *, uint32_t *, int) dontdiscard; +int32_t __sys_accept4(int32_t, void *, uint32_t *, int) dontdiscard; +int32_t __sys_bind(int32_t, const void *, uint32_t); +int32_t __sys_connect(int32_t, const void *, uint32_t); +int32_t __sys_getpeername(int32_t, void *, uint32_t *); +int32_t __sys_getsockname(int32_t, void *, uint32_t *); +int32_t __sys_socket(int32_t, int32_t, int32_t); +int32_t __sys_socketpair(int32_t, int32_t, int32_t, int32_t[2]); -int32_t sys_accept4(int32_t, struct sockaddr_storage *, int) dontdiscard _Hide; -int32_t sys_bind(int32_t, const void *, uint32_t) _Hide; -int32_t sys_connect(int32_t, const void *, uint32_t) _Hide; -int32_t sys_getsockopt(int32_t, int32_t, int32_t, void *, uint32_t *) _Hide; -int32_t sys_listen(int32_t, int32_t) _Hide; -int32_t sys_getsockname(int32_t, void *, uint32_t *) _Hide; -int32_t sys_getpeername(int32_t, void *, uint32_t *) _Hide; -int32_t sys_shutdown(int32_t, int32_t) _Hide; -int32_t sys_socket(int32_t, int32_t, int32_t) _Hide; -int32_t sys_socketpair(int32_t, int32_t, int32_t, int32_t[2]) _Hide; -ssize_t sys_recvfrom(int, void *, size_t, int, void *, uint32_t *) _Hide; -ssize_t sys_sendto(int, const void *, size_t, int, const void *, - uint32_t) _Hide; -int32_t sys_select(int32_t, fd_set *, fd_set *, fd_set *, - struct timeval *) _Hide; +int32_t sys_accept4(int32_t, struct sockaddr_storage *, int) dontdiscard; +int32_t sys_bind(int32_t, const void *, uint32_t); +int32_t sys_connect(int32_t, const void *, uint32_t); +int32_t sys_getsockopt(int32_t, int32_t, int32_t, void *, uint32_t *); +int32_t sys_listen(int32_t, int32_t); +int32_t sys_getsockname(int32_t, void *, uint32_t *); +int32_t sys_getpeername(int32_t, void *, uint32_t *); +int32_t sys_shutdown(int32_t, int32_t); +int32_t sys_socket(int32_t, int32_t, int32_t); +int32_t sys_socketpair(int32_t, int32_t, int32_t, int32_t[2]); +ssize_t sys_recvfrom(int, void *, size_t, int, void *, uint32_t *); +ssize_t sys_sendto(int, const void *, size_t, int, const void *, uint32_t); +int32_t sys_select(int32_t, fd_set *, fd_set *, fd_set *, struct timeval *); int sys_pselect(int, fd_set *, fd_set *, fd_set *, struct timespec *, - const void *) _Hide; -int sys_setsockopt(int, int, int, const void *, uint32_t) _Hide; -int32_t sys_epoll_create(int32_t) _Hide; -int32_t sys_epoll_ctl(int32_t, int32_t, int32_t, void *) _Hide; -int32_t sys_epoll_wait(int32_t, void *, int32_t, int32_t) _Hide; + const void *); +int sys_setsockopt(int, int, int, const void *, uint32_t); +int32_t sys_epoll_create(int32_t); +int32_t sys_epoll_ctl(int32_t, int32_t, int32_t, void *); +int32_t sys_epoll_wait(int32_t, void *, int32_t, int32_t); int32_t sys_epoll_pwait(int32_t, void *, int32_t, int32_t, const sigset_t *, size_t); -int sys_socket_nt(int, int, int) _Hide; +int sys_socket_nt(int, int, int); /* -int sys_socketpair_nt_stream(int, int, int, int[2]) _Hide; -int sys_socketpair_nt_dgram(int, int, int, int[2]) _Hide; +int sys_socketpair_nt_stream(int, int, int, int[2]) ; +int sys_socketpair_nt_dgram(int, int, int, int[2]) ; */ -int sys_socketpair_nt(int, int, int, int[2]) _Hide; +int sys_socketpair_nt(int, int, int, int[2]); int sys_select_nt(int, fd_set *, fd_set *, fd_set *, struct timeval *, - const sigset_t *) _Hide; + const sigset_t *); -size_t __iovec2nt(struct NtIovec[hasatleast 16], const struct iovec *, - size_t) _Hide; +size_t __iovec2nt(struct NtIovec[hasatleast 16], const struct iovec *, size_t); -void WinSockInit(void) _Hide; -int64_t __winsockerr(void) nocallback _Hide; -int __fixupnewsockfd(int, int) _Hide; -int64_t __winsockblock(int64_t, unsigned, int64_t, uint32_t) _Hide; -struct SockFd *_dupsockfd(struct SockFd *) _Hide; -int64_t GetNtBaseSocket(int64_t) _Hide; -int sys_close_epoll(int) _Hide; +void WinSockInit(void); +int64_t __winsockerr(void) nocallback; +int __fixupnewsockfd(int, int); +int64_t __winsockblock(int64_t, unsigned, int64_t, uint32_t); +struct SockFd *_dupsockfd(struct SockFd *); +int64_t GetNtBaseSocket(int64_t); +int sys_close_epoll(int); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/sock/kntwsadata.c b/libc/sock/kntwsadata.c index 048d896ec..fce9b568f 100644 --- a/libc/sock/kntwsadata.c +++ b/libc/sock/kntwsadata.c @@ -34,7 +34,7 @@ * Berkeley Socket wrappers are linked. The latest version of Winsock * was introduced alongside x64, so this should never fail. */ -_Hide struct NtWsaData kNtWsaData; +struct NtWsaData kNtWsaData; static textwindows void WinSockCleanup(void) { int i, rc; diff --git a/libc/sock/sendfile.internal.h b/libc/sock/sendfile.internal.h index d989521c8..56f5b8cb4 100644 --- a/libc/sock/sendfile.internal.h +++ b/libc/sock/sendfile.internal.h @@ -5,11 +5,11 @@ COSMOPOLITAN_C_START_ int sys_sendfile_xnu(int32_t infd, int32_t outfd, int64_t offset, int64_t *out_opt_sbytes, const void *opt_hdtr, - int32_t flags) _Hide; + int32_t flags); int sys_sendfile_freebsd(int32_t infd, int32_t outfd, int64_t offset, size_t nbytes, const void *opt_hdtr, - int64_t *out_opt_sbytes, int32_t flags) _Hide; + int64_t *out_opt_sbytes, int32_t flags); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/sock/struct/msghdr.internal.h b/libc/sock/struct/msghdr.internal.h index d9d0dcca4..d369bbe3e 100644 --- a/libc/sock/struct/msghdr.internal.h +++ b/libc/sock/struct/msghdr.internal.h @@ -14,8 +14,8 @@ struct msghdr_bsd { uint32_t msg_flags; /* « different type */ }; -ssize_t sys_sendmsg(int, const struct msghdr *, int) _Hide; -ssize_t sys_recvmsg(int, struct msghdr *, int) _Hide; +ssize_t sys_sendmsg(int, const struct msghdr *, int); +ssize_t sys_recvmsg(int, struct msghdr *, int); bool __asan_is_valid_msghdr(const struct msghdr *); COSMOPOLITAN_C_END_ diff --git a/libc/sock/struct/pollfd.internal.h b/libc/sock/struct/pollfd.internal.h index c6ff54bf7..673a3a7a4 100644 --- a/libc/sock/struct/pollfd.internal.h +++ b/libc/sock/struct/pollfd.internal.h @@ -7,12 +7,12 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -int32_t sys_poll(struct pollfd *, uint64_t, signed) _Hide; -int32_t __sys_poll(struct pollfd *, uint64_t, signed) _Hide; +int32_t sys_poll(struct pollfd *, uint64_t, signed); +int32_t __sys_poll(struct pollfd *, uint64_t, signed); int sys_ppoll(struct pollfd *, size_t, const struct timespec *, const sigset_t *, size_t); int sys_poll_metal(struct pollfd *, size_t, unsigned); -int sys_poll_nt(struct pollfd *, uint64_t, uint64_t *, const sigset_t *) _Hide; +int sys_poll_nt(struct pollfd *, uint64_t, uint64_t *, const sigset_t *); const char *DescribePollFds(char[300], ssize_t, struct pollfd *, size_t); #define DescribePollFds(x, y, z) DescribePollFds(alloca(300), x, y, z) diff --git a/libc/sock/syscall_fd.internal.h b/libc/sock/syscall_fd.internal.h index aa3b87dda..f3907bbcb 100644 --- a/libc/sock/syscall_fd.internal.h +++ b/libc/sock/syscall_fd.internal.h @@ -7,21 +7,20 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -int sys_accept_nt(struct Fd *, struct sockaddr_storage *, int) _Hide; +int sys_accept_nt(struct Fd *, struct sockaddr_storage *, int); int sys_bind_nt(struct Fd *, const void *, uint32_t); -int sys_closesocket_nt(struct Fd *) _Hide; -int sys_connect_nt(struct Fd *, const void *, uint32_t) _Hide; -int sys_getpeername_nt(struct Fd *, void *, uint32_t *) _Hide; -int sys_getsockname_nt(struct Fd *, void *, uint32_t *) _Hide; -int sys_getsockopt_nt(struct Fd *, int, int, void *, uint32_t *) _Hide; -int sys_listen_nt(struct Fd *, int) _Hide; -int sys_setsockopt_nt(struct Fd *, int, int, const void *, uint32_t) _Hide; -int sys_shutdown_nt(struct Fd *, int) _Hide; -ssize_t sys_recv_nt(struct Fd *, const struct iovec *, size_t, uint32_t) _Hide; +int sys_closesocket_nt(struct Fd *); +int sys_connect_nt(struct Fd *, const void *, uint32_t); +int sys_getpeername_nt(struct Fd *, void *, uint32_t *); +int sys_getsockname_nt(struct Fd *, void *, uint32_t *); +int sys_getsockopt_nt(struct Fd *, int, int, void *, uint32_t *); +int sys_listen_nt(struct Fd *, int); +int sys_setsockopt_nt(struct Fd *, int, int, const void *, uint32_t); +int sys_shutdown_nt(struct Fd *, int); +ssize_t sys_recv_nt(struct Fd *, const struct iovec *, size_t, uint32_t); ssize_t sys_recvfrom_nt(struct Fd *, const struct iovec *, size_t, uint32_t, - void *, uint32_t *) _Hide; -int __wsablock(struct Fd *, struct NtOverlapped *, uint32_t *, bool, - uint32_t) _Hide; + void *, uint32_t *); +int __wsablock(struct Fd *, struct NtOverlapped *, uint32_t *, bool, uint32_t); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/sock/xinet_ntop.c b/libc/sock/xinet_ntop.c deleted file mode 100644 index 9e7618d89..000000000 --- a/libc/sock/xinet_ntop.c +++ /dev/null @@ -1,41 +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/weaken.h" -#include "libc/log/log.h" -#include "libc/mem/mem.h" -#include "libc/runtime/runtime.h" -#include "libc/sock/sock.h" - -/** - * Formats internet address to string, or dies. - * - * @param af can be AF_INET, e.g. addr->sin_family - * @param src is the binary-encoded address, e.g. &addr->sin_addr - * @return allocated IP address string, which must be free()'d - */ -char *sys_xinet_ntop(int af, const void *src) { - char *res, ip[16]; - if (inet_ntop(af, src, ip, sizeof(ip)) && (res = strdup(ip))) { - return res; - } else { - if (_weaken(__die)) _weaken(__die)(); - abort(); - __builtin_unreachable(); - } -} diff --git a/libc/stdio/dirstream.c b/libc/stdio/dirstream.c index ad6618e63..397ef1692 100644 --- a/libc/stdio/dirstream.c +++ b/libc/stdio/dirstream.c @@ -583,3 +583,5 @@ void seekdir(DIR *dir, long off) { dir->tell = i; _unlockdir(dir); } + +__weak_reference(readdir, readdir64); diff --git a/libc/stdio/fflush.internal.h b/libc/stdio/fflush.internal.h index 5475744bb..fff364eff 100644 --- a/libc/stdio/fflush.internal.h +++ b/libc/stdio/fflush.internal.h @@ -17,8 +17,8 @@ struct StdioFlush { FILE *handles_initmem[8]; }; -_Hide extern struct StdioFlush __fflush; -_Hide extern pthread_mutex_t __fflush_lock_obj; +extern struct StdioFlush __fflush; +extern pthread_mutex_t __fflush_lock_obj; void __fflush_lock(void); void __fflush_unlock(void); diff --git a/libc/stdio/fmt.c b/libc/stdio/fmt.c index f55619772..d6a2e392d 100644 --- a/libc/stdio/fmt.c +++ b/libc/stdio/fmt.c @@ -777,7 +777,7 @@ haveinc: * @asyncsignalsafe if floating point isn't used * @vforksafe if floating point isn't used */ -_Hide int __fmt(void *fn, void *arg, const char *format, va_list va) { +int __fmt(void *fn, void *arg, const char *format, va_list va) { long ld; void *p; double x; diff --git a/libc/stdio/fread_unlocked.c b/libc/stdio/fread_unlocked.c index b016fe849..25175dea2 100644 --- a/libc/stdio/fread_unlocked.c +++ b/libc/stdio/fread_unlocked.c @@ -19,17 +19,12 @@ #include "libc/calls/calls.h" #include "libc/calls/struct/iovec.h" #include "libc/errno.h" -#include "libc/fmt/conv.h" #include "libc/macros.internal.h" -#include "libc/runtime/runtime.h" -#include "libc/sock/sock.h" #include "libc/stdckdint.h" #include "libc/stdio/internal.h" #include "libc/stdio/stdio.h" -#include "libc/str/internal.h" #include "libc/str/str.h" #include "libc/sysv/consts/o.h" -#include "libc/sysv/errfuns.h" /** * Reads data from stream. diff --git a/libc/stdio/fwrite_unlocked.c b/libc/stdio/fwrite_unlocked.c index 77b154aca..f722ac873 100644 --- a/libc/stdio/fwrite_unlocked.c +++ b/libc/stdio/fwrite_unlocked.c @@ -16,18 +16,12 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/assert.h" #include "libc/calls/calls.h" -#include "libc/calls/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" -#include "libc/runtime/runtime.h" -#include "libc/sock/sock.h" #include "libc/stdckdint.h" -#include "libc/stdio/internal.h" #include "libc/stdio/stdio.h" #include "libc/str/str.h" #include "libc/sysv/consts/o.h" @@ -45,7 +39,7 @@ size_t fwrite_unlocked(const void *data, size_t stride, size_t count, FILE *f) { size_t n, m; const char *p; struct iovec iov[2]; - if (!stride) { + if (!stride || !count) { return 0; } if ((f->iomode & O_ACCMODE) == O_RDONLY) { @@ -109,7 +103,7 @@ size_t fwrite_unlocked(const void *data, size_t stride, size_t count, FILE *f) { iov[1].iov_base = data; iov[1].iov_len = n; n += f->beg; - if (WritevUninterruptible(f->fd, iov, 2) == -1) { + if (__robust_writev(f->fd, iov, 2) == -1) { f->state = errno; return 0; } diff --git a/libc/stdio/internal.h b/libc/stdio/internal.h index 74b1db5e3..91adc2e21 100644 --- a/libc/stdio/internal.h +++ b/libc/stdio/internal.h @@ -7,14 +7,14 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -_Hide extern uint64_t g_rando; +extern uint64_t g_rando; -int __fflush_impl(FILE *) _Hide; -int __fflush_register(FILE *) _Hide; -void __fflush_unregister(FILE *) _Hide; -bool __stdio_isok(FILE *) _Hide; -FILE *__stdio_alloc(void) _Hide; -void __stdio_free(FILE *) _Hide; +int __fflush_impl(FILE *); +int __fflush_register(FILE *); +void __fflush_unregister(FILE *); +bool __stdio_isok(FILE *); +FILE *__stdio_alloc(void); +void __stdio_free(FILE *); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/stdio/posix_spawn.c b/libc/stdio/posix_spawn.c index 3805e983d..62d6c2c83 100644 --- a/libc/stdio/posix_spawn.c +++ b/libc/stdio/posix_spawn.c @@ -69,13 +69,14 @@ static int RunFileActions(struct _posix_faction *a) { * @param envp is environment variables, or `environ` if null * @return 0 on success or error number on failure * @see posix_spawnp() for `$PATH` searching + * @returnserrno * @tlsrequired * @threadsafe */ -int posix_spawn(int *pid, const char *path, - const posix_spawn_file_actions_t *file_actions, - const posix_spawnattr_t *attrp, char *const argv[], - char *const envp[]) { +errno_t posix_spawn(int *pid, const char *path, + const posix_spawn_file_actions_t *file_actions, + const posix_spawnattr_t *attrp, char *const argv[], + char *const envp[]) { short flags = 0; sigset_t sigmask; int s, child, policy; diff --git a/libc/stdio/readdir64.S b/libc/stdio/readdir64.S deleted file mode 100644 index ea6608a79..000000000 --- a/libc/stdio/readdir64.S +++ /dev/null @@ -1,31 +0,0 @@ -/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│ -│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│ -╞══════════════════════════════════════════════════════════════════════════════╡ -│ This is free and unencumbered software released into the public domain. │ -│ │ -│ Anyone is free to copy, modify, publish, use, compile, sell, or │ -│ distribute this software, either in source code form or as a compiled │ -│ binary, for any purpose, commercial or non-commercial, and by any │ -│ means. │ -│ │ -│ In jurisdictions that recognize copyright laws, the author or authors │ -│ of this software dedicate any and all copyright interest in the │ -│ software to the public domain. We make this dedication for the benefit │ -│ of the public at large and to the detriment of our heirs and │ -│ successors. We intend this dedication to be an overt act of │ -│ relinquishment in perpetuity of all present and future rights to this │ -│ software under copyright law. │ -│ │ -│ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │ -│ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │ -│ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │ -│ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR │ -│ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, │ -│ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR │ -│ OTHER DEALINGS IN THE SOFTWARE. │ -╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/macros.internal.h" - -readdir64: - jmp readdir - .endfn readdir64,globl diff --git a/libc/stdio/stdbuf.c b/libc/stdio/stdbuf.c index 4bd48c5ad..17ab7ff18 100644 --- a/libc/stdio/stdbuf.c +++ b/libc/stdio/stdbuf.c @@ -18,5 +18,5 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/stdio/internal.h" -char g_stdoutbuf[BUFSIZ] _Hide; -char g_stderrbuf[BUFSIZ] _Hide; +char g_stdoutbuf[BUFSIZ]; +char g_stderrbuf[BUFSIZ]; diff --git a/libc/stdio/strlist.internal.h b/libc/stdio/strlist.internal.h index 6ed7db1f8..cfb270353 100644 --- a/libc/stdio/strlist.internal.h +++ b/libc/stdio/strlist.internal.h @@ -8,10 +8,10 @@ struct StrList { char **p; }; -void FreeStrList(struct StrList *) _Hide; -int AppendStrList(struct StrList *) _Hide; -void SortStrList(struct StrList *) _Hide; -int JoinStrList(struct StrList *, char **, uint64_t) _Hide; +void FreeStrList(struct StrList *); +int AppendStrList(struct StrList *); +void SortStrList(struct StrList *); +int JoinStrList(struct StrList *, char **, uint64_t); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/stdio/temp.h b/libc/stdio/temp.h index efc7b4649..b0448f9e4 100644 --- a/libc/stdio/temp.h +++ b/libc/stdio/temp.h @@ -15,7 +15,7 @@ int mkstemp(char *); int mkstemps(char *, int); int mkostempsmi(char *, int, unsigned, uint64_t *, int, - int (*)(const char *, int, ...)) _Hide dontdiscard; + int (*)(const char *, int, ...)) dontdiscard; COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/stdio/vdprintf.c b/libc/stdio/vdprintf.c index 6becb772c..d64486215 100644 --- a/libc/stdio/vdprintf.c +++ b/libc/stdio/vdprintf.c @@ -16,7 +16,6 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/calls/struct/iovec.h" #include "libc/calls/struct/iovec.internal.h" #include "libc/dce.h" #include "libc/fmt/fmt.h" @@ -43,7 +42,7 @@ static int vdprintf_putc(const char *s, struct VdprintfState *t, size_t n) { iov[0].iov_len = t->n; iov[1].iov_base = s; iov[1].iov_len = n; - if (WritevUninterruptible(t->fd, iov, 2) == -1) { + if (__robust_writev(t->fd, iov, 2) == -1) { return -1; } t->t += t->n; @@ -68,7 +67,7 @@ int vdprintf(int fd, const char *fmt, va_list va) { if (t.n) { iov[0].iov_base = t.b; iov[0].iov_len = t.n; - if (WritevUninterruptible(t.fd, iov, 1) == -1) { + if (__robust_writev(t.fd, iov, 1) == -1) { return -1; } t.t += t.n; diff --git a/libc/str/internal.h b/libc/str/internal.h deleted file mode 100644 index eff39b23f..000000000 --- a/libc/str/internal.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef COSMOPOLITAN_LIBC_STR_INTERNAL_H_ -#define COSMOPOLITAN_LIBC_STR_INTERNAL_H_ -#ifndef __STRICT_ANSI__ -#include "libc/str/str.h" - -#if !(__ASSEMBLER__ + __LINKER__ + 0) - -_Hide extern const uint32_t kSha256Tab[64]; - -nodebuginfo forceinline bool32 ismoar(wint_t c) { - return (c & 0300) == 0300; -} - -nodebuginfo forceinline bool32 iscont(wint_t c) { - return (c & 0300) == 0200; -} - -char *strstr_sse42(const char *, const char *) strlenesque _Hide; -char16_t *strstr16_sse42(const char16_t *, const char16_t *) strlenesque _Hide; -void *memmem_sse42(const void *, size_t, const void *, size_t) -strlenesque _Hide; -void sha256_x86(uint32_t[hasatleast 8], const uint8_t[hasatleast 64], - uint32_t) _Hide; - -#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ -#endif /* !ANSI */ -#endif /* COSMOPOLITAN_LIBC_STR_INTERNAL_H_ */ diff --git a/libc/str/kmonthyearday.c b/libc/str/kmonthyearday.c index b5662b58c..c76338cf3 100644 --- a/libc/str/kmonthyearday.c +++ b/libc/str/kmonthyearday.c @@ -18,7 +18,7 @@ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/time/time.h" -_Hide const unsigned short kMonthYearDay[2][12] = { +const unsigned short kMonthYearDay[2][12] = { {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}, {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335}, }; diff --git a/libc/str/kx86processormodels.c b/libc/str/kx86processormodels.c index ecda01192..9cd1c3926 100644 --- a/libc/str/kx86processormodels.c +++ b/libc/str/kx86processormodels.c @@ -20,7 +20,7 @@ #include "libc/macros.internal.h" #include "libc/nexgen32e/x86info.h" -_Hide const struct X86ProcessorModel kX86ProcessorModels[] = { +const struct X86ProcessorModel kX86ProcessorModels[] = { /* */ {0x060F, X86_MARCH_CORE2, X86_GRADE_CLIENT}, {0x0616, X86_MARCH_CORE2, X86_GRADE_MOBILE}, @@ -79,4 +79,4 @@ _Hide const struct X86ProcessorModel kX86ProcessorModels[] = { /* */ }; -_Hide const size_t kX86ProcessorModelCount = ARRAYLEN(kX86ProcessorModels); +const size_t kX86ProcessorModelCount = ARRAYLEN(kX86ProcessorModels); diff --git a/libc/thread/posixthread.internal.h b/libc/thread/posixthread.internal.h index 29ae16a8f..fa618b15f 100644 --- a/libc/thread/posixthread.internal.h +++ b/libc/thread/posixthread.internal.h @@ -87,18 +87,18 @@ typedef void (*atfork_f)(void); extern struct Dll *_pthread_list; extern pthread_spinlock_t _pthread_lock; -extern _Atomic(pthread_key_dtor) _pthread_key_dtor[PTHREAD_KEYS_MAX] _Hide; +extern _Atomic(pthread_key_dtor) _pthread_key_dtor[PTHREAD_KEYS_MAX]; -int _pthread_atfork(atfork_f, atfork_f, atfork_f) _Hide; -int _pthread_reschedule(struct PosixThread *) _Hide; -int _pthread_setschedparam_freebsd(int, int, const struct sched_param *) _Hide; -void _pthread_zombify(struct PosixThread *) _Hide; -void _pthread_free(struct PosixThread *) _Hide; -void _pthread_onfork_prepare(void) _Hide; -void _pthread_onfork_parent(void) _Hide; -void _pthread_onfork_child(void) _Hide; -void _pthread_ungarbage(void) _Hide; -int _pthread_cancel_sys(void) _Hide; +int _pthread_atfork(atfork_f, atfork_f, atfork_f); +int _pthread_reschedule(struct PosixThread *); +int _pthread_setschedparam_freebsd(int, int, const struct sched_param *); +void _pthread_zombify(struct PosixThread *); +void _pthread_free(struct PosixThread *); +void _pthread_onfork_prepare(void); +void _pthread_onfork_parent(void); +void _pthread_onfork_child(void); +void _pthread_ungarbage(void); +int _pthread_cancel_sys(void); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/thread/spawn.h b/libc/thread/spawn.h index e47ae1e06..f6c1b16d6 100644 --- a/libc/thread/spawn.h +++ b/libc/thread/spawn.h @@ -11,9 +11,9 @@ struct spawn { struct CosmoTib *tib; }; -int _spawn(int (*)(void *, int), void *, struct spawn *) _Hide; -int _join(struct spawn *) _Hide; -char *_mktls(struct CosmoTib **) _Hide; +int _spawn(int (*)(void *, int), void *, struct spawn *); +int _join(struct spawn *); +char *_mktls(struct CosmoTib **); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/thread/wait0.internal.h b/libc/thread/wait0.internal.h index 89e986f69..5b716dec9 100644 --- a/libc/thread/wait0.internal.h +++ b/libc/thread/wait0.internal.h @@ -5,7 +5,7 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -errno_t _wait0(const atomic_int *, struct timespec *) _Hide; +errno_t _wait0(const atomic_int *, struct timespec *); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/time/struct/utimbuf.internal.h b/libc/time/struct/utimbuf.internal.h index fcb285c37..3a18d3893 100644 --- a/libc/time/struct/utimbuf.internal.h +++ b/libc/time/struct/utimbuf.internal.h @@ -4,7 +4,7 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -int sys_utime(const char *, const struct utimbuf *) _Hide; +int sys_utime(const char *, const struct utimbuf *); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/time/time.h b/libc/time/time.h index 72c7d7256..2c7a59ec7 100644 --- a/libc/time/time.h +++ b/libc/time/time.h @@ -18,11 +18,11 @@ int64_t time2posix(int64_t) pureconst; void tzset(void); #ifdef COSMO -_Hide extern const char kWeekdayNameShort[7][4]; -_Hide extern const char kWeekdayName[7][10]; -_Hide extern const char kMonthNameShort[12][4]; -_Hide extern const char kMonthName[12][10]; -_Hide extern const unsigned short kMonthYearDay[2][12]; +extern const char kWeekdayNameShort[7][4]; +extern const char kWeekdayName[7][10]; +extern const char kMonthNameShort[12][4]; +extern const char kMonthName[12][10]; +extern const unsigned short kMonthYearDay[2][12]; extern long double (*nowl)(void); long double ConvertTicksToNanos(double); long double dsleep(long double); diff --git a/libc/tinymath/atan_data.internal.h b/libc/tinymath/atan_data.internal.h index 5c4f5d35c..90aa24bf7 100644 --- a/libc/tinymath/atan_data.internal.h +++ b/libc/tinymath/atan_data.internal.h @@ -6,7 +6,7 @@ COSMOPOLITAN_C_START_ #define ATAN_POLY_NCOEFFS 20 extern const struct atan_poly_data { double poly[ATAN_POLY_NCOEFFS]; -} __atan_poly_data _Hide; +} __atan_poly_data; COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/tinymath/atanf_data.internal.h b/libc/tinymath/atanf_data.internal.h index 747643b1a..5389b1b42 100644 --- a/libc/tinymath/atanf_data.internal.h +++ b/libc/tinymath/atanf_data.internal.h @@ -6,7 +6,7 @@ COSMOPOLITAN_C_START_ #define ATANF_POLY_NCOEFFS 8 extern const struct atanf_poly_data { float poly[ATANF_POLY_NCOEFFS]; -} __atanf_poly_data _Hide; +} __atanf_poly_data; COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/tinymath/complex.internal.h b/libc/tinymath/complex.internal.h index 9b4f85185..4ee6f0d3e 100644 --- a/libc/tinymath/complex.internal.h +++ b/libc/tinymath/complex.internal.h @@ -40,8 +40,8 @@ COSMOPOLITAN_C_START_ (d) = asfloat(w); \ } while (0) -_Complex double __ldexp_cexp(_Complex double, int) _Hide; -_Complex float __ldexp_cexpf(_Complex float, int) _Hide; +_Complex double __ldexp_cexp(_Complex double, int); +_Complex float __ldexp_cexpf(_Complex float, int); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/tinymath/exp2f_data.internal.h b/libc/tinymath/exp2f_data.internal.h index 728adf885..90ac8b061 100644 --- a/libc/tinymath/exp2f_data.internal.h +++ b/libc/tinymath/exp2f_data.internal.h @@ -7,7 +7,7 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -extern _Hide const struct exp2f_data { +extern const struct exp2f_data { uint64_t tab[1 << EXP2F_TABLE_BITS]; double shift_scaled; double poly[EXP2F_POLY_ORDER]; diff --git a/libc/tinymath/exp_data.internal.h b/libc/tinymath/exp_data.internal.h index a974bae25..308a7e27d 100644 --- a/libc/tinymath/exp_data.internal.h +++ b/libc/tinymath/exp_data.internal.h @@ -9,7 +9,7 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -extern _Hide const struct exp_data { +extern const struct exp_data { double invln2N; double shift; double negln2hiN; diff --git a/libc/tinymath/freebsd.internal.h b/libc/tinymath/freebsd.internal.h index be8b158f1..d41f8c973 100644 --- a/libc/tinymath/freebsd.internal.h +++ b/libc/tinymath/freebsd.internal.h @@ -972,7 +972,7 @@ struct ExplData { extern const struct ExplData kExplData[INTERVALS]; -void __k_expl(long double , long double *, long double *, int *) _Hide; +void __k_expl(long double , long double *, long double *, int *) ; /* * XXX: the rest of the functions are identical for ld80 and ld128. diff --git a/libc/tinymath/internal.h b/libc/tinymath/internal.h index 47a4b3bf8..d01764d0f 100644 --- a/libc/tinymath/internal.h +++ b/libc/tinymath/internal.h @@ -54,21 +54,21 @@ static inline float fp_barrierf(float x) { return y; } -extern const uint16_t __rsqrt_tab[128] _Hide; +extern const uint16_t __rsqrt_tab[128]; -double __math_divzero(uint32_t) _Hide; -double __math_invalid(double) _Hide; -double __math_oflow(uint32_t) _Hide; -double __math_uflow(uint32_t) _Hide; -double __math_xflow(uint32_t, double) _Hide; -float __math_divzerof(uint32_t) _Hide; -float __math_invalidf(float) _Hide; -float __math_oflowf(uint32_t) _Hide; -float __math_uflowf(uint32_t) _Hide; -float __math_xflowf(uint32_t, float) _Hide; -long double __polevll(long double, const long double *, int) _Hide; -long double __p1evll(long double, const long double *, int) _Hide; -long double __math_invalidl(long double) _Hide; +double __math_divzero(uint32_t); +double __math_invalid(double); +double __math_oflow(uint32_t); +double __math_uflow(uint32_t); +double __math_xflow(uint32_t, double); +float __math_divzerof(uint32_t); +float __math_invalidf(float); +float __math_oflowf(uint32_t); +float __math_uflowf(uint32_t); +float __math_xflowf(uint32_t, float); +long double __polevll(long double, const long double *, int); +long double __p1evll(long double, const long double *, int); +long double __math_invalidl(long double); #define FORCE_EVAL(x) \ do { \ diff --git a/libc/tinymath/invtrigl.internal.h b/libc/tinymath/invtrigl.internal.h index 235f24271..95bb76b5f 100644 --- a/libc/tinymath/invtrigl.internal.h +++ b/libc/tinymath/invtrigl.internal.h @@ -7,9 +7,9 @@ COSMOPOLITAN_C_START_ #define pio2_hi __pio2_hi #define pio2_lo __pio2_lo -_Hide extern const long double pio2_hi, pio2_lo; +extern const long double pio2_hi, pio2_lo; -_Hide long double __invtrigl_R(long double z); +long double __invtrigl_R(long double z); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/tinymath/kernel.internal.h b/libc/tinymath/kernel.internal.h index 7488b88c2..21575c99d 100644 --- a/libc/tinymath/kernel.internal.h +++ b/libc/tinymath/kernel.internal.h @@ -3,19 +3,19 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -double __cos(double, double) _Hide; -double __sin(double, double, int) _Hide; -double __tan(double, double, int) _Hide; -float __cosdf(double) _Hide; -float __sindf(double) _Hide; -float __tandf(double, int) _Hide; -long double __cosl(long double, long double) _Hide; -long double __sinl(long double, long double, int) _Hide; -long double __tanl(long double, long double, int) _Hide; -int __rem_pio2(double, double *) _Hide; -int __rem_pio2l(long double, long double *) _Hide; -int __rem_pio2_large(double *, double *, int, int, int) _Hide; -int __rem_pio2f(float, double *) _Hide; +double __cos(double, double); +double __sin(double, double, int); +double __tan(double, double, int); +float __cosdf(double); +float __sindf(double); +float __tandf(double, int); +long double __cosl(long double, long double); +long double __sinl(long double, long double, int); +long double __tanl(long double, long double, int); +int __rem_pio2(double, double *); +int __rem_pio2l(long double, long double *); +int __rem_pio2_large(double *, double *, int, int, int); +int __rem_pio2f(float, double *); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/tinymath/log1pf_data.internal.h b/libc/tinymath/log1pf_data.internal.h index 25d952c29..39ce659b0 100644 --- a/libc/tinymath/log1pf_data.internal.h +++ b/libc/tinymath/log1pf_data.internal.h @@ -7,8 +7,8 @@ COSMOPOLITAN_C_START_ #define V_LOG1PF_2U5 #define LOG1PF_NCOEFFS 9 extern const struct log1pf_data { - float coeffs[LOG1PF_NCOEFFS]; -} __log1pf_data _Hide; + float coeffs[LOG1PF_NCOEFFS]; // +} __log1pf_data; COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/libc/tinymath/log2_data.internal.h b/libc/tinymath/log2_data.internal.h index bef0d8555..b4a70c4d5 100644 --- a/libc/tinymath/log2_data.internal.h +++ b/libc/tinymath/log2_data.internal.h @@ -8,7 +8,7 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -extern _Hide const struct log2_data { +extern const struct log2_data { double invln2hi; double invln2lo; double poly[LOG2_POLY_ORDER - 1]; diff --git a/libc/tinymath/log2f_data.internal.h b/libc/tinymath/log2f_data.internal.h index 85eb6ebab..82aff7c9c 100644 --- a/libc/tinymath/log2f_data.internal.h +++ b/libc/tinymath/log2f_data.internal.h @@ -7,7 +7,7 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -extern _Hide const struct log2f_data { +extern const struct log2f_data { struct { double invc, logc; } tab[1 << LOG2F_TABLE_BITS]; diff --git a/libc/tinymath/log_data.internal.h b/libc/tinymath/log_data.internal.h index 64998e59a..8b7585e64 100644 --- a/libc/tinymath/log_data.internal.h +++ b/libc/tinymath/log_data.internal.h @@ -8,7 +8,7 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -extern _Hide const struct log_data { +extern const struct log_data { double ln2hi; double ln2lo; double poly[LOG_POLY_ORDER - 1]; /* First coefficient is 1. */ diff --git a/libc/tinymath/logf_data.internal.h b/libc/tinymath/logf_data.internal.h index 14cdbac5f..bbfc55170 100644 --- a/libc/tinymath/logf_data.internal.h +++ b/libc/tinymath/logf_data.internal.h @@ -7,7 +7,7 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -extern _Hide const struct logf_data { +extern const struct logf_data { struct { double invc, logc; } tab[1 << LOGF_TABLE_BITS]; diff --git a/libc/tinymath/pow_data.internal.h b/libc/tinymath/pow_data.internal.h index 006a5eeb1..9f0df8012 100644 --- a/libc/tinymath/pow_data.internal.h +++ b/libc/tinymath/pow_data.internal.h @@ -7,7 +7,7 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -extern _Hide const struct pow_log_data { +extern const struct pow_log_data { double ln2hi; double ln2lo; double poly[POW_LOG_POLY_ORDER - 1]; /* First coefficient is 1. */ diff --git a/libc/tinymath/powf_data.internal.h b/libc/tinymath/powf_data.internal.h index 18e85d74c..6f072505e 100644 --- a/libc/tinymath/powf_data.internal.h +++ b/libc/tinymath/powf_data.internal.h @@ -13,7 +13,7 @@ #if !(__ASSEMBLER__ + __LINKER__ + 0) COSMOPOLITAN_C_START_ -extern _Hide const struct powf_log2_data { +extern const struct powf_log2_data { struct { double invc, logc; } tab[1 << POWF_LOG2_TABLE_BITS]; diff --git a/libc/tinymath/sincosf.internal.h b/libc/tinymath/sincosf.internal.h index d7d14a83a..49140d98d 100644 --- a/libc/tinymath/sincosf.internal.h +++ b/libc/tinymath/sincosf.internal.h @@ -28,10 +28,10 @@ typedef struct } sincos_t; /* Polynomial data (the cosine polynomial is negated in the 2nd entry). */ -extern const sincos_t __sincosf_table[2] _Hide; +extern const sincos_t __sincosf_table[2] ; /* Table with 4/PI to 192 bit precision. */ -extern const uint32_t __inv_pio4[] _Hide; +extern const uint32_t __inv_pio4[] ; /* Top 12 bits of the float representation with the sign bit cleared. */ static inline uint32_t diff --git a/libc/zipos/zipos.internal.h b/libc/zipos/zipos.internal.h index 661d098ec..1a095c46e 100644 --- a/libc/zipos/zipos.internal.h +++ b/libc/zipos/zipos.internal.h @@ -31,27 +31,27 @@ struct Zipos { struct ZiposHandle *freelist; }; -void __zipos_lock(void) _Hide; -void __zipos_unlock(void) _Hide; -int __zipos_close(int) _Hide; -struct Zipos *__zipos_get(void) pureconst _Hide; -void __zipos_free(struct Zipos *, struct ZiposHandle *) _Hide; -ssize_t __zipos_parseuri(const char *, struct ZiposUri *) _Hide; +void __zipos_lock(void); +void __zipos_unlock(void); +int __zipos_close(int); +struct Zipos *__zipos_get(void) pureconst; +void __zipos_free(struct Zipos *, struct ZiposHandle *); +ssize_t __zipos_parseuri(const char *, struct ZiposUri *); ssize_t __zipos_find(struct Zipos *, const struct ZiposUri *); -int __zipos_open(const struct ZiposUri *, unsigned, int) _Hide; -int __zipos_access(const struct ZiposUri *, int) _Hide; -int __zipos_stat(const struct ZiposUri *, struct stat *) _Hide; -int __zipos_fstat(const struct ZiposHandle *, struct stat *) _Hide; -int __zipos_stat_impl(struct Zipos *, size_t, struct stat *) _Hide; +int __zipos_open(const struct ZiposUri *, unsigned, int); +int __zipos_access(const struct ZiposUri *, int); +int __zipos_stat(const struct ZiposUri *, struct stat *); +int __zipos_fstat(const struct ZiposHandle *, struct stat *); +int __zipos_stat_impl(struct Zipos *, size_t, struct stat *); ssize_t __zipos_read(struct ZiposHandle *, const struct iovec *, size_t, - ssize_t) _Hide; + ssize_t); ssize_t __zipos_write(struct ZiposHandle *, const struct iovec *, size_t, - ssize_t) _Hide; -int64_t __zipos_lseek(struct ZiposHandle *, int64_t, unsigned) _Hide; -int __zipos_fcntl(int, int, uintptr_t) _Hide; -int __zipos_notat(int, const char *) _Hide; + ssize_t); +int64_t __zipos_lseek(struct ZiposHandle *, int64_t, unsigned); +int __zipos_fcntl(int, int, uintptr_t); +int __zipos_notat(int, const char *); noasan void *__zipos_Mmap(void *, uint64_t, int32_t, int32_t, - struct ZiposHandle *, int64_t) _Hide; + struct ZiposHandle *, int64_t); #ifdef _NOPL0 #define __zipos_lock() _NOPL0("__threadcalls", __zipos_lock) diff --git a/test/dsp/tty/windex_test.c b/test/dsp/tty/windex_test.c index b057ba12e..210dd6cce 100644 --- a/test/dsp/tty/windex_test.c +++ b/test/dsp/tty/windex_test.c @@ -28,9 +28,9 @@ #include "libc/testlib/ezbench.h" #include "libc/testlib/testlib.h" -unsigned windex_k8(short *, size_t) _Hide; -unsigned windex_avx2(short *, size_t) _Hide; -unsigned windex_sse4(short *, size_t) _Hide; +unsigned windex_k8(short *, size_t); +unsigned windex_avx2(short *, size_t); +unsigned windex_sse4(short *, size_t); const short kW[64] forcealign(32) = { 8281, 3883, 1365, 1786, 9006, 3681, 5563, 8013, 5787, 9063, 2923, diff --git a/test/libc/str/memmem_test.c b/test/libc/str/memmem_test.c index 409988c8a..f8b7ba222 100644 --- a/test/libc/str/memmem_test.c +++ b/test/libc/str/memmem_test.c @@ -16,12 +16,11 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/mem/alg.h" +#include "libc/mem/mem.h" #include "libc/intrin/bits.h" #include "libc/intrin/likely.h" -#include "libc/mem/mem.h" +#include "libc/mem/alg.h" #include "libc/stdio/rand.h" -#include "libc/str/internal.h" #include "libc/str/str.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" diff --git a/test/libc/str/strcasestr_test.c b/test/libc/str/strcasestr_test.c index ac8d93cd8..518e5bb67 100644 --- a/test/libc/str/strcasestr_test.c +++ b/test/libc/str/strcasestr_test.c @@ -16,13 +16,13 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ +#include "libc/str/str.h" #include "libc/dce.h" #include "libc/intrin/bits.h" #include "libc/mem/alg.h" #include "libc/mem/gc.internal.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/x86feature.h" -#include "libc/str/internal.h" #include "libc/str/tab.internal.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" diff --git a/test/libc/str/strstr_test.c b/test/libc/str/strstr_test.c index 42c97dcff..99fb6b589 100644 --- a/test/libc/str/strstr_test.c +++ b/test/libc/str/strstr_test.c @@ -16,13 +16,13 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ -#include "libc/mem/alg.h" -#include "libc/intrin/bits.h" +#include "libc/str/str.h" #include "libc/dce.h" +#include "libc/intrin/bits.h" +#include "libc/mem/alg.h" +#include "libc/mem/gc.internal.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/x86feature.h" -#include "libc/mem/gc.internal.h" -#include "libc/str/internal.h" #include "libc/testlib/ezbench.h" #include "libc/testlib/hyperion.h" #include "libc/testlib/testlib.h" diff --git a/third_party/dlmalloc/dlmalloc.h b/third_party/dlmalloc/dlmalloc.h index 03162b1af..0083d5480 100644 --- a/third_party/dlmalloc/dlmalloc.h +++ b/third_party/dlmalloc/dlmalloc.h @@ -505,8 +505,8 @@ void mspace_inspect_all(mspace msp, void (*handler)(void*, void*, size_t, void*), void* arg); -_Hide void dlmalloc_atfork(void); -_Hide void dlmalloc_abort(void); +void dlmalloc_atfork(void); +void dlmalloc_abort(void); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/third_party/gdtoa/gdtoa.internal.h b/third_party/gdtoa/gdtoa.internal.h index a314de29e..bbb4d1e2c 100644 --- a/third_party/gdtoa/gdtoa.internal.h +++ b/third_party/gdtoa/gdtoa.internal.h @@ -348,13 +348,13 @@ typedef struct ThInfo { #define Bcopy(x, y) \ memcpy(&x->sign, &y->sign, y->wds * sizeof(ULong) + 2 * sizeof(int)) -_Hide extern const double __gdtoa_tens[]; -_Hide extern const double __gdtoa_bigtens[]; -_Hide extern const double __gdtoa_tinytens[]; -_Hide extern const unsigned char __gdtoa_hexdig[]; -_Hide extern const char *const __gdtoa_InfName[6]; -_Hide extern const char *const __gdtoa_NanName[3]; -_Hide extern const ULong __gdtoa_NanDflt_Q[4]; +extern const double __gdtoa_tens[]; +extern const double __gdtoa_bigtens[]; +extern const double __gdtoa_tinytens[]; +extern const unsigned char __gdtoa_hexdig[]; +extern const char *const __gdtoa_InfName[6]; +extern const char *const __gdtoa_NanName[3]; +extern const ULong __gdtoa_NanDflt_Q[4]; Bigint *__gdtoa_Balloc(int, ThInfo **); void __gdtoa_Bfree(Bigint *, ThInfo **); diff --git a/third_party/musl/crypt_des.internal.h b/third_party/musl/crypt_des.internal.h index 9dbe111ac..304dc0da2 100644 --- a/third_party/musl/crypt_des.internal.h +++ b/third_party/musl/crypt_des.internal.h @@ -9,8 +9,8 @@ struct expanded_key { uint32_t l[16], r[16]; }; -_Hide void __des_setkey(const unsigned char *, struct expanded_key *); -_Hide void __do_des(uint32_t, uint32_t, uint32_t *, uint32_t *, + void __des_setkey(const unsigned char *, struct expanded_key *); + void __do_des(uint32_t, uint32_t, uint32_t *, uint32_t *, uint32_t, uint32_t, const struct expanded_key *); #endif diff --git a/third_party/regex/tre.inc b/third_party/regex/tre.inc index a4e8154b6..d072d72fb 100644 --- a/third_party/regex/tre.inc +++ b/third_party/regex/tre.inc @@ -143,13 +143,13 @@ struct tnfa_transition { }; /* Assertions. */ -#define ASSERT_AT_BOL 1 /* Beginning of line. */ -#define ASSERT_AT_EOL 2 /* End of line. */ -#define ASSERT_CHAR_CLASS 4 /* Character class in `class'. */ -#define ASSERT_CHAR_CLASS_NEG 8 /* Character classes in `neg_classes'. */ -#define ASSERT_AT_BOW 16 /* Beginning of word. */ -#define ASSERT_AT_EOW 32 /* End of word. */ -#define ASSERT_AT_WB 64 /* Word boundary. */ +#define ASSERT_AT_BOL 1 /* Beginning of line. */ +#define ASSERT_AT_EOL 2 /* End of line. */ +#define ASSERT_CHAR_CLASS 4 /* Character class in `class'. */ +#define ASSERT_CHAR_CLASS_NEG 8 /* Character classes in `neg_classes'. */ +#define ASSERT_AT_BOW 16 /* Beginning of word. */ +#define ASSERT_AT_EOW 32 /* End of word. */ +#define ASSERT_AT_WB 64 /* Word boundary. */ #define ASSERT_AT_WB_NEG 128 /* Not a word boundary. */ #define ASSERT_BACKREF 256 /* A back reference in `backref'. */ #define ASSERT_LAST 256 @@ -215,9 +215,9 @@ typedef struct tre_mem_struct { #define tre_mem_alloc_impl __tre_mem_alloc_impl #define tre_mem_destroy __tre_mem_destroy -tre_mem_t tre_mem_new_impl(int provided, void *provided_block) _Hide; +tre_mem_t tre_mem_new_impl(int provided, void *provided_block); void *tre_mem_alloc_impl(tre_mem_t mem, int provided, void *provided_block, - int zero, size_t size) _Hide; + int zero, size_t size); /* Returns a new memory allocator or NULL if out of memory. */ #define tre_mem_new() tre_mem_new_impl(0, NULL) @@ -245,4 +245,4 @@ void *tre_mem_alloc_impl(tre_mem_t mem, int provided, void *provided_block, #endif /* TRE_USE_ALLOCA */ /* Frees the memory allocator and all memory allocated with it. */ -_Hide void tre_mem_destroy(tre_mem_t mem); +void tre_mem_destroy(tre_mem_t mem); diff --git a/third_party/zlib/cpu_features.internal.h b/third_party/zlib/cpu_features.internal.h index 9765a5e55..d600276df 100644 --- a/third_party/zlib/cpu_features.internal.h +++ b/third_party/zlib/cpu_features.internal.h @@ -14,9 +14,9 @@ COSMOPOLITAN_C_START_ #elif defined(__aarch64__) #define cpu_check_features zlib_cpu_check_features -_Hide extern int arm_cpu_enable_crc32; -_Hide extern int arm_cpu_enable_pmull; -_Hide void cpu_check_features(void); +extern int arm_cpu_enable_crc32; +extern int arm_cpu_enable_pmull; +void cpu_check_features(void); #endif COSMOPOLITAN_C_END_ diff --git a/third_party/zlib/inffast.internal.h b/third_party/zlib/inffast.internal.h index 63d5764b3..9dbe3d1be 100644 --- a/third_party/zlib/inffast.internal.h +++ b/third_party/zlib/inffast.internal.h @@ -20,7 +20,7 @@ COSMOPOLITAN_C_START_ */ #define INFLATE_FAST_MIN_OUTPUT 258 -void inflate_fast(z_streamp strm, unsigned start) _Hide; +void inflate_fast(z_streamp strm, unsigned start); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/third_party/zlib/internal.h b/third_party/zlib/internal.h index aed2494a2..34d383dde 100644 --- a/third_party/zlib/internal.h +++ b/third_party/zlib/internal.h @@ -13,18 +13,18 @@ COSMOPOLITAN_C_START_ #define zmemzero bzero #define zmemcpy memmove -unsigned deflate_read_buf(z_streamp, Bytef *, unsigned) _Hide; -void copy_with_crc(z_streamp, Bytef *, long) _Hide; -void crc_finalize(deflate_state *const) _Hide; -void crc_reset(deflate_state *const) _Hide; -uint32_t adler32_simd_(uint32_t, const unsigned char *, size_t) _Hide; -void crc_fold_init(deflate_state *const) _Hide; +unsigned deflate_read_buf(z_streamp, Bytef *, unsigned); +void copy_with_crc(z_streamp, Bytef *, long); +void crc_finalize(deflate_state *const); +void crc_reset(deflate_state *const); +uint32_t adler32_simd_(uint32_t, const unsigned char *, size_t); +void crc_fold_init(deflate_state *const); void crc_fold_copy(deflate_state *const, unsigned char *, const unsigned char *, - long) _Hide; -unsigned crc_fold_512to32(deflate_state *const) _Hide; -void fill_window_sse(deflate_state *) _Hide; -void *zcalloc(void *, uInt, uInt) _Hide; -void zcfree(void *, void *) _Hide; + long); +unsigned crc_fold_512to32(deflate_state *const); +void fill_window_sse(deflate_state *); +void *zcalloc(void *, uInt, uInt); +void zcfree(void *, void *); COSMOPOLITAN_C_END_ #endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */ diff --git a/third_party/zlib/treeconst.c b/third_party/zlib/treeconst.c index e473bb588..37fa4100e 100644 --- a/third_party/zlib/treeconst.c +++ b/third_party/zlib/treeconst.c @@ -1,12 +1,12 @@ /* header created automatically with -DGEN_TREES_H */ #include "third_party/zlib/internal.h" -_Hide const int kZlibBaseLength[LENGTH_CODES] = { +const int kZlibBaseLength[LENGTH_CODES] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 0, }; -_Hide const int kZlibBaseDist[D_CODES] = { +const int kZlibBaseDist[D_CODES] = { 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576, diff --git a/third_party/zlib/zutil.internal.h b/third_party/zlib/zutil.internal.h index d79a591dc..2417f749c 100644 --- a/third_party/zlib/zutil.internal.h +++ b/third_party/zlib/zutil.internal.h @@ -38,7 +38,7 @@ COSMOPOLITAN_C_START_ define "local" for the non-static meaning of "static", for readability (compile with -Dlocal if your debugger can't find static symbols) */ -extern const char *const z_errmsg[10] _Hide; /* indexed by 2-zlib_error */ +extern const char *const z_errmsg[10]; /* indexed by 2-zlib_error */ /* (size given to avoid silly warnings with Visual C++) */ #define ERR_MSG(err) z_errmsg[Z_NEED_DICT - (err)] @@ -52,8 +52,8 @@ extern const char *const z_errmsg[10] _Hide; /* indexed by 2-zlib_error */ /* Diagnostic functions */ #ifdef ZLIB_DEBUG -extern int z_verbose _Hide; -extern void z_error(const char *, int, char *) _Hide; +extern int z_verbose; +extern void z_error(const char *, int, char *); #define Assert(cond, msg) \ { \ if (!(cond)) { \ diff --git a/tool/build/pledge.c b/tool/build/pledge.c index 9f23bb87d..765a91831 100644 --- a/tool/build/pledge.c +++ b/tool/build/pledge.c @@ -30,7 +30,9 @@ #include "libc/calls/syscall_support-sysv.internal.h" #include "libc/dce.h" #include "libc/elf/def.h" +#include "libc/elf/elf.h" #include "libc/elf/struct/ehdr.h" +#include "libc/elf/struct/phdr.h" #include "libc/errno.h" #include "libc/fmt/conv.h" #include "libc/intrin/bits.h" @@ -530,6 +532,54 @@ int Extract(const char *from, const char *to, int mode) { return close(fdout) | close(fdin); } +/** + * Returns true if ELF executable uses dynamic loading magic. + */ +static bool IsDynamicExecutable(const char *prog) { + bool res; + Elf64_Ehdr *e; + Elf64_Phdr *p; + struct stat st; + int i, fd, err; + fd = -1; + err = errno; + e = MAP_FAILED; + if ((fd = open(prog, O_RDONLY)) == -1) { + res = false; + goto Finish; + } + if (fstat(fd, &st) == -1 || st.st_size < 64) { + res = false; + goto Finish; + } + if ((e = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0)) == MAP_FAILED) { + res = false; + goto Finish; + } + if (READ32LE(e->e_ident) != READ32LE(ELFMAG)) { + res = false; + goto Finish; + } + if (e->e_type == ET_DYN) { + res = true; + goto Finish; + } + for (i = 0; i < e->e_phnum; ++i) { + p = GetElfProgramHeaderAddress(e, st.st_size, i); + if (p->p_type == PT_INTERP || p->p_type == PT_DYNAMIC) { + res = true; + goto Finish; + } + } + res = false; + goto Finish; +Finish: + if (e != MAP_FAILED) munmap(e, st.st_size); + if (fd != -1) close(fd); + errno = err; + return res; +} + int main(int argc, char *argv[]) { const char *s; bool hasfunbits; @@ -659,7 +709,7 @@ int main(int argc, char *argv[]) { } // figure out where we want the dso - if (_IsDynamicExecutable(prog)) { + if (IsDynamicExecutable(prog)) { isdynamic = true; if ((s = getenv("TMPDIR")) || // (s = getenv("HOME")) || // diff --git a/tool/build/runit.c b/tool/build/runit.c index 6c42ca539..f90456e97 100644 --- a/tool/build/runit.c +++ b/tool/build/runit.c @@ -119,7 +119,7 @@ char g_hostname[128]; uint16_t g_runitdport; volatile bool alarmed; -int __sys_execve(const char *, char *const[], char *const[]) _Hide; +int __sys_execve(const char *, char *const[], char *const[]); static void OnAlarm(int sig) { alarmed = true; diff --git a/tool/emacs/c.lang b/tool/emacs/c.lang index cdaef059c..b9d450b2d 100644 --- a/tool/emacs/c.lang +++ b/tool/emacs/c.lang @@ -116,7 +116,6 @@ Keywords={ "nullterminated", "unreachable", "notpossible", -"_Hide", "privileged", "hasatleast", "nodebuginfo", diff --git a/tool/emacs/cosmo-c-keywords.el b/tool/emacs/cosmo-c-keywords.el index 269108d8b..ba97f28db 100644 --- a/tool/emacs/cosmo-c-keywords.el +++ b/tool/emacs/cosmo-c-keywords.el @@ -66,7 +66,6 @@ "reallocesque" "nullterminated" "notpossible" - "_Hide" "privileged" "hasatleast" "nodebuginfo" diff --git a/tool/emacs/key.py b/tool/emacs/key.py index 18ca0e31a..470b265d5 100644 --- a/tool/emacs/key.py +++ b/tool/emacs/key.py @@ -337,7 +337,6 @@ cosmo_kws = frozenset([ "forceinline", "frownedupon", "hasatleast", - "_Hide", "initarray", "interruptfn", "mallocesque", @@ -399,7 +398,6 @@ cosmo_kws = frozenset([ "forceinline", "frownedupon", "hasatleast", - "_Hide", "initarray", "interruptfn", "mallocesque",