From 415aff0516fd90fb11fc7f01743480f22460a3f7 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Mon, 30 Mar 2020 06:43:49 +0200 Subject: [PATCH 1/4] move OS constants to platform crate --- Cargo.lock | 4 ++-- src/libstd/Cargo.toml | 2 +- src/libstd/sys/hermit/fs.rs | 10 ++-------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fdc84e53d121d..a0233124b84ac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1372,9 +1372,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.1.1" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f22b8f315b98f415780ddbe9163c7dbbc5a07225b6d102ace1d8aeef85775140" +checksum = "0ebe6e23502442c4c9cd80fcb8bdf867dc5f4a9e9f1d882499fa49c5ed83e559" dependencies = [ "compiler_builtins", "libc", diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml index 0dd2f79d066e4..1bb764897ea54 100644 --- a/src/libstd/Cargo.toml +++ b/src/libstd/Cargo.toml @@ -41,7 +41,7 @@ dlmalloc = { version = "0.1", features = ['rustc-dep-of-std'] } fortanix-sgx-abi = { version = "0.3.2", features = ['rustc-dep-of-std'] } [target.'cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_os = "hermit"))'.dependencies] -hermit-abi = { version = "0.1", features = ['rustc-dep-of-std'] } +hermit-abi = { version = "0.1.9", features = ['rustc-dep-of-std'] } [target.wasm32-wasi.dependencies] wasi = { version = "0.9.0", features = ['rustc-dep-of-std'], default-features = false } diff --git a/src/libstd/sys/hermit/fs.rs b/src/libstd/sys/hermit/fs.rs index 37ac5984eeeaf..9d2fe5e1f606a 100644 --- a/src/libstd/sys/hermit/fs.rs +++ b/src/libstd/sys/hermit/fs.rs @@ -6,6 +6,8 @@ use crate::io::{IoSlice, IoSliceMut, SeekFrom}; use crate::path::{Path, PathBuf}; use crate::sys::cvt; use crate::sys::hermit::abi; +use crate::sys::hermit::abi::{O_RDONLY, O_WRONLY, O_RDWR,O_CREAT, + O_EXCL, O_TRUNC, O_APPEND}; use crate::sys::hermit::fd::FileDesc; use crate::sys::time::SystemTime; use crate::sys::{unsupported, Void}; @@ -17,14 +19,6 @@ pub use crate::sys_common::fs::copy; fn cstr(path: &Path) -> io::Result { Ok(CString::new(path.as_os_str().as_bytes())?) } -//const O_ACCMODE: i32 = 00000003; -const O_RDONLY: i32 = 00000000; -const O_WRONLY: i32 = 00000001; -const O_RDWR: i32 = 00000002; -const O_CREAT: i32 = 00000100; -const O_EXCL: i32 = 00000200; -const O_TRUNC: i32 = 00001000; -const O_APPEND: i32 = 00002000; #[derive(Debug)] pub struct File(FileDesc); From 412083469e717bb45299570841194bc45b019792 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Mon, 30 Mar 2020 07:05:35 +0200 Subject: [PATCH 2/4] minor changes to pass the format check --- src/libstd/sys/hermit/fs.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libstd/sys/hermit/fs.rs b/src/libstd/sys/hermit/fs.rs index 9d2fe5e1f606a..973ee768d7b00 100644 --- a/src/libstd/sys/hermit/fs.rs +++ b/src/libstd/sys/hermit/fs.rs @@ -6,8 +6,7 @@ use crate::io::{IoSlice, IoSliceMut, SeekFrom}; use crate::path::{Path, PathBuf}; use crate::sys::cvt; use crate::sys::hermit::abi; -use crate::sys::hermit::abi::{O_RDONLY, O_WRONLY, O_RDWR,O_CREAT, - O_EXCL, O_TRUNC, O_APPEND}; +use crate::sys::hermit::abi::{O_RDONLY, O_WRONLY, O_RDWR,O_CREAT, O_EXCL, O_TRUNC, O_APPEND}; use crate::sys::hermit::fd::FileDesc; use crate::sys::time::SystemTime; use crate::sys::{unsupported, Void}; From 6c80bdb388618eb574149a18e2ae7d1c34f6f762 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Mon, 30 Mar 2020 07:17:00 +0200 Subject: [PATCH 3/4] reorder imports to pass the format check --- src/libstd/sys/hermit/fs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/sys/hermit/fs.rs b/src/libstd/sys/hermit/fs.rs index 973ee768d7b00..287a039066780 100644 --- a/src/libstd/sys/hermit/fs.rs +++ b/src/libstd/sys/hermit/fs.rs @@ -6,7 +6,7 @@ use crate::io::{IoSlice, IoSliceMut, SeekFrom}; use crate::path::{Path, PathBuf}; use crate::sys::cvt; use crate::sys::hermit::abi; -use crate::sys::hermit::abi::{O_RDONLY, O_WRONLY, O_RDWR,O_CREAT, O_EXCL, O_TRUNC, O_APPEND}; +use crate::sys::hermit::abi::{O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY}; use crate::sys::hermit::fd::FileDesc; use crate::sys::time::SystemTime; use crate::sys::{unsupported, Void}; From 9f6b96e461003853bf36052cfaf79b12e1c35413 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Mon, 30 Mar 2020 07:37:52 +0200 Subject: [PATCH 4/4] move the definition of thread priorities to hermit-abi --- Cargo.lock | 4 ++-- src/libstd/Cargo.toml | 2 +- src/libstd/sys/hermit/thread.rs | 25 +------------------------ 3 files changed, 4 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a0233124b84ac..e51eded2200de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1372,9 +1372,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ebe6e23502442c4c9cd80fcb8bdf867dc5f4a9e9f1d882499fa49c5ed83e559" +checksum = "725cf19794cf90aa94e65050cb4191ff5d8fa87a498383774c47b332e3af952e" dependencies = [ "compiler_builtins", "libc", diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml index 1bb764897ea54..3a83f3f569a26 100644 --- a/src/libstd/Cargo.toml +++ b/src/libstd/Cargo.toml @@ -41,7 +41,7 @@ dlmalloc = { version = "0.1", features = ['rustc-dep-of-std'] } fortanix-sgx-abi = { version = "0.3.2", features = ['rustc-dep-of-std'] } [target.'cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_os = "hermit"))'.dependencies] -hermit-abi = { version = "0.1.9", features = ['rustc-dep-of-std'] } +hermit-abi = { version = "0.1.10", features = ['rustc-dep-of-std'] } [target.wasm32-wasi.dependencies] wasi = { version = "0.9.0", features = ['rustc-dep-of-std'], default-features = false } diff --git a/src/libstd/sys/hermit/thread.rs b/src/libstd/sys/hermit/thread.rs index c3c29c93826de..00d760d02e877 100644 --- a/src/libstd/sys/hermit/thread.rs +++ b/src/libstd/sys/hermit/thread.rs @@ -1,7 +1,6 @@ #![allow(dead_code)] use crate::ffi::CStr; -use crate::fmt; use crate::io; use crate::mem; use crate::sys::hermit::abi; @@ -12,28 +11,6 @@ use crate::sys_common::thread::*; pub type Tid = abi::Tid; -/// Priority of a task -#[derive(PartialEq, Eq, PartialOrd, Ord, Debug, Clone, Copy)] -pub struct Priority(u8); - -impl Priority { - pub const fn into(self) -> u8 { - self.0 - } - - pub const fn from(x: u8) -> Self { - Priority(x) - } -} - -impl fmt::Display for Priority { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", self.0) - } -} - -pub const NORMAL_PRIO: Priority = Priority::from(2); - pub struct Thread { tid: Tid, } @@ -55,7 +32,7 @@ impl Thread { &mut tid as *mut Tid, thread_start, &*p as *const _ as *const u8 as usize, - Priority::into(NORMAL_PRIO), + abi::Priority::into(abi::NORMAL_PRIO), core_id, );