12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #include <assert.h>
- #include <errno.h>
- #include <stdbool.h>
- #include <time.h>
- #include <sysdep.h>
- #include "pthreadP.h"
- #include <bits/kernel-features.h>
- int
- pthread_condattr_setclock (
- 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_NWAITERS_SHIFT));
- int *valuep = &((struct pthread_condattr *) attr)->value;
- *valuep = ((*valuep & ~(((1 << COND_NWAITERS_SHIFT) - 1) << 1))
- | (clock_id << 1));
- return 0;
- }
|