@@ -197,6 +197,50 @@ e! {
197197 B_UTILITIES_DIRECTORY ,
198198 B_PACKAGE_LINKS_DIRECTORY ,
199199 }
200+
201+ // kernel/OS.h
202+
203+ pub enum topology_level_type {
204+ B_TOPOLOGY_UNKNOWN ,
205+ B_TOPOLOGY_ROOT ,
206+ B_TOPOLOGY_SMT ,
207+ B_TOPOLOGY_CORE ,
208+ B_TOPOLOGY_PACKAGE ,
209+ }
210+
211+ pub enum cpu_platform {
212+ B_CPU_UNKNOWN ,
213+ B_CPU_x86 ,
214+ B_CPU_x86_64 ,
215+ B_CPU_PPC ,
216+ B_CPU_PPC_64 ,
217+ B_CPU_M68K ,
218+ B_CPU_ARM ,
219+ B_CPU_ARM_64 ,
220+ B_CPU_ALPHA ,
221+ B_CPU_MIPS ,
222+ B_CPU_SH ,
223+ B_CPU_SPARC ,
224+ B_CPU_RISC_V
225+ }
226+
227+ pub enum cpu_vendor {
228+ B_CPU_VENDOR_UNKNOWN ,
229+ B_CPU_VENDOR_AMD ,
230+ B_CPU_VENDOR_CYRIX ,
231+ B_CPU_VENDOR_IDT ,
232+ B_CPU_VENDOR_INTEL ,
233+ B_CPU_VENDOR_NATIONAL_SEMICONDUCTOR ,
234+ B_CPU_VENDOR_RISE ,
235+ B_CPU_VENDOR_TRANSMETA ,
236+ B_CPU_VENDOR_VIA ,
237+ B_CPU_VENDOR_IBM ,
238+ B_CPU_VENDOR_MOTOROLA ,
239+ B_CPU_VENDOR_NEC ,
240+ B_CPU_VENDOR_HYGON ,
241+ B_CPU_VENDOR_SUN ,
242+ B_CPU_VENDOR_FUJITSU
243+ }
200244}
201245
202246s ! {
@@ -310,6 +354,19 @@ s! {
310354 pub events: u16
311355 }
312356
357+ pub struct cpu_topology_root_info {
358+ pub platform: cpu_platform,
359+ }
360+
361+ pub struct cpu_topology_package_info {
362+ pub vendor: cpu_vendor,
363+ pub cache_line_size: u32 ,
364+ }
365+
366+ pub struct cpu_topology_core_info {
367+ pub model: u32 ,
368+ pub default_frequency: u64 ,
369+ }
313370 // kernel/fs_attr.h
314371 pub struct attr_info {
315372 pub type_: u32 ,
@@ -412,6 +469,23 @@ s_no_extra_traits! {
412469 pub as_chars: [ :: c_char; 16 ] ,
413470 pub regs: __c_anonymous_regs,
414471 }
472+
473+ #[ cfg( libc_union) ]
474+ pub union __c_anonymous_cpu_topology_info_data {
475+ pub root: cpu_topology_root_info,
476+ pub package: cpu_topology_package_info,
477+ pub core: cpu_topology_core_info,
478+ }
479+
480+ pub struct cpu_topology_node_info {
481+ pub id: u32 ,
482+ pub type_: topology_level_type,
483+ pub level: u32 ,
484+ #[ cfg( libc_union) ]
485+ pub data: __c_anonymous_cpu_topology_info_data,
486+ #[ cfg( not( libc_union) ) ]
487+ pub data: cpu_topology_core_info,
488+ }
415489}
416490
417491cfg_if ! {
@@ -446,6 +520,50 @@ cfg_if! {
446520 }
447521 }
448522 }
523+
524+ #[ cfg( libc_union) ]
525+ impl PartialEq for __c_anonymous_cpu_topology_info_data {
526+ fn eq( & self , other: & __c_anonymous_cpu_topology_info_data) -> bool {
527+ unsafe {
528+ self . root == other. root
529+ || self . package == other. package
530+ || self . core == other. core
531+ }
532+ }
533+ }
534+ #[ cfg( libc_union) ]
535+ impl Eq for __c_anonymous_cpu_topology_info_data { }
536+ #[ cfg( libc_union) ]
537+ impl :: fmt:: Debug for __c_anonymous_cpu_topology_info_data {
538+ fn fmt( & self , f: & mut :: fmt:: Formatter ) -> :: fmt:: Result {
539+ unsafe {
540+ f. debug_struct( "__c_anonymous_cpu_topology_info_data" )
541+ . field( "root" , & self . root)
542+ . field( "package" , & self . package)
543+ . field( "core" , & self . core)
544+ . finish( )
545+ }
546+ }
547+ }
548+
549+ impl PartialEq for cpu_topology_node_info {
550+ fn eq( & self , other: & cpu_topology_node_info) -> bool {
551+ self . id == other. id
552+ && self . type_ == other. type_
553+ && self . level == other. level
554+ }
555+ }
556+
557+ impl Eq for cpu_topology_node_info { }
558+ impl :: fmt:: Debug for cpu_topology_node_info {
559+ fn fmt( & self , f: & mut :: fmt:: Formatter ) -> :: fmt:: Result {
560+ f. debug_struct( "cpu_topology_node_info" )
561+ . field( "id" , & self . id)
562+ . field( "type" , & self . type_)
563+ . field( "level" , & self . level)
564+ . finish( )
565+ }
566+ }
449567 }
450568}
451569
@@ -1026,6 +1144,10 @@ extern "C" {
10261144 info : * mut cpu_info ,
10271145 size : :: size_t ,
10281146 ) -> status_t ;
1147+ pub fn get_cpu_topology_info (
1148+ topologyInfos : * mut cpu_topology_node_info ,
1149+ topologyInfoCount : * mut u32 ,
1150+ ) -> status_t ;
10291151 pub fn is_computer_on ( ) -> i32 ;
10301152 pub fn is_computer_on_fire ( ) -> :: c_double ;
10311153 pub fn send_signal ( threadID : thread_id , signal : :: c_uint ) -> :: c_int ;
0 commit comments