Commit f949908f authored by Jeremy Soller's avatar Jeremy Soller
Browse files

WIP: Support cross compiling for Redox std build

parent 0b092068
......@@ -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" }
[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" }
//! 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::*;
......@@ -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?
......
......@@ -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
......
......@@ -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;
......
//! 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::*;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment