From 3726cbb5fefe28c922f5c265231a3d00bca198d5 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Wed, 28 Feb 2024 23:01:56 +0100 Subject: [PATCH] add platform-specific function to get the error number for HermitOS Extending `std` to get the last error number for HermitOS. HermitOS is a tier 3 platform and this PR changes only files, wich are related to the tier 3 platform. --- Cargo.lock | 4 ++-- library/std/Cargo.toml | 2 +- library/std/src/sys/pal/hermit/os.rs | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4d216f26b61..04e6139b7e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1640,9 +1640,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.6" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd5256b483761cd23699d0da46cc6fd2ee3be420bbe6d020ae4a091e70b7e9fd" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" dependencies = [ "compiler_builtins", "rustc-std-workspace-alloc", diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index 20f4310603a..d2804b4d20a 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -48,7 +48,7 @@ dlmalloc = { version = "0.2.4", 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.2", features = ['rustc-dep-of-std'], public = true } +hermit-abi = { version = "0.3.9", features = ['rustc-dep-of-std'], public = true } [target.'cfg(target_os = "wasi")'.dependencies] wasi = { version = "0.11.0", features = ['rustc-dep-of-std'], default-features = false } diff --git a/library/std/src/sys/pal/hermit/os.rs b/library/std/src/sys/pal/hermit/os.rs index a54536aecb8..645f0dc1e31 100644 --- a/library/std/src/sys/pal/hermit/os.rs +++ b/library/std/src/sys/pal/hermit/os.rs @@ -14,15 +14,15 @@ use crate::vec; pub fn errno() -> i32 { - 0 + unsafe { abi::get_errno() } } -pub fn error_string(_errno: i32) -> String { - "operation successful".to_string() +pub fn error_string(errno: i32) -> String { + abi::error_string(errno).to_string() } pub fn getcwd() -> io::Result { - unsupported() + Ok(PathBuf::from("/")) } pub fn chdir(_: &path::Path) -> io::Result<()> { @@ -188,7 +188,7 @@ pub fn unsetenv(k: &OsStr) -> io::Result<()> { } pub fn temp_dir() -> PathBuf { - panic!("no filesystem on hermit") + PathBuf::from("/tmp") } pub fn home_dir() -> Option {