From 889748564c3e45f63b14b0f79e50669a8335d0c7 Mon Sep 17 00:00:00 2001 From: xd009642 Date: Mon, 27 Jan 2025 17:10:51 +0900 Subject: [PATCH] Adds in SI_SIGTRAP codes One android and linux systems this PR adds in the following constants when applicable: * SI_ASYNCIO * SI_ASYNCNL * SI_DETHREAD * SI_KERNEL * SI_MESGQ * SI_QUEUE * SI_SIGIO * SI_TIMER * SI_TKILL * SI_USER * TRAP_BRANCH * TRAP_BRKPT * TRAP_HWBKPT * TRAP_PERF * TRAP_TRACE * TRAP_UNK --- libc-test/build.rs | 6 ++++++ libc-test/semver/linux.txt | 16 ++++++++++++++++ src/unix/linux_like/android/mod.rs | 4 ++++ src/unix/linux_like/linux/mod.rs | 4 ++++ src/unix/linux_like/mod.rs | 18 ++++++++++++++++++ 5 files changed, 48 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index b1cff7aa9911..be0c840530d0 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2991,6 +2991,9 @@ fn test_emscripten(target: &str) { // https://github.com/emscripten-core/emscripten/pull/14883 "SIG_IGN" => true, + // Constants present in other linuxes but not emscripten + "SI_DETHREAD" | "TRAP_PERF" => true, + // LFS64 types have been removed in Emscripten 3.1.44 // https://github.com/emscripten-core/emscripten/pull/19812 n if n.starts_with("RLIM64") => true, @@ -4052,6 +4055,9 @@ fn test_linux(target: &str) { // FIXME: Not currently available in headers on ARM and musl. "NETLINK_GET_STRICT_CHK" if arm => true, + // Skip as this signal codes and trap reasons need newer headers + "SI_DETHREAD" | "TRAP_PERF" => true, + // kernel constants not available in uclibc 1.0.34 | "EXTPROC" | "IPPROTO_BEETPH" diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 6775a8bfbcb9..5a6bbc7f7e56 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -2879,7 +2879,17 @@ SIOCSMIIREG SIOCSRARP SIOCWANDEV SIOGIFINDEX +SI_ASYNCIO +SI_ASYNCNL +SI_DETHREAD +SI_KERNEL SI_LOAD_SHIFT +SI_MESGQ +SI_QUEUE +SI_SIGIO +SI_TIMER +SI_TKILL +SI_USER SND_CNT SND_MAX SOCK_CLOEXEC @@ -3360,6 +3370,12 @@ TP_STATUS_USER TP_STATUS_VLAN_TPID_VALID TP_STATUS_VLAN_VALID TP_STATUS_WRONG_FORMAT +TRAP_BRANCH +TRAP_BRKPT +TRAP_HWBKPT +TRAP_PERF +TRAP_TRACE +TRAP_UNK TUNATTACHFILTER TUNDETACHFILTER TUNGETFEATURES diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 053f0bbbfdf4..0e5be313f59d 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -3526,6 +3526,10 @@ pub const AT_RSEQ_ALIGN: c_ulong = 28; pub const AT_EXECFN: c_ulong = 31; pub const AT_MINSIGSTKSZ: c_ulong = 51; +// siginfo.h +pub const SI_DETHREAD: c_int = -7; +pub const TRAP_PERF: c_int = 6; + // Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the // following are only available on newer Linux versions than the versions // currently used in CI in some configurations, so we define them here. diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index a9723bb7927f..013ece4bec75 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -5810,6 +5810,10 @@ pub const EPIOCGPARAMS: Ioctl = 0x80088a02; const _IOC_NRBITS: u32 = 8; const _IOC_TYPEBITS: u32 = 8; +// siginfo.h +pub const SI_DETHREAD: c_int = -7; +pub const TRAP_PERF: c_int = 6; + // https://github.com/search?q=repo%3Atorvalds%2Flinux+%22%23define+_IOC_NONE%22&type=code cfg_if! { if #[cfg(any( diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index b856ed5cd358..4df3d4fb708b 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -1288,6 +1288,17 @@ pub const PIPE_BUF: usize = 4096; pub const SI_LOAD_SHIFT: c_uint = 16; +// si_code values +pub const SI_USER: c_int = 0; +pub const SI_KERNEL: c_int = 0x80; +pub const SI_QUEUE: c_int = -1; +pub const SI_TIMER: c_int = -2; +pub const SI_MESGQ: c_int = -3; +pub const SI_ASYNCIO: c_int = -4; +pub const SI_SIGIO: c_int = -5; +pub const SI_TKILL: c_int = -6; +pub const SI_ASYNCNL: c_int = -60; + // si_code values for SIGBUS signal pub const BUS_ADRALN: c_int = 1; pub const BUS_ADRERR: c_int = 2; @@ -1296,6 +1307,13 @@ pub const BUS_OBJERR: c_int = 3; pub const BUS_MCEERR_AR: c_int = 4; pub const BUS_MCEERR_AO: c_int = 5; +// si_code values for SIGTRAP +pub const TRAP_BRKPT: c_int = 1; +pub const TRAP_TRACE: c_int = 2; +pub const TRAP_BRANCH: c_int = 3; +pub const TRAP_HWBKPT: c_int = 4; +pub const TRAP_UNK: c_int = 5; + // si_code values for SIGCHLD signal pub const CLD_EXITED: c_int = 1; pub const CLD_KILLED: c_int = 2;