timer_gettime.c 785 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * timer_gettime.c - get the timer value.
  3. */
  4. #include <errno.h>
  5. #include <stdlib.h>
  6. #include <time.h>
  7. #include <sys/syscall.h>
  8. #include "kernel-posix-timers.h"
  9. #if defined(__NR_timer_gettime) || defined(__NR_timer_gettime64)
  10. #if defined(__UCLIBC_USE_TIME64__) && defined(__NR_timer_gettime64)
  11. #define __NR___syscall_timer_gettime __NR_timer_gettime64
  12. #else
  13. #define __NR___syscall_timer_gettime __NR_timer_gettime
  14. #endif
  15. static __inline__ _syscall2(int, __syscall_timer_gettime, kernel_timer_t, ktimerid,
  16. void *, value);
  17. /* Get the amount of time left on a timer */
  18. int timer_gettime(timer_t timerid, struct itimerspec *value)
  19. {
  20. struct timer *kt = (struct timer *)timerid;
  21. /* Get timeout from the kernel */
  22. return __syscall_timer_gettime(kt->ktimerid, value);
  23. }
  24. #endif