Skip to content

Commit 1524495

Browse files
committed
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
2 parents add9726 + 51461b1 commit 1524495

File tree

1 file changed

+73
-0
lines changed
  • src/unix/linux_like/android

1 file changed

+73
-0
lines changed

src/unix/linux_like/android/mod.rs

+73
Original file line numberDiff line numberDiff line change
@@ -2824,6 +2824,17 @@ cfg_if! {
28242824
}
28252825

28262826
impl siginfo_t {
2827+
pub unsafe fn si_addr(&self) -> *mut ::c_void {
2828+
#[repr(C)]
2829+
struct siginfo_sigfault {
2830+
_si_signo: ::c_int,
2831+
_si_errno: ::c_int,
2832+
_si_code: ::c_int,
2833+
si_addr: *mut ::c_void,
2834+
}
2835+
(*(self as *const siginfo_t as *const siginfo_sigfault)).si_addr
2836+
}
2837+
28272838
pub unsafe fn si_value(&self) -> ::sigval {
28282839
#[repr(C)]
28292840
struct siginfo_timer {
@@ -2837,3 +2848,65 @@ impl siginfo_t {
28372848
(*(self as *const siginfo_t as *const siginfo_timer)).si_sigval
28382849
}
28392850
}
2851+
2852+
cfg_if! {
2853+
if #[cfg(libc_union)] {
2854+
// Internal, for casts to access union fields
2855+
#[repr(C)]
2856+
struct sifields_sigchld {
2857+
si_pid: ::pid_t,
2858+
si_uid: ::uid_t,
2859+
si_status: ::c_int,
2860+
si_utime: ::c_long,
2861+
si_stime: ::c_long,
2862+
}
2863+
impl ::Copy for sifields_sigchld {}
2864+
impl ::Clone for sifields_sigchld {
2865+
fn clone(&self) -> sifields_sigchld {
2866+
*self
2867+
}
2868+
}
2869+
2870+
// Internal, for casts to access union fields
2871+
#[repr(C)]
2872+
union sifields {
2873+
_align_pointer: *mut ::c_void,
2874+
sigchld: sifields_sigchld,
2875+
}
2876+
2877+
// Internal, for casts to access union fields. Note that some variants
2878+
// of sifields start with a pointer, which makes the alignment of
2879+
// sifields vary on 32-bit and 64-bit architectures.
2880+
#[repr(C)]
2881+
struct siginfo_f {
2882+
_siginfo_base: [::c_int; 3],
2883+
sifields: sifields,
2884+
}
2885+
2886+
impl siginfo_t {
2887+
unsafe fn sifields(&self) -> &sifields {
2888+
&(*(self as *const siginfo_t as *const siginfo_f)).sifields
2889+
}
2890+
2891+
pub unsafe fn si_pid(&self) -> ::pid_t {
2892+
self.sifields().sigchld.si_pid
2893+
}
2894+
2895+
pub unsafe fn si_uid(&self) -> ::uid_t {
2896+
self.sifields().sigchld.si_uid
2897+
}
2898+
2899+
pub unsafe fn si_status(&self) -> ::c_int {
2900+
self.sifields().sigchld.si_status
2901+
}
2902+
2903+
pub unsafe fn si_utime(&self) -> ::c_long {
2904+
self.sifields().sigchld.si_utime
2905+
}
2906+
2907+
pub unsafe fn si_stime(&self) -> ::c_long {
2908+
self.sifields().sigchld.si_stime
2909+
}
2910+
}
2911+
}
2912+
}

0 commit comments

Comments
 (0)