@@ -60,6 +60,11 @@ pub type processor_info_array_t = *mut integer_t;
6060
6161pub type thread_info_t = * mut integer_t ;
6262pub type thread_basic_info_t = * mut thread_basic_info ;
63+ pub type thread_basic_info_data_t = thread_basic_info ;
64+ pub type thread_identifier_info_t = * mut thread_identifier_info ;
65+ pub type thread_identifier_info_data_t = thread_identifier_info ;
66+ pub type thread_extended_info_t = * mut thread_extended_info ;
67+ pub type thread_extended_info_data_t = thread_extended_info ;
6368
6469pub type thread_t = mach_port_t ;
6570pub type thread_policy_flavor_t = natural_t ;
@@ -828,6 +833,26 @@ s_no_extra_traits! {
828833 pub suspend_count: :: integer_t,
829834 pub sleep_time: :: integer_t,
830835 }
836+
837+ pub struct thread_identifier_info {
838+ pub thread_id: u64 ,
839+ pub thread_handle: u64 ,
840+ pub dispatch_qaddr: u64 ,
841+ }
842+
843+ pub struct thread_extended_info {
844+ pub pth_user_time: u64 ,
845+ pub pth_system_time: u64 ,
846+ pub pth_cpu_usage: i32 ,
847+ pub pth_policy: i32 ,
848+ pub pth_run_state: i32 ,
849+ pub pth_flags: i32 ,
850+ pub pth_sleep_time: i32 ,
851+ pub pth_curpri: i32 ,
852+ pub pth_priority: i32 ,
853+ pub pth_maxpriority: i32 ,
854+ pub pth_name: [ :: c_char; MAXTHREADNAMESIZE ] ,
855+ }
831856}
832857
833858impl siginfo_t {
@@ -1603,6 +1628,81 @@ cfg_if! {
16031628 self . sleep_time. hash( state) ;
16041629 }
16051630 }
1631+ impl PartialEq for thread_extended_info {
1632+ fn eq( & self , other: & thread_extended_info) -> bool {
1633+ self . pth_user_time == other. pth_user_time
1634+ && self . pth_system_time == other. pth_system_time
1635+ && self . pth_cpu_usage == other. pth_cpu_usage
1636+ && self . pth_policy == other. pth_policy
1637+ && self . pth_run_state == other. pth_run_state
1638+ && self . pth_flags == other. pth_flags
1639+ && self . pth_sleep_time == other. pth_sleep_time
1640+ && self . pth_curpri == other. pth_curpri
1641+ && self . pth_priority == other. pth_priority
1642+ && self . pth_maxpriority == other. pth_maxpriority
1643+ && self . pth_name
1644+ . iter( )
1645+ . zip( other. pth_name. iter( ) )
1646+ . all( |( a, b) | a == b)
1647+ }
1648+ }
1649+ impl Eq for thread_extended_info { }
1650+ impl :: fmt:: Debug for thread_extended_info {
1651+ fn fmt( & self , f: & mut :: fmt:: Formatter ) -> :: fmt:: Result {
1652+ f. debug_struct( "proc_threadinfo" )
1653+ . field( "pth_user_time" , & self . pth_user_time)
1654+ . field( "pth_system_time" , & self . pth_system_time)
1655+ . field( "pth_cpu_usage" , & self . pth_cpu_usage)
1656+ . field( "pth_policy" , & self . pth_policy)
1657+ . field( "pth_run_state" , & self . pth_run_state)
1658+ . field( "pth_flags" , & self . pth_flags)
1659+ . field( "pth_sleep_time" , & self . pth_sleep_time)
1660+ . field( "pth_curpri" , & self . pth_curpri)
1661+ . field( "pth_priority" , & self . pth_priority)
1662+ . field( "pth_maxpriority" , & self . pth_maxpriority)
1663+ // FIXME: .field("pth_name", &self.pth_name)
1664+ . finish( )
1665+ }
1666+ }
1667+ impl :: hash:: Hash for thread_extended_info {
1668+ fn hash<H : :: hash:: Hasher >( & self , state: & mut H ) {
1669+ self . pth_user_time. hash( state) ;
1670+ self . pth_system_time. hash( state) ;
1671+ self . pth_cpu_usage. hash( state) ;
1672+ self . pth_policy. hash( state) ;
1673+ self . pth_run_state. hash( state) ;
1674+ self . pth_flags. hash( state) ;
1675+ self . pth_sleep_time. hash( state) ;
1676+ self . pth_curpri. hash( state) ;
1677+ self . pth_priority. hash( state) ;
1678+ self . pth_maxpriority. hash( state) ;
1679+ self . pth_name. hash( state) ;
1680+ }
1681+ }
1682+ impl PartialEq for thread_identifier_info {
1683+ fn eq( & self , other: & thread_identifier_info) -> bool {
1684+ self . thread_id == other. thread_id
1685+ && self . thread_handle == other. thread_handle
1686+ && self . dispatch_qaddr == other. dispatch_qaddr
1687+ }
1688+ }
1689+ impl Eq for thread_identifier_info { }
1690+ impl :: fmt:: Debug for thread_identifier_info {
1691+ fn fmt( & self , f: & mut :: fmt:: Formatter ) -> :: fmt:: Result {
1692+ f. debug_struct( "thread_identifier_info" )
1693+ . field( "thread_id" , & self . thread_id)
1694+ . field( "thread_handlee" , & self . thread_handle)
1695+ . field( "dispatch_qaddr" , & self . dispatch_qaddr)
1696+ . finish( )
1697+ }
1698+ }
1699+ impl :: hash:: Hash for thread_identifier_info {
1700+ fn hash<H : :: hash:: Hasher >( & self , state: & mut H ) {
1701+ self . thread_id. hash( state) ;
1702+ self . thread_handle. hash( state) ;
1703+ self . dispatch_qaddr. hash( state) ;
1704+ }
1705+ }
16061706 }
16071707}
16081708
@@ -3618,6 +3718,8 @@ pub const TH_FLAGS_SWAPPED: ::c_int = 0x1;
36183718pub const TH_FLAGS_IDLE : :: c_int = 0x2 ;
36193719pub const TH_FLAGS_GLOBAL_FORCED_IDLE : :: c_int = 0x4 ;
36203720pub const THREAD_BASIC_INFO : :: c_int = 3 ;
3721+ pub const THREAD_IDENTIFIER_INFO : :: c_int = 4 ;
3722+ pub const THREAD_EXTENDED_INFO : :: c_int = 5 ;
36213723
36223724// CommonCrypto/CommonCryptoError.h
36233725pub const kCCSuccess: i32 = 0 ;
@@ -3666,6 +3768,15 @@ cfg_if! {
36663768 pub const THREAD_THROUGHPUT_QOS_POLICY_COUNT : mach_msg_type_number_t =
36673769 ( :: mem:: size_of:: <thread_throughput_qos_policy_data_t>( ) /
36683770 :: mem:: size_of:: <integer_t>( ) ) as mach_msg_type_number_t;
3771+ pub const THREAD_BASIC_INFO_COUNT : mach_msg_type_number_t =
3772+ ( :: mem:: size_of:: <thread_basic_info_data_t>( ) / :: mem:: size_of:: <integer_t>( ) )
3773+ as mach_msg_type_number_t;
3774+ pub const THREAD_IDENTIFIER_INFO_COUNT : mach_msg_type_number_t =
3775+ ( :: mem:: size_of:: <thread_identifier_info_data_t>( ) / :: mem:: size_of:: <integer_t>( ) )
3776+ as mach_msg_type_number_t;
3777+ pub const THREAD_EXTENDED_INFO_COUNT : mach_msg_type_number_t =
3778+ ( :: mem:: size_of:: <thread_extended_info_data_t>( ) / :: mem:: size_of:: <integer_t>( ) )
3779+ as mach_msg_type_number_t;
36693780 } else {
36703781 fn __DARWIN_ALIGN32( p: usize ) -> usize {
36713782 let __DARWIN_ALIGNBYTES32: usize = :: mem:: size_of:: <u32 >( ) - 1 ;
@@ -3678,6 +3789,9 @@ cfg_if! {
36783789 pub const THREAD_BACKGROUND_POLICY_COUNT : mach_msg_type_number_t = 1 ;
36793790 pub const THREAD_LATENCY_QOS_POLICY_COUNT : mach_msg_type_number_t = 1 ;
36803791 pub const THREAD_THROUGHPUT_QOS_POLICY_COUNT : mach_msg_type_number_t = 1 ;
3792+ pub const THREAD_BASIC_INFO_COUNT : mach_msg_type_number_t = 10 ;
3793+ pub const THREAD_IDENTIFIER_INFO_COUNT : mach_msg_type_number_t = 6 ;
3794+ pub const THREAD_EXTENDED_INFO_COUNT : mach_msg_type_number_t = 28 ;
36813795 }
36823796}
36833797
0 commit comments