summaryrefslogtreecommitdiff
path: root/libpthread/nptl
diff options
context:
space:
mode:
authorSergey Korolev <s.korolev@ndmsystems.com>2017-04-25 02:14:59 +0300
committerWaldemar Brodkorb <wbx@openadk.org>2017-05-12 17:05:21 +0200
commitbe6a02b9a0317a7441de9aa2e3e07fe838787d57 (patch)
treedb3a94effa570ecf96dd0a6a91d4767751828940 /libpthread/nptl
parent5b0f49037e8ea8500b05c8f31ee88529ccac4cee (diff)
pthread_getcpuclockid.c: fix clockid computation
For the linux kernel (since 2.6.12) MAKE_THREAD_CPUCLOCK macro-like computation should be used to get clockid.
Diffstat (limited to 'libpthread/nptl')
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pthread_getcpuclockid.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_getcpuclockid.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_getcpuclockid.c
index ca3570f5f..f4ed2dc7e 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_getcpuclockid.c
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_getcpuclockid.c
@@ -20,6 +20,8 @@
#include <sys/time.h>
#include <tls.h>
+#define CPUCLOCK_PERTHREAD_MASK 4
+#define CPUCLOCK_SCHED 2
int
pthread_getcpuclockid (
@@ -46,7 +48,8 @@ pthread_getcpuclockid (
return ERANGE;
/* Store the number. */
- *clockid = CLOCK_THREAD_CPUTIME_ID | (pd->tid << CLOCK_IDFIELD_SIZE);
+ *clockid = ((~(clockid_t) (pd->tid)) << CLOCK_IDFIELD_SIZE)
+ | CPUCLOCK_SCHED | CPUCLOCK_PERTHREAD_MASK;
return 0;
#else