diff options
author | Ulrich Drepper <drepper@redhat.com> | 2003-06-25 00:00:50 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2003-06-25 00:00:50 +0000 |
commit | 4165d44d7026bb2572d4cdfe27f8fec348b4089a (patch) | |
tree | 911aa068d7d9c4205ad6a4965ce156c937fed219 /nptl/sysdeps | |
parent | 51d1ca00fd1ddc2ed77b615b7a23ecdf3e8a55a9 (diff) | |
download | glibc-4165d44d7026bb2572d4cdfe27f8fec348b4089a.zip glibc-4165d44d7026bb2572d4cdfe27f8fec348b4089a.tar.gz glibc-4165d44d7026bb2572d4cdfe27f8fec348b4089a.tar.bz2 |
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')
-rw-r--r-- | nptl/sysdeps/pthread/pthread_getcpuclockid.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/nptl/sysdeps/pthread/pthread_getcpuclockid.c b/nptl/sysdeps/pthread/pthread_getcpuclockid.c index 6386dc4..8506f94 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 |