Rich Felker | f5ba2bc | 2011-03-18 21:52:26 -0400 | [diff] [blame] | 1 | #ifndef _SYS_TIMEX_H |
| 2 | #define _SYS_TIMEX_H |
| 3 | |
| 4 | #ifdef __cplusplus |
| 5 | extern "C" { |
| 6 | #endif |
| 7 | |
| 8 | #include <sys/time.h> |
| 9 | |
Rich Felker | fd9e01e | 2011-09-20 20:02:48 -0400 | [diff] [blame^] | 10 | struct ntptimeval { |
Rich Felker | f5ba2bc | 2011-03-18 21:52:26 -0400 | [diff] [blame] | 11 | struct timeval time; |
| 12 | long maxerror, esterror; |
| 13 | }; |
| 14 | |
| 15 | struct timex { |
| 16 | unsigned modes; |
| 17 | long offset, freq, maxerror, esterror; |
| 18 | int status; |
| 19 | long constant, precision, tolerance; |
| 20 | struct timeval time; |
| 21 | long tick, ppsfreq, jitter; |
| 22 | int shift; |
| 23 | long stabil, jitcnt, calcnt, errcnt, stbcnt; |
| 24 | int tai; |
| 25 | int __padding[11]; |
| 26 | }; |
| 27 | |
| 28 | #define ADJ_OFFSET 0x0001 |
| 29 | #define ADJ_FREQUENCY 0x0002 |
| 30 | #define ADJ_MAXERROR 0x0004 |
| 31 | #define ADJ_ESTERROR 0x0008 |
| 32 | #define ADJ_STATUS 0x0010 |
| 33 | #define ADJ_TIMECONST 0x0020 |
| 34 | #define ADJ_TAI 0x0080 |
| 35 | #define ADJ_MICRO 0x1000 |
| 36 | #define ADJ_NANO 0x2000 |
| 37 | #define ADJ_TICK 0x4000 |
| 38 | #define ADJ_OFFSET_SINGLESHOT 0x8001 |
| 39 | #define ADJ_OFFSET_SS_READ 0xa001 |
| 40 | |
| 41 | #define MOD_OFFSET ADJ_OFFSET |
| 42 | #define MOD_FREQUENCY ADJ_FREQUENCY |
| 43 | #define MOD_MAXERROR ADJ_MAXERROR |
| 44 | #define MOD_ESTERROR ADJ_ESTERROR |
| 45 | #define MOD_STATUS ADJ_STATUS |
| 46 | #define MOD_TIMECONST ADJ_TIMECONST |
| 47 | #define MOD_CLKB ADJ_TICK |
| 48 | #define MOD_CLKA ADJ_OFFSET_SINGLESHOT |
| 49 | #define MOD_MICRO ADJ_MICRO |
| 50 | #define MOD_NANO ADJ_NANO |
| 51 | |
| 52 | #define STA_PLL 0x0001 |
| 53 | #define STA_PPSFREQ 0x0002 |
| 54 | #define STA_PPSTIME 0x0004 |
| 55 | #define STA_FLL 0x0008 |
| 56 | |
| 57 | #define STA_INS 0x0010 |
| 58 | #define STA_DEL 0x0020 |
| 59 | #define STA_UNSYNC 0x0040 |
| 60 | #define STA_FREQHOLD 0x0080 |
| 61 | |
| 62 | #define STA_PPSSIGNAL 0x0100 |
| 63 | #define STA_PPSJITTER 0x0200 |
| 64 | #define STA_PPSWANDER 0x0400 |
| 65 | #define STA_PPSERROR 0x0800 |
| 66 | |
| 67 | #define STA_CLOCKERR 0x1000 |
| 68 | #define STA_NANO 0x2000 |
| 69 | #define STA_MODE 0x4000 |
| 70 | #define STA_CLK 0x8000 |
| 71 | |
| 72 | #define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \ |
| 73 | STA_PPSERROR | STA_CLOCKERR) |
| 74 | |
| 75 | #define TIME_OK 0 |
| 76 | #define TIME_INS 1 |
| 77 | #define TIME_DEL 2 |
| 78 | #define TIME_OOP 3 |
| 79 | #define TIME_WAIT 4 |
| 80 | #define TIME_ERROR 5 |
| 81 | #define TIME_BAD TIME_ERROR |
| 82 | |
| 83 | #define MAXTC 6 |
| 84 | |
| 85 | int adjtimex(struct timex *); |
| 86 | |
| 87 | #ifdef __cplusplus |
| 88 | } |
| 89 | #endif |
| 90 | |
| 91 | #endif |