Skip to content

Commit d5f6711

Browse files
committed
Expose si_addr on siginfo_t. Refs #716
1 parent 363ba93 commit d5f6711

File tree

1 file changed

+87
-11
lines changed
  • src/unix/notbsd/linux/other

1 file changed

+87
-11
lines changed

src/unix/notbsd/linux/other/mod.rs

+87-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,92 @@
11
pub type __priority_which_t = ::c_uint;
22

3+
#[repr(C)]
4+
#[derive(Copy, Clone)]
5+
struct addr_bnd_t {
6+
lower: *mut ::c_void,
7+
upper: *mut ::c_void,
8+
}
9+
10+
#[repr(C)]
11+
#[derive(Copy, Clone)]
12+
union sigfault_t_anonymous_union {
13+
addr_bnd: addr_bnd_t,
14+
pkey: u32,
15+
}
16+
17+
#[repr(C)]
18+
#[derive(Copy, Clone)]
19+
struct sigfault_t {
20+
addr: *mut ::c_void,
21+
#[cfg(target_arch = "sparc")]
22+
trapno: ::c_int,
23+
addr_lsb: ::c_short,
24+
anonymous_union: sigfault_t_anonymous_union,
25+
}
26+
27+
#[repr(C, packed)]
28+
#[derive(Copy, Clone)]
29+
union sifields_t {
30+
_pad: [::c_int; 29],
31+
sigfault: sigfault_t,
32+
}
33+
34+
#[repr(C)]
35+
#[derive(Copy, Clone)]
36+
pub struct siginfo_t {
37+
pub si_signo: ::c_int,
38+
pub si_errno: ::c_int,
39+
pub si_code: ::c_int,
40+
sifields: sifields_t,
41+
#[cfg(target_arch = "x86_64")]
42+
_align: [u64; 0],
43+
#[cfg(not(target_arch = "x86_64"))]
44+
_align: [usize; 0],
45+
}
46+
47+
impl ::fmt::Debug for sigfault_t_anonymous_union {
48+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
49+
// TODO: no idea how to tell which of the members is used
50+
f.debug_struct("sigfault_t_anonymous_union")
51+
.finish()
52+
}
53+
}
54+
55+
impl ::fmt::Debug for sigfault_t {
56+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
57+
// TODO: include trapno on Sparc
58+
f.debug_struct("sigfault_t")
59+
.field("addr", &self.addr)
60+
.field("addr_lsb", &self.addr_lsb)
61+
.field("anonymous_union", &self.anonymous_union)
62+
.finish()
63+
}
64+
}
65+
66+
impl ::fmt::Debug for sifields_t {
67+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
68+
// No way to print anything more detailed without the discriminant from siginfo_t
69+
f.debug_struct("sifields_t").finish()
70+
}
71+
}
72+
73+
impl siginfo_t {
74+
pub unsafe fn si_addr(&self) -> *mut ::c_void {
75+
self.sifields.sigfault.addr
76+
}
77+
}
78+
79+
impl ::fmt::Debug for siginfo_t {
80+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
81+
// TODO: include fields from sifields
82+
f.debug_struct("siginfo_t")
83+
.field("si_signo", &self.si_signo)
84+
.field("si_errno", &self.si_errno)
85+
.field("si_code", &self.si_code)
86+
.finish()
87+
}
88+
}
89+
390
s! {
491
pub struct aiocb {
592
pub aio_fildes: ::c_int,
@@ -44,17 +131,6 @@ s! {
44131
pub ss_size: ::size_t
45132
}
46133

47-
pub struct siginfo_t {
48-
pub si_signo: ::c_int,
49-
pub si_errno: ::c_int,
50-
pub si_code: ::c_int,
51-
pub _pad: [::c_int; 29],
52-
#[cfg(target_arch = "x86_64")]
53-
_align: [u64; 0],
54-
#[cfg(not(target_arch = "x86_64"))]
55-
_align: [usize; 0],
56-
}
57-
58134
pub struct glob64_t {
59135
pub gl_pathc: ::size_t,
60136
pub gl_pathv: *mut *mut ::c_char,

0 commit comments

Comments
 (0)