Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add in the sigtrap si_codes #4225

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2994,6 +2994,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,
Expand Down Expand Up @@ -4055,6 +4058,9 @@ fn test_linux(target: &str) {
// FIXME(linux): 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"
Expand Down
16 changes: 16 additions & 0 deletions libc-test/semver/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/unix/linux_like/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5798,6 +5798,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(
Expand Down
18 changes: 18 additions & 0 deletions src/unix/linux_like/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down