about summary refs log tree commit diff
path: root/nptl/pthread_mutex_init.c
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2019-10-30 13:29:40 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2019-10-31 11:09:10 -0300
commit6b1472eb2ea16f99c4729f975ca25af980ce3894 (patch)
tree14cd1db1ac52188e91e81ab3ef3a93735d1683be /nptl/pthread_mutex_init.c
parentfbb4a3143724ef3f044a4f05351fe041300ee382 (diff)
downloadglibc-6b1472eb2ea16f99c4729f975ca25af980ce3894.tar.gz
glibc-6b1472eb2ea16f99c4729f975ca25af980ce3894.tar.xz
glibc-6b1472eb2ea16f99c4729f975ca25af980ce3894.zip
Refactor PI mutexes internal definitions
This patch adds the generic futex_lock_pi and futex_unlock_pi to wrap
around the syscall machinery required to issue the syscall calls. It
simplifies a bit the futex code required to implement PI mutexes.

No function changes, checked on x86_64-linux-gnu.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'nptl/pthread_mutex_init.c')
-rw-r--r--nptl/pthread_mutex_init.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/nptl/pthread_mutex_init.c b/nptl/pthread_mutex_init.c
index fe4eeee37c..20800b80f5 100644
--- a/nptl/pthread_mutex_init.c
+++ b/nptl/pthread_mutex_init.c
@@ -24,6 +24,7 @@
 #include "pthreadP.h"
 #include <atomic.h>
 #include <pthread-offsets.h>
+#include <futex-internal.h>
 
 #include <stap-probe.h>
 
@@ -37,19 +38,13 @@ static const struct pthread_mutexattr default_mutexattr =
 static bool
 prio_inherit_missing (void)
 {
-#ifdef __NR_futex
   static int tpi_supported;
-  if (__glibc_unlikely (tpi_supported == 0))
+  if (__glibc_unlikely (atomic_load_relaxed (&tpi_supported) == 0))
     {
-      int lock = 0;
-      INTERNAL_SYSCALL_DECL (err);
-      int ret = INTERNAL_SYSCALL (futex, err, 4, &lock, FUTEX_UNLOCK_PI, 0, 0);
-      assert (INTERNAL_SYSCALL_ERROR_P (ret, err));
-      tpi_supported = INTERNAL_SYSCALL_ERRNO (ret, err) == ENOSYS ? -1 : 1;
+      int e = futex_unlock_pi (&(unsigned int){0}, 0);
+      atomic_store_relaxed (&tpi_supported, e == ENOSYS ? -1 : 1);
     }
   return __glibc_unlikely (tpi_supported < 0);
-#endif
-  return true;
 }
 
 int