diff options
| author | bors <bors@rust-lang.org> | 2015-01-09 01:19:54 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-01-09 01:19:54 +0000 |
| commit | 948d1d004da14a59316d3fb6f144da906ed9df6d (patch) | |
| tree | c7eb3ea18e59285e8f4e81e8766172b14835b780 /src/libstd/sys | |
| parent | e72ad98e46590e136fd22f51fe6dd77832bbdfe1 (diff) | |
| parent | b527494d2d1d705d9aa8c4c0c9042e63d9825619 (diff) | |
| download | rust-948d1d004da14a59316d3fb6f144da906ed9df6d.tar.gz rust-948d1d004da14a59316d3fb6f144da906ed9df6d.zip | |
Merge pull request #20741 from mneumann/dragonfly-pthread-mutex
Fix assertion in Mutex::destroy() on DragonFly (#20698) Reviewed-by: alexcrichton
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/unix/condvar.rs | 12 | ||||
| -rw-r--r-- | src/libstd/sys/unix/mutex.rs | 12 | ||||
| -rw-r--r-- | src/libstd/sys/unix/rwlock.rs | 13 |
3 files changed, 37 insertions, 0 deletions
diff --git a/src/libstd/sys/unix/condvar.rs b/src/libstd/sys/unix/condvar.rs index 3aa4825f3be..52dd261824f 100644 --- a/src/libstd/sys/unix/condvar.rs +++ b/src/libstd/sys/unix/condvar.rs @@ -76,8 +76,20 @@ impl Condvar { } #[inline] + #[cfg(not(target_os = "dragonfly"))] pub unsafe fn destroy(&self) { let r = ffi::pthread_cond_destroy(self.inner.get()); debug_assert_eq!(r, 0); } + + #[inline] + #[cfg(target_os = "dragonfly")] + pub unsafe fn destroy(&self) { + let r = ffi::pthread_cond_destroy(self.inner.get()); + // On DragonFly pthread_cond_destroy() returns EINVAL if called on + // a condvar that was just initialized with + // ffi::PTHREAD_COND_INITIALIZER. Once it is used or + // pthread_cond_init() is called, this behaviour no longer occurs. + debug_assert!(r == 0 || r == libc::EINVAL); + } } diff --git a/src/libstd/sys/unix/mutex.rs b/src/libstd/sys/unix/mutex.rs index ada8a7f2349..9e1527aef20 100644 --- a/src/libstd/sys/unix/mutex.rs +++ b/src/libstd/sys/unix/mutex.rs @@ -48,8 +48,20 @@ impl Mutex { ffi::pthread_mutex_trylock(self.inner.get()) == 0 } #[inline] + #[cfg(not(target_os = "dragonfly"))] pub unsafe fn destroy(&self) { let r = ffi::pthread_mutex_destroy(self.inner.get()); debug_assert_eq!(r, 0); } + #[inline] + #[cfg(target_os = "dragonfly")] + pub unsafe fn destroy(&self) { + use libc; + let r = ffi::pthread_mutex_destroy(self.inner.get()); + // On DragonFly pthread_mutex_destroy() returns EINVAL if called on a + // mutex that was just initialized with ffi::PTHREAD_MUTEX_INITIALIZER. + // Once it is used (locked/unlocked) or pthread_mutex_init() is called, + // this behaviour no longer occurs. + debug_assert!(r == 0 || r == libc::EINVAL); + } } diff --git a/src/libstd/sys/unix/rwlock.rs b/src/libstd/sys/unix/rwlock.rs index 0d63ff14ff2..54523e0076d 100644 --- a/src/libstd/sys/unix/rwlock.rs +++ b/src/libstd/sys/unix/rwlock.rs @@ -50,8 +50,21 @@ impl RWLock { #[inline] pub unsafe fn write_unlock(&self) { self.read_unlock() } #[inline] + #[cfg(not(target_os = "dragonfly"))] pub unsafe fn destroy(&self) { let r = ffi::pthread_rwlock_destroy(self.inner.get()); debug_assert_eq!(r, 0); } + + #[inline] + #[cfg(target_os = "dragonfly")] + pub unsafe fn destroy(&self) { + use libc; + let r = ffi::pthread_rwlock_destroy(self.inner.get()); + // On DragonFly pthread_rwlock_destroy() returns EINVAL if called on a + // rwlock that was just initialized with + // ffi::PTHREAD_RWLOCK_INITIALIZER. Once it is used (locked/unlocked) + // or pthread_rwlock_init() is called, this behaviour no longer occurs. + debug_assert!(r == 0 || r == libc::EINVAL); + } } |
