@@ -882,12 +882,6 @@ s! {
882882 pub profhz: :: c_int,
883883 }
884884
885- #[ cfg( libc_union) ]
886- pub struct __c_anonymous_sigev_thread {
887- pub _function: * mut :: c_void, // Actually a function pointer
888- pub _attribute: * mut :: pthread_attr_t,
889- }
890-
891885 pub struct __c_anonymous_stailq_entry_devstat {
892886 pub stqe_next: * mut devstat,
893887 }
@@ -1325,25 +1319,6 @@ s! {
13251319 pub strchange_instrms: u16 ,
13261320 pub strchange_outstrms: u16 ,
13271321 }
1328-
1329- // When sigevent was first added to libc, Rust still didn't support unions.
1330- // So the definition only included one of the union's member. This
1331- // structure exists for backwards-compatibility with consumers that still
1332- // try to access that one member.
1333- #[ doc( hidden) ]
1334- #[ deprecated(
1335- since = "0.2.127" ,
1336- note = "Use sigevent instead"
1337- ) ]
1338- pub struct sigevent_0_2_126 {
1339- pub sigev_notify: :: c_int,
1340- pub sigev_signo: :: c_int,
1341- pub sigev_value: :: sigval,
1342- pub sigev_notify_thread_id: :: lwpid_t,
1343- #[ cfg( target_pointer_width = "64" ) ]
1344- __unused1: :: c_int,
1345- __unused2: [ :: c_long; 7 ]
1346- }
13471322}
13481323
13491324s_no_extra_traits ! {
@@ -1394,30 +1369,6 @@ s_no_extra_traits! {
13941369 __reserved: [ :: c_long; 4 ]
13951370 }
13961371
1397- // Can't correctly impl Debug for unions
1398- #[ allow( missing_debug_implementations) ]
1399- #[ cfg( libc_union) ]
1400- pub union __c_anonymous_sigev_un {
1401- pub _threadid: :: __lwpid_t,
1402- pub _sigev_thread: __c_anonymous_sigev_thread,
1403- pub _kevent_flags: :: c_ushort,
1404- __spare__: [ :: c_long; 8 ] ,
1405- }
1406-
1407- #[ cfg( libc_union) ]
1408- pub struct sigevent {
1409- pub sigev_notify: :: c_int,
1410- pub sigev_signo: :: c_int,
1411- pub sigev_value: :: sigval,
1412- pub _sigev_un: __c_anonymous_sigev_un,
1413- /// Exists just to prevent the struct from being safely constructed,
1414- /// because the Debug, Hash, PartialImpl, and
1415- /// Deref<Target=sigevent_0_2_0126> trait impls might read uninitialized
1416- /// fields of _sigev_un. This field may be removed once those trait
1417- /// impls are.
1418- _private: ( )
1419- }
1420-
14211372 pub struct ptsstat {
14221373 #[ cfg( any( freebsd12, freebsd13, freebsd14) ) ]
14231374 pub dev: u64 ,
@@ -1650,7 +1601,79 @@ s_no_extra_traits! {
16501601 }
16511602}
16521603
1604+ #[ cfg( libc_union) ]
1605+ s ! {
1606+ pub struct __c_anonymous_sigev_thread {
1607+ pub _function: * mut :: c_void, // Actually a function pointer
1608+ pub _attribute: * mut :: pthread_attr_t,
1609+ }
1610+
1611+ // When sigevent was first added to libc, Rust still didn't support unions.
1612+ // So the definition only included one of the union's member. This
1613+ // structure exists for backwards-compatibility with consumers that still
1614+ // try to access that one member.
1615+ #[ doc( hidden) ]
1616+ #[ deprecated(
1617+ since = "0.2.147" ,
1618+ note = "Use sigevent instead"
1619+ ) ]
1620+ pub struct sigevent_0_2_126 {
1621+ pub sigev_notify: :: c_int,
1622+ pub sigev_signo: :: c_int,
1623+ pub sigev_value: :: sigval,
1624+ pub sigev_notify_thread_id: :: lwpid_t,
1625+ #[ cfg( target_pointer_width = "64" ) ]
1626+ __unused1: :: c_int,
1627+ __unused2: [ :: c_long; 7 ]
1628+ }
1629+ }
1630+
1631+ #[ cfg( libc_union) ]
1632+ s_no_extra_traits ! {
1633+ // Can't correctly impl Debug for unions
1634+ #[ allow( missing_debug_implementations) ]
1635+ pub union __c_anonymous_sigev_un {
1636+ pub _threadid: :: __lwpid_t,
1637+ pub _sigev_thread: __c_anonymous_sigev_thread,
1638+ pub _kevent_flags: :: c_ushort,
1639+ __spare__: [ :: c_long; 8 ] ,
1640+ }
1641+
1642+ pub struct sigevent {
1643+ pub sigev_notify: :: c_int,
1644+ pub sigev_signo: :: c_int,
1645+ pub sigev_value: :: sigval,
1646+ pub _sigev_un: __c_anonymous_sigev_un,
1647+ /// Exists just to prevent the struct from being safely constructed,
1648+ /// because the Debug, Hash, PartialImpl, and
1649+ /// Deref<Target=sigevent_0_2_126> trait impls might read uninitialized
1650+ /// fields of _sigev_un. This field may be removed once those trait
1651+ /// impls are.
1652+ _private: ( )
1653+ }
1654+ }
1655+
1656+ #[ cfg( not( libc_union) ) ]
1657+ s_no_extra_traits ! {
1658+ pub struct sigevent {
1659+ pub sigev_notify: :: c_int,
1660+ pub sigev_signo: :: c_int,
1661+ pub sigev_value: :: sigval,
1662+ pub _unused0: :: lwpid_t,
1663+ #[ cfg( target_pointer_width = "64" ) ]
1664+ __unused1: :: c_int,
1665+ __unused2: [ :: c_long; 7 ] ,
1666+ /// Exists just to prevent the struct from being safely constructed,
1667+ /// because the Debug, Hash, PartialImpl, and
1668+ /// Deref<Target=sigevent_0_2_126> trait impls might read uninitialized
1669+ /// fields of _sigev_un. This field may be removed once those trait
1670+ /// impls are.
1671+ _private: ( )
1672+ }
1673+ }
1674+
16531675#[ allow( deprecated) ]
1676+ #[ cfg( libc_union) ]
16541677impl :: core:: ops:: Deref for sigevent {
16551678 type Target = sigevent_0_2_126 ;
16561679
@@ -1660,6 +1683,7 @@ impl ::core::ops::Deref for sigevent {
16601683}
16611684
16621685#[ allow( deprecated) ]
1686+ #[ cfg( libc_union) ]
16631687impl :: core:: ops:: DerefMut for sigevent {
16641688 fn deref_mut ( & mut self ) -> & mut Self :: Target {
16651689 unsafe { & mut * ( self as * mut Self as * mut sigevent_0_2_126 ) }
@@ -1855,6 +1879,7 @@ cfg_if! {
18551879 }
18561880 }
18571881
1882+ #[ cfg( libc_union) ]
18581883 impl PartialEq for sigevent {
18591884 fn eq( & self , other: & sigevent) -> bool {
18601885 self . sigev_notify == other. sigev_notify
@@ -1880,13 +1905,22 @@ cfg_if! {
18801905 }
18811906 }
18821907 }
1908+ #[ cfg( not( libc_union) ) ]
1909+ impl PartialEq for sigevent {
1910+ fn eq( & self , other: & sigevent) -> bool {
1911+ self . sigev_notify == other. sigev_notify
1912+ && self . sigev_signo == other. sigev_signo
1913+ && self . sigev_value == other. sigev_value
1914+ }
1915+ }
18831916 impl Eq for sigevent { }
18841917 impl :: fmt:: Debug for sigevent {
18851918 fn fmt( & self , f: & mut :: fmt:: Formatter ) -> :: fmt:: Result {
18861919 let mut ds = f. debug_struct( "sigevent" ) ;
18871920 ds. field( "sigev_notify" , & self . sigev_notify) ;
18881921 ds. field( "sigev_signo" , & self . sigev_signo) ;
18891922 ds. field( "sigev_value" , & self . sigev_value) ;
1923+ #[ cfg( libc_union) ]
18901924 // The sigev_notify field indicates which union fields are valid
18911925 unsafe {
18921926 match self . sigev_notify {
@@ -1907,6 +1941,7 @@ cfg_if! {
19071941 self . sigev_notify. hash( state) ;
19081942 self . sigev_signo. hash( state) ;
19091943 self . sigev_value. hash( state) ;
1944+ #[ cfg( libc_union) ]
19101945 // The sigev_notify field indicates which union fields are valid
19111946 unsafe {
19121947 match self . sigev_notify {
0 commit comments