timex.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #include <bits/types.h>
  2. #include <bits/time.h>
  3. #include <syscall.h>
  4. /* Ref. linux/include/uapi/linux/timex.h */
  5. /* timex.mode */
  6. #define ADJ_OFFSET 0x0001
  7. #define ADJ_FREQUENCY 0x0002
  8. #define ADJ_MAXERROR 0x0004
  9. #define ADJ_ESTERROR 0x0008
  10. #define ADJ_STATUS 0x0010
  11. #define ADJ_TIMECONST 0x0020
  12. #define ADJ_TAI 0x0080
  13. #define ADJ_SETOFFSET 0x0100
  14. #define ADJ_MICRO 0x1000
  15. #define ADJ_NANO 0x2000
  16. #define ADJ_TICK 0x4000
  17. /* timex.status */
  18. #define STA_PLL 0x0001
  19. #define STA_PPSFREQ 0x0002
  20. #define STA_PPSTIME 0x0004
  21. #define STA_FLL 0x0008
  22. #define STA_INS 0x0010
  23. #define STA_DEL 0x0020
  24. #define STA_UNSYNC 0x0040
  25. #define STA_FREQHOLD 0x0080
  26. #define STA_PPSSIGNAL 0x0100
  27. #define STA_PPSJITTER 0x0200
  28. #define STA_PPSWANDER 0x0400
  29. #define STA_PPSERROR 0x0800
  30. #define STA_CLOCKERR 0x1000
  31. #define STA_NANO 0x2000
  32. #define STA_MODE 0x4000
  33. #define STA_CLK 0x8000
  34. struct timex {
  35. uint modes;
  36. long offset;
  37. long freq;
  38. long maxerror;
  39. long esterror;
  40. int status;
  41. long constant;
  42. long precision;
  43. long tolerance;
  44. struct timeval time;
  45. long tick;
  46. long ppsfreq;
  47. long jitter;
  48. int shift;
  49. long stabil;
  50. long jitcnt;
  51. long calcnt;
  52. long errcnt;
  53. long stbcnt;
  54. int tai;
  55. int pad[11];
  56. };
  57. inline static long sys_adjtimex(struct timex* tx)
  58. {
  59. return syscall1(NR_adjtimex, (long)tx);
  60. }