Skip to content

Commit

Permalink
Adds in SI_SIGTRAP codes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
xd009642 committed Jan 27, 2025
1 parent 8b69878 commit 8897485
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"
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 @@ -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(
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

0 comments on commit 8897485

Please sign in to comment.