diff options
author | Sergey Korolev <s.korolev@ndmsystems.com> | 2017-04-25 02:14:59 +0300 |
---|---|---|
committer | Waldemar Brodkorb <wbx@openadk.org> | 2017-05-12 17:05:21 +0200 |
commit | be6a02b9a0317a7441de9aa2e3e07fe838787d57 (patch) | |
tree | db3a94effa570ecf96dd0a6a91d4767751828940 /libpthread/nptl | |
parent | 5b0f49037e8ea8500b05c8f31ee88529ccac4cee (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.c | 5 |
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 |