aboutsummaryrefslogtreecommitdiff
path: root/nptl/pthread_mutex_lock.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_lock.c
parentfbb4a3143724ef3f044a4f05351fe041300ee382 (diff)
downloadglibc-6b1472eb2ea16f99c4729f975ca25af980ce3894.tar
glibc-6b1472eb2ea16f99c4729f975ca25af980ce3894.tar.gz
glibc-6b1472eb2ea16f99c4729f975ca25af980ce3894.tar.bz2
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_lock.c')
-rw-r--r--nptl/pthread_mutex_lock.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c
index ace436d5a6..05bba50666 100644
--- a/nptl/pthread_mutex_lock.c
+++ b/nptl/pthread_mutex_lock.c
@@ -24,7 +24,7 @@
#include <not-cancel.h>
#include "pthreadP.h"
#include <atomic.h>
-#include <lowlevellock.h>
+#include <futex-internal.h>
#include <stap-probe.h>
#ifndef lll_lock_elision
@@ -416,21 +416,16 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex)
int private = (robust
? PTHREAD_ROBUST_MUTEX_PSHARED (mutex)
: PTHREAD_MUTEX_PSHARED (mutex));
- INTERNAL_SYSCALL_DECL (__err);
- int e = INTERNAL_SYSCALL (futex, __err, 4, &mutex->__data.__lock,
- __lll_private_flag (FUTEX_LOCK_PI,
- private), 1, 0);
-
- if (INTERNAL_SYSCALL_ERROR_P (e, __err)
- && (INTERNAL_SYSCALL_ERRNO (e, __err) == ESRCH
- || INTERNAL_SYSCALL_ERRNO (e, __err) == EDEADLK))
+ int e = futex_lock_pi ((unsigned int *) &mutex->__data.__lock,
+ NULL, private);
+ if (e == ESRCH || e == EDEADLK)
{
- assert (INTERNAL_SYSCALL_ERRNO (e, __err) != EDEADLK
+ assert (e != EDEADLK
|| (kind != PTHREAD_MUTEX_ERRORCHECK_NP
&& kind != PTHREAD_MUTEX_RECURSIVE_NP));
/* ESRCH can happen only for non-robust PI mutexes where
the owner of the lock died. */
- assert (INTERNAL_SYSCALL_ERRNO (e, __err) != ESRCH || !robust);
+ assert (e != ESRCH || !robust);
/* Delay the thread indefinitely. */
while (1)
@@ -479,11 +474,8 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex)
/* This mutex is now not recoverable. */
mutex->__data.__count = 0;
- INTERNAL_SYSCALL_DECL (__err);
- INTERNAL_SYSCALL (futex, __err, 4, &mutex->__data.__lock,
- __lll_private_flag (FUTEX_UNLOCK_PI,
- PTHREAD_ROBUST_MUTEX_PSHARED (mutex)),
- 0, 0);
+ futex_unlock_pi ((unsigned int *) &mutex->__data.__lock,
+ PTHREAD_ROBUST_MUTEX_PSHARED (mutex));
/* To the kernel, this will be visible after the kernel has
acquired the mutex in the syscall. */