aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2020-11-25 17:15:51 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2020-11-27 09:59:13 -0300
commit71eeae0325a95f5e5d7ec4a27a6a6c357e0c8ef4 (patch)
tree470fe6a8c1ab863ad0c400d6e19924c2d265ac68 /sysdeps
parent9ff2674ef82eccd5ae5dfa6bb733c0e3613764c6 (diff)
downloadglibc-71eeae0325a95f5e5d7ec4a27a6a6c357e0c8ef4.zip
glibc-71eeae0325a95f5e5d7ec4a27a6a6c357e0c8ef4.tar.gz
glibc-71eeae0325a95f5e5d7ec4a27a6a6c357e0c8ef4.tar.bz2
nptl: Fix PTHREAD_PRIO_PROTECT timed lock
The 878fe624d4 changed lll_futex_timed_wait, which expects a relative timeout, with a __futex_abstimed_wait64, which expects an absolute timeout. However the code still passes a relative timeout. Also, the PTHREAD_PRIO_PROTECT support for clocks different than CLOCK_REALTIME was broken since the inclusion of pthread_mutex_clocklock (9d20e22e46) since lll_futex_timed_wait always use CLOCK_REALTIME. This patch fixes by removing the relative time calculation. It also adds some xtests that tests both thread and inter-process usage. Checked on x86_64-linux-gnu.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/pthread/tst-mutex5.c12
-rw-r--r--sysdeps/pthread/tst-mutex9.c13
2 files changed, 23 insertions, 2 deletions
diff --git a/sysdeps/pthread/tst-mutex5.c b/sysdeps/pthread/tst-mutex5.c
index bfe1a79..dbd2c3c 100644
--- a/sysdeps/pthread/tst-mutex5.c
+++ b/sysdeps/pthread/tst-mutex5.c
@@ -27,6 +27,9 @@
#include <support/check.h>
#include <support/timespec.h>
+#ifdef ENABLE_PP
+#include "tst-tpp.h"
+#endif
#ifndef TYPE
# define TYPE PTHREAD_MUTEX_NORMAL
@@ -47,8 +50,11 @@ do_test_clock (clockid_t clockid, const char *fnname)
TEST_COMPARE (pthread_mutexattr_init (&a), 0);
TEST_COMPARE (pthread_mutexattr_settype (&a, TYPE), 0);
-#ifdef ENABLE_PI
+#if defined ENABLE_PI
TEST_COMPARE (pthread_mutexattr_setprotocol (&a, PTHREAD_PRIO_INHERIT), 0);
+#elif defined ENABLE_PP
+ TEST_COMPARE (pthread_mutexattr_setprotocol (&a, PTHREAD_PRIO_PROTECT), 0);
+ TEST_COMPARE (pthread_mutexattr_setprioceiling (&a, 6), 0);
#endif
int err = pthread_mutex_init (&m, &a);
@@ -110,6 +116,10 @@ do_test_clock (clockid_t clockid, const char *fnname)
static int do_test (void)
{
+#ifdef ENABLE_PP
+ init_tpp_test ();
+#endif
+
do_test_clock (CLOCK_USE_TIMEDLOCK, "timedlock");
do_test_clock (CLOCK_REALTIME, "clocklock(realtime)");
#ifndef ENABLE_PI
diff --git a/sysdeps/pthread/tst-mutex9.c b/sysdeps/pthread/tst-mutex9.c
index bfc01f8..081aeff 100644
--- a/sysdeps/pthread/tst-mutex9.c
+++ b/sysdeps/pthread/tst-mutex9.c
@@ -30,6 +30,10 @@
#include <support/timespec.h>
#include <support/xunistd.h>
+#ifdef ENABLE_PP
+#include "tst-tpp.h"
+#endif
+
/* A bogus clock value that tells run_test to use pthread_mutex_timedlock
rather than pthread_mutex_clocklock. */
@@ -73,8 +77,11 @@ do_test_clock (clockid_t clockid)
TEST_COMPARE (pthread_mutexattr_settype (&a, PTHREAD_MUTEX_RECURSIVE), 0);
-#ifdef ENABLE_PI
+#if defined ENABLE_PI
TEST_COMPARE (pthread_mutexattr_setprotocol (&a, PTHREAD_PRIO_INHERIT), 0);
+#elif defined ENABLE_PP
+ TEST_COMPARE (pthread_mutexattr_setprotocol (&a, PTHREAD_PRIO_PROTECT), 0);
+ TEST_COMPARE (pthread_mutexattr_setprioceiling (&a, 6), 0);
#endif
int e;
@@ -131,6 +138,10 @@ do_test_clock (clockid_t clockid)
static int
do_test (void)
{
+#ifdef ENABLE_PP
+ init_tpp_test ();
+#endif
+
do_test_clock (CLOCK_USE_TIMEDLOCK);
do_test_clock (CLOCK_REALTIME);
#ifndef ENABLE_PI