Browse Source

WIP: Support cross compiling for Redox std build

Jeremy Soller 8 years ago
parent
commit
f949908f4d
9 changed files with 20 additions and 55 deletions
  1. 4 8
      Cargo.toml
  2. 0 19
      shim/Cargo.toml
  3. 0 19
      shim/src/lib.rs
  4. 2 1
      src/block.rs
  5. 4 2
      src/bookkeeper.rs
  6. 0 4
      src/lib.rs
  7. 10 2
      src/sys/mod.rs
  8. 0 0
      src/sys/redox.rs
  9. 0 0
      src/sys/unix.rs

+ 4 - 8
Cargo.toml

@@ -12,12 +12,11 @@ readme = "README.md"
 keywords = ["alloc", "malloc", "allocator", "ralloc", "redox"]
 license = "MIT"
 
-[dependencies]
-unborrow = "0.3.0"
+[target.'cfg(not(target_os = "redox"))'.dependencies]
+libc = { version = "0.2", default-features = false }
 
-[dependencies.ralloc_shim]
-path = "shim"
-version = "0.1"
+[target.'cfg(target_os = "redox")'.dependencies]
+redox_syscall = { git = "https://github.com/redox-os/syscall.git" }
 
 [dependencies.clippy]
 version = "0.0.80"
@@ -46,6 +45,3 @@ tls = []
 unsafe_no_brk_lock = []
 unsafe_no_mutex_lock = []
 write = []
-
-[replace]
-"libc:0.2.17" = { git = "https://github.com/redox-os/liblibc.git", branch = "redox" }

+ 0 - 19
shim/Cargo.toml

@@ -1,19 +0,0 @@
-[package]
-name = "ralloc_shim"
-version = "0.1.2"
-authors = ["Jeremy Soller <jackpot51@gmail.com>", "Ticki"]
-
-[profile.release]
-panic = "abort"
-opt-level = 3
-debug = false
-rpath = false
-lto = true
-debug-assertions = false
-codegen-units = 1
-
-[target.'cfg(not(target_os = "redox"))'.dependencies]
-libc = { version = "0.2", default-features = false }
-
-[target.'cfg(target_os = "redox")'.dependencies]
-redox_syscall = { git = "https://github.com/redox-os/syscall.git" }

+ 0 - 19
shim/src/lib.rs

@@ -1,19 +0,0 @@
-//! Symbols and externs that `ralloc` depends on.
-//!
-//! This crate provides implementation/import of these in Linux, BSD, and Mac OS.
-
-#![cfg_attr(not(redox), feature(linkage))]
-#![no_std]
-#![warn(missing_docs)]
-
-#[cfg(target_os = "redox")]
-mod redox;
-
-#[cfg(target_os = "redox")]
-pub use redox::*;
-
-#[cfg(not(target_os = "redox"))]
-mod unix;
-
-#[cfg(not(target_os = "redox"))]
-pub use unix::*;

+ 2 - 1
src/block.rs

@@ -159,7 +159,8 @@ impl Block {
     /// This marks it as free, and returns the old value.
     #[inline]
     pub fn pop(&mut self) -> Block {
-        unborrow!(mem::replace(self, Block::empty(self.ptr.clone())))
+        let new = Block::empty(self.ptr.clone());
+        mem::replace(self, new)
     }
 
     /// Is this block placed left to the given other block?

+ 4 - 2
src/bookkeeper.rs

@@ -639,7 +639,8 @@ pub trait Allocator: ops::DerefMut<Target = Bookkeeper> {
             }
 
             // Reserve space and free the old buffer.
-            if let Some(x) = unborrow!(self.reserve(self.pool.len() + 1)) {
+            let new_len = self.pool.len() + 1;
+            if let Some(x) = self.reserve(new_len) {
                 self.free(x);
             }
 
@@ -807,7 +808,8 @@ pub trait Allocator: ops::DerefMut<Target = Bookkeeper> {
 
             // Reserve space. This does not break order, due to the assumption that
             // `reserve` never breaks order.
-            old_buf = unborrow!(self.reserve(self.pool.len() + 1));
+            let new_len = self.pool.len() + 1;
+            old_buf = self.reserve(new_len);
 
             // We will move a block into reserved memory but outside of the vec's bounds. For
             // that reason, we push an uninitialized element to extend the length, which will

+ 0 - 4
src/lib.rs

@@ -22,10 +22,6 @@
         invalid_upcast_comparisons, mutex_integer, nonminimal_bool, shadow_same, shadow_unrelated,
         single_match_else, string_add, string_add_assign, wrong_pub_self_convention)]
 
-#[macro_use]
-#[no_link]
-extern crate unborrow;
-
 #[cfg(feature = "write")]
 #[macro_use]
 mod write;

+ 10 - 2
src/sys.rs → src/sys/mod.rs

@@ -1,6 +1,14 @@
-//! System primitives.
+//! Symbols and externs that `ralloc` depends on.
+//!
+//! This crate provides implementation/import of these in Linux, BSD, and Mac OS.
 
-extern crate ralloc_shim as shim;
+#[cfg(target_os = "redox")]
+#[path="redox.rs"]
+mod shim;
+
+#[cfg(not(target_os = "redox"))]
+#[path="unix.rs"]
+mod shim;
 
 use prelude::*;
 

+ 0 - 0
shim/src/redox.rs → src/sys/redox.rs


+ 0 - 0
shim/src/unix.rs → src/sys/unix.rs