diff --git a/build.rs b/build.rs index 345db4fc47..8f61a6d4b2 100644 --- a/build.rs +++ b/build.rs @@ -1,22 +1,22 @@ extern crate cc; -// use std::env; +use std::env; fn main() { - // let crate_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set"); - // - // cc::Build::new() - // .flag("-nostdinc") - // .flag("-nostdlib") - // .flag("-I") - // .flag(&format!("{}/include", crate_dir)) - // .flag("-fno-stack-protector") - // .file("src/c/dlmalloc.c") - // .file("src/c/fcntl.c") - // .file("src/c/stack_chk.c") - // .file("src/c/stdio.c") - // .file("src/c/unistd.c") - // .compile("relibc_c"); + let crate_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set"); + + cc::Build::new() + .flag("-nostdinc") + .flag("-nostdlib") + .flag("-I") + .flag(&format!("{}/include", crate_dir)) + .flag("-fno-stack-protector") + .file("src/c/dlmalloc.c") + .file("src/c/fcntl.c") + .file("src/c/stack_chk.c") + .file("src/c/stdio.c") + .file("src/c/unistd.c") + .compile("relibc_c"); println!("cargo:rustc-link-lib=static=relibc_c"); } diff --git a/src/header/_template/mod.rs b/src/header/_template/mod.rs index e0c83c7cef..ed73313a1d 100644 --- a/src/header/_template/mod.rs +++ b/src/header/_template/mod.rs @@ -1,9 +1,5 @@ //! template implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/template.h.html -#![no_std] - -extern crate platform; - use platform::types::*; /* diff --git a/src/header/dirent/mod.rs b/src/header/dirent/mod.rs index abdb433b06..0083e5f39d 100644 --- a/src/header/dirent/mod.rs +++ b/src/header/dirent/mod.rs @@ -4,6 +4,7 @@ use alloc::boxed::Box; use core::{mem, ptr}; use header::{errno, fcntl, stdio, unistd}; +use platform; use platform::{Pal, Sys}; use platform::types::*; diff --git a/src/header/fcntl/mod.rs b/src/header/fcntl/mod.rs index 4237e905ad..2aadfaa4cc 100644 --- a/src/header/fcntl/mod.rs +++ b/src/header/fcntl/mod.rs @@ -4,7 +4,7 @@ use platform; use platform::{Pal, Sys}; use platform::types::*; -pub use sys::*; +pub use self::sys::*; #[cfg(target_os = "linux")] #[path = "linux.rs"] diff --git a/src/header/inttypes/mod.rs b/src/header/inttypes/mod.rs index a5780290f2..8a433ad2e7 100644 --- a/src/header/inttypes/mod.rs +++ b/src/header/inttypes/mod.rs @@ -1,5 +1,6 @@ use header::{ctype, stdlib}; use header::errno::*; +use header::stdlib::*; use platform; use platform::types::*; @@ -29,7 +30,6 @@ pub unsafe extern "C" fn strtoimax( endptr: *mut *mut c_char, base: c_int, ) -> intmax_t { - use stdlib::*; strto_impl!( intmax_t, false, @@ -47,7 +47,6 @@ pub unsafe extern "C" fn strtoumax( endptr: *mut *mut c_char, base: c_int, ) -> uintmax_t { - use stdlib::*; strto_impl!( uintmax_t, false, diff --git a/src/header/signal/mod.rs b/src/header/signal/mod.rs index c37e81e456..9929bd0709 100644 --- a/src/header/signal/mod.rs +++ b/src/header/signal/mod.rs @@ -1,5 +1,14 @@ //! signal implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/signal.h.html +use core::{mem, ptr}; + +use header::errno; +use platform; +use platform::{PalSignal, Sys}; +use platform::types::*; + +pub use self::sys::*; + #[cfg(target_os = "linux")] #[path = "linux.rs"] pub mod sys; @@ -8,15 +17,6 @@ pub mod sys; #[path = "redox.rs"] pub mod sys; -pub use sys::*; - -use core::{mem, ptr}; - -use header::errno; -use platform; -use platform::{PalSignal, Sys}; -use platform::types::*; - const SIG_ERR: usize = !0; pub const SIG_BLOCK: c_int = 0; diff --git a/src/header/stdio/helpers.rs b/src/header/stdio/helpers.rs index f888162728..7f5bcad833 100644 --- a/src/header/stdio/helpers.rs +++ b/src/header/stdio/helpers.rs @@ -1,15 +1,17 @@ -use super::constants::*; -use super::{BUFSIZ, FILE, UNGET}; use core::mem; use core::sync::atomic::AtomicBool; -use errno; -use fcntl::*; + +use header::errno; +use header::fcntl::*; +use header::string::strchr; use platform; use platform::types::*; +use super::constants::*; +use super::{BUFSIZ, FILE, UNGET}; + /// Parse mode flags as a string and output a mode flags integer pub unsafe fn parse_mode_flags(mode_str: *const c_char) -> i32 { - use string::strchr; let mut flags = if !strchr(mode_str, b'+' as i32).is_null() { O_RDWR } else if (*mode_str) == b'r' as i8 { @@ -38,7 +40,6 @@ pub unsafe fn parse_mode_flags(mode_str: *const c_char) -> i32 { /// Open a file with the file descriptor `fd` in the mode `mode` pub unsafe fn _fdopen(fd: c_int, mode: *const c_char) -> Option<*mut FILE> { - use string::strchr; if *mode != b'r' as i8 && *mode != b'w' as i8 && *mode != b'a' as i8 { platform::errno = errno::EINVAL; return None; diff --git a/src/header/stdio/mod.rs b/src/header/stdio/mod.rs index 77b879f5c2..f274c7caae 100644 --- a/src/header/stdio/mod.rs +++ b/src/header/stdio/mod.rs @@ -17,11 +17,11 @@ use platform::{c_str, errno, Read, Write}; mod printf; mod scanf; +pub use self::default::*; mod default; -pub use default::*; +pub use self::constants::*; mod constants; -pub use constants::*; mod helpers; diff --git a/src/header/stdio/printf.rs b/src/header/stdio/printf.rs index 71c0ca94fa..061fba7ef1 100644 --- a/src/header/stdio/printf.rs +++ b/src/header/stdio/printf.rs @@ -3,7 +3,7 @@ use core::{slice, str}; use platform::types::*; use platform::{self, Write}; -use vl::VaList; +use va_list::VaList; pub unsafe fn printf(w: W, format: *const c_char, mut ap: VaList) -> c_int { let mut w = platform::CountingWriter::new(w); diff --git a/src/header/stdio/scanf.rs b/src/header/stdio/scanf.rs index 2652c141b4..bdb12fb4fa 100644 --- a/src/header/stdio/scanf.rs +++ b/src/header/stdio/scanf.rs @@ -2,7 +2,7 @@ use alloc::String; use alloc::Vec; use platform::types::*; use platform::Read; -use vl::VaList; +use va_list::VaList; #[derive(PartialEq, Eq)] enum IntKind { diff --git a/src/header/stdlib/mod.rs b/src/header/stdlib/mod.rs index c64612d368..fb695bf2f4 100644 --- a/src/header/stdlib/mod.rs +++ b/src/header/stdlib/mod.rs @@ -1,15 +1,16 @@ //! stdlib implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/stdlib.h.html -use core::{iter, mem, ptr, slice, str}; +use core::{intrinsics, iter, mem, ptr, slice, str}; use rand::distributions::Alphanumeric; use rand::prng::XorShiftRng; use rand::rngs::JitterRng; use rand::{Rng, SeedableRng}; -use header::{ctype, time, unistd, wchar}; +use header::{ctype, errno, time, unistd, wchar}; use header::errno::*; use header::fcntl::*; use header::string::*; +use header::time::constants::CLOCK_MONOTONIC; use header::wchar::*; use platform; use platform::{Pal, Sys}; @@ -58,8 +59,6 @@ pub unsafe extern "C" fn a64l(s: *const c_char) -> c_long { #[no_mangle] pub unsafe extern "C" fn abort() { - use core::intrinsics; - intrinsics::abort(); } @@ -173,8 +172,6 @@ pub unsafe extern "C" fn bsearch( #[no_mangle] pub unsafe extern "C" fn calloc(nelem: size_t, elsize: size_t) -> *mut c_void { - use core::intrinsics; - let size = nelem * elsize; let ptr = malloc(size); if !ptr.is_null() { @@ -453,8 +450,6 @@ pub extern "C" fn mktemp(name: *mut c_char) -> *mut c_char { } fn get_nstime() -> u64 { - use core::mem; - use time::constants::CLOCK_MONOTONIC; let mut ts: timespec = unsafe { mem::uninitialized() }; Sys::clock_gettime(CLOCK_MONOTONIC, &mut ts); ts.tv_nsec as u64 @@ -820,110 +815,6 @@ pub fn convert_integer(s: *const c_char, base: c_int) -> Option<(c_ulong, isize, } } -#[macro_export] -macro_rules! strto_impl { - ( - $rettype:ty, $signed:expr, $maxval:expr, $minval:expr, $s:ident, $endptr:ident, $base:ident - ) => {{ - // ensure these are constants - const CHECK_SIGN: bool = $signed; - const MAX_VAL: $rettype = $maxval; - const MIN_VAL: $rettype = $minval; - - let set_endptr = |idx: isize| { - if !$endptr.is_null() { - // This is stupid, but apparently strto* functions want - // const input but mut output, yet the man page says - // "stores the address of the first invalid character in *endptr" - // so obviously it doesn't want us to clone it. - *$endptr = $s.offset(idx) as *mut _; - } - }; - - let invalid_input = || { - platform::errno = EINVAL; - set_endptr(0); - }; - - // only valid bases are 2 through 36 - if $base != 0 && ($base < 2 || $base > 36) { - invalid_input(); - return 0; - } - - let mut idx = 0; - - // skip any whitespace at the beginning of the string - while ctype::isspace(*$s.offset(idx) as c_int) != 0 { - idx += 1; - } - - // check for +/- - let positive = match is_positive(*$s.offset(idx)) { - Some((pos, i)) => { - idx += i; - pos - } - None => { - invalid_input(); - return 0; - } - }; - - // convert the string to a number - let num_str = $s.offset(idx); - let res = match $base { - 0 => detect_base(num_str) - .and_then(|($base, i)| convert_integer(num_str.offset(i), $base)), - 8 => convert_octal(num_str), - 16 => convert_hex(num_str), - _ => convert_integer(num_str, $base), - }; - - // check for error parsing octal/hex prefix - // also check to ensure a number was indeed parsed - let (num, i, overflow) = match res { - Some(res) => res, - None => { - invalid_input(); - return 0; - } - }; - idx += i; - - let overflow = if CHECK_SIGN { - overflow || (num as c_long).is_negative() - } else { - overflow - }; - // account for the sign - let num = num as $rettype; - let num = if overflow { - platform::errno = ERANGE; - if CHECK_SIGN { - if positive { - MAX_VAL - } else { - MIN_VAL - } - } else { - MAX_VAL - } - } else { - if positive { - num - } else { - // not using -num to keep the compiler happy - num.overflowing_neg().0 - } - }; - - set_endptr(idx); - - num - }}; -} - #[no_mangle] pub unsafe extern "C" fn strtoul( s: *const c_char, diff --git a/src/header/sys_file/mod.rs b/src/header/sys_file/mod.rs index 098dddc1b4..f126dd64ba 100644 --- a/src/header/sys_file/mod.rs +++ b/src/header/sys_file/mod.rs @@ -1,6 +1,6 @@ //! sys/file.h implementation -use platform; +use platform::{Pal, Sys}; use platform::types::*; pub const LOCK_SH: usize = 1; @@ -14,5 +14,5 @@ pub const L_XTND: usize = 2; #[no_mangle] pub extern "C" fn flock(fd: c_int, operation: c_int) -> c_int { - platform::flock(fd, operation) + Sys::flock(fd, operation) } diff --git a/src/header/sys_ioctl/mod.rs b/src/header/sys_ioctl/mod.rs index f6c1e44d32..1e392810af 100644 --- a/src/header/sys_ioctl/mod.rs +++ b/src/header/sys_ioctl/mod.rs @@ -16,7 +16,7 @@ pub struct sgttyb { #[cfg(target_os = "linux")] pub mod inner { - use *; + use super::*; #[repr(C)] pub struct winsize { @@ -222,4 +222,4 @@ pub mod inner { } #[cfg(target_os = "linux")] -pub use inner::*; +pub use self::inner::*; diff --git a/src/header/sys_mman/mod.rs b/src/header/sys_mman/mod.rs index e346a2f6e4..96a6f3a8d2 100644 --- a/src/header/sys_mman/mod.rs +++ b/src/header/sys_mman/mod.rs @@ -2,7 +2,7 @@ use platform; use platform::{Pal, Sys}; use platform::types::*; -pub use sys::*; +pub use self::sys::*; #[cfg(target_os = "linux")] #[path = "linux.rs"] diff --git a/src/header/sys_socket/mod.rs b/src/header/sys_socket/mod.rs index 1d5fe32409..714ce9c0b2 100644 --- a/src/header/sys_socket/mod.rs +++ b/src/header/sys_socket/mod.rs @@ -6,8 +6,8 @@ use platform; use platform::{PalSocket, Sys}; use platform::types::*; +use self::constants::*; mod constants; -use constants::*; pub type in_addr_t = [u8; 4]; pub type in_port_t = u16; diff --git a/src/header/sys_utsname/mod.rs b/src/header/sys_utsname/mod.rs index a20924b598..1899d90962 100644 --- a/src/header/sys_utsname/mod.rs +++ b/src/header/sys_utsname/mod.rs @@ -24,4 +24,4 @@ mod inner { } } #[cfg(target_os = "linux")] -pub use inner::*; +pub use self::inner::*; diff --git a/src/header/time/constants.rs b/src/header/time/constants.rs index d677f91b50..45541d4a28 100644 --- a/src/header/time/constants.rs +++ b/src/header/time/constants.rs @@ -1,3 +1,7 @@ +use platform::types::*; + +pub use self::sys::*; + #[cfg(target_os = "linux")] #[path = "linux.rs"] pub mod sys; @@ -6,9 +10,6 @@ pub mod sys; #[path = "redox.rs"] pub mod sys; -use platform::types::*; -pub use sys::*; - // Move epoch from 01.01.1970 to 01.03.0000 (yes, Year 0) - this is the first // day of a 400-year long "era", right after additional day of leap year. // This adjustment is required only for date calculation, so instead of diff --git a/src/header/time/helpers.rs b/src/header/time/helpers.rs index 581c72eca1..70ff5f3afe 100644 --- a/src/header/time/helpers.rs +++ b/src/header/time/helpers.rs @@ -1,6 +1,7 @@ -use constants::*; use platform::types::*; +use super::constants::*; + // compute year, month, day & day of year // for description of this algorithm see // http://howardhinnant.github.io/date_algorithms.html#civil_from_days diff --git a/src/header/time/mod.rs b/src/header/time/mod.rs index 09ba1e1617..1382fb5cbe 100644 --- a/src/header/time/mod.rs +++ b/src/header/time/mod.rs @@ -8,8 +8,8 @@ use platform; use platform::{Pal, Sys}; use platform::types::*; -use constants::*; -use helpers::*; +use self::constants::*; +use self::helpers::*; pub mod constants; mod helpers; diff --git a/src/header/time/strftime.rs b/src/header/time/strftime.rs index aef702f684..bc8a649b49 100644 --- a/src/header/time/strftime.rs +++ b/src/header/time/strftime.rs @@ -1,7 +1,9 @@ use alloc::string::String; -use platform::types::*; + use platform::{self, Write}; -use tm; +use platform::types::*; + +use super::tm; pub unsafe fn strftime( w: &mut W, @@ -115,7 +117,7 @@ pub unsafe fn strftime( b'r' => w!(recurse "%I:%M:%S %p"), b'R' => w!(recurse "%H:%M"), // Nothing is modified in mktime, but the C standard of course requires a mutable pointer ._. - b's' => w!("{}", ::mktime(t as *mut tm)), + b's' => w!("{}", super::mktime(t as *mut tm)), b'S' => w!("{:02}", (*t).tm_sec), b'T' => w!(recurse "%H:%M:%S"), b'u' => w!("{}", ((*t).tm_wday + 7 - 1) % 7 + 1), diff --git a/src/header/unistd/brk.rs b/src/header/unistd/brk.rs index 78ece98354..7cf6ead43a 100644 --- a/src/header/unistd/brk.rs +++ b/src/header/unistd/brk.rs @@ -1,6 +1,6 @@ use core::ptr; -use errno::ENOMEM; +use header::errno::ENOMEM; use platform; use platform::{Pal, Sys}; use platform::types::*; diff --git a/src/header/unistd/getopt.rs b/src/header/unistd/getopt.rs index 29d77b4df6..1a4a66fd2f 100644 --- a/src/header/unistd/getopt.rs +++ b/src/header/unistd/getopt.rs @@ -2,9 +2,8 @@ use core::ptr; +use header::{stdio, string}; use platform::types::*; -use stdio; -use string; #[allow(non_upper_case_globals)] #[no_mangle] diff --git a/src/header/unistd/mod.rs b/src/header/unistd/mod.rs index 7765abd7f6..08eb2deca3 100644 --- a/src/header/unistd/mod.rs +++ b/src/header/unistd/mod.rs @@ -7,9 +7,9 @@ use platform; use platform::{Pal, Sys}; use platform::types::*; -pub use brk::*; -pub use getopt::*; -pub use pathconf::*; +pub use self::brk::*; +pub use self::getopt::*; +pub use self::pathconf::*; mod brk; mod getopt; diff --git a/src/header/wchar/utf8.rs b/src/header/wchar/utf8.rs index f3ef32dd66..1f8e72f03b 100644 --- a/src/header/wchar/utf8.rs +++ b/src/header/wchar/utf8.rs @@ -7,7 +7,7 @@ use header::errno; use platform; use platform::types::*; -use mbstate_t; +use super::mbstate_t; //It's guaranteed that we don't have any nullpointers here pub unsafe fn mbrtowc(pwc: *mut wchar_t, s: *const c_char, n: usize, ps: *mut mbstate_t) -> usize { diff --git a/src/lib.rs b/src/lib.rs index 866cc2db26..28f7d58d0d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,11 +2,15 @@ #![allow(non_camel_case_types)] #![feature(alloc)] #![feature(allocator_api)] +#![feature(const_fn)] #![feature(const_vec_new)] +#![feature(core_intrinsics)] +#![feature(extern_prelude)] #![feature(global_asm)] #![feature(lang_items)] #![feature(linkage)] #![feature(panic_implementation)] +#![feature(str_internals)] #![feature(thread_local)] #[macro_use] @@ -26,10 +30,15 @@ extern crate syscall; #[cfg(target_os = "redox")] extern crate spin; +#[macro_use] +mod macros; pub mod header; pub mod platform; -use platform::{Pal, Sys}; +use platform::{Allocator, Pal, Sys}; + +#[global_allocator] +static ALLOCATOR: Allocator = Allocator; #[cfg(not(test))] #[panic_implementation] diff --git a/src/macros.rs b/src/macros.rs new file mode 100644 index 0000000000..bdccf675b3 --- /dev/null +++ b/src/macros.rs @@ -0,0 +1,103 @@ +#[macro_export] +macro_rules! strto_impl { + ( + $rettype:ty, $signed:expr, $maxval:expr, $minval:expr, $s:ident, $endptr:ident, $base:ident + ) => {{ + // ensure these are constants + const CHECK_SIGN: bool = $signed; + const MAX_VAL: $rettype = $maxval; + const MIN_VAL: $rettype = $minval; + + let set_endptr = |idx: isize| { + if !$endptr.is_null() { + // This is stupid, but apparently strto* functions want + // const input but mut output, yet the man page says + // "stores the address of the first invalid character in *endptr" + // so obviously it doesn't want us to clone it. + *$endptr = $s.offset(idx) as *mut _; + } + }; + + let invalid_input = || { + platform::errno = EINVAL; + set_endptr(0); + }; + + // only valid bases are 2 through 36 + if $base != 0 && ($base < 2 || $base > 36) { + invalid_input(); + return 0; + } + + let mut idx = 0; + + // skip any whitespace at the beginning of the string + while ctype::isspace(*$s.offset(idx) as c_int) != 0 { + idx += 1; + } + + // check for +/- + let positive = match is_positive(*$s.offset(idx)) { + Some((pos, i)) => { + idx += i; + pos + } + None => { + invalid_input(); + return 0; + } + }; + + // convert the string to a number + let num_str = $s.offset(idx); + let res = match $base { + 0 => detect_base(num_str) + .and_then(|($base, i)| convert_integer(num_str.offset(i), $base)), + 8 => convert_octal(num_str), + 16 => convert_hex(num_str), + _ => convert_integer(num_str, $base), + }; + + // check for error parsing octal/hex prefix + // also check to ensure a number was indeed parsed + let (num, i, overflow) = match res { + Some(res) => res, + None => { + invalid_input(); + return 0; + } + }; + idx += i; + + let overflow = if CHECK_SIGN { + overflow || (num as c_long).is_negative() + } else { + overflow + }; + // account for the sign + let num = num as $rettype; + let num = if overflow { + platform::errno = ERANGE; + if CHECK_SIGN { + if positive { + MAX_VAL + } else { + MIN_VAL + } + } else { + MAX_VAL + } + } else { + if positive { + num + } else { + // not using -num to keep the compiler happy + num.overflowing_neg().0 + } + }; + + set_endptr(idx); + + num + }}; +} diff --git a/src/platform/allocator/dlmalloc.rs b/src/platform/allocator/dlmalloc.rs index ad02e7539d..a57748c7e0 100644 --- a/src/platform/allocator/dlmalloc.rs +++ b/src/platform/allocator/dlmalloc.rs @@ -1,6 +1,6 @@ use core::alloc::{GlobalAlloc, Layout}; -use types::*; +use super::types::*; extern "C" { fn dlmalloc(bytes: size_t) -> *mut c_void; diff --git a/src/platform/linux/mod.rs b/src/platform/linux/mod.rs index a11f13da22..232b6a11a6 100644 --- a/src/platform/linux/mod.rs +++ b/src/platform/linux/mod.rs @@ -1,8 +1,8 @@ use core::{mem, ptr}; use core::fmt::Write; -use {errno, FileWriter, Pal}; -use types::*; +use super::{errno, FileWriter, Pal}; +use super::types::*; mod signal; mod socket; @@ -107,7 +107,7 @@ impl Pal for Sys { } fn fstat(fildes: c_int, buf: *mut stat) -> c_int { - let empty_cstr: *const c_char = unsafe { ::cstr_from_bytes_with_nul_unchecked(b"\0") }; + let empty_cstr: *const c_char = unsafe { super::cstr_from_bytes_with_nul_unchecked(b"\0") }; e(unsafe { syscall!(NEWFSTATAT, fildes, empty_cstr, buf, AT_EMPTY_PATH) }) as c_int } diff --git a/src/platform/linux/signal.rs b/src/platform/linux/signal.rs index 1d29bc3d41..0e2e72d80d 100644 --- a/src/platform/linux/signal.rs +++ b/src/platform/linux/signal.rs @@ -1,8 +1,8 @@ use core::mem; use super::{e, Sys}; -use PalSignal; -use types::*; +use super::super::PalSignal; +use super::super::types::*; impl PalSignal for Sys { fn kill(pid: pid_t, sig: c_int) -> c_int { diff --git a/src/platform/linux/socket.rs b/src/platform/linux/socket.rs index f222a6e365..73707d7e42 100644 --- a/src/platform/linux/socket.rs +++ b/src/platform/linux/socket.rs @@ -1,6 +1,6 @@ use super::{e, Sys}; -use PalSocket; -use types::*; +use super::super::PalSocket; +use super::super::types::*; impl PalSocket for Sys { unsafe fn accept(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> c_int { diff --git a/src/platform/mod.rs b/src/platform/mod.rs index 918c19f59a..4abdab5df7 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -1,4 +1,7 @@ -pub use allocator::*; +use alloc::vec::Vec; +use core::{fmt, ptr}; + +pub use self::allocator::*; #[cfg(not(feature = "ralloc"))] #[path = "allocator/dlmalloc.rs"] @@ -8,11 +11,11 @@ mod allocator; #[path = "allocator/ralloc.rs"] mod allocator; -pub use pal::{Pal, PalSignal, PalSocket}; +pub use self::pal::{Pal, PalSignal, PalSocket}; mod pal; -pub use sys::Sys; +pub use self::sys::Sys; #[cfg(all(not(feature = "no_std"), target_os = "linux"))] #[path = "linux/mod.rs"] @@ -22,19 +25,13 @@ mod sys; #[path = "redox/mod.rs"] mod sys; +pub use self::rawfile::RawFile; + pub mod rawfile; + +use self::types::*; pub mod types; -pub use rawfile::RawFile; - -use alloc::vec::Vec; -use core::{fmt, ptr}; - -use types::*; - -#[global_allocator] -static ALLOCATOR: Allocator = Allocator; - //TODO #[thread_local] #[allow(non_upper_case_globals)] #[no_mangle] diff --git a/src/platform/pal/mod.rs b/src/platform/pal/mod.rs index 45f13c053a..25b8ea242d 100644 --- a/src/platform/pal/mod.rs +++ b/src/platform/pal/mod.rs @@ -1,6 +1,6 @@ use core::ptr; -use types::*; +use super::types::*; pub use self::signal::PalSignal; mod signal; diff --git a/src/platform/pal/signal.rs b/src/platform/pal/signal.rs index 50176b913c..e8a40a9621 100644 --- a/src/platform/pal/signal.rs +++ b/src/platform/pal/signal.rs @@ -1,5 +1,5 @@ -use Pal; -use types::*; +use super::super::Pal; +use super::super::types::*; pub trait PalSignal: Pal { fn kill(pid: pid_t, sig: c_int) -> c_int { diff --git a/src/platform/pal/socket.rs b/src/platform/pal/socket.rs index a1329d6026..8e8c1f6d90 100644 --- a/src/platform/pal/socket.rs +++ b/src/platform/pal/socket.rs @@ -1,5 +1,5 @@ -use Pal; -use types::*; +use super::super::Pal; +use super::super::types::*; pub trait PalSocket: Pal { unsafe fn accept(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> c_int { diff --git a/src/platform/rawfile.rs b/src/platform/rawfile.rs index 58d870123c..338ed0b4f3 100644 --- a/src/platform/rawfile.rs +++ b/src/platform/rawfile.rs @@ -1,6 +1,6 @@ use core::ops::Deref; -use {Pal, Sys, types::*}; +use super::{Pal, Sys, types::*}; pub struct RawFile(c_int); diff --git a/src/platform/redox/mod.rs b/src/platform/redox/mod.rs index bbe4920bcb..7c93747043 100644 --- a/src/platform/redox/mod.rs +++ b/src/platform/redox/mod.rs @@ -9,8 +9,8 @@ use syscall::data::TimeSpec as redox_timespec; use syscall::flag::*; use syscall::{self, Result}; -use {c_str, errno, FileReader, FileWriter, Pal, RawFile, Read}; -use types::*; +use super::{c_str, errno, FileReader, FileWriter, Pal, RawFile, Read}; +use super::types::*; mod signal; mod socket; diff --git a/src/platform/redox/signal.rs b/src/platform/redox/signal.rs index 612b04f2ef..76b8b818a4 100644 --- a/src/platform/redox/signal.rs +++ b/src/platform/redox/signal.rs @@ -1,8 +1,8 @@ use syscall; use super::{e, Sys}; -use {Pal, PalSignal}; -use types::*; +use super::super::{Pal, PalSignal}; +use super::super::types::*; #[thread_local] static mut SIG_HANDLER: Option = None; diff --git a/src/platform/redox/socket.rs b/src/platform/redox/socket.rs index bd78eafc90..7de759dab5 100644 --- a/src/platform/redox/socket.rs +++ b/src/platform/redox/socket.rs @@ -3,8 +3,8 @@ use syscall::{self, Result}; use syscall::flag::*; use super::{e, Sys}; -use {errno, Pal, PalSocket}; -use types::*; +use super::super::{errno, Pal, PalSocket}; +use super::super::types::*; macro_rules! bind_or_connect { (bind $path:expr) => {