1
Fork 0

Rollup merge of #22596 - alexcrichton:fix-some-impls, r=huonw

This commit removes many unnecessary `unsafe impl` blocks as well as pushing the
needed implementations to the lowest level possible. I noticed that the bounds
for `RwLock` are a little off when reviewing #22574 and wanted to ensure that we
had our story straight on these implementations.
This commit is contained in:
Manish Goregaokar 2015-02-25 10:29:32 +05:30
commit 7b7cf84975
12 changed files with 68 additions and 25 deletions

View file

@ -8,10 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use prelude::v1::*;
use cell::UnsafeCell;
use libc;
use ptr;
use std::option::Option::{Some, None};
use sys::mutex::{self, Mutex};
use sys::time;
use sys::sync as ffi;
@ -20,6 +21,9 @@ use num::{Int, NumCast};
pub struct Condvar { inner: UnsafeCell<ffi::pthread_cond_t> }
unsafe impl Send for Condvar {}
unsafe impl Sync for Condvar {}
pub const CONDVAR_INIT: Condvar = Condvar {
inner: UnsafeCell { value: ffi::PTHREAD_COND_INITIALIZER },
};

View file

@ -8,8 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use prelude::v1::*;
use cell::UnsafeCell;
use marker::Sync;
use sys::sync as ffi;
use sys_common::mutex;
@ -24,6 +25,7 @@ pub const MUTEX_INIT: Mutex = Mutex {
inner: UnsafeCell { value: ffi::PTHREAD_MUTEX_INITIALIZER },
};
unsafe impl Send for Mutex {}
unsafe impl Sync for Mutex {}
impl Mutex {

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use prelude::v1::*;
use cell::UnsafeCell;
use sys::sync as ffi;
@ -17,6 +19,9 @@ pub const RWLOCK_INIT: RWLock = RWLock {
inner: UnsafeCell { value: ffi::PTHREAD_RWLOCK_INITIALIZER },
};
unsafe impl Send for RWLock {}
unsafe impl Sync for RWLock {}
impl RWLock {
#[inline]
pub unsafe fn new() -> RWLock {