Merge pull request #1741 from kubo39/patch-CPU_ALLOC_SIZE

Add CPU_ALLOC_SIZE
This commit is contained in:
Yuki Okushi 2020-04-16 09:52:55 +09:00 committed by GitHub
commit 1da0baa684
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2620,6 +2620,12 @@ f! {
}
}
pub fn CPU_ALLOC_SIZE(count: ::c_int) -> ::size_t {
let _dummy: cpu_set_t = ::mem::zeroed();
let size_in_bits = 8 * ::mem::size_of_val(&_dummy.bits[0]);
((count as ::size_t + size_in_bits - 1) / 8) as ::size_t
}
pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () {
for slot in cpuset.bits.iter_mut() {
*slot = 0;