diff options
author | Mike Crowe <mac@mcrowe.com> | 2019-10-31 10:03:21 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2019-11-01 11:23:43 -0300 |
commit | 69ca4b54c151cec42ccca5e05790efc1a8206b47 (patch) | |
tree | e239090413e1da5dbd3a9fc3ce54895da5624346 /nptl/tst-join5.c | |
parent | 893bbdd0072fbf96808e66af04b970e5b39171fb (diff) | |
download | glibc-69ca4b54c151cec42ccca5e05790efc1a8206b47.tar.gz glibc-69ca4b54c151cec42ccca5e05790efc1a8206b47.tar.xz glibc-69ca4b54c151cec42ccca5e05790efc1a8206b47.zip |
nptl: Add pthread_clockjoin_np
Introduce pthread_clockjoin_np as a version of pthread_timedjoin_np that accepts a clockid_t parameter to indicate which clock the timeout should be measured against. This mirrors the recently-added POSIX-proposed "clock" wait functions. Checked on x86_64-linux-gnu. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'nptl/tst-join5.c')
-rw-r--r-- | nptl/tst-join5.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/nptl/tst-join5.c b/nptl/tst-join5.c index 41cacf1251..2fa178cc90 100644 --- a/nptl/tst-join5.c +++ b/nptl/tst-join5.c @@ -24,7 +24,9 @@ #include <unistd.h> #include <support/check.h> +#include <support/timespec.h> #include <support/xthread.h> +#include <support/xtime.h> static void wait_code (void) @@ -42,14 +44,20 @@ static pthread_barrier_t b; static int thread_join (pthread_t thread, void **retval) { -#ifdef USE_PTHREAD_TIMEDJOIN_NP - struct timespec tv; - TEST_COMPARE (clock_gettime (CLOCK_REALTIME, &tv), 0); - /* Arbitrary large timeout to make it act as pthread_join. */ - tv.tv_sec += 1000; - return pthread_timedjoin_np ((pthread_t) thread, retval, &tv); +#if defined USE_PTHREAD_TIMEDJOIN_NP + const struct timespec ts = timespec_add (xclock_now (CLOCK_REALTIME), + make_timespec (1000, 0)); + return pthread_timedjoin_np (thread, retval, &ts); +#elif defined USE_PTHREAD_CLOCKJOIN_NP_REALTIME + const struct timespec ts = timespec_add (xclock_now (CLOCK_REALTIME), + make_timespec (1000, 0)); + return pthread_clockjoin_np (thread, retval, CLOCK_REALTIME, &ts); +#elif defined USE_PTHREAD_CLOCKJOIN_NP_MONOTONIC + const struct timespec ts = timespec_add (xclock_now (CLOCK_MONOTONIC), + make_timespec (1000, 0)); + return pthread_clockjoin_np (thread, retval, CLOCK_MONOTONIC, &ts); #else - return pthread_join ((pthread_t) thread, retval); + return pthread_join (thread, retval); #endif } |