From 36e93824497c18d9b18596f96521a4bf830f83e3 Mon Sep 17 00:00:00 2001 From: Christiaan Dirkx Date: Sat, 24 Apr 2021 17:32:25 +0200 Subject: [PATCH] Reuse `unix::path` and `unsupported::{io, thread_local_key}` on `hermit` --- library/std/src/sys/hermit/io.rs | 47 ------------------- library/std/src/sys/hermit/mod.rs | 3 ++ library/std/src/sys/hermit/path.rs | 19 -------- .../std/src/sys/hermit/thread_local_key.rs | 26 ---------- 4 files changed, 3 insertions(+), 92 deletions(-) delete mode 100644 library/std/src/sys/hermit/io.rs delete mode 100644 library/std/src/sys/hermit/path.rs delete mode 100644 library/std/src/sys/hermit/thread_local_key.rs diff --git a/library/std/src/sys/hermit/io.rs b/library/std/src/sys/hermit/io.rs deleted file mode 100644 index d5f475b4310fd..0000000000000 --- a/library/std/src/sys/hermit/io.rs +++ /dev/null @@ -1,47 +0,0 @@ -use crate::mem; - -#[derive(Copy, Clone)] -pub struct IoSlice<'a>(&'a [u8]); - -impl<'a> IoSlice<'a> { - #[inline] - pub fn new(buf: &'a [u8]) -> IoSlice<'a> { - IoSlice(buf) - } - - #[inline] - pub fn advance(&mut self, n: usize) { - self.0 = &self.0[n..] - } - - #[inline] - pub fn as_slice(&self) -> &[u8] { - self.0 - } -} - -pub struct IoSliceMut<'a>(&'a mut [u8]); - -impl<'a> IoSliceMut<'a> { - #[inline] - pub fn new(buf: &'a mut [u8]) -> IoSliceMut<'a> { - IoSliceMut(buf) - } - - #[inline] - pub fn advance(&mut self, n: usize) { - let slice = mem::replace(&mut self.0, &mut []); - let (_, remaining) = slice.split_at_mut(n); - self.0 = remaining; - } - - #[inline] - pub fn as_slice(&self) -> &[u8] { - self.0 - } - - #[inline] - pub fn as_mut_slice(&mut self) -> &mut [u8] { - self.0 - } -} diff --git a/library/std/src/sys/hermit/mod.rs b/library/std/src/sys/hermit/mod.rs index 56497162c0333..b6366b105ce4f 100644 --- a/library/std/src/sys/hermit/mod.rs +++ b/library/std/src/sys/hermit/mod.rs @@ -26,11 +26,13 @@ pub mod env; pub mod ext; pub mod fd; pub mod fs; +#[path = "../unsupported/io.rs"] pub mod io; pub mod memchr; pub mod mutex; pub mod net; pub mod os; +#[path = "../unix/path.rs"] pub mod path; #[path = "../unsupported/pipe.rs"] pub mod pipe; @@ -41,6 +43,7 @@ pub mod stack_overflow; pub mod stdio; pub mod thread; pub mod thread_local_dtor; +#[path = "../unsupported/thread_local_key.rs"] pub mod thread_local_key; pub mod time; diff --git a/library/std/src/sys/hermit/path.rs b/library/std/src/sys/hermit/path.rs deleted file mode 100644 index 840a7ae042625..0000000000000 --- a/library/std/src/sys/hermit/path.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::ffi::OsStr; -use crate::path::Prefix; - -#[inline] -pub fn is_sep_byte(b: u8) -> bool { - b == b'/' -} - -#[inline] -pub fn is_verbatim_sep(b: u8) -> bool { - b == b'/' -} - -pub fn parse_prefix(_: &OsStr) -> Option> { - None -} - -pub const MAIN_SEP_STR: &str = "/"; -pub const MAIN_SEP: char = '/'; diff --git a/library/std/src/sys/hermit/thread_local_key.rs b/library/std/src/sys/hermit/thread_local_key.rs deleted file mode 100644 index bf1b49eb83b7e..0000000000000 --- a/library/std/src/sys/hermit/thread_local_key.rs +++ /dev/null @@ -1,26 +0,0 @@ -pub type Key = usize; - -#[inline] -pub unsafe fn create(_dtor: Option) -> Key { - panic!("should not be used on the hermit target"); -} - -#[inline] -pub unsafe fn set(_key: Key, _value: *mut u8) { - panic!("should not be used on the hermit target"); -} - -#[inline] -pub unsafe fn get(_key: Key) -> *mut u8 { - panic!("should not be used on the hermit target"); -} - -#[inline] -pub unsafe fn destroy(_key: Key) { - panic!("should not be used on the hermit target"); -} - -#[inline] -pub fn requires_synchronized_create() -> bool { - panic!("should not be used on the hermit target"); -}