From deaef814636708040a1eab7d49130f793266511d Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Tue, 28 May 2024 02:34:17 -0700 Subject: [PATCH] Favor siginfo_t over struct siginfo --- dsp/tty/ttyraw.c | 2 +- libc/calls/sigaction.c | 2 +- libc/calls/sigenter-linux.c | 2 +- libc/calls/sigenter-netbsd.c | 2 +- libc/calls/sigenter-openbsd.c | 2 +- libc/calls/siginfo2cosmo.c | 5 ++--- libc/calls/struct/sigaction.h | 2 +- libc/calls/struct/sigaction.internal.h | 10 +++++----- libc/calls/struct/siginfo-meta.internal.h | 4 ++-- libc/log/internal.h | 2 +- libc/log/oncrash_amd64.c | 6 +++--- libc/log/oncrash_arm64.c | 5 ++--- test/libc/calls/sigaction_test.c | 12 ++++++------ test/libc/calls/signal_test.c | 4 ++-- test/libc/runtime/mprotect_test.c | 4 ++-- test/libc/thread/pthread_create_test.c | 3 +-- test/libc/thread/pthread_detach_test.c | 2 +- third_party/libcxx/__config_site | 1 + third_party/python/launch.c | 2 +- tool/viz/memzoom.c | 4 ++-- 20 files changed, 37 insertions(+), 39 deletions(-) diff --git a/dsp/tty/ttyraw.c b/dsp/tty/ttyraw.c index b2b8812ef..333c641f0 100644 --- a/dsp/tty/ttyraw.c +++ b/dsp/tty/ttyraw.c @@ -87,7 +87,7 @@ static textexit void ttyraw_onexit(void) { ttyraw_disable(); } -static relegated void ttyraw_onsig(int sig, struct siginfo *info, +static relegated void ttyraw_onsig(int sig, siginfo_t *info, struct ucontext *ctx) { size_t i; if (g_ttyraw.noreentry) diff --git a/libc/calls/sigaction.c b/libc/calls/sigaction.c index 82a534970..df751f353 100644 --- a/libc/calls/sigaction.c +++ b/libc/calls/sigaction.c @@ -421,7 +421,7 @@ static int __sigaction(int sig, const struct sigaction *act, * ctx->uc_mcontext.rip += xedd.length; * } * - * void OnCrash(int sig, struct siginfo *si, void *vctx) { + * void OnCrash(int sig, siginfo_t *si, void *vctx) { * struct ucontext *ctx = vctx; * SkipOverFaultingInstruction(ctx); * ContinueOnCrash(); // reinstall here in case *rip faults diff --git a/libc/calls/sigenter-linux.c b/libc/calls/sigenter-linux.c index 7baa17e43..b0a14322d 100644 --- a/libc/calls/sigenter-linux.c +++ b/libc/calls/sigenter-linux.c @@ -31,7 +31,7 @@ #ifdef __x86_64__ -privileged void __sigenter_wsl(int sig, struct siginfo *info, ucontext_t *ctx) { +privileged void __sigenter_wsl(int sig, siginfo_t *info, ucontext_t *ctx) { int rva, flags; rva = __sighandrvas[sig]; if (rva >= kSigactionMinRva) { diff --git a/libc/calls/sigenter-netbsd.c b/libc/calls/sigenter-netbsd.c index 6e3fef37c..9e20817df 100644 --- a/libc/calls/sigenter-netbsd.c +++ b/libc/calls/sigenter-netbsd.c @@ -43,7 +43,7 @@ privileged void __sigenter_netbsd(int sig, struct siginfo_netbsd *si, CheckLargeStackAllocation(&uc, sizeof(uc)); #pragma GCC pop_options int rva, flags; - struct siginfo si2; + siginfo_t si2; rva = __sighandrvas[sig]; if (rva >= kSigactionMinRva) { flags = __sighandflags[sig]; diff --git a/libc/calls/sigenter-openbsd.c b/libc/calls/sigenter-openbsd.c index 2c0242eac..5be46f32a 100644 --- a/libc/calls/sigenter-openbsd.c +++ b/libc/calls/sigenter-openbsd.c @@ -41,7 +41,7 @@ privileged void __sigenter_openbsd(int sig, struct siginfo_openbsd *openbsdinfo, #pragma GCC diagnostic ignored "-Wframe-larger-than=" struct Goodies { ucontext_t uc; - struct siginfo si; + siginfo_t si; } g; CheckLargeStackAllocation(&g, sizeof(g)); #pragma GCC pop_options diff --git a/libc/calls/siginfo2cosmo.c b/libc/calls/siginfo2cosmo.c index 6c0f856c9..77040820b 100644 --- a/libc/calls/siginfo2cosmo.c +++ b/libc/calls/siginfo2cosmo.c @@ -21,8 +21,7 @@ #include "libc/dce.h" #include "libc/sysv/consts/sig.h" -privileged void __siginfo2cosmo(struct siginfo *si, - const union siginfo_meta *m) { +privileged void __siginfo2cosmo(siginfo_t *si, const union siginfo_meta *m) { void *si_addr; int32_t si_signo; int32_t si_errno; @@ -93,7 +92,7 @@ privileged void __siginfo2cosmo(struct siginfo *si, } } - *si = (struct siginfo){0}; + *si = (siginfo_t){0}; si->si_signo = si_signo; si->si_errno = si_errno; si->si_code = si_code; diff --git a/libc/calls/struct/sigaction.h b/libc/calls/struct/sigaction.h index 49d0d6fe3..b7e4c7fc7 100644 --- a/libc/calls/struct/sigaction.h +++ b/libc/calls/struct/sigaction.h @@ -5,7 +5,7 @@ COSMOPOLITAN_C_START_ typedef void (*sighandler_t)(int); -typedef void (*sigaction_f)(int, struct siginfo *, void *); +typedef void (*sigaction_f)(int, siginfo_t *, void *); struct sigaction { union { diff --git a/libc/calls/struct/sigaction.internal.h b/libc/calls/struct/sigaction.internal.h index 00a425d70..bf69a81db 100644 --- a/libc/calls/struct/sigaction.internal.h +++ b/libc/calls/struct/sigaction.internal.h @@ -60,11 +60,11 @@ union metasigaction { struct sigaction_xnu_out xnu_out; }; -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 *); +void __sigenter_xnu(int, siginfo_t *, void *); +void __sigenter_wsl(int, siginfo_t *, void *); +void __sigenter_netbsd(int, siginfo_t *, void *); +void __sigenter_freebsd(int, siginfo_t *, void *); +void __sigenter_openbsd(int, siginfo_t *, 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 4fdbdf389..d48426c34 100644 --- a/libc/calls/struct/siginfo-meta.internal.h +++ b/libc/calls/struct/siginfo-meta.internal.h @@ -8,14 +8,14 @@ COSMOPOLITAN_C_START_ union siginfo_meta { - struct siginfo linux; + siginfo_t linux; struct siginfo_xnu xnu; struct siginfo_freebsd freebsd; struct siginfo_openbsd openbsd; struct siginfo_netbsd netbsd; }; -void __siginfo2cosmo(struct siginfo *, const union siginfo_meta *); +void __siginfo2cosmo(siginfo_t *, const union siginfo_meta *); COSMOPOLITAN_C_END_ #endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGINFO_META_INTERNAL_H_ */ diff --git a/libc/log/internal.h b/libc/log/internal.h index cec8ae390..367b47dde 100644 --- a/libc/log/internal.h +++ b/libc/log/internal.h @@ -8,7 +8,7 @@ extern bool32 g_isrunningundermake; void __start_fatal(const char *, int); void __restore_tty(void); -void __oncrash(int, struct siginfo *, void *); +void __oncrash(int, siginfo_t *, void *); COSMOPOLITAN_C_END_ #endif /* COSMOPOLITAN_LIBC_LOG_INTERNAL_H_ */ diff --git a/libc/log/oncrash_amd64.c b/libc/log/oncrash_amd64.c index 229c351cd..8fb2dca4d 100644 --- a/libc/log/oncrash_amd64.c +++ b/libc/log/oncrash_amd64.c @@ -188,9 +188,9 @@ relegated static char *ShowSseRegisters(char *p, ucontext_t *ctx) { return p; } -void ShowCrashReportHook(int, int, int, struct siginfo *, ucontext_t *); +void ShowCrashReportHook(int, int, int, siginfo_t *, ucontext_t *); -static relegated void ShowCrashReport(int err, int sig, struct siginfo *si, +static relegated void ShowCrashReport(int err, int sig, siginfo_t *si, ucontext_t *ctx) { #pragma GCC push_options #pragma GCC diagnostic ignored "-Walloca-larger-than=" @@ -267,7 +267,7 @@ static inline void SpinUnlock(atomic_uint *lock) { atomic_store_explicit(lock, 0, memory_order_release); } -relegated void __oncrash(int sig, struct siginfo *si, void *arg) { +relegated void __oncrash(int sig, siginfo_t *si, void *arg) { static atomic_uint lock; BLOCK_CANCELATION; SpinLock(&lock); diff --git a/libc/log/oncrash_arm64.c b/libc/log/oncrash_arm64.c index 7628bfffa..1d6041032 100644 --- a/libc/log/oncrash_arm64.c +++ b/libc/log/oncrash_arm64.c @@ -189,8 +189,7 @@ static relegated char *GetSymbolName(struct SymbolTable *st, int symbol) { return buf; } -static relegated void __oncrash_impl(int sig, struct siginfo *si, - ucontext_t *ctx) { +static relegated void __oncrash_impl(int sig, siginfo_t *si, ucontext_t *ctx) { #pragma GCC push_options #pragma GCC diagnostic ignored "-Walloca-larger-than=" long size = __get_safe_size(10000, 4096); @@ -389,7 +388,7 @@ static inline void SpinUnlock(atomic_uint *lock) { atomic_store_explicit(lock, 0, memory_order_release); } -relegated void __oncrash(int sig, struct siginfo *si, void *arg) { +relegated void __oncrash(int sig, siginfo_t *si, void *arg) { static atomic_uint lock; BLOCK_CANCELATION; SpinLock(&lock); diff --git a/test/libc/calls/sigaction_test.c b/test/libc/calls/sigaction_test.c index f093bd24b..d9e5cb735 100644 --- a/test/libc/calls/sigaction_test.c +++ b/test/libc/calls/sigaction_test.c @@ -81,7 +81,7 @@ void PromisedLand(void *arg) { pthread_exit(arg); } -void Teleporter(int sig, struct siginfo *si, void *ctx) { +void Teleporter(int sig, siginfo_t *si, void *ctx) { ucontext_t *uc = ctx; sigaddset(&uc->uc_sigmask, SIGUSR1); uc->uc_mcontext.PC = (uintptr_t)PromisedLand; @@ -177,7 +177,7 @@ TEST(sigaction, testPingPongParentChildWithSigint) { volatile int trapeax; -void OnTrap(int sig, struct siginfo *si, void *vctx) { +void OnTrap(int sig, siginfo_t *si, void *vctx) { struct ucontext *ctx = vctx; CheckStackIsAligned(); trapeax = ctx->uc_mcontext.rax; @@ -203,7 +203,7 @@ void SkipOverFaultingInstruction(struct ucontext *ctx) { ctx->uc_mcontext.rip += xedd.length; } -void OnFpe(int sig, struct siginfo *si, void *vctx) { +void OnFpe(int sig, siginfo_t *si, void *vctx) { struct ucontext *ctx = vctx; CheckStackIsAligned(); SkipOverFaultingInstruction(ctx); @@ -286,7 +286,7 @@ TEST(sigaction, enosys_returnsErrnoRatherThanSigsysByDefault) { sig_atomic_t gotusr1; -void OnSigMask(int sig, struct siginfo *si, void *ctx) { +void OnSigMask(int sig, siginfo_t *si, void *ctx) { ucontext_t *uc = ctx; sigaddset(&uc->uc_sigmask, sig); gotusr1 = true; @@ -329,7 +329,7 @@ TEST(sig_ign, discardsPendingSignalsEvenIfBlocked) { ASSERT_SYS(0, 0, sigprocmask(SIG_SETMASK, &oldmask, 0)); } -void AutoMask(int sig, struct siginfo *si, void *ctx) { +void AutoMask(int sig, siginfo_t *si, void *ctx) { sigset_t ss; ucontext_t *uc = ctx; sigprocmask(SIG_SETMASK, 0, &ss); @@ -347,7 +347,7 @@ TEST(sigaction, signalBeingDeliveredGetsAutoMasked) { EXPECT_FALSE(sigismember(&ss, SIGUSR2)); // original mask } -void NoDefer(int sig, struct siginfo *si, void *ctx) { +void NoDefer(int sig, siginfo_t *si, void *ctx) { sigset_t ss; ucontext_t *uc = ctx; sigprocmask(SIG_SETMASK, 0, &ss); diff --git a/test/libc/calls/signal_test.c b/test/libc/calls/signal_test.c index c900d4b9b..74dfad41b 100644 --- a/test/libc/calls/signal_test.c +++ b/test/libc/calls/signal_test.c @@ -48,7 +48,7 @@ TEST(signal, test) { //////////////////////////////////////////////////////////////////////////////// // signal round-trip delivery takes about 1µs -void OnSigTrap(int sig, struct siginfo *si, void *ctx) { +void OnSigTrap(int sig, siginfo_t *si, void *ctx) { } void TrapBench(int n) { @@ -79,7 +79,7 @@ BENCH(signal, trapBenchSiginfo) { #ifdef __x86_64__ -void OnSigHlt(int sig, struct siginfo *si, void *vctx) { +void OnSigHlt(int sig, siginfo_t *si, void *vctx) { struct ucontext *ctx = vctx; ctx->uc_mcontext.rip += 1; } diff --git a/test/libc/runtime/mprotect_test.c b/test/libc/runtime/mprotect_test.c index c06eeb005..bac4cf73e 100644 --- a/test/libc/runtime/mprotect_test.c +++ b/test/libc/runtime/mprotect_test.c @@ -73,13 +73,13 @@ void SkipOverFaultingInstruction(struct ucontext *ctx) { #endif } -void OnSigSegv(int sig, struct siginfo *si, void *vctx) { +void OnSigSegv(int sig, siginfo_t *si, void *vctx) { struct ucontext *ctx = vctx; gotsegv = true; SkipOverFaultingInstruction(ctx); } -void OnSigBus(int sig, struct siginfo *si, void *vctx) { +void OnSigBus(int sig, siginfo_t *si, void *vctx) { struct ucontext *ctx = vctx; gotbusted = true; SkipOverFaultingInstruction(ctx); diff --git a/test/libc/thread/pthread_create_test.c b/test/libc/thread/pthread_create_test.c index bb6c974bb..ad680cd10 100644 --- a/test/libc/thread/pthread_create_test.c +++ b/test/libc/thread/pthread_create_test.c @@ -29,7 +29,6 @@ #include "libc/limits.h" #include "libc/macros.internal.h" #include "libc/mem/gc.h" -#include "libc/mem/gc.h" #include "libc/mem/mem.h" #include "libc/nexgen32e/nexgen32e.h" #include "libc/nexgen32e/vendor.internal.h" @@ -48,7 +47,7 @@ #include "libc/thread/thread.h" #include "libc/thread/thread2.h" -void OnUsr1(int sig, struct siginfo *si, void *vctx) { +void OnUsr1(int sig, siginfo_t *si, void *vctx) { } void SetUp(void) { diff --git a/test/libc/thread/pthread_detach_test.c b/test/libc/thread/pthread_detach_test.c index 59ce21c58..bfbb9c9c5 100644 --- a/test/libc/thread/pthread_detach_test.c +++ b/test/libc/thread/pthread_detach_test.c @@ -26,7 +26,7 @@ #include "libc/thread/posixthread.internal.h" #include "libc/thread/thread.h" -void OnUsr1(int sig, struct siginfo *si, void *vctx) { +void OnUsr1(int sig, siginfo_t *si, void *vctx) { } void SetUp(void) { diff --git a/third_party/libcxx/__config_site b/third_party/libcxx/__config_site index c2d92b0e4..f5f01f7de 100644 --- a/third_party/libcxx/__config_site +++ b/third_party/libcxx/__config_site @@ -26,6 +26,7 @@ #define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS #define _LIBCPP_NO_VCRUNTIME #define _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION 1 +#define _LIBCPP_REMOVE_TRANSITIVE_INCLUDES #ifdef MODE_DBG #define _LIBCPP_ENABLE_DEBUG_MODE diff --git a/third_party/python/launch.c b/third_party/python/launch.c index 6914f08f6..75ddc987f 100644 --- a/third_party/python/launch.c +++ b/third_party/python/launch.c @@ -96,7 +96,7 @@ LaunchPythonModule(const char *name) #if USE_COSMO_CRASH void ShowCrashReportHook(int err, int fd, int sig, - struct siginfo *si, ucontext_t *ctx) + siginfo_t *si, ucontext_t *ctx) { PyObject *str; PyFrameObject *frame; diff --git a/tool/viz/memzoom.c b/tool/viz/memzoom.c index fc19e835e..d76fa82d3 100644 --- a/tool/viz/memzoom.c +++ b/tool/viz/memzoom.c @@ -225,11 +225,11 @@ static void OnExit(void) { tcsetattr(out, TCSANOW, &oldterm); } -static void OnSigInt(int sig, struct siginfo *sa, void *uc) { +static void OnSigInt(int sig, siginfo_t *sa, void *uc) { action |= INTERRUPTED; } -static void OnSigWinch(int sig, struct siginfo *sa, void *uc) { +static void OnSigWinch(int sig, siginfo_t *sa, void *uc) { action |= RESIZED; }