From ca211ce279b4dfab3dd457154f7f47bce1b5995c Mon Sep 17 00:00:00 2001 From: Laurence Tratt Date: Sat, 19 Dec 2020 08:50:27 +0000 Subject: [PATCH 1/3] OpenBSD returns EINVAL in the same way as DragonFlyBSD. --- core/src/thread_parker/unix.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/thread_parker/unix.rs b/core/src/thread_parker/unix.rs index a58e6ffe..537b9e70 100644 --- a/core/src/thread_parker/unix.rs +++ b/core/src/thread_parker/unix.rs @@ -156,13 +156,13 @@ impl Drop for ThreadParker { // this behaviour no longer occurs. The same applies to condvars. unsafe { let r = libc::pthread_mutex_destroy(self.mutex.get()); - if cfg!(target_os = "dragonfly") { + if cfg!(any(target_os = "dragonfly", target_os = "openbsd")) { debug_assert!(r == 0 || r == libc::EINVAL); } else { debug_assert_eq!(r, 0); } let r = libc::pthread_cond_destroy(self.condvar.get()); - if cfg!(target_os = "dragonfly") { + if cfg!(any(target_os = "dragonfly", target_os = "openbsd")) { debug_assert!(r == 0 || r == libc::EINVAL); } else { debug_assert_eq!(r, 0); From b6d4fdb510d34f096b6c0016043a28dddf623916 Mon Sep 17 00:00:00 2001 From: Laurence Tratt Date: Mon, 21 Dec 2020 18:41:25 +0000 Subject: [PATCH 2/3] Revert "OpenBSD returns EINVAL in the same way as DragonFlyBSD." This reverts commit ca211ce279b4dfab3dd457154f7f47bce1b5995c. --- core/src/thread_parker/unix.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/thread_parker/unix.rs b/core/src/thread_parker/unix.rs index 537b9e70..a58e6ffe 100644 --- a/core/src/thread_parker/unix.rs +++ b/core/src/thread_parker/unix.rs @@ -156,13 +156,13 @@ impl Drop for ThreadParker { // this behaviour no longer occurs. The same applies to condvars. unsafe { let r = libc::pthread_mutex_destroy(self.mutex.get()); - if cfg!(any(target_os = "dragonfly", target_os = "openbsd")) { + if cfg!(target_os = "dragonfly") { debug_assert!(r == 0 || r == libc::EINVAL); } else { debug_assert_eq!(r, 0); } let r = libc::pthread_cond_destroy(self.condvar.get()); - if cfg!(any(target_os = "dragonfly", target_os = "openbsd")) { + if cfg!(target_os = "dragonfly") { debug_assert!(r == 0 || r == libc::EINVAL); } else { debug_assert_eq!(r, 0); From 36a77db305769cd4f4d6ff49eb03e870bde4cb88 Mon Sep 17 00:00:00 2001 From: Laurence Tratt Date: Mon, 21 Dec 2020 18:45:40 +0000 Subject: [PATCH 3/3] Simplify debug_asserts. --- core/src/thread_parker/unix.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/core/src/thread_parker/unix.rs b/core/src/thread_parker/unix.rs index a58e6ffe..c2381e6d 100644 --- a/core/src/thread_parker/unix.rs +++ b/core/src/thread_parker/unix.rs @@ -156,17 +156,9 @@ impl Drop for ThreadParker { // this behaviour no longer occurs. The same applies to condvars. unsafe { let r = libc::pthread_mutex_destroy(self.mutex.get()); - if cfg!(target_os = "dragonfly") { - debug_assert!(r == 0 || r == libc::EINVAL); - } else { - debug_assert_eq!(r, 0); - } + debug_assert!(r == 0 || r == libc::EINVAL); let r = libc::pthread_cond_destroy(self.condvar.get()); - if cfg!(target_os = "dragonfly") { - debug_assert!(r == 0 || r == libc::EINVAL); - } else { - debug_assert_eq!(r, 0); - } + debug_assert!(r == 0 || r == libc::EINVAL); } } }