1 #include <time.h> 2 #include <limits.h> 3 #include "pthread_impl.h" 4 timer_gettime(timer_t t,struct itimerspec * val)5int timer_gettime(timer_t t, struct itimerspec *val) 6 { 7 if ((intptr_t)t < 0) { 8 pthread_t td = (void *)((uintptr_t)t << 1); 9 t = (void *)(uintptr_t)(td->timer_id & INT_MAX); 10 } 11 #ifdef SYS_timer_gettime64 12 int r = -ENOSYS; 13 if (sizeof(time_t) > 4) 14 r = __syscall(SYS_timer_gettime64, t, val); 15 if (SYS_timer_gettime == SYS_timer_gettime64 || r!=-ENOSYS) 16 return __syscall_ret(r); 17 long val32[4]; 18 r = __syscall(SYS_timer_gettime, t, val32); 19 if (!r) { 20 val->it_interval.tv_sec = val32[0]; 21 val->it_interval.tv_nsec = val32[1]; 22 val->it_value.tv_sec = val32[2]; 23 val->it_value.tv_nsec = val32[3]; 24 } 25 return __syscall_ret(r); 26 #endif 27 return syscall(SYS_timer_gettime, t, val); 28 } 29