Skip to content

Commit eda09d7

Browse files
authored
Rollup merge of #112525 - hermitcore:devel, r=m-ou-se
Adjustments for RustyHermit The interface between `libstd` and the OS changed and some changes are not correctly merged for RustHermit. For instance, the crate `hermit_abi` isn't defined as public, although it provided the socket interface for the application. In addition, the support of thread::available_parallelism is realized. It returns the number of available processors.
2 parents d69a46a + acb92f9 commit eda09d7

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

std/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ dlmalloc = { version = "0.2.3", features = ['rustc-dep-of-std'] }
4545
fortanix-sgx-abi = { version = "0.5.0", features = ['rustc-dep-of-std'], public = true }
4646

4747
[target.'cfg(target_os = "hermit")'.dependencies]
48-
hermit-abi = { version = "0.3.0", features = ['rustc-dep-of-std'] }
48+
hermit-abi = { version = "0.3.2", features = ['rustc-dep-of-std'], public = true }
4949

5050
[target.wasm32-wasi.dependencies]
5151
wasi = { version = "0.11.0", features = ['rustc-dep-of-std'], default-features = false }

std/src/sys/hermit/thread.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![allow(dead_code)]
22

3-
use super::unsupported;
43
use crate::ffi::CStr;
54
use crate::io;
65
use crate::mem;
@@ -99,7 +98,7 @@ impl Thread {
9998
}
10099

101100
pub fn available_parallelism() -> io::Result<NonZeroUsize> {
102-
unsupported()
101+
unsafe { Ok(NonZeroUsize::new_unchecked(abi::get_processor_count())) }
103102
}
104103

105104
pub mod guard {

std/src/sys/hermit/time.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl Timespec {
4040
}
4141

4242
fn checked_add_duration(&self, other: &Duration) -> Option<Timespec> {
43-
let mut secs = self.tv_sec.checked_add_unsigned(other.as_secs())?;
43+
let mut secs = self.t.tv_sec.checked_add_unsigned(other.as_secs())?;
4444

4545
// Nano calculations can't overflow because nanos are <1B which fit
4646
// in a u32.
@@ -53,7 +53,7 @@ impl Timespec {
5353
}
5454

5555
fn checked_sub_duration(&self, other: &Duration) -> Option<Timespec> {
56-
let mut secs = self.tv_sec.checked_sub_unsigned(other.as_secs())?;
56+
let mut secs = self.t.tv_sec.checked_sub_unsigned(other.as_secs())?;
5757

5858
// Similar to above, nanos can't overflow.
5959
let mut nsec = self.t.tv_nsec as i32 - other.subsec_nanos() as i32;

0 commit comments

Comments
 (0)