diff options
| author | bors <bors@rust-lang.org> | 2023-06-16 21:14:24 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-06-16 21:14:24 +0000 |
| commit | 670a0edaa9d80683df8db81554890710e79f8024 (patch) | |
| tree | 4bbbcd5f4ab51712cefa538eeaed165118fc94b9 /library/std/src/sys | |
| parent | 6bba061467f7c2cab04b262b95eb67bf89265587 (diff) | |
| parent | 56c96d755262be18788191c1f6cddeeae7911379 (diff) | |
| download | rust-670a0edaa9d80683df8db81554890710e79f8024.tar.gz rust-670a0edaa9d80683df8db81554890710e79f8024.zip | |
Auto merge of #112716 - compiler-errors:rollup-h77daia, r=compiler-errors
Rollup of 7 pull requests Successful merges: - #111074 (Relax implicit `T: Sized` bounds on `BufReader<T>`, `BufWriter<T>` and `LineWriter<T>`) - #112226 (std: available_parallelism using native netbsd api first) - #112474 (Support 128-bit enum variant in debuginfo codegen) - #112662 (`#[lang_item]` for `core::ptr::Unique`) - #112665 (Make assumption functions in new solver take `Binder<'tcx, Clause<'tcx>>`) - #112684 (Disable alignment checks on i686-pc-windows-msvc) - #112706 (Add `SyntaxContext::is_root`) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library/std/src/sys')
| -rw-r--r-- | library/std/src/sys/unix/kernel_copy.rs | 4 | ||||
| -rw-r--r-- | library/std/src/sys/unix/thread.rs | 23 |
2 files changed, 25 insertions, 2 deletions
diff --git a/library/std/src/sys/unix/kernel_copy.rs b/library/std/src/sys/unix/kernel_copy.rs index 16c8e0c0ebf..7d49bbdcbe0 100644 --- a/library/std/src/sys/unix/kernel_copy.rs +++ b/library/std/src/sys/unix/kernel_copy.rs @@ -466,7 +466,7 @@ impl<T: CopyRead> CopyRead for Take<T> { } } -impl<T: CopyRead> CopyRead for BufReader<T> { +impl<T: ?Sized + CopyRead> CopyRead for BufReader<T> { fn drain_to<W: Write>(&mut self, writer: &mut W, outer_limit: u64) -> Result<u64> { let buf = self.buffer(); let buf = &buf[0..min(buf.len(), outer_limit.try_into().unwrap_or(usize::MAX))]; @@ -495,7 +495,7 @@ impl<T: CopyRead> CopyRead for BufReader<T> { } } -impl<T: CopyWrite> CopyWrite for BufWriter<T> { +impl<T: ?Sized + CopyWrite> CopyWrite for BufWriter<T> { fn properties(&self) -> CopyParams { self.get_ref().properties() } diff --git a/library/std/src/sys/unix/thread.rs b/library/std/src/sys/unix/thread.rs index 878af5088d9..010015667f7 100644 --- a/library/std/src/sys/unix/thread.rs +++ b/library/std/src/sys/unix/thread.rs @@ -344,6 +344,29 @@ pub fn available_parallelism() -> io::Result<NonZeroUsize> { } } + #[cfg(target_os = "netbsd")] + { + unsafe { + let set = libc::_cpuset_create(); + if !set.is_null() { + let mut count: usize = 0; + if libc::pthread_getaffinity_np(libc::pthread_self(), libc::_cpuset_size(set), set) == 0 { + for i in 0..u64::MAX { + match libc::_cpuset_isset(i, set) { + -1 => break, + 0 => continue, + _ => count = count + 1, + } + } + } + libc::_cpuset_destroy(set); + if let Some(count) = NonZeroUsize::new(count) { + return Ok(count); + } + } + } + } + let mut cpus: libc::c_uint = 0; let mut cpus_size = crate::mem::size_of_val(&cpus); |
