1 /* Copyright (C) 1995-1997,1999,2007,2009,2011 Free Software Foundation, Inc. 2 This file is part of the GNU C Library. 3 4 The GNU C Library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Lesser General Public 6 License as published by the Free Software Foundation; either 7 version 2.1 of the License, or (at your option) any later version. 8 9 The GNU C Library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 14 You should have received a copy of the GNU Lesser General Public 15 License along with the GNU C Library; if not, write to the Free 16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 02111-1307 USA. */ 18 19 #ifndef _BITS_TIMEX_H 20 #define _BITS_TIMEX_H 1 21 22 /* These definitions from linux/timex.h as of 2.6.30. */ 23 24 struct timex 25 { 26 unsigned int modes; /* mode selector */ 27 long int offset; /* time offset (usec) */ 28 long int freq; /* frequency offset (scaled ppm) */ 29 long int maxerror; /* maximum error (usec) */ 30 long int esterror; /* estimated error (usec) */ 31 int status; /* clock command/status */ 32 long int constant; /* pll time constant */ 33 long int precision; /* clock precision (usec) (read only) */ 34 long int tolerance; /* clock frequency tolerance (ppm) (read only) */ 35 struct timeval time; /* (read only) */ 36 long int tick; /* (modified) usecs between clock ticks */ 37 38 long int ppsfreq; /* pps frequency (scaled ppm) (ro) */ 39 long int jitter; /* pps jitter (us) (ro) */ 40 int shift; /* interval duration (s) (shift) (ro) */ 41 long int stabil; /* pps stability (scaled ppm) (ro) */ 42 long int jitcnt; /* jitter limit exceeded (ro) */ 43 long int calcnt; /* calibration intervals (ro) */ 44 long int errcnt; /* calibration errors (ro) */ 45 long int stbcnt; /* stability limit exceeded (ro) */ 46 47 int tai; /* TAI offset (ro) */ 48 49 /* ??? */ 50 int :32; int :32; int :32; int :32; 51 int :32; int :32; int :32; int :32; 52 int :32; int :32; int :32; 53 }; 54 55 /* Mode codes (timex.mode) */ 56 #define ADJ_OFFSET 0x0001 /* time offset */ 57 #define ADJ_FREQUENCY 0x0002 /* frequency offset */ 58 #define ADJ_MAXERROR 0x0004 /* maximum time error */ 59 #define ADJ_ESTERROR 0x0008 /* estimated time error */ 60 #define ADJ_STATUS 0x0010 /* clock status */ 61 #define ADJ_TIMECONST 0x0020 /* pll time constant */ 62 #define ADJ_TAI 0x0080 /* set TAI offset */ 63 #define ADJ_MICRO 0x1000 /* select microsecond resolution */ 64 #define ADJ_NANO 0x2000 /* select nanosecond resolution */ 65 #define ADJ_TICK 0x4000 /* tick value */ 66 #define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */ 67 #define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */ 68 69 /* xntp 3.4 compatibility names */ 70 #define MOD_OFFSET ADJ_OFFSET 71 #define MOD_FREQUENCY ADJ_FREQUENCY 72 #define MOD_MAXERROR ADJ_MAXERROR 73 #define MOD_ESTERROR ADJ_ESTERROR 74 #define MOD_STATUS ADJ_STATUS 75 #define MOD_TIMECONST ADJ_TIMECONST 76 #define MOD_CLKB ADJ_TICK 77 #define MOD_CLKA ADJ_OFFSET_SINGLESHOT /* 0x8000 in original */ 78 #define MOD_TAI ADJ_TAI 79 #define MOD_MICRO ADJ_MICRO 80 #define MOD_NANO ADJ_NANO 81 82 83 /* Status codes (timex.status) */ 84 #define STA_PLL 0x0001 /* enable PLL updates (rw) */ 85 #define STA_PPSFREQ 0x0002 /* enable PPS freq discipline (rw) */ 86 #define STA_PPSTIME 0x0004 /* enable PPS time discipline (rw) */ 87 #define STA_FLL 0x0008 /* select frequency-lock mode (rw) */ 88 89 #define STA_INS 0x0010 /* insert leap (rw) */ 90 #define STA_DEL 0x0020 /* delete leap (rw) */ 91 #define STA_UNSYNC 0x0040 /* clock unsynchronized (rw) */ 92 #define STA_FREQHOLD 0x0080 /* hold frequency (rw) */ 93 94 #define STA_PPSSIGNAL 0x0100 /* PPS signal present (ro) */ 95 #define STA_PPSJITTER 0x0200 /* PPS signal jitter exceeded (ro) */ 96 #define STA_PPSWANDER 0x0400 /* PPS signal wander exceeded (ro) */ 97 #define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */ 98 99 #define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */ 100 #define STA_NANO 0x2000 /* resolution (0 = us, 1 = ns) (ro) */ 101 #define STA_MODE 0x4000 /* mode (0 = PLL, 1 = FLL) (ro) */ 102 #define STA_CLK 0x8000 /* clock source (0 = A, 1 = B) (ro) */ 103 104 /* Read-only bits */ 105 #define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \ 106 STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK) 107 108 #endif /* bits/timex.h */ 109