1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00

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>
This commit is contained in:
Adhemerval Zanella
2019-10-30 13:29:40 -03:00
parent fbb4a31437
commit 6b1472eb2e
7 changed files with 136 additions and 68 deletions

View File

@ -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