Back to index

glibc  2.9
timex.h
Go to the documentation of this file.
00001 /* Copyright (C) 1995, 1996, 1997, 1999, 2007 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 #ifndef       _SYS_TIMEX_H
00020 #define       _SYS_TIMEX_H  1
00021 
00022 #include <features.h>
00023 #include <sys/time.h>
00024 
00025 /* These definitions from linux/timex.h as of 2.2.0.  */
00026 
00027 struct ntptimeval
00028 {
00029   struct timeval time;      /* current time (ro) */
00030   long int maxerror; /* maximum error (us) (ro) */
00031   long int esterror; /* estimated error (us) (ro) */
00032 };
00033 
00034 struct timex
00035 {
00036   unsigned int modes;       /* mode selector */
00037   long int offset;   /* time offset (usec) */
00038   long int freq;     /* frequency offset (scaled ppm) */
00039   long int maxerror; /* maximum error (usec) */
00040   long int esterror; /* estimated error (usec) */
00041   int status;        /* clock command/status */
00042   long int constant; /* pll time constant */
00043   long int precision;       /* clock precision (usec) (read only) */
00044   long int tolerance;       /* clock frequency tolerance (ppm) (read only) */
00045   struct timeval time;      /* (read only) */
00046   long int tick;     /* (modified) usecs between clock ticks */
00047 
00048   long int ppsfreq;  /* pps frequency (scaled ppm) (ro) */
00049   long int jitter;   /* pps jitter (us) (ro) */
00050   int shift;         /* interval duration (s) (shift) (ro) */
00051   long int stabil;   /* pps stability (scaled ppm) (ro) */
00052   long int jitcnt;   /* jitter limit exceeded (ro) */
00053   long int calcnt;   /* calibration intervals (ro) */
00054   long int errcnt;   /* calibration errors (ro) */
00055   long int stbcnt;   /* stability limit exceeded (ro) */
00056 
00057   /* ??? */
00058   int  :32; int  :32; int  :32; int  :32;
00059   int  :32; int  :32; int  :32; int  :32;
00060   int  :32; int  :32; int  :32; int  :32;
00061 };
00062 
00063 /* Mode codes (timex.mode) */
00064 #define ADJ_OFFSET          0x0001 /* time offset */
00065 #define ADJ_FREQUENCY              0x0002 /* frequency offset */
00066 #define ADJ_MAXERROR        0x0004 /* maximum time error */
00067 #define ADJ_ESTERROR        0x0008 /* estimated time error */
00068 #define ADJ_STATUS          0x0010 /* clock status */
00069 #define ADJ_TIMECONST              0x0020 /* pll time constant */
00070 #define ADJ_TICK            0x4000 /* tick value */
00071 #define ADJ_OFFSET_SINGLESHOT      0x8001 /* old-fashioned adjtime */
00072 #define ADJ_OFFSET_SS_READ  0xa001 /* read-only adjtime */
00073 
00074 /* xntp 3.4 compatibility names */
00075 #define MOD_OFFSET   ADJ_OFFSET
00076 #define MOD_FREQUENCY       ADJ_FREQUENCY
00077 #define MOD_MAXERROR ADJ_MAXERROR
00078 #define MOD_ESTERROR ADJ_ESTERROR
00079 #define MOD_STATUS   ADJ_STATUS
00080 #define MOD_TIMECONST       ADJ_TIMECONST
00081 #define MOD_CLKB     ADJ_TICK
00082 #define MOD_CLKA     ADJ_OFFSET_SINGLESHOT /* 0x8000 in original */
00083 
00084 
00085 /* Status codes (timex.status) */
00086 #define STA_PLL             0x0001 /* enable PLL updates (rw) */
00087 #define STA_PPSFREQ  0x0002 /* enable PPS freq discipline (rw) */
00088 #define STA_PPSTIME  0x0004 /* enable PPS time discipline (rw) */
00089 #define STA_FLL             0x0008 /* select frequency-lock mode (rw) */
00090 
00091 #define STA_INS             0x0010 /* insert leap (rw) */
00092 #define STA_DEL             0x0020 /* delete leap (rw) */
00093 #define STA_UNSYNC   0x0040 /* clock unsynchronized (rw) */
00094 #define STA_FREQHOLD 0x0080 /* hold frequency (rw) */
00095 
00096 #define STA_PPSSIGNAL       0x0100 /* PPS signal present (ro) */
00097 #define STA_PPSJITTER       0x0200 /* PPS signal jitter exceeded (ro) */
00098 #define STA_PPSWANDER       0x0400 /* PPS signal wander exceeded (ro) */
00099 #define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */
00100 
00101 #define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */
00102 
00103 #define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \
00104     STA_PPSERROR | STA_CLOCKERR) /* read-only bits */
00105 
00106 /* Clock states (time_state) */
00107 #define TIME_OK             0      /* clock synchronized, no leap second */
00108 #define TIME_INS     1      /* insert leap second */
00109 #define TIME_DEL     2      /* delete leap second */
00110 #define TIME_OOP     3      /* leap second in progress */
00111 #define TIME_WAIT    4      /* leap second has occurred */
00112 #define TIME_ERROR   5      /* clock not synchronized */
00113 #define TIME_BAD     TIME_ERROR /* bw compat */
00114 
00115 /* Maximum time constant of the PLL.  */
00116 #define MAXTC        6
00117 
00118 __BEGIN_DECLS
00119 
00120 extern int __adjtimex (struct timex *__ntx) __THROW;
00121 extern int adjtimex (struct timex *__ntx) __THROW;
00122 
00123 extern int ntp_gettime (struct ntptimeval *__ntv) __THROW;
00124 extern int ntp_adjtime (struct timex *__tntx) __THROW;
00125 
00126 __END_DECLS
00127 
00128 #endif /* sys/timex.h */