mirror of
https://github.com/allankoechke/rust.git
synced 2026-11-30 11:05:36 +00:00
Revert "Rollup merge of #120589 - devnexen:cpuaff_fbsd_upd, r=clarfonthey"
This reverts commit0a4206a714, reversing changes made to8f3a9a1017.
This commit is contained in:
@@ -162,7 +162,6 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> {
|
||||
target_os = "hurd",
|
||||
target_os = "linux",
|
||||
target_os = "aix",
|
||||
target_os = "freebsd",
|
||||
target_vendor = "apple",
|
||||
target_os = "cygwin",
|
||||
target_os = "redox",
|
||||
@@ -175,17 +174,9 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> {
|
||||
#[cfg(any(target_os = "android", target_os = "linux"))]
|
||||
{
|
||||
quota = cgroups::quota().max(1);
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "android", target_os = "linux", target_os = "freebsd"))]
|
||||
{
|
||||
#[cfg(not(target_os = "freebsd"))]
|
||||
type Cpuset = libc::cpu_set_t;
|
||||
#[cfg(target_os = "freebsd")]
|
||||
type Cpuset = libc::cpuset_t;
|
||||
let mut set: Cpuset = unsafe { mem::zeroed() };
|
||||
let mut set: libc::cpu_set_t = unsafe { mem::zeroed() };
|
||||
unsafe {
|
||||
if libc::sched_getaffinity(0, size_of::<Cpuset>(), &mut set) == 0 {
|
||||
if libc::sched_getaffinity(0, size_of::<libc::cpu_set_t>(), &mut set) == 0 {
|
||||
let count = libc::CPU_COUNT(&set) as usize;
|
||||
let count = count.min(quota);
|
||||
|
||||
@@ -210,9 +201,34 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> {
|
||||
}
|
||||
}
|
||||
}
|
||||
any(target_os = "dragonfly", target_os = "openbsd", target_os = "netbsd") => {
|
||||
any(
|
||||
target_os = "freebsd",
|
||||
target_os = "dragonfly",
|
||||
target_os = "openbsd",
|
||||
target_os = "netbsd",
|
||||
) => {
|
||||
use crate::ptr;
|
||||
|
||||
#[cfg(target_os = "freebsd")]
|
||||
{
|
||||
let mut set: libc::cpuset_t = unsafe { mem::zeroed() };
|
||||
unsafe {
|
||||
if libc::cpuset_getaffinity(
|
||||
libc::CPU_LEVEL_WHICH,
|
||||
libc::CPU_WHICH_PID,
|
||||
-1,
|
||||
size_of::<libc::cpuset_t>(),
|
||||
&mut set,
|
||||
) == 0
|
||||
{
|
||||
let count = libc::CPU_COUNT(&set) as usize;
|
||||
if count > 0 {
|
||||
return Ok(NonZero::new_unchecked(count));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "netbsd")]
|
||||
{
|
||||
unsafe {
|
||||
|
||||
Reference in New Issue
Block a user