Skip to content

Commit

Permalink
Add host_cpu_load_info on Apple
Browse files Browse the repository at this point in the history
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;
```

(backport <rust-lang#3916>)
(cherry picked from commit f31fe2a)
  • Loading branch information
stepancheg authored and tgross35 committed Nov 7, 2024
1 parent 7f24222 commit 7064f6c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libc-test/semver/apple.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1983,6 +1983,9 @@ getxattr
glob
glob_t
globfree
host_cpu_load_info
host_cpu_load_info_data_t
host_cpu_load_info_t
iconv
iconv_close
iconv_open
Expand Down
10 changes: 10 additions & 0 deletions src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ pub type ledger_array_t = *mut ::ledger_t;

pub type iconv_t = *mut ::c_void;

// mach/host_info.h
pub type host_cpu_load_info_t = *mut host_cpu_load_info;
pub type host_cpu_load_info_data_t = host_cpu_load_info;

// mach/processor_info.h
pub type processor_cpu_load_info_t = *mut processor_cpu_load_info;
pub type processor_cpu_load_info_data_t = processor_cpu_load_info;
pub type processor_basic_info_t = *mut processor_basic_info;
Expand Down Expand Up @@ -1189,6 +1194,11 @@ s! {
pub tcpi_rxoutoforderbytes: u64,
pub tcpi_rxretransmitpackets: u64,
}

// mach/host_info.h
pub struct host_cpu_load_info {
pub cpu_ticks: [::natural_t; CPU_STATE_MAX as usize],
}
}

s_no_extra_traits! {
Expand Down

0 comments on commit 7064f6c

Please sign in to comment.