Skip to content

Commit

Permalink
Rollup merge of #112525 - hermitcore:devel, r=m-ou-se
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
matthiaskrgr authored Jul 13, 2023
2 parents 7bd81ee + 8666ade commit efc3c71
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1529,9 +1529,9 @@ dependencies = [

[[package]]
name = "hermit-abi"
version = "0.3.1"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b"
dependencies = [
"compiler_builtins",
"rustc-std-workspace-alloc",
Expand Down Expand Up @@ -1864,7 +1864,7 @@ version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2"
dependencies = [
"hermit-abi 0.3.1",
"hermit-abi 0.3.2",
"libc",
"windows-sys 0.48.0",
]
Expand All @@ -1881,7 +1881,7 @@ version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24fddda5af7e54bf7da53067d6e802dbcc381d0a8eef629df528e3ebf68755cb"
dependencies = [
"hermit-abi 0.3.1",
"hermit-abi 0.3.2",
"rustix 0.38.2",
"windows-sys 0.48.0",
]
Expand Down Expand Up @@ -2396,7 +2396,7 @@ version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
dependencies = [
"hermit-abi 0.3.1",
"hermit-abi 0.3.2",
"libc",
]

Expand Down Expand Up @@ -4819,7 +4819,7 @@ dependencies = [
"dlmalloc",
"fortanix-sgx-abi",
"hashbrown 0.14.0",
"hermit-abi 0.3.1",
"hermit-abi 0.3.2",
"libc",
"miniz_oxide",
"object",
Expand Down
2 changes: 1 addition & 1 deletion library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dlmalloc = { version = "0.2.3", features = ['rustc-dep-of-std'] }
fortanix-sgx-abi = { version = "0.5.0", features = ['rustc-dep-of-std'], public = true }

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

[target.wasm32-wasi.dependencies]
wasi = { version = "0.11.0", features = ['rustc-dep-of-std'], default-features = false }
Expand Down
3 changes: 1 addition & 2 deletions library/std/src/sys/hermit/thread.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![allow(dead_code)]

use super::unsupported;
use crate::ffi::CStr;
use crate::io;
use crate::mem;
Expand Down Expand Up @@ -99,7 +98,7 @@ impl Thread {
}

pub fn available_parallelism() -> io::Result<NonZeroUsize> {
unsupported()
unsafe { Ok(NonZeroUsize::new_unchecked(abi::get_processor_count())) }
}

pub mod guard {
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/sys/hermit/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl Timespec {
}

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

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

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

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

0 comments on commit efc3c71

Please sign in to comment.