123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- #include <assert.h>
- #include <errno.h>
- #include <stdbool.h>
- #include <time.h>
- #include <sysdep.h>
- #include "pthreadP.h"
- #include <kernel-features.h>
- int
- pthread_condattr_setclock (attr, clock_id)
- pthread_condattr_t *attr;
- clockid_t clock_id;
- {
-
- if (clock_id == CLOCK_MONOTONIC)
- {
- #ifndef __ASSUME_POSIX_TIMERS
- # ifdef __NR_clock_getres
-
- static int avail;
- if (avail == 0)
- {
- struct timespec ts;
- INTERNAL_SYSCALL_DECL (err);
- int val;
- val = INTERNAL_SYSCALL (clock_getres, err, 2, CLOCK_MONOTONIC, &ts);
- avail = INTERNAL_SYSCALL_ERROR_P (val, err) ? -1 : 1;
- }
- if (avail < 0)
- # endif
-
- return EINVAL;
- #endif
- }
- else if (clock_id != CLOCK_REALTIME)
-
- return EINVAL;
-
- assert (clock_id < (1 << COND_CLOCK_BITS));
- int *valuep = &((struct pthread_condattr *) attr)->value;
- *valuep = (*valuep & ~(1 << (COND_CLOCK_BITS + 1)) & ~1) | (clock_id << 1);
- return 0;
- }
|