Hi,

I found that MAKE_THREAD_CPUCLOCK really introduced in
Linux 2.6.12 with POSIX timers implementation. So it is safe to
change clockid computation for all kernels (that support POSIX timers).

On Thu, Apr 27, 2017 at 9:23 AM, Waldemar Brodkorb <w...@uclibc-ng.org>
wrote:

> Hi,
> Sergey Korolev wrote,
>
> > Hi, Waldemar.
> >
> > Should uClibc-ng support Linux kernels before 2.6.24?
>
> That would be good, some users still use something like 2.6.18 IIRC.
>
> best regards
>  Waldemar
>
From 57326b60773d5cafa3aa219b60ff91a703a90964 Mon Sep 17 00:00:00 2001
From: Sergey Korolev <s.koro...@ndmsystems.com>
Date: Tue, 25 Apr 2017 02:14:59 +0300
Subject: [PATCH] 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.
---
 libpthread/nptl/sysdeps/unix/sysv/linux/pthread_getcpuclockid.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_getcpuclockid.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_getcpuclockid.c
index ca3570f..f4ed2dc 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
-- 
2.7.4

_______________________________________________
devel mailing list
devel@uclibc-ng.org
https://mailman.uclibc-ng.org/cgi-bin/mailman/listinfo/devel

Reply via email to