Skip to content

Commit 4288a08

Browse files
committed
std: Favor cfg! over #[cfg] in unix rwlocks
1 parent e962870 commit 4288a08

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/libstd/sys/unix/rwlock.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,16 @@ impl RWLock {
4949
#[inline]
5050
pub unsafe fn write_unlock(&self) { self.read_unlock() }
5151
#[inline]
52-
#[cfg(not(target_os = "dragonfly"))]
5352
pub unsafe fn destroy(&self) {
54-
let r = ffi::pthread_rwlock_destroy(self.inner.get());
55-
debug_assert_eq!(r, 0);
56-
}
57-
58-
#[inline]
59-
#[cfg(target_os = "dragonfly")]
60-
pub unsafe fn destroy(&self) {
61-
use libc;
6253
let r = ffi::pthread_rwlock_destroy(self.inner.get());
6354
// On DragonFly pthread_rwlock_destroy() returns EINVAL if called on a
6455
// rwlock that was just initialized with
6556
// ffi::PTHREAD_RWLOCK_INITIALIZER. Once it is used (locked/unlocked)
6657
// or pthread_rwlock_init() is called, this behaviour no longer occurs.
67-
debug_assert!(r == 0 || r == libc::EINVAL);
58+
if cfg!(target_os = "dragonfly") {
59+
debug_assert!(r == 0 || r == libc::EINVAL);
60+
} else {
61+
debug_assert_eq!(r, 0);
62+
}
6863
}
6964
}

0 commit comments

Comments
 (0)