about summary refs log tree commit diff
path: root/src/libstd/sync
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-12-29 16:38:07 -0800
committerAlex Crichton <alex@alexcrichton.com>2014-12-29 23:55:49 -0800
commit470ae101d6e26a6ce07292b7fca6eaed527451c7 (patch)
treeb976bc0eb040da67646a9d99bb9b901cb9f55abd /src/libstd/sync
parentcb7599b83e8f072a8871db3fb238f50e067794de (diff)
downloadrust-470ae101d6e26a6ce07292b7fca6eaed527451c7.tar.gz
rust-470ae101d6e26a6ce07292b7fca6eaed527451c7.zip
Test fixes and rebase conflicts
Diffstat (limited to 'src/libstd/sync')
-rw-r--r--src/libstd/sync/mutex.rs8
-rw-r--r--src/libstd/sync/rwlock.rs12
2 files changed, 12 insertions, 8 deletions
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<T: Send> Drop for Mutex<T> {
     }
 }
 
-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<MutexGuard<()>> {
         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<MutexGuard<()>> {
         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<T> Drop for RWLock<T> {
     }
 }
 
-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<RWLockReadGuard<'static, ()>> {
         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<RWLockReadGuard<'static, ()>> {
         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<RWLockWriteGuard<'static, ()>> {
         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<RWLockWriteGuard<'static, ()>> {
         if unsafe { self.lock.try_write() } {
-            Ok(try!(RWLockWriteGuard::new(self, &DUMMY)))
+            Ok(try!(RWLockWriteGuard::new(self, &DUMMY.0)))
         } else {
             Err(TryLockError::WouldBlock)
         }