We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fd9bf59 commit 25b3751Copy full SHA for 25b3751
library/std/src/sys/unix/thread.rs
@@ -344,6 +344,29 @@ pub fn available_parallelism() -> io::Result<NonZeroUsize> {
344
}
345
346
347
+ #[cfg(target_os = "netbsd")]
348
+ {
349
+ unsafe {
350
+ let set = libc::_cpuset_create();
351
+ if !set.is_null() {
352
+ let mut count: usize = 0;
353
+ if libc::pthread_getaffinity_np(libc::pthread_self(), libc::_cpuset_size(set), set) == 0 {
354
+ for i in 0..u64::MAX {
355
+ match libc::_cpuset_isset(i, set) {
356
+ -1 => break,
357
+ 0 => continue,
358
+ _ => count = count + 1,
359
+ }
360
361
362
+ libc::_cpuset_destroy(set);
363
+ if let Some(count) = NonZeroUsize::new(count) {
364
+ return Ok(count);
365
366
367
368
369
+
370
let mut cpus: libc::c_uint = 0;
371
let mut cpus_size = crate::mem::size_of_val(&cpus);
372
0 commit comments