aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 20474af..fa1267c 100644
--- a/src/lib.rs
+++ b/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",