lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /* |
| 2 | * timer_gettime.c - get the timer value. |
| 3 | */ |
| 4 | |
| 5 | #include <errno.h> |
| 6 | #include <stdlib.h> |
| 7 | #include <time.h> |
| 8 | #include <sys/syscall.h> |
| 9 | |
| 10 | #include "kernel-posix-timers.h" |
| 11 | |
| 12 | #ifdef __NR_timer_gettime |
| 13 | |
| 14 | #define __NR___syscall_timer_gettime __NR_timer_gettime |
| 15 | static __inline__ _syscall2(int, __syscall_timer_gettime, kernel_timer_t, ktimerid, |
| 16 | void *, value); |
| 17 | |
| 18 | /* Get the amount of time left on a timer */ |
| 19 | int timer_gettime(timer_t timerid, struct itimerspec *value) |
| 20 | { |
| 21 | struct timer *kt = (struct timer *)timerid; |
| 22 | |
| 23 | /* Get timeout from the kernel */ |
| 24 | return __syscall_timer_gettime(kt->ktimerid, value); |
| 25 | } |
| 26 | |
| 27 | #endif |