about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2021-04-27 19:08:46 +0200
committerGitHub <noreply@github.com>2021-04-27 19:08:46 +0200
commite7be5ddc4a49628d247dc0edf4b339996e0f429a (patch)
treecb411ad0715232607233506851a52a69713494d9
parent78e0f2f52db304187677e89089d59bf6531d6c4f (diff)
parent36e93824497c18d9b18596f96521a4bf830f83e3 (diff)
downloadrust-e7be5ddc4a49628d247dc0edf4b339996e0f429a.tar.gz
rust-e7be5ddc4a49628d247dc0edf4b339996e0f429a.zip
Rollup merge of #84521 - CDirkx:hermit-dedup, r=Mark-Simulacrum
Reuse modules on `hermit`

Reuse the following modules on `hermit`:
- `unix::path` (contents identical)
- `unsupported::io` (contents identical)
- `unsupported::thread_local_key` (contents functionally identical, only changes are the panic error messages)

`@rustbot` label: +T-libs-impl
-rw-r--r--library/std/src/sys/hermit/io.rs47
-rw-r--r--library/std/src/sys/hermit/mod.rs3
-rw-r--r--library/std/src/sys/hermit/path.rs19
-rw-r--r--library/std/src/sys/hermit/thread_local_key.rs26
4 files changed, 3 insertions, 92 deletions
diff --git a/library/std/src/sys/hermit/io.rs b/library/std/src/sys/hermit/io.rs
deleted file mode 100644
index d5f475b4310..00000000000
--- 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 a70d1db7ca6..3364d215776 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;
@@ -40,6 +42,7 @@ pub mod rwlock;
 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 840a7ae0426..00000000000
--- 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<Prefix<'_>> {
-    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 bf1b49eb83b..00000000000
--- 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<unsafe extern "C" fn(*mut u8)>) -> 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");
-}