Fix build, mostly
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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::*;
|
||||
|
||||
/*
|
||||
|
||||
@@ -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::*;
|
||||
|
||||
|
||||
@@ -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"]
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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: Write>(w: W, format: *const c_char, mut ap: VaList) -> c_int {
|
||||
let mut w = platform::CountingWriter::new(w);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
+3
-112
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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::*;
|
||||
|
||||
@@ -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"]
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -24,4 +24,4 @@ mod inner {
|
||||
}
|
||||
}
|
||||
#[cfg(target_os = "linux")]
|
||||
pub use inner::*;
|
||||
pub use self::inner::*;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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: Write>(
|
||||
w: &mut W,
|
||||
@@ -115,7 +117,7 @@ pub unsafe fn strftime<W: Write>(
|
||||
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),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use core::ptr;
|
||||
|
||||
use errno::ENOMEM;
|
||||
use header::errno::ENOMEM;
|
||||
use platform;
|
||||
use platform::{Pal, Sys};
|
||||
use platform::types::*;
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
+10
-1
@@ -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]
|
||||
|
||||
+103
@@ -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
|
||||
}};
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
use core::alloc::{GlobalAlloc, Layout};
|
||||
|
||||
use types::*;
|
||||
use super::types::*;
|
||||
|
||||
extern "C" {
|
||||
fn dlmalloc(bytes: size_t) -> *mut c_void;
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
+10
-13
@@ -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]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use core::ptr;
|
||||
|
||||
use types::*;
|
||||
use super::types::*;
|
||||
|
||||
pub use self::signal::PalSignal;
|
||||
mod signal;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use core::ops::Deref;
|
||||
|
||||
use {Pal, Sys, types::*};
|
||||
use super::{Pal, Sys, types::*};
|
||||
|
||||
pub struct RawFile(c_int);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<extern "C" fn(c_int)> = None;
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user