[PATCH v2 1/3] support: Add support_process_shared_robust_mutex
Adhemerval Zanella <[email protected]> Wed, 29 Jul 2026 14:46:36 -0300
| Newsgroups | gmane.comp.lib.glibc.alpha |
|---|---|
| Message-ID | <[email protected]> |
Returns whether process-shared robust mutexes are supported.
---
support/Makefile | 1 +
support/support_mutex_robust.c | 34 ++++++++++++++++++++++++++++++++++
support/xthread.h | 3 +++
3 files changed, 38 insertions(+)
create mode 100644 support/support_mutex_robust.c
diff --git a/support/Makefile b/support/Makefile
index 87eeb8199f6..159b21a329f 100644
--- a/support/Makefile
+++ b/support/Makefile
@@ -88,6 +88,7 @@ libsupport-routines = \
support_isolate_in_subprocess \
support_mem_access \
support_mutex_pi_monotonic \
+ support_mutex_robust \
support_need_proc \
support_nscd \
support_open_and_compare_file_bytes \
diff --git a/support/support_mutex_robust.c b/support/support_mutex_robust.c
new file mode 100644
index 00000000000..37fd0f6ce80
--- /dev/null
+++ b/support/support_mutex_robust.c
@@ -0,0 +1,34 @@
+/* Returns whether process-shared robust mutexes are supported.
+ Copyright (C) 2026 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <support/xthread.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+
+bool
+support_process_shared_robust_mutex (void)
+{
+#ifdef __linux__
+ void *head;
+ size_t len;
+ int r = syscall (__NR_get_robust_list, 0, &head, &len);
+ return r == 0;
+#else
+ return true;
+#endif
+}
diff --git a/support/xthread.h b/support/xthread.h
index 3bdc6907aab..0bbaa0f074a 100644
--- a/support/xthread.h
+++ b/support/xthread.h
@@ -36,6 +36,9 @@ void delayed__exit (int seconds);
/* Returns true if Priority Inheritance support CLOCK_MONOTONIC. */
bool support_mutex_pi_monotonic (void);
+/* Returns true if process-shared robust mutexes are supported. */
+bool support_process_shared_robust_mutex (void);
+
/* Terminate the process (with exit status 1) if VALUE is not zero.
In that case, print a failure message to standard output mentioning
FUNCTION. The process is terminated with the exit function, so
--
2.53.0