1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #include <errno.h>
- #include <pthreadP.h>
- #include <sys/time.h>
- #include <tls.h>
- #define CPUCLOCK_PERTHREAD_MASK 4
- #define CPUCLOCK_SCHED 2
- int
- pthread_getcpuclockid (
- pthread_t threadid,
- clockid_t *clockid)
- {
- struct pthread *pd = (struct pthread *) threadid;
-
- if (INVALID_TD_P (pd))
-
- return ESRCH;
- #ifdef CLOCK_THREAD_CPUTIME_ID
-
- if (pd->tid >= 1 << (8 * sizeof (*clockid) - CLOCK_IDFIELD_SIZE))
- return ERANGE;
-
- *clockid = ((~(clockid_t) (pd->tid)) << CLOCK_IDFIELD_SIZE)
- | CPUCLOCK_SCHED | CPUCLOCK_PERTHREAD_MASK;
- return 0;
- #else
-
- return ENOENT;
- #endif
- }
|