Skip to content

explicit use libc to refer to HW_NCPU #30525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 25, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/libtest/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -923,21 +923,21 @@ fn get_concurrency() -> usize {
target_os = "netbsd"))]
fn num_cpus() -> usize {
let mut cpus: libc::c_uint = 0;
let mut CPUS_SIZE = std::mem::size_of_val(&cpus);
let mut cpus_size = std::mem::size_of_val(&cpus);
let mut mib = [libc::CTL_HW, libc::HW_AVAILCPU, 0, 0];

unsafe {
libc::sysctl(mib.as_mut_ptr(), 2,
&mut cpus as *mut _ as *mut _,
&mut CPUS_SIZE as *mut _ as *mut _,
&mut cpus_size as *mut _ as *mut _,
0 as *mut _, 0);
}
if cpus < 1 {
mib[1] = HW_NCPU;
mib[1] = libc::HW_NCPU;
unsafe {
libc::sysctl(mib.as_mut_ptr(), 2,
&mut cpus as *mut _ as *mut _,
&mut CPUS_SIZE as *mut _ as *mut _,
&mut cpus_size as *mut _ as *mut _,
0 as *mut _, 0);
}
if cpus < 1 {
Expand Down