Skip to content

Commit 65efdc3

Browse files
committed
Add host_cpu_load_info on Apple
Snippet from `host_info.h`: ``` struct host_cpu_load_info { /* number of ticks while running... */ natural_t cpu_ticks[CPU_STATE_MAX]; /* ... in the given mode */ }; typedef struct host_cpu_load_info host_cpu_load_info_data_t; typedef struct host_cpu_load_info *host_cpu_load_info_t; ```
1 parent 2c0250f commit 65efdc3

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

libc-test/semver/apple.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,6 +1874,9 @@ getxattr
18741874
glob
18751875
glob_t
18761876
globfree
1877+
host_cpu_load_info
1878+
host_cpu_load_info_data_t
1879+
host_cpu_load_info_t
18771880
icmp6_ifstat
18781881
iconv_t
18791882
id_t

src/unix/bsd/apple/mod.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ pub type ledger_array_t = *mut ::ledger_t;
7373

7474
pub type iconv_t = *mut ::c_void;
7575

76+
// mach/host_info.h
77+
pub type host_cpu_load_info_t = *mut host_cpu_load_info;
78+
pub type host_cpu_load_info_data_t = host_cpu_load_info;
79+
80+
// mach/processor_info.h
7681
pub type processor_cpu_load_info_t = *mut processor_cpu_load_info;
7782
pub type processor_cpu_load_info_data_t = processor_cpu_load_info;
7883
pub type processor_basic_info_t = *mut processor_basic_info;
@@ -1338,6 +1343,10 @@ s_no_extra_traits! {
13381343
pub sigev_notify_attributes: *mut ::pthread_attr_t
13391344
}
13401345

1346+
pub struct host_cpu_load_info {
1347+
pub cpu_ticks: [::natural_t; CPU_STATE_MAX as usize],
1348+
}
1349+
13411350
pub struct processor_cpu_load_info {
13421351
pub cpu_ticks: [::c_uint; CPU_STATE_MAX as usize],
13431352
}
@@ -2180,6 +2189,25 @@ cfg_if! {
21802189
}
21812190
}
21822191

2192+
impl PartialEq for host_cpu_load_info {
2193+
fn eq(&self, other: &host_cpu_load_info) -> bool {
2194+
self.cpu_ticks == other.cpu_ticks
2195+
}
2196+
}
2197+
impl Eq for host_cpu_load_info {}
2198+
impl ::fmt::Debug for host_cpu_load_info {
2199+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
2200+
f.debug_struct("host_cpu_load_info")
2201+
.field("cpu_ticks", &self.cpu_ticks)
2202+
.finish()
2203+
}
2204+
}
2205+
impl ::hash::Hash for host_cpu_load_info {
2206+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
2207+
self.cpu_ticks.hash(state);
2208+
}
2209+
}
2210+
21832211
impl PartialEq for processor_cpu_load_info {
21842212
fn eq(&self, other: &processor_cpu_load_info) -> bool {
21852213
self.cpu_ticks == other.cpu_ticks

0 commit comments

Comments
 (0)