aboutsummaryrefslogtreecommitdiff
path: root/nptl/sysdeps/pthread/pthread_getcpuclockid.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-06-25 00:00:50 +0000
committerUlrich Drepper <drepper@redhat.com>2003-06-25 00:00:50 +0000
commit4165d44d7026bb2572d4cdfe27f8fec348b4089a (patch)
tree911aa068d7d9c4205ad6a4965ce156c937fed219 /nptl/sysdeps/pthread/pthread_getcpuclockid.c
parent51d1ca00fd1ddc2ed77b615b7a23ecdf3e8a55a9 (diff)
downloadglibc-4165d44d7026bb2572d4cdfe27f8fec348b4089a.tar
glibc-4165d44d7026bb2572d4cdfe27f8fec348b4089a.tar.gz
glibc-4165d44d7026bb2572d4cdfe27f8fec348b4089a.tar.bz2
glibc-4165d44d7026bb2572d4cdfe27f8fec348b4089a.zip
Update.
* include/time.h: Define CLOCK_IDFIELD_SIZE. * sysdeps/posix/clock_getres.c: Recognize thread CPU clock IDs. * sysdeps/unix/clock_gettime.c: Likewise. * sysdeps/unix/clock_settime.c: Likewise. * sysdeps/unix/clock_nanosleep.c (CPUCLOCK_P): Adjust for new clock id for thread CPU clocks.
Diffstat (limited to 'nptl/sysdeps/pthread/pthread_getcpuclockid.c')
-rw-r--r--nptl/sysdeps/pthread/pthread_getcpuclockid.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/nptl/sysdeps/pthread/pthread_getcpuclockid.c b/nptl/sysdeps/pthread/pthread_getcpuclockid.c
index 6386dc4dc0..8506f94eb4 100644
--- a/nptl/sysdeps/pthread/pthread_getcpuclockid.c
+++ b/nptl/sysdeps/pthread/pthread_getcpuclockid.c
@@ -34,13 +34,20 @@ pthread_getcpuclockid (threadid, clockid)
/* Not a valid thread handle. */
return ESRCH;
- /* We don't allow any process ID but our own. */
- if (pd != THREAD_SELF)
- return EPERM;
-
#ifdef CLOCK_THREAD_CPUTIME_ID
+ /* We need to store the thread ID in the CLOCKID variable together
+ with a number identifying the clock. We reserve the low 3 bits
+ for the clock ID and the rest for the thread ID. This is
+ problematic if the thread ID is too large. But 29 bits should be
+ fine.
+
+ If some day more clock IDs are needed the ID part can be
+ enlarged. The IDs are entirely internal. */
+ if (pd->tid >= 1 << (8 * sizeof (*clockid) - CLOCK_IDFIELD_SIZE))
+ return ERANGE;
+
/* Store the number. */
- *clockid = CLOCK_THREAD_CPUTIME_ID;
+ *clockid = CLOCK_THREAD_CPUTIME_ID | (pd->tid << CLOCK_IDFIELD_SIZE);
return 0;
#else