Favor siginfo_t over struct siginfo

This commit is contained in:
Justine Tunney 2024-05-28 02:34:17 -07:00
parent c638eabfe0
commit deaef81463
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
20 changed files with 37 additions and 39 deletions

View file

@ -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)

View file

@ -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

View file

@ -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) {

View file

@ -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];

View file

@ -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

View file

@ -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;

View file

@ -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 {

View file

@ -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)

View file

@ -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_ */

View file

@ -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_ */

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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;
}

View file

@ -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);

View file

@ -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) {

View file

@ -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) {

View file

@ -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

View file

@ -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;

View file

@ -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;
}