@@ -2,6 +2,126 @@ pub type pthread_t = c_ulong;
2
2
pub type __priority_which_t = :: c_uint ;
3
3
pub type __rlimit_resource_t = :: c_uint ;
4
4
5
+ cfg_if ! {
6
+ if #[ cfg( libc_union) ] {
7
+ #[ repr( C ) ]
8
+ #[ derive( Copy , Clone ) ]
9
+ struct addr_bnd_t {
10
+ lower: * mut :: c_void,
11
+ upper: * mut :: c_void,
12
+ }
13
+
14
+ #[ repr( C ) ]
15
+ #[ derive( Copy , Clone ) ]
16
+ union sigfault_t_anonymous_union {
17
+ addr_bnd: addr_bnd_t,
18
+ pkey: u32 ,
19
+ }
20
+
21
+ #[ repr( C ) ]
22
+ #[ derive( Copy , Clone ) ]
23
+ struct sigfault_t {
24
+ addr: * mut :: c_void,
25
+ #[ cfg( target_arch = "sparc" ) ]
26
+ trapno: :: c_int,
27
+ addr_lsb: :: c_short,
28
+ anonymous_union: sigfault_t_anonymous_union,
29
+ }
30
+
31
+ cfg_if! {
32
+ if #[ cfg( target_pointer_width = "64" ) ] {
33
+ type SI_PADDING = [ :: c_int; 28 ] ;
34
+ } else {
35
+ type SI_PADDING = [ :: c_int; 29 ] ;
36
+ }
37
+ }
38
+
39
+ #[ repr( C ) ]
40
+ #[ derive( Copy , Clone ) ]
41
+ union sifields_t {
42
+ _pad: SI_PADDING ,
43
+ sigfault: sigfault_t,
44
+ }
45
+
46
+ impl :: fmt:: Debug for sigfault_t_anonymous_union {
47
+ fn fmt( & self , f: & mut :: fmt:: Formatter ) -> :: fmt:: Result {
48
+ // Excludes the fields because we can't know which is valid
49
+ f. debug_struct( "sigfault_t_anonymous_union" )
50
+ . finish( )
51
+ }
52
+ }
53
+
54
+ impl :: fmt:: Debug for sigfault_t {
55
+ fn fmt( & self , f: & mut :: fmt:: Formatter ) -> :: fmt:: Result {
56
+ // TODO: include trapno on Sparc
57
+ f. debug_struct( "sigfault_t" )
58
+ . field( "addr" , & self . addr)
59
+ . field( "addr_lsb" , & self . addr_lsb)
60
+ . field( "anonymous_union" , & self . anonymous_union)
61
+ . finish( )
62
+ }
63
+ }
64
+
65
+ impl :: fmt:: Debug for sifields_t {
66
+ fn fmt( & self , f: & mut :: fmt:: Formatter ) -> :: fmt:: Result {
67
+ // No way to print anything more detailed without the
68
+ // discriminant from siginfo_t
69
+ f. debug_struct( "sifields_t" ) . finish( )
70
+ }
71
+ }
72
+ } else {
73
+ type sifields_t = [ :: c_int; 29 ] ;
74
+ }
75
+ }
76
+
77
+ s_no_extra_traits ! {
78
+ pub struct siginfo_t {
79
+ pub si_signo: :: c_int,
80
+ pub si_errno: :: c_int,
81
+ pub si_code: :: c_int,
82
+ sifields: sifields_t,
83
+
84
+ #[ cfg( target_arch = "x86_64" ) ]
85
+ _align: [ u64 ; 0 ] ,
86
+ #[ cfg( not( target_arch = "x86_64" ) ) ]
87
+ _align: [ usize ; 0 ] ,
88
+ }
89
+ }
90
+
91
+ cfg_if ! {
92
+ if #[ cfg( libc_union) ] {
93
+ impl siginfo_t {
94
+ pub unsafe fn si_addr( & self ) -> * mut :: c_void {
95
+ self . sifields. sigfault. addr
96
+ }
97
+ }
98
+ } else {
99
+ impl siginfo_t {
100
+ pub unsafe fn si_addr( & self ) -> * mut :: c_void {
101
+ #[ repr( C ) ]
102
+ struct siginfo_sigfault {
103
+ _si_signo: :: c_int,
104
+ _si_errno: :: c_int,
105
+ _si_code: :: c_int,
106
+ si_addr: * mut :: c_void
107
+ }
108
+ ( * ( self as * const siginfo_t as * const siginfo_sigfault) ) . si_addr
109
+ }
110
+ }
111
+ }
112
+ }
113
+
114
+ impl :: fmt:: Debug for siginfo_t {
115
+ fn fmt ( & self , f : & mut :: fmt:: Formatter ) -> :: fmt:: Result {
116
+ // TODO: include fields from sifields
117
+ f. debug_struct ( "siginfo_t" )
118
+ . field ( "si_signo" , & self . si_signo )
119
+ . field ( "si_errno" , & self . si_errno )
120
+ . field ( "si_code" , & self . si_code )
121
+ . finish ( )
122
+ }
123
+ }
124
+
5
125
s ! {
6
126
pub struct statx {
7
127
pub stx_mask: u32 ,
@@ -182,19 +302,6 @@ s! {
182
302
}
183
303
}
184
304
185
- impl siginfo_t {
186
- pub unsafe fn si_addr ( & self ) -> * mut :: c_void {
187
- #[ repr( C ) ]
188
- struct siginfo_sigfault {
189
- _si_signo : :: c_int ,
190
- _si_errno : :: c_int ,
191
- _si_code : :: c_int ,
192
- si_addr : * mut :: c_void
193
- }
194
- ( * ( self as * const siginfo_t as * const siginfo_sigfault ) ) . si_addr
195
- }
196
- }
197
-
198
305
s_no_extra_traits ! {
199
306
pub struct utmpx {
200
307
pub ut_type: :: c_short,
0 commit comments