Skip to content

Commit ed7c9e8

Browse files
committed
netbsd/openbsd adding more accessors to siginfo_t.
close #3397
1 parent e06d905 commit ed7c9e8

File tree

3 files changed

+72
-2
lines changed

3 files changed

+72
-2
lines changed

libc-test/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ fn test_windows(target: &str) {
638638

639639
// Windows uppercase structs don't have `struct` in front:
640640
t if is_struct => {
641-
if ty.clone().chars().next().unwrap().is_uppercase() {
641+
if ty.chars().next().unwrap().is_uppercase() {
642642
t.to_string()
643643
} else if t == "stat" {
644644
"struct __stat64".to_string()

src/unix/bsd/netbsdlike/netbsd/mod.rs

+33
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,39 @@ impl siginfo_t {
6060
self.si_addr
6161
}
6262

63+
pub unsafe fn si_code(&self) -> ::c_int {
64+
self.si_code
65+
}
66+
67+
pub unsafe fn si_errno(&self) -> ::c_int {
68+
self.si_errno
69+
}
70+
71+
pub unsafe fn si_pid(&self) -> ::pid_t {
72+
#[repr(C)]
73+
struct siginfo_timer {
74+
_si_signo: ::c_int,
75+
_si_errno: ::c_int,
76+
_si_code: ::c_int,
77+
__pad1: ::c_int,
78+
_pid: ::pid_t,
79+
}
80+
(*(self as *const siginfo_t as *const siginfo_timer))._pid
81+
}
82+
83+
pub unsafe fn si_uid(&self) -> ::uid_t {
84+
#[repr(C)]
85+
struct siginfo_timer {
86+
_si_signo: ::c_int,
87+
_si_errno: ::c_int,
88+
_si_code: ::c_int,
89+
__pad1: ::c_int,
90+
_pid: ::pid_t,
91+
_uid: ::uid_t,
92+
}
93+
(*(self as *const siginfo_t as *const siginfo_timer))._uid
94+
}
95+
6396
pub unsafe fn si_value(&self) -> ::sigval {
6497
#[repr(C)]
6598
struct siginfo_timer {

src/unix/bsd/netbsdlike/openbsd/mod.rs

+38-1
Original file line numberDiff line numberDiff line change
@@ -540,12 +540,46 @@ impl siginfo_t {
540540
self.si_addr
541541
}
542542

543-
pub unsafe fn si_value(&self) -> ::sigval {
543+
pub unsafe fn si_code(&self) -> ::c_int {
544+
self.si_code
545+
}
546+
547+
pub unsafe fn si_errno(&self) -> ::c_int {
548+
self.si_errno
549+
}
550+
551+
pub unsafe fn si_pid(&self) -> ::pid_t {
552+
#[repr(C)]
553+
struct siginfo_timer {
554+
_si_signo: ::c_int,
555+
_si_code: ::c_int,
556+
_si_errno: ::c_int,
557+
_pad: [::c_int; SI_PAD],
558+
_pid: ::pid_t,
559+
}
560+
(*(self as *const siginfo_t as *const siginfo_timer))._pid
561+
}
562+
563+
pub unsafe fn si_uid(&self) -> ::uid_t {
544564
#[repr(C)]
545565
struct siginfo_timer {
546566
_si_signo: ::c_int,
567+
_si_code: ::c_int,
547568
_si_errno: ::c_int,
569+
_pad: [::c_int; SI_PAD],
570+
_pid: ::pid_t,
571+
_uid: ::uid_t,
572+
}
573+
(*(self as *const siginfo_t as *const siginfo_timer))._uid
574+
}
575+
576+
pub unsafe fn si_value(&self) -> ::sigval {
577+
#[repr(C)]
578+
struct siginfo_timer {
579+
_si_signo: ::c_int,
548580
_si_code: ::c_int,
581+
_si_errno: ::c_int,
582+
_pad: [::c_int; SI_PAD],
549583
_pid: ::pid_t,
550584
_uid: ::uid_t,
551585
value: ::sigval,
@@ -1576,6 +1610,9 @@ pub const NTFS_MFLAG_ALLNAMES: ::c_int = 0x2;
15761610

15771611
pub const TMPFS_ARGS_VERSION: ::c_int = 1;
15781612

1613+
const SI_MAXSZ: ::size_t = 128;
1614+
const SI_PAD: ::size_t = (SI_MAXSZ / ::mem::size_of::<::c_int>()) - 3;
1615+
15791616
pub const MAP_STACK: ::c_int = 0x4000;
15801617
pub const MAP_CONCEAL: ::c_int = 0x8000;
15811618

0 commit comments

Comments
 (0)