Removing more unnecessary unsafe blocks throughout
This commit is contained in:
@@ -231,7 +231,6 @@ unsafe fn walk_gc_roots(mem: Memory, sentinel: **Word, visitor: Visitor) {
|
||||
// the stack.
|
||||
let mut reached_sentinel = ptr::is_null(sentinel);
|
||||
for stackwalk::walk_stack |frame| {
|
||||
unsafe {
|
||||
let pc = last_ret;
|
||||
let Segment {segment: next_segment, boundary: boundary} =
|
||||
find_segment_for_frame(frame.fp, segment);
|
||||
@@ -292,7 +291,6 @@ unsafe fn walk_gc_roots(mem: Memory, sentinel: **Word, visitor: Visitor) {
|
||||
reached_sentinel = delay_reached_sentinel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn gc() {
|
||||
unsafe {
|
||||
|
||||
@@ -156,10 +156,8 @@ pub impl PacketHeader {
|
||||
unsafe fn unblock(&self) {
|
||||
let old_task = swap_task(&mut self.blocked_task, ptr::null());
|
||||
if !old_task.is_null() {
|
||||
unsafe {
|
||||
rustrt::rust_task_deref(old_task)
|
||||
}
|
||||
}
|
||||
match swap_state_acq(&mut self.state, Empty) {
|
||||
Empty | Blocked => (),
|
||||
Terminated => self.state = Terminated,
|
||||
|
||||
@@ -80,11 +80,9 @@ pub unsafe fn unsafe_borrow() -> &mut Scheduler {
|
||||
}
|
||||
|
||||
pub unsafe fn unsafe_borrow_io() -> &mut IoFactoryObject {
|
||||
unsafe {
|
||||
let sched = unsafe_borrow();
|
||||
return sched.event_loop.io().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
fn tls_key() -> tls::Key {
|
||||
maybe_tls_key().get()
|
||||
|
||||
@@ -98,7 +98,7 @@ pub enum uv_req_type {
|
||||
|
||||
pub unsafe fn malloc_handle(handle: uv_handle_type) -> *c_void {
|
||||
assert!(handle != UV_UNKNOWN_HANDLE && handle != UV_HANDLE_TYPE_MAX);
|
||||
let size = unsafe { rust_uv_handle_size(handle as uint) };
|
||||
let size = rust_uv_handle_size(handle as uint);
|
||||
let p = malloc(size);
|
||||
assert!(p.is_not_null());
|
||||
return p;
|
||||
@@ -110,7 +110,7 @@ pub unsafe fn free_handle(v: *c_void) {
|
||||
|
||||
pub unsafe fn malloc_req(req: uv_req_type) -> *c_void {
|
||||
assert!(req != UV_UNKNOWN_REQ && req != UV_REQ_TYPE_MAX);
|
||||
let size = unsafe { rust_uv_req_size(req as uint) };
|
||||
let size = rust_uv_req_size(req as uint);
|
||||
let p = malloc(size);
|
||||
assert!(p.is_not_null());
|
||||
return p;
|
||||
|
||||
@@ -262,7 +262,6 @@ pub impl<T:Owned> Exclusive<T> {
|
||||
// the exclusive. Supporting that is a work in progress.
|
||||
#[inline(always)]
|
||||
unsafe fn with<U>(&self, f: &fn(x: &mut T) -> U) -> U {
|
||||
unsafe {
|
||||
let rec = get_shared_mutable_state(&self.x);
|
||||
do (*rec).lock.lock {
|
||||
if (*rec).failed {
|
||||
@@ -275,7 +274,6 @@ pub impl<T:Owned> Exclusive<T> {
|
||||
result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
unsafe fn with_imm<U>(&self, f: &fn(x: &T) -> U) -> U {
|
||||
|
||||
@@ -43,11 +43,11 @@ pub unsafe fn weaken_task(f: &fn(Port<ShutdownMsg>)) {
|
||||
let task = get_task_id();
|
||||
// Expect the weak task service to be alive
|
||||
assert!(service.try_send(RegisterWeakTask(task, shutdown_chan)));
|
||||
unsafe { rust_dec_kernel_live_count(); }
|
||||
rust_dec_kernel_live_count();
|
||||
do (|| {
|
||||
f(shutdown_port.take())
|
||||
}).finally || {
|
||||
unsafe { rust_inc_kernel_live_count(); }
|
||||
rust_inc_kernel_live_count();
|
||||
// Service my have already exited
|
||||
service.send(UnregisterWeakTask(task));
|
||||
}
|
||||
|
||||
@@ -2628,13 +2628,11 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::node_id) -> ValueRef {
|
||||
let class_ty = ty::lookup_item_type(tcx, parent_id).ty;
|
||||
// This code shouldn't be reached if the class is generic
|
||||
assert!(!ty::type_has_params(class_ty));
|
||||
let lldty = unsafe {
|
||||
T_fn(~[
|
||||
let lldty = T_fn(~[
|
||||
T_ptr(T_i8()),
|
||||
T_ptr(type_of(ccx, class_ty))
|
||||
],
|
||||
T_nil())
|
||||
};
|
||||
T_nil());
|
||||
let s = get_dtor_symbol(ccx, /*bad*/copy *pt, dt.node.id, None);
|
||||
|
||||
/* Make the declaration for the dtor */
|
||||
|
||||
@@ -177,7 +177,6 @@ pub impl<T:Owned> MutexARC<T> {
|
||||
*/
|
||||
#[inline(always)]
|
||||
unsafe fn access<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
|
||||
unsafe {
|
||||
let state = get_shared_mutable_state(&self.x);
|
||||
// Borrowck would complain about this if the function were
|
||||
// not already unsafe. See borrow_rwlock, far below.
|
||||
@@ -187,7 +186,6 @@ pub impl<T:Owned> MutexARC<T> {
|
||||
blk(&mut (*state).data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// As access(), but with a condvar, as sync::mutex.lock_cond().
|
||||
#[inline(always)]
|
||||
@@ -195,7 +193,6 @@ pub impl<T:Owned> MutexARC<T> {
|
||||
&self,
|
||||
blk: &fn(x: &'x mut T, c: &'c Condvar) -> U) -> U
|
||||
{
|
||||
unsafe {
|
||||
let state = get_shared_mutable_state(&self.x);
|
||||
do (&(*state).lock).lock_cond |cond| {
|
||||
check_poison(true, (*state).failed);
|
||||
@@ -207,7 +204,6 @@ pub impl<T:Owned> MutexARC<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Common code for {mutex.access,rwlock.write}{,_cond}.
|
||||
#[inline(always)]
|
||||
|
||||
Reference in New Issue
Block a user