Commit 974f00a2 authored by John Hodge's avatar John Hodge
Browse files

Misc - Compilation fixes from nightly breakage

parent 2ec9d3ba
......@@ -90,12 +90,12 @@ endif
# Invoke xargo to build the main part of the kernel
# - This includes all modules enabled in ./Cargo.toml
#
$(OBJDIR)libmain.a: PHONY $(OBJDIR)modules.rs targets/target-$(ARCH).json
$(OBJDIR)libmain.a: PHONY $(OBJDIR)modules.rs targets/target-k-$(ARCH).json
@echo "[XARGO] . > [email protected]"
$VRUSTOS_MODPATH=../$(OBJDIR)modules.rs RUSTFLAGS="-C target-feature=$(subst $(space),$(comma),$(EXCLUDE_FEATURES:%=-%))" $(ENV) $(XARGO) build --target=target-$(ARCH) --release --features "$(CARGO_FEATURES)"
$VRUSTOS_MODPATH=../$(OBJDIR)modules.rs RUSTFLAGS="-C target-feature=$(subst $(space),$(comma),$(EXCLUDE_FEATURES:%=-%))" $(ENV) $(XARGO) build --target=target-k-$(ARCH) --release --features "$(CARGO_FEATURES)"
@mkdir -p $(dir [email protected])
@cp target/target-$(ARCH)/release/libmain.a [email protected]
$(patsubst %,$(OBJDIR)lib%.a,main $(MODS)): $(OBJDIR)libmain.a
@cp target/target-k-$(ARCH)/release/libmain.a [email protected]
$(patsubst %,$(OBJDIR)lib%.a,$(MODS)): $(OBJDIR)libmain.a
# - Module listing
$(OBJDIR)modules.rs: Makefile-xargo
......@@ -103,7 +103,7 @@ $(OBJDIR)modules.rs: Makefile-xargo
@echo '{\n $(patsubst %,extern crate %;\n,$(MODS))' >> [email protected]
@echo " $(patsubst %,use_mod(&%::S_MODULE); rv+=1;\n ,$(MODS))" >> [email protected]
@echo "}" >> [email protected]
targets/target-$(ARCH).json: Core/arch/$(ARCH)/target.json
targets/targetk-k-$(ARCH).json: Core/arch/$(ARCH)/target.json
@mkdir -p $(dir [email protected])
$Vcp $< [email protected]
......
......@@ -24,7 +24,5 @@ UPDATE:
curl https://static.rust-lang.org/rustup/rustup-init.sh -sSf | RUSTUP_HOME=$(abspath .prefix) CARGO_HOME=$(abspath .prefix) sh -s -- --default-toolchain none --no-modify-path -y
$(call fn_rustcmd,rustup) update $(RUSTUP_VER)
$(call fn_rustcmd,rustup) default $(RUSTUP_VER)
# curl $(RUSTC_SRC_URL) -o rustc-nightly-src.tar.gz
# tar -xf rustc-nightly-src.tar.gz --wildcards rustc-nightly-src/src/lib\* rustc-nightly-src/src/stdsimd rustc-nightly-src/vendor/compiler_builtins
# rm -rf rustc-nightly-src/src/libcompiler_builtins; mv rustc-nightly-src/vendor/compiler_builtins rustc-nightly-src/src/libcompiler_builtins
$(call fn_rustcmd,rustup) component add rust-src
$(CARGO) install xargo --git https://github.com/thepowersgang/xargo --force
......@@ -15,6 +15,9 @@
#![feature(alloc,allocator_api)]
#![feature(allocator_internals)]
#![feature(core_panic_info)] // Needed because of import of `panic` macro bringin in the module too
#![feature(__rust_unstable_column)] // needed for panics
#![feature(test,custom_test_frameworks)] // used for macro import
#![feature(asm,global_asm,concat_idents,format_args_nl,log_syntax)]
#![default_lib_allocator]
#![no_std]
......@@ -29,7 +32,9 @@ extern crate alloc_system;
//extern crate loader;
// Macros
pub use alloc::{/*vec, */format};
pub use core::{try, assert_eq, panic, write, unreachable, unimplemented};
pub use core::{try, assert, assert_eq, panic, write, unreachable, unimplemented};
pub use core::{file, line, __rust_unstable_column};
//pub use core::{deriving_Debug};
// Raw re-exports from core
......@@ -47,6 +52,7 @@ pub use core::raw;
// Crate re-exports
pub use alloc::{rc,boxed};
pub use alloc::slice;
pub use alloc::fmt;
mod std {
pub use core::{option, result};
......@@ -61,41 +67,72 @@ mod std {
/// Prelude
pub mod prelude {
pub mod v1 {
pub use core::marker::{Copy,Send,Sync,Sized};
pub use core::marker::{/*Copy,*/Send,Sync,Sized};
pub use core::ops::{Drop,Fn,FnMut,FnOnce};
pub use core::mem::drop;
pub use alloc::boxed::Box;
pub use borrow::ToOwned;
pub use core::clone::Clone;
pub use core::cmp::{PartialEq, PartialOrd, Eq, Ord};
//pub use core::clone::Clone;
//pub use core::cmp::{PartialEq, PartialOrd, Eq, Ord};
pub use core::convert::{AsRef,AsMut,Into,From};
pub use core::default::Default;
//pub use core::default::Default;
pub use core::iter::{Iterator,Extend,IntoIterator};
pub use core::iter::{DoubleEndedIterator, ExactSizeIterator};
pub use core::option::Option::{self,Some,None};
pub use core::result::Result::{self,Ok,Err};
pub use slice::SliceConcatExt;
//pub use slice::SliceConcatExt;
pub use string::{String,ToString};
pub use alloc::vec::Vec;
}
}
/// Formatted output
pub mod fmt {
pub use core::fmt::*;
pub fn format(args: ::std::fmt::Arguments) -> ::string::String
{
let mut output = ::string::String::new();
let _ = output.write_fmt(args);
output
// Macro imports?
pub use core::prelude::v1::{
Clone,
Copy,
Debug,
Default,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
RustcDecodable,
RustcEncodable,
bench,
global_allocator,
test,
test_case,
};
pub use core::prelude::v1::{
__rust_unstable_column,
asm,
assert,
cfg,
column,
compile_error,
concat,
concat_idents,
env,
file,
format_args,
format_args_nl,
global_asm,
include,
include_bytes,
include_str,
line,
log_syntax,
module_path,
option_env,
stringify,
//trace_macros,
};
}
}
pub mod collections {
//pub use alloc::BTreeMap;
}
......
......@@ -3,42 +3,26 @@
#![feature(raw_vec_internals)]
extern crate alloc;
use alloc::collections::vec_deque::{self, VecDeque};
pub struct VecRing<T> {
buf: alloc::raw_vec::RawVec<T>,
base_pos: usize,
len: usize,
inner: VecDeque<T>,
}
impl<T> VecRing<T> {
pub fn new() -> VecRing<T> {
VecRing {
buf: alloc::raw_vec::RawVec::new(),
base_pos: 0,
len: 0,
inner: VecDeque::new(),
}
}
pub fn with_capacity(cap: usize) -> VecRing<T> {
VecRing {
buf: alloc::raw_vec::RawVec::with_capacity(cap),
base_pos: 0,
len: 0,
inner: VecDeque::with_capacity(cap),
}
}
pub fn len(&self) -> usize {
self.len
}
fn inner_ptr(&self, ofs: usize) -> *mut T {
assert!(ofs < self.buf.cap());
// SAFE: Returns raw pointer within bounds
unsafe {
self.buf.ptr().offset(ofs as isize)
}
}
fn ptr(&self, idx: usize) -> *mut T {
self.inner_ptr( (idx + self.base_pos) % self.buf.cap() )
self.inner.len()
}
/*
......@@ -101,64 +85,40 @@ impl<T> VecRing<T> {
*/
pub fn push_back(&mut self, v: T) -> bool {
if self.len < self.buf.cap() {
// Write to an unused slot
let pos = self.len;
self.len += 1;
// SAFE: Memory used is empty
unsafe {
::std::ptr::write(&mut self[pos], v);
}
if self.inner.capacity() == 0 {
// Just drop, no capacity
false
}
else if self.inner.len() < self.inner.capacity() {
self.inner.push_back(v);
true
}
else {
// Overwrite first item and shift base up
self[0] = v;
if self.base_pos == self.buf.cap() - 1 {
self.base_pos = 0;
}
else {
self.base_pos += 1;
}
self.inner.pop_front();
self.inner.push_back(v);
false
}
}
pub fn push_front(&mut self, v: T) -> bool {
if self.buf.cap() == 0 {
if self.inner.capacity() == 0 {
// Just drop, no capacity
false
}
else if self.len < self.buf.cap() {
// Write to an unused slot
let pos = self.len;
self.len += 1;
// SAFE: Memory used is empty
unsafe {
::std::ptr::write(&mut self[pos], v);
}
else if self.inner.len() < self.inner.capacity() {
self.inner.push_front(v);
true
}
else {
// Overwrite last item and shift base up
let pos = self.len - 1;
self[pos] = v;
if self.base_pos == 0 {
self.base_pos = self.buf.cap() - 1;
}
else {
self.base_pos -= 1;
}
self.inner.pop_back();
self.inner.push_front(v);
false
}
}
pub fn iter(&self) -> Iter<T> {
Iter {
ring: self,
idx: 0,
inner_it: self.inner.iter(),
}
}
}
......@@ -166,16 +126,12 @@ impl<T> VecRing<T> {
impl<T> ::std::ops::Index<usize> for VecRing<T> {
type Output = T;
fn index(&self, idx: usize) -> &T {
assert!(idx < self.len());
// SAFE: Range-checked pointer into valid region
unsafe { &*self.ptr(idx) }
&self.inner[idx]
}
}
impl<T> ::std::ops::IndexMut<usize> for VecRing<T> {
fn index_mut(&mut self, idx: usize) -> &mut T {
assert!(idx < self.len());
// SAFE: Range-checked pointer into valid region
unsafe { &mut *self.ptr(idx) }
&mut self.inner[idx]
}
}
......@@ -189,20 +145,12 @@ impl<'a, T: 'a> ::std::iter::IntoIterator for &'a VecRing<T> {
}
pub struct Iter<'a, T: 'a> {
ring: &'a VecRing<T>,
idx: usize,
inner_it: vec_deque::Iter<'a, T>,
}
impl<'a, T: 'a> Iterator for Iter<'a, T> {
type Item = &'a T;
fn next(&mut self) -> Option<&'a T> {
if self.idx == self.ring.len() {
None
}
else {
self.idx += 1;
// SAFE: Bounds-checked pointer
Some( unsafe { &*self.ring.ptr(self.idx-1) } )
}
self.inner_it.next()
}
}
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