timer_gettime.c 607 B

123456789101112131415161718192021222324252627
  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. #ifdef __NR_timer_gettime
  10. #define __NR___syscall_timer_gettime __NR_timer_gettime
  11. static __inline__ _syscall2(int, __syscall_timer_gettime, kernel_timer_t, ktimerid,
  12. void *, value);
  13. /* Get the amount of time left on a timer */
  14. int timer_gettime(timer_t timerid, struct itimerspec *value)
  15. {
  16. struct timer *kt = (struct timer *)timerid;
  17. /* Get timeout from the kernel */
  18. return __syscall_timer_gettime(kt->ktimerid, value);
  19. }
  20. #endif