From 9baba9ee1bb2bc209249fb0d9bf4c3a2320eac8e Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 21 Oct 2023 20:36:55 +0100 Subject: [PATCH] netbsd/openbsd adding more accessors to siginfo_t. close #3397 --- libc-test/build.rs | 2 +- src/unix/bsd/netbsdlike/netbsd/mod.rs | 33 ++++++++++++++++++++++++++ src/unix/bsd/netbsdlike/openbsd/mod.rs | 33 ++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 2f993486ef311..59d32513dc0e7 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -638,7 +638,7 @@ fn test_windows(target: &str) { // Windows uppercase structs don't have `struct` in front: t if is_struct => { - if ty.clone().chars().next().unwrap().is_uppercase() { + if ty.chars().next().unwrap().is_uppercase() { t.to_string() } else if t == "stat" { "struct __stat64".to_string() diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index de5ec3863e717..ac79b9f45ac4e 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -60,6 +60,39 @@ impl siginfo_t { self.si_addr } + pub unsafe fn si_code(&self) -> ::c_int { + self.si_code + } + + pub unsafe fn si_errno(&self) -> ::c_int { + self.si_errno + } + + pub unsafe fn si_pid(&self) -> ::pid_t { + #[repr(C)] + struct siginfo_timer { + _si_signo: ::c_int, + _si_errno: ::c_int, + _si_code: ::c_int, + __pad1: ::c_int, + _pid: ::pid_t, + } + (*(self as *const siginfo_t as *const siginfo_timer))._pid + } + + pub unsafe fn si_uid(&self) -> ::uid_t { + #[repr(C)] + struct siginfo_timer { + _si_signo: ::c_int, + _si_errno: ::c_int, + _si_code: ::c_int, + __pad1: ::c_int, + _pid: ::pid_t, + _uid: ::uid_t, + } + (*(self as *const siginfo_t as *const siginfo_timer))._uid + } + pub unsafe fn si_value(&self) -> ::sigval { #[repr(C)] struct siginfo_timer { diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 3b87dc211f236..51ba3b3d33eb6 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -540,6 +540,39 @@ impl siginfo_t { self.si_addr } + pub unsafe fn si_code(&self) -> ::c_int { + self.si_code + } + + pub unsafe fn si_errno(&self) -> ::c_int { + self.si_errno + } + + pub unsafe fn si_pid(&self) -> ::pid_t { + #[repr(C)] + struct siginfo_timer { + _si_signo: ::c_int, + _si_errno: ::c_int, + _si_code: ::c_int, + __pad1: ::c_int, + _pid: ::pid_t, + } + (*(self as *const siginfo_t as *const siginfo_timer))._pid + } + + pub unsafe fn si_uid(&self) -> ::uid_t { + #[repr(C)] + struct siginfo_timer { + _si_signo: ::c_int, + _si_errno: ::c_int, + _si_code: ::c_int, + __pad1: ::c_int, + _pid: ::pid_t, + _uid: ::uid_t, + } + (*(self as *const siginfo_t as *const siginfo_timer))._uid + } + pub unsafe fn si_value(&self) -> ::sigval { #[repr(C)] struct siginfo_timer {