time.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include <bits/time.h>
  2. #include <syscall.h>
  3. /* Ref. linux/include/uapi/linux/time.h */
  4. #define CLOCK_REALTIME 0
  5. #define CLOCK_MONOTONIC 1
  6. #define CLOCK_PROCESS_CPUTIME_ID 2
  7. #define CLOCK_THREAD_CPUTIME_ID 3
  8. #define CLOCK_MONOTONIC_RAW 4
  9. #define CLOCK_REALTIME_COARSE 5
  10. #define CLOCK_MONOTONIC_COARSE 6
  11. #define CLOCK_BOOTTIME 7
  12. #define CLOCK_REALTIME_ALARM 8
  13. #define CLOCK_BOOTTIME_ALARM 9
  14. #define CLOCK_SGI_CYCLE 10
  15. #define CLOCK_TAI 11
  16. inline static long sys_clock_getres(int id, struct timespec* tp)
  17. {
  18. return syscall2(NR_clock_getres, id, (long)tp);
  19. }
  20. inline static long sys_clock_gettime(int id, struct timespec* tp)
  21. {
  22. return syscall2(NR_clock_gettime, id, (long)tp);
  23. }
  24. inline static long sys_clock_settime(int id, const struct timespec* tp)
  25. {
  26. return syscall2(NR_clock_settime, id, (long)tp);
  27. }
  28. inline static long sys_gettimeofday(struct timeval* tv,
  29. struct timezone* tz)
  30. {
  31. return syscall2(NR_gettimeofday, (long)tv, (long)tz);
  32. }
  33. inline static long sys_settimeofday(const struct timeval* tv,
  34. const struct timezone* tz)
  35. {
  36. return syscall2(NR_settimeofday, (long)tv, (long)tz);
  37. }