Browse Source

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.
Sergey Korolev 7 years ago
parent
commit
be6a02b9a0
1 changed files with 4 additions and 1 deletions
  1. 4 1
      libpthread/nptl/sysdeps/unix/sysv/linux/pthread_getcpuclockid.c

+ 4 - 1
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