From 470ae101d6e26a6ce07292b7fca6eaed527451c7 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 29 Dec 2014 16:38:07 -0800 Subject: Test fixes and rebase conflicts --- src/libstd/sync/mutex.rs | 8 +++++--- src/libstd/sync/rwlock.rs | 12 +++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src/libstd/sync') diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 32c2c67152f..52004bb4a8f 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -234,7 +234,9 @@ impl Drop for Mutex { } } -static DUMMY: UnsafeCell<()> = UnsafeCell { value: () }; +struct Dummy(UnsafeCell<()>); +unsafe impl Sync for Dummy {} +static DUMMY: Dummy = Dummy(UnsafeCell { value: () }); impl StaticMutex { /// Acquires this lock, see `Mutex::lock` @@ -242,7 +244,7 @@ impl StaticMutex { #[unstable = "may be merged with Mutex in the future"] pub fn lock(&'static self) -> LockResult> { unsafe { self.lock.lock() } - MutexGuard::new(self, &DUMMY) + MutexGuard::new(self, &DUMMY.0) } /// Attempts to grab this lock, see `Mutex::try_lock` @@ -250,7 +252,7 @@ impl StaticMutex { #[unstable = "may be merged with Mutex in the future"] pub fn try_lock(&'static self) -> TryLockResult> { if unsafe { self.lock.try_lock() } { - Ok(try!(MutexGuard::new(self, &DUMMY))) + Ok(try!(MutexGuard::new(self, &DUMMY.0))) } else { Err(TryLockError::WouldBlock) } diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index 1b7a7f3f323..7f3c77c97ad 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -233,7 +233,9 @@ impl Drop for RWLock { } } -static DUMMY: UnsafeCell<()> = UnsafeCell { value: () }; +struct Dummy(UnsafeCell<()>); +unsafe impl Sync for Dummy {} +static DUMMY: Dummy = Dummy(UnsafeCell { value: () }); impl StaticRWLock { /// Locks this rwlock with shared read access, blocking the current thread @@ -244,7 +246,7 @@ impl StaticRWLock { #[unstable = "may be merged with RWLock in the future"] pub fn read(&'static self) -> LockResult> { unsafe { self.lock.read() } - RWLockReadGuard::new(self, &DUMMY) + RWLockReadGuard::new(self, &DUMMY.0) } /// Attempt to acquire this lock with shared read access. @@ -255,7 +257,7 @@ impl StaticRWLock { pub fn try_read(&'static self) -> TryLockResult> { if unsafe { self.lock.try_read() } { - Ok(try!(RWLockReadGuard::new(self, &DUMMY))) + Ok(try!(RWLockReadGuard::new(self, &DUMMY.0))) } else { Err(TryLockError::WouldBlock) } @@ -269,7 +271,7 @@ impl StaticRWLock { #[unstable = "may be merged with RWLock in the future"] pub fn write(&'static self) -> LockResult> { unsafe { self.lock.write() } - RWLockWriteGuard::new(self, &DUMMY) + RWLockWriteGuard::new(self, &DUMMY.0) } /// Attempt to lock this rwlock with exclusive write access. @@ -280,7 +282,7 @@ impl StaticRWLock { pub fn try_write(&'static self) -> TryLockResult> { if unsafe { self.lock.try_write() } { - Ok(try!(RWLockWriteGuard::new(self, &DUMMY))) + Ok(try!(RWLockWriteGuard::new(self, &DUMMY.0))) } else { Err(TryLockError::WouldBlock) } -- cgit 1.4.1-3-g733a5