about summary refs log tree commit diff
path: root/library/std/src/sys
diff options
context:
space:
mode:
authorDavid Carlier <devnexen@gmail.com>2021-09-27 18:51:52 +0100
committerDavid Carlier <devnexen@gmail.com>2021-09-27 18:51:52 +0100
commit5d4048b66fa42ad44947bb004fdb7f8141ea65a2 (patch)
tree7d2bce84c69eeea74a9ee4cae78b496fd518b9d2 /library/std/src/sys
parent2b6ed3b675475abc01ce7e68bb75b457f0c85684 (diff)
downloadrust-5d4048b66fa42ad44947bb004fdb7f8141ea65a2.tar.gz
rust-5d4048b66fa42ad44947bb004fdb7f8141ea65a2.zip
thread: implements available_concurrency on haiku
Diffstat (limited to 'library/std/src/sys')
-rw-r--r--library/std/src/sys/unix/thread.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/library/std/src/sys/unix/thread.rs b/library/std/src/sys/unix/thread.rs
index 133ad3ea420..05f51a46168 100644
--- a/library/std/src/sys/unix/thread.rs
+++ b/library/std/src/sys/unix/thread.rs
@@ -338,8 +338,17 @@ pub fn available_concurrency() -> io::Result<NonZeroUsize> {
             }
 
             Ok(unsafe { NonZeroUsize::new_unchecked(cpus as usize) })
+        } else if #[cfg(target_os = "haiku")] {
+            let mut sinfo: libc::system_info = crate::mem::zeroed();
+            let res = libc::get_system_info(&mut sinfo);
+
+            if res != libc::B_OK {
+                return Err(io::Error::last_os_error());
+            }
+
+            Ok(unsafe { NonZeroUsize::new_unchecked(sinfo.cpu_count as usize) })
         } else {
-            // FIXME: implement on vxWorks, Redox, Haiku, l4re
+            // FIXME: implement on vxWorks, Redox, l4re
             Err(io::Error::new_const(io::ErrorKind::Unsupported, &"Getting the number of hardware threads is not supported on the target platform"))
         }
     }