Support building for Redox

This commit is contained in:
Jeremy Soller
2018-03-04 08:10:42 -07:00
parent 352f485649
commit 866d952924
9 changed files with 64 additions and 19 deletions
+3
View File
@@ -7,3 +7,6 @@
[submodule "ralloc"]
path = ralloc
url = https://github.com/redox-os/ralloc.git
[submodule "va_list"]
path = va_list
url = https://github.com/redox-os/va_list-rs.git
Generated
+19 -3
View File
@@ -97,6 +97,11 @@ name = "fuchsia-zircon-sys"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "gcc"
version = "0.3.54"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "grp"
version = "0.1.0"
@@ -177,6 +182,7 @@ dependencies = [
name = "platform"
version = "0.1.0"
dependencies = [
"redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"syscall 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -197,6 +203,7 @@ dependencies = [
name = "ralloc_shim"
version = "0.1.1"
dependencies = [
"redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"sc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -411,7 +418,7 @@ version = "0.1.0"
dependencies = [
"cbindgen 0.5.0",
"platform 0.1.0",
"va_list 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"va_list 0.1.0",
]
[[package]]
@@ -534,7 +541,16 @@ dependencies = [
[[package]]
name = "va_list"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"va_list-helper 0.0.2",
]
[[package]]
name = "va_list-helper"
version = "0.0.2"
dependencies = [
"gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "vec_map"
@@ -580,6 +596,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab"
"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
"checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb"
"checksum itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8324a32baf01e2ae060e9de58ed0bc2320c9a2833491ee36cd3b4c414de4db8c"
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
"checksum libc 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)" = "56aebce561378d99a0bb578f8cb15b6114d2a1814a6c7949bbe646d968bb4fa9"
@@ -624,7 +641,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f"
"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
"checksum va_list 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7365862faee55ed0dbc112491aa5f0451ca01bf98afcc6463183b5aaa5bd3128"
"checksum vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "887b5b631c2ad01628bbbaa7dd4c869f80d3186688f8d0b6f58774fbe324988c"
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
"checksum winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "04e3bd221fcbe8a271359c04f21a76db7d0c6028862d1bb5512d85e1e2eb5bb3"
+4 -1
View File
@@ -3,5 +3,8 @@ name = "platform"
version = "0.1.0"
authors = ["Jeremy Soller <jackpot51@gmail.com>"]
[dependencies]
[target.'cfg(target_os = "linux")'.dependencies]
syscall = "0.2"
[target.'cfg(target_os = "redox")'.dependencies]
redox_syscall = "0.1"
+16 -1
View File
@@ -20,7 +20,22 @@ pub mod types;
use core::fmt;
use types::c_int;
use types::*;
pub unsafe fn c_str(s: *const c_char) -> &'static [u8] {
use core::slice;
let mut size = 0;
loop {
if *s.offset(size) == 0 {
break;
}
size += 1;
}
slice::from_raw_parts(s as *const u8, size as usize)
}
pub struct FileWriter(pub c_int);
+18 -2
View File
@@ -1,8 +1,24 @@
use syscall;
use c_str;
use types::*;
pub fn close(fd: c_int) -> c_int {
syscall::close(fd as usize);
0
}
pub fn exit(status: c_int) -> ! {
syscall::exit(status);
syscall::exit(status as usize);
loop {}
}
pub fn open(path: *const c_char, oflag: c_int, mode: mode_t) -> c_int {
let path = unsafe { c_str(path) };
syscall::open(path, (oflag as usize) | (mode as usize)).unwrap() as c_int
}
pub fn write(fd: c_int, buf: &[u8]) -> ssize_t {
syscall::write(fd, buf);
syscall::write(fd as usize, buf);
buf.len() as ssize_t
}
+1 -1
Submodule ralloc updated: b521bac287...31b781a287
+1 -1
View File
@@ -9,4 +9,4 @@ cbindgen = { path = "../../cbindgen" }
[dependencies]
platform = { path = "../../platform" }
va_list = { version = "0.1", features = ["no_std"] }
va_list = { path = "../../va_list", features = ["no_std"] }
+1 -10
View File
@@ -104,16 +104,7 @@ pub extern "C" fn strerror(errnum: c_int) -> *mut c_char {
#[no_mangle]
pub unsafe extern "C" fn strlen(s: *const c_char) -> size_t {
let mut size = 0;
loop {
if *s.offset(size) == 0 {
break;
}
size += 1;
}
size as size_t
platform::c_str(s).len() as size_t
}
#[no_mangle]
Submodule
+1
Submodule va_list added at 4762a18450