rt: remove a series of unfortunate casts.

This commit is contained in:
Huon Wilson 2013-08-29 22:28:49 +10:00
parent 440f1e2dad
commit e835c6b042

View File

@ -121,27 +121,20 @@ pub unsafe fn borrow<T>(f: &fn(&mut T)) {
/// For the Scheduler pointer to be aliased /// For the Scheduler pointer to be aliased
pub unsafe fn unsafe_borrow<T>() -> *mut T { pub unsafe fn unsafe_borrow<T>() -> *mut T {
let key = tls_key(); let key = tls_key();
let mut void_ptr: *mut c_void = tls::get(key); let void_ptr = tls::get(key);
if void_ptr.is_null() { if void_ptr.is_null() {
rtabort!("thread-local pointer is null. bogus!"); rtabort!("thread-local pointer is null. bogus!");
} }
let ptr: *mut *mut c_void = &mut void_ptr; void_ptr as *mut T
let ptr: *mut ~T = ptr as *mut ~T;
let ptr: *mut T = &mut **ptr;
return ptr;
} }
pub unsafe fn try_unsafe_borrow<T>() -> Option<*mut T> { pub unsafe fn try_unsafe_borrow<T>() -> Option<*mut T> {
let key = tls_key(); let key = tls_key();
let mut void_ptr: *mut c_void = tls::get(key); let void_ptr = tls::get(key);
if void_ptr.is_null() { if void_ptr.is_null() {
return None; None
} } else {
{ Some(void_ptr as *mut T)
let ptr: *mut *mut c_void = &mut void_ptr;
let ptr: *mut ~T = ptr as *mut ~T;
let ptr: *mut T = &mut **ptr;
return Some(ptr);
} }
} }