workspace: move crates under crates
This commit is contained in:
parent
0016bc8cf0
commit
6393fdf3c0
354 changed files with 102 additions and 102 deletions
|
|
@ -1,20 +0,0 @@
|
|||
use {
|
||||
crate::oserror::{OsError, OsErrorExt},
|
||||
smallvec::{SmallVec, smallvec_inline},
|
||||
uapi::c,
|
||||
};
|
||||
|
||||
pub fn num_cpus() -> Result<u32, OsError> {
|
||||
let mut buf: SmallVec<[usize; 32]> = smallvec_inline![0; 32];
|
||||
loop {
|
||||
match uapi::sched_getaffinity(0, &mut buf).to_os_error() {
|
||||
Ok(_) => return Ok(count(&buf)),
|
||||
Err(OsError(c::EINVAL)) => buf.extend_from_slice(&[0; 32][..]),
|
||||
Err(e) => return Err(e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn count(buf: &[usize]) -> u32 {
|
||||
buf.iter().copied().map(|n| n.count_ones()).sum()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue