summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-02-28 00:38:00 +0000
committerbors <bors@rust-lang.org>2021-02-28 00:38:00 +0000
commit1524495dcf85e1f806835a5223dbe10cc15586db (patch)
tree160a59c701215112dbb21d43611569b747f40333
parentadd972649f03a75255dd2bbc5789a1d501beb2e9 (diff)
parent51461b1bbe9b540315fdf9c7078cfb7405139c0a (diff)
downloadrust-libc-1524495dcf85e1f806835a5223dbe10cc15586db.tar.gz
Auto merge of #2082 - landfillbaby:patch-1, r=Amanieu
use GNU/Linux siginfo_t on Android Bionic uses an unchanged siginfo.h from the upstream linux so why not? :) I literally just copied everything with siginfo_t from unix/linux_like/linux/gnu/mod.rs to unix/linux_like/android/mod.rs
-rw-r--r--src/unix/linux_like/android/mod.rs73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs
index dfbef65028..a005ee632f 100644
--- a/src/unix/linux_like/android/mod.rs
+++ b/src/unix/linux_like/android/mod.rs
@@ -2824,6 +2824,17 @@ cfg_if! {
}
impl siginfo_t {
+ pub unsafe fn si_addr(&self) -> *mut ::c_void {
+ #[repr(C)]
+ struct siginfo_sigfault {
+ _si_signo: ::c_int,
+ _si_errno: ::c_int,
+ _si_code: ::c_int,
+ si_addr: *mut ::c_void,
+ }
+ (*(self as *const siginfo_t as *const siginfo_sigfault)).si_addr
+ }
+
pub unsafe fn si_value(&self) -> ::sigval {
#[repr(C)]
struct siginfo_timer {
@@ -2837,3 +2848,65 @@ impl siginfo_t {
(*(self as *const siginfo_t as *const siginfo_timer)).si_sigval
}
}
+
+cfg_if! {
+ if #[cfg(libc_union)] {
+ // Internal, for casts to access union fields
+ #[repr(C)]
+ struct sifields_sigchld {
+ si_pid: ::pid_t,
+ si_uid: ::uid_t,
+ si_status: ::c_int,
+ si_utime: ::c_long,
+ si_stime: ::c_long,
+ }
+ impl ::Copy for sifields_sigchld {}
+ impl ::Clone for sifields_sigchld {
+ fn clone(&self) -> sifields_sigchld {
+ *self
+ }
+ }
+
+ // Internal, for casts to access union fields
+ #[repr(C)]
+ union sifields {
+ _align_pointer: *mut ::c_void,
+ sigchld: sifields_sigchld,
+ }
+
+ // Internal, for casts to access union fields. Note that some variants
+ // of sifields start with a pointer, which makes the alignment of
+ // sifields vary on 32-bit and 64-bit architectures.
+ #[repr(C)]
+ struct siginfo_f {
+ _siginfo_base: [::c_int; 3],
+ sifields: sifields,
+ }
+
+ impl siginfo_t {
+ unsafe fn sifields(&self) -> &sifields {
+ &(*(self as *const siginfo_t as *const siginfo_f)).sifields
+ }
+
+ pub unsafe fn si_pid(&self) -> ::pid_t {
+ self.sifields().sigchld.si_pid
+ }
+
+ pub unsafe fn si_uid(&self) -> ::uid_t {
+ self.sifields().sigchld.si_uid
+ }
+
+ pub unsafe fn si_status(&self) -> ::c_int {
+ self.sifields().sigchld.si_status
+ }
+
+ pub unsafe fn si_utime(&self) -> ::c_long {
+ self.sifields().sigchld.si_utime
+ }
+
+ pub unsafe fn si_stime(&self) -> ::c_long {
+ self.sifields().sigchld.si_stime
+ }
+ }
+ }
+}