@@ -24,7 +24,6 @@ impl siginfo_t {
24
24
_si_code : :: c_int ,
25
25
si_addr : * mut :: c_void ,
26
26
}
27
-
28
27
( * ( self as * const siginfo_t as * const siginfo_sigfault ) ) . si_addr
29
28
}
30
29
@@ -38,11 +37,72 @@ impl siginfo_t {
38
37
_si_overrun : :: c_int ,
39
38
si_value : :: sigval ,
40
39
}
41
-
42
40
( * ( self as * const siginfo_t as * const siginfo_si_value ) ) . si_value
43
41
}
44
42
}
45
43
44
+ cfg_if ! {
45
+ if #[ cfg( libc_union) ] {
46
+ // Internal, for casts to access union fields
47
+ #[ repr( C ) ]
48
+ struct sifields_sigchld {
49
+ si_pid: :: pid_t,
50
+ si_uid: :: uid_t,
51
+ si_status: :: c_int,
52
+ si_utime: :: c_long,
53
+ si_stime: :: c_long,
54
+ }
55
+ impl :: Copy for sifields_sigchld { }
56
+ impl :: Clone for sifields_sigchld {
57
+ fn clone( & self ) -> sifields_sigchld {
58
+ * self
59
+ }
60
+ }
61
+
62
+ // Internal, for casts to access union fields
63
+ #[ repr( C ) ]
64
+ union sifields {
65
+ _align_pointer: * mut :: c_void,
66
+ sigchld: sifields_sigchld,
67
+ }
68
+
69
+ // Internal, for casts to access union fields. Note that some variants
70
+ // of sifields start with a pointer, which makes the alignment of
71
+ // sifields vary on 32-bit and 64-bit architectures.
72
+ #[ repr( C ) ]
73
+ struct siginfo_f {
74
+ _siginfo_base: [ :: c_int; 3 ] ,
75
+ sifields: sifields,
76
+ }
77
+
78
+ impl siginfo_t {
79
+ unsafe fn sifields( & self ) -> & sifields {
80
+ & ( * ( self as * const siginfo_t as * const siginfo_f) ) . sifields
81
+ }
82
+
83
+ pub unsafe fn si_pid( & self ) -> :: pid_t {
84
+ self . sifields( ) . sigchld. si_pid
85
+ }
86
+
87
+ pub unsafe fn si_uid( & self ) -> :: uid_t {
88
+ self . sifields( ) . sigchld. si_uid
89
+ }
90
+
91
+ pub unsafe fn si_status( & self ) -> :: c_int {
92
+ self . sifields( ) . sigchld. si_status
93
+ }
94
+
95
+ pub unsafe fn si_utime( & self ) -> :: c_long {
96
+ self . sifields( ) . sigchld. si_utime
97
+ }
98
+
99
+ pub unsafe fn si_stime( & self ) -> :: c_long {
100
+ self . sifields( ) . sigchld. si_stime
101
+ }
102
+ }
103
+ }
104
+ }
105
+
46
106
s ! {
47
107
pub struct aiocb {
48
108
pub aio_fildes: :: c_int,
0 commit comments