Skip to content

Commit

Permalink
[vga, intrusive] update for changes in const_fn, ptr::Unique
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw committed Jan 24, 2018
1 parent bde2347 commit 16adab4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 3 additions & 1 deletion sos_intrusive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
//! + `use-std`: use the Rust standard library (`std`), rather than `core`.
#![crate_name = "sos_intrusive"]
#![crate_type = "lib"]
#![feature( const_fn, unique )]
#![feature( const_fn
, const_ptr_null_mut )]
#![feature(unique )]
#![cfg_attr(not(feature = "use-std"), no_std )]
#![cfg_attr(feature = "clippy", feature(plugin))]
#![cfg_attr(feature = "clippy", plugin(clippy))]
Expand Down
2 changes: 2 additions & 0 deletions sos_intrusive/src/list/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,8 @@ unsafe impl<T> OwnedRef<T> for Unique<T> {

unsafe fn from_raw(ptr: *mut T) -> Self {
Unique::new(ptr)
// TODO: probably don't panic here.
.expect("null pointer passed to OwnedRef::from_raw!")
}
}

Expand Down
14 changes: 9 additions & 5 deletions vga/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
//! + `log`: provides a `log!` macro for kernel log messages.
#![crate_name = "vga"]
#![crate_type = "lib"]
#![feature( const_fn
, slice_patterns
#![feature( slice_patterns
, unique )]
#![feature( const_fn
, const_unique_new )]
#![cfg_attr(feature = "system_term", feature(lang_items))]
#![cfg_attr(feature = "clippy", feature(plugin))]
#![cfg_attr(feature = "clippy", plugin(clippy))]
Expand Down Expand Up @@ -193,12 +194,15 @@ impl Terminal {
///
/// # Unsafe due to:
/// + Casting a raw address to an array
/// + Constructing a `ptr::Unique` from an unchecked mut pointer.
pub const unsafe fn new( colors: Palette
, buffer_start: usize)
-> Terminal {
-> Terminal {
Terminal { x: 0, y: 0
, colors: colors
, buffer: ptr::Unique::new(buffer_start as *mut _)
, colors
// TODO: this probably shouldn't be unchecked, but this
// can't be a const fn otherwise...
, buffer: ptr::Unique::new_unchecked(buffer_start as *mut _)
}
}

Expand Down

0 comments on commit 16adab4

Please sign in to comment.