@@ -313,6 +313,63 @@ impl siginfo_t {
313313 }
314314}
315315
316+ cfg_if ! {
317+ if #[ cfg( libc_union) ] {
318+ // Internal, for casts to access union fields
319+ #[ repr( C ) ]
320+ #[ derive( Copy , Clone ) ]
321+ struct sifields_sigchld {
322+ si_pid: :: pid_t,
323+ si_uid: :: uid_t,
324+ si_status: :: c_int,
325+ si_utime: :: c_long,
326+ si_stime: :: c_long,
327+ }
328+
329+ // Internal, for casts to access union fields
330+ #[ repr( C ) ]
331+ union sifields {
332+ _align_pointer: * mut :: c_void,
333+ sigchld: sifields_sigchld,
334+ }
335+
336+ // Internal, for casts to access union fields. Note that some variants
337+ // of sifields start with a pointer, which makes the alignment of
338+ // sifields vary on 32-bit and 64-bit architectures.
339+ #[ repr( C ) ]
340+ struct siginfo_f {
341+ _siginfo_base: [ :: c_int; 3 ] ,
342+ sifields: sifields,
343+ }
344+
345+ impl siginfo_t {
346+ unsafe fn sifields( & self ) -> & sifields {
347+ & ( * ( self as * const siginfo_t as * const siginfo_f) ) . sifields
348+ }
349+
350+ pub unsafe fn si_pid( & self ) -> :: pid_t {
351+ self . sifields( ) . sigchld. si_pid
352+ }
353+
354+ pub unsafe fn si_uid( & self ) -> :: uid_t {
355+ self . sifields( ) . sigchld. si_uid
356+ }
357+
358+ pub unsafe fn si_status( & self ) -> :: c_int {
359+ self . sifields( ) . sigchld. si_status
360+ }
361+
362+ pub unsafe fn si_utime( & self ) -> :: c_long {
363+ self . sifields( ) . sigchld. si_utime
364+ }
365+
366+ pub unsafe fn si_stime( & self ) -> :: c_long {
367+ self . sifields( ) . sigchld. si_stime
368+ }
369+ }
370+ }
371+ }
372+
316373s_no_extra_traits ! {
317374 pub struct utmpx {
318375 pub ut_type: :: c_short,
0 commit comments