about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJubilee <workingjubilee@gmail.com>2025-02-13 21:37:51 -0800
committerGitHub <noreply@github.com>2025-02-13 21:37:51 -0800
commitdfc235f80c4f3d94f91043cc7795fe72709b11d2 (patch)
treecda481ccc2ad54e24557a5c553cba6d620a08b8a
parenta82d7d602638449c94af6cfb8bb5927c50ca2aa5 (diff)
parent4b086d47118668bff5f04b511e673fa3c84369d3 (diff)
downloadrust-dfc235f80c4f3d94f91043cc7795fe72709b11d2.tar.gz
rust-dfc235f80c4f3d94f91043cc7795fe72709b11d2.zip
Rollup merge of #136908 - mustartt:aix-mutex-destory-einval, r=joboet
[AIX] expect `EINVAL` for `pthread_mutex_destroy`

Calling `pthread_mutex_destory` on a mutex initalized with the static initializer macro `PTHREAD_MUTEX_INITIALIZER` will result in `EINVAL` if the mutex is not lock/unlocked prior to calling `pthread_mutex_destroy`.
-rw-r--r--library/std/src/sys/pal/unix/sync/mutex.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/library/std/src/sys/pal/unix/sync/mutex.rs b/library/std/src/sys/pal/unix/sync/mutex.rs
index 8ff6c3d3d15..557e70af94b 100644
--- a/library/std/src/sys/pal/unix/sync/mutex.rs
+++ b/library/std/src/sys/pal/unix/sync/mutex.rs
@@ -111,9 +111,9 @@ impl Drop for Mutex {
         // `PTHREAD_MUTEX_INITIALIZER`, which is valid at all locations. Thus,
         // this call always destroys a valid mutex.
         let r = unsafe { libc::pthread_mutex_destroy(self.raw()) };
-        if cfg!(target_os = "dragonfly") {
-            // On DragonFly pthread_mutex_destroy() returns EINVAL if called on a
-            // mutex that was just initialized with libc::PTHREAD_MUTEX_INITIALIZER.
+        if cfg!(any(target_os = "aix", target_os = "dragonfly")) {
+            // On AIX and DragonFly pthread_mutex_destroy() returns EINVAL if called
+            // on a mutex that was just initialized with libc::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);