diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:31 +0000 |
commit | dc0db358abe19481e475e10c32149b53370f1a1c (patch) | |
tree | ab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/num_cpus/src/lib.rs | |
parent | Releasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff) | |
download | rustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip |
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/num_cpus/src/lib.rs')
-rw-r--r-- | vendor/num_cpus/src/lib.rs | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/vendor/num_cpus/src/lib.rs b/vendor/num_cpus/src/lib.rs index 20474af4b..fa1267c66 100644 --- a/vendor/num_cpus/src/lib.rs +++ b/vendor/num_cpus/src/lib.rs @@ -110,7 +110,12 @@ pub fn get_physical() -> usize { } -#[cfg(not(any(target_os = "linux", target_os = "windows", target_os="macos", target_os="openbsd")))] +#[cfg(not(any( + target_os = "linux", + target_os = "windows", + target_os = "macos", + target_os = "openbsd", + target_os = "aix")))] #[inline] fn get_num_physical_cpus() -> usize { // Not implemented, fall back @@ -327,11 +332,31 @@ fn get_num_physical_cpus() -> usize { cpus as usize } +#[cfg(target_os = "aix")] +fn get_num_physical_cpus() -> usize { + match get_smt_threads_aix() { + Some(num) => get_num_cpus() / num, + None => get_num_cpus(), + } +} + +#[cfg(target_os = "aix")] +fn get_smt_threads_aix() -> Option<usize> { + let smt = unsafe { + libc::getsystemcfg(libc::SC_SMT_TC) + }; + if smt == u64::MAX { + return None; + } + Some(smt as usize) +} + #[cfg(any( target_os = "nacl", target_os = "macos", target_os = "ios", target_os = "android", + target_os = "aix", target_os = "solaris", target_os = "illumos", target_os = "fuchsia") @@ -413,6 +438,7 @@ fn get_num_cpus() -> usize { target_os = "macos", target_os = "ios", target_os = "android", + target_os = "aix", target_os = "solaris", target_os = "illumos", target_os = "fuchsia", |