diff --git a/Cargo.toml b/Cargo.toml index 466de3e1469754b08a132b97cdab6bbdb7ba2436..753a030e2581fbc99559f3d226ae513c74977d74 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ crate-type = ["staticlib"] [workspace] members = ["src/crt0", "src/crti", "src/crtn", "cbindgen"] -exclude = ["core_io"] +exclude = ["core_io", "ralloc"] [build-dependencies] cc = "1.0.17" diff --git a/src/header/stdio/mod.rs b/src/header/stdio/mod.rs index f632daf36ba1a1ed0ea31a62a8490aad3accc4a1..6ba42ef7869d2f6ff6ee7a583db013b3662baf11 100644 --- a/src/header/stdio/mod.rs +++ b/src/header/stdio/mod.rs @@ -15,7 +15,7 @@ use header::stdlib::mkstemp; use header::string::strlen; use platform; use platform::types::*; -use platform::{c_str, errno, Read, Write}; +use platform::{c_str, errno, ReadByte, WriteByte}; use platform::{Pal, Sys}; mod printf; @@ -219,7 +219,7 @@ impl<'a> fmt::Write for LockGuard<'a> { } } } -impl<'a> Write for LockGuard<'a> { +impl<'a> WriteByte for LockGuard<'a> { fn write_u8(&mut self, byte: u8) -> fmt::Result { if !self.0.can_write() { return Err(Error); @@ -231,7 +231,7 @@ impl<'a> Write for LockGuard<'a> { } } } -impl<'a> Read for LockGuard<'a> { +impl<'a> ReadByte for LockGuard<'a> { fn read_u8(&mut self) -> Result<Option<u8>, ()> { let mut buf = [0]; match self.0.read(&mut buf) { diff --git a/src/header/stdio/printf.rs b/src/header/stdio/printf.rs index 46489d2bf66ef18d677883e322439084a43912b1..55b0c6b6155dc72c5041b28d95cd67fc15f168f2 100644 --- a/src/header/stdio/printf.rs +++ b/src/header/stdio/printf.rs @@ -2,10 +2,10 @@ use core::fmt::Write as CoreWrite; use core::{ptr, slice, str}; use platform::types::*; -use platform::{self, Write}; +use platform::{self, WriteByte}; use va_list::VaList; -pub unsafe fn printf<W: Write>(w: W, format: *const c_char, mut ap: VaList) -> c_int { +pub unsafe fn printf<W: WriteByte>(w: W, format: *const c_char, mut ap: VaList) -> c_int { let mut w = platform::CountingWriter::new(w); let format = slice::from_raw_parts(format as *const u8, usize::max_value()); diff --git a/src/header/stdio/scanf.rs b/src/header/stdio/scanf.rs index d9cd3e15eb69b13fd6dc03834801ac3cb93757a8..97864af620e7cf3c9816cbb5ef708fe81f1f85ea 100644 --- a/src/header/stdio/scanf.rs +++ b/src/header/stdio/scanf.rs @@ -1,7 +1,7 @@ use alloc::String; use alloc::Vec; use platform::types::*; -use platform::Read; +use platform::ReadByte; use va_list::VaList; #[derive(PartialEq, Eq)] @@ -27,7 +27,7 @@ unsafe fn next_byte(string: &mut *const c_char) -> Result<u8, c_int> { } } -unsafe fn inner_scanf<R: Read>( +unsafe fn inner_scanf<R: ReadByte>( mut r: R, mut format: *const c_char, mut ap: VaList, @@ -420,7 +420,7 @@ unsafe fn inner_scanf<R: Read>( } Ok(matched) } -pub unsafe fn scanf<R: Read>(r: R, format: *const c_char, ap: VaList) -> c_int { +pub unsafe fn scanf<R: ReadByte>(r: R, format: *const c_char, ap: VaList) -> c_int { match inner_scanf(r, format, ap) { Ok(n) => n, Err(n) => n, diff --git a/src/header/time/strftime.rs b/src/header/time/strftime.rs index d2f6f91100b51ff3f8cdf0cbb3450a021b3ecff9..43bda5c4d2c3be2b32d925d1cffd114350dee456 100644 --- a/src/header/time/strftime.rs +++ b/src/header/time/strftime.rs @@ -1,12 +1,12 @@ use alloc::string::String; use platform::types::*; -use platform::{self, Write}; +use platform::{self, WriteByte}; use super::tm; -pub unsafe fn strftime<W: Write>(w: &mut W, format: *const c_char, t: *const tm) -> size_t { - pub unsafe fn inner_strftime<W: Write>( +pub unsafe fn strftime<W: WriteByte>(w: &mut W, format: *const c_char, t: *const tm) -> size_t { + pub unsafe fn inner_strftime<W: WriteByte>( w: &mut W, mut format: *const c_char, t: *const tm, diff --git a/src/platform/mod.rs b/src/platform/mod.rs index c23f7a6ca13de3394fb3f11c636a67eeaabdf7ad..9334c7a65703e8c34e595ba8a452eea8751d11fd 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -107,21 +107,21 @@ pub unsafe fn memcpy(s1: *mut c_void, s2: *const c_void, n: usize) -> *mut c_voi s1 } -pub trait Write: fmt::Write { +pub trait WriteByte: fmt::Write { fn write_u8(&mut self, byte: u8) -> fmt::Result; } -impl<'a, W: Write> Write for &'a mut W { +impl<'a, W: WriteByte> WriteByte for &'a mut W { fn write_u8(&mut self, byte: u8) -> fmt::Result { (**self).write_u8(byte) } } -pub trait Read { +pub trait ReadByte { fn read_u8(&mut self) -> Result<Option<u8>, ()>; } -impl<'a, R: Read> Read for &'a mut R { +impl<'a, R: ReadByte> ReadByte for &'a mut R { fn read_u8(&mut self) -> Result<Option<u8>, ()> { (**self).read_u8() } @@ -142,7 +142,7 @@ impl fmt::Write for FileWriter { } } -impl Write for FileWriter { +impl WriteByte for FileWriter { fn write_u8(&mut self, byte: u8) -> fmt::Result { self.write(&[byte]); Ok(()) @@ -157,7 +157,7 @@ impl FileReader { } } -impl Read for FileReader { +impl ReadByte for FileReader { fn read_u8(&mut self) -> Result<Option<u8>, ()> { let mut buf = [0]; match self.read(&mut buf) { @@ -194,7 +194,7 @@ impl fmt::Write for StringWriter { } } -impl Write for StringWriter { +impl WriteByte for StringWriter { fn write_u8(&mut self, byte: u8) -> fmt::Result { unsafe { self.write(&[byte]) }; Ok(()) @@ -222,7 +222,7 @@ impl fmt::Write for UnsafeStringWriter { } } -impl Write for UnsafeStringWriter { +impl WriteByte for UnsafeStringWriter { fn write_u8(&mut self, byte: u8) -> fmt::Result { unsafe { self.write(&[byte]) }; Ok(()) @@ -231,7 +231,7 @@ impl Write for UnsafeStringWriter { pub struct StringReader<'a>(pub &'a [u8]); -impl<'a> Read for StringReader<'a> { +impl<'a> ReadByte for StringReader<'a> { fn read_u8(&mut self) -> Result<Option<u8>, ()> { if self.0.is_empty() { Ok(None) @@ -245,7 +245,7 @@ impl<'a> Read for StringReader<'a> { pub struct UnsafeStringReader(pub *const u8); -impl Read for UnsafeStringReader { +impl ReadByte for UnsafeStringReader { fn read_u8(&mut self) -> Result<Option<u8>, ()> { unsafe { if *self.0 == 0 { @@ -277,7 +277,7 @@ impl<T: fmt::Write> fmt::Write for CountingWriter<T> { self.inner.write_str(s) } } -impl<T: Write> Write for CountingWriter<T> { +impl<T: WriteByte> WriteByte for CountingWriter<T> { fn write_u8(&mut self, byte: u8) -> fmt::Result { self.written += 1; self.inner.write_u8(byte) diff --git a/src/platform/pal/mod.rs b/src/platform/pal/mod.rs index 3ef78b2aa232666ffc9f76b71e08391d289bf6bf..9a3a2030dc193ef37d48060b63cbd379b9f816ce 100644 --- a/src/platform/pal/mod.rs +++ b/src/platform/pal/mod.rs @@ -1,5 +1,3 @@ -use core::ptr; - use super::types::*; use c_str::CStr; use header::dirent::dirent;