Skip to content

Commit e74d544

Browse files
devnexenAndy-Python-Programmer
authored andcommitted
linux/uclibc completing siginfo fields.
close rust-lang#3529
1 parent 8b9349e commit e74d544

File tree

1 file changed

+58
-0
lines changed
  • src/unix/linux_like/linux/uclibc

1 file changed

+58
-0
lines changed

src/unix/linux_like/linux/uclibc/mod.rs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,64 @@ impl siginfo_t {
107107
}
108108
}
109109

110+
// Internal, for casts to access union fields
111+
#[repr(C)]
112+
struct sifields_sigchld {
113+
si_pid: ::pid_t,
114+
si_uid: ::uid_t,
115+
si_status: ::c_int,
116+
si_utime: ::c_long,
117+
si_stime: ::c_long,
118+
}
119+
impl ::Copy for sifields_sigchld {}
120+
impl ::Clone for sifields_sigchld {
121+
fn clone(&self) -> sifields_sigchld {
122+
*self
123+
}
124+
}
125+
126+
// Internal, for casts to access union fields
127+
#[repr(C)]
128+
union sifields {
129+
_align_pointer: *mut ::c_void,
130+
sigchld: sifields_sigchld,
131+
}
132+
133+
// Internal, for casts to access union fields. Note that some variants
134+
// of sifields start with a pointer, which makes the alignment of
135+
// sifields vary on 32-bit and 64-bit architectures.
136+
#[repr(C)]
137+
struct siginfo_f {
138+
_siginfo_base: [::c_int; 3],
139+
sifields: sifields,
140+
}
141+
142+
impl siginfo_t {
143+
unsafe fn sifields(&self) -> &sifields {
144+
&(*(self as *const siginfo_t as *const siginfo_f)).sifields
145+
}
146+
147+
pub unsafe fn si_pid(&self) -> ::pid_t {
148+
self.sifields().sigchld.si_pid
149+
}
150+
151+
pub unsafe fn si_uid(&self) -> ::uid_t {
152+
self.sifields().sigchld.si_uid
153+
}
154+
155+
pub unsafe fn si_status(&self) -> ::c_int {
156+
self.sifields().sigchld.si_status
157+
}
158+
159+
pub unsafe fn si_utime(&self) -> ::c_long {
160+
self.sifields().sigchld.si_utime
161+
}
162+
163+
pub unsafe fn si_stime(&self) -> ::c_long {
164+
self.sifields().sigchld.si_stime
165+
}
166+
}
167+
110168
pub const MCL_CURRENT: ::c_int = 0x0001;
111169
pub const MCL_FUTURE: ::c_int = 0x0002;
112170
pub const MCL_ONFAULT: ::c_int = 0x0004;

0 commit comments

Comments
 (0)