sys: use system headers for adjtimex
This commit is contained in:
parent
c4d57f0e3d
commit
fc73accfe5
2 changed files with 20 additions and 79 deletions
|
@ -1,74 +0,0 @@
|
||||||
/* Taken from /usr/include/linux/timex.h. Avoids the need to
|
|
||||||
* include kernel header files. */
|
|
||||||
|
|
||||||
#ifndef CHRONY_TIMEX_H
|
|
||||||
#define CHRONY_TIMEX_H
|
|
||||||
|
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
struct timex {
|
|
||||||
unsigned int modes; /* mode selector */
|
|
||||||
long offset; /* time offset (usec) */
|
|
||||||
long freq; /* frequency offset (scaled ppm) */
|
|
||||||
long maxerror; /* maximum error (usec) */
|
|
||||||
long esterror; /* estimated error (usec) */
|
|
||||||
int status; /* clock command/status */
|
|
||||||
long constant; /* pll time constant */
|
|
||||||
long precision; /* clock precision (usec) (read only) */
|
|
||||||
long tolerance; /* clock frequency tolerance (ppm)
|
|
||||||
* (read only)
|
|
||||||
*/
|
|
||||||
struct timeval time; /* (read only) */
|
|
||||||
long tick; /* (modified) usecs between clock ticks */
|
|
||||||
|
|
||||||
long ppsfreq; /* pps frequency (scaled ppm) (ro) */
|
|
||||||
long jitter; /* pps jitter (us) (ro) */
|
|
||||||
int shift; /* interval duration (s) (shift) (ro) */
|
|
||||||
long stabil; /* pps stability (scaled ppm) (ro) */
|
|
||||||
long jitcnt; /* jitter limit exceeded (ro) */
|
|
||||||
long calcnt; /* calibration intervals (ro) */
|
|
||||||
long errcnt; /* calibration errors (ro) */
|
|
||||||
long stbcnt; /* stability limit exceeded (ro) */
|
|
||||||
|
|
||||||
int :32; int :32; int :32; int :32;
|
|
||||||
int :32; int :32; int :32; int :32;
|
|
||||||
int :32; int :32; int :32; int :32;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define ADJ_OFFSET 0x0001 /* time offset */
|
|
||||||
#define ADJ_FREQUENCY 0x0002 /* frequency offset */
|
|
||||||
#define ADJ_MAXERROR 0x0004 /* maximum time error */
|
|
||||||
#define ADJ_ESTERROR 0x0008 /* estimated time error */
|
|
||||||
#define ADJ_STATUS 0x0010 /* clock status */
|
|
||||||
#define ADJ_TIMECONST 0x0020 /* pll time constant */
|
|
||||||
#define ADJ_SETOFFSET 0x0100 /* add 'time' to current time */
|
|
||||||
#define ADJ_NANO 0x2000 /* select nanosecond resolution */
|
|
||||||
#define ADJ_TICK 0x4000 /* tick value */
|
|
||||||
#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */
|
|
||||||
#define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */
|
|
||||||
|
|
||||||
#define SHIFT_USEC 16 /* frequency offset scale (shift) */
|
|
||||||
|
|
||||||
#define STA_PLL 0x0001 /* enable PLL updates (rw) */
|
|
||||||
#define STA_PPSFREQ 0x0002 /* enable PPS freq discipline (rw) */
|
|
||||||
#define STA_PPSTIME 0x0004 /* enable PPS time discipline (rw) */
|
|
||||||
#define STA_FLL 0x0008 /* select frequency-lock mode (rw) */
|
|
||||||
|
|
||||||
#define STA_INS 0x0010 /* insert leap (rw) */
|
|
||||||
#define STA_DEL 0x0020 /* delete leap (rw) */
|
|
||||||
#define STA_UNSYNC 0x0040 /* clock unsynchronized (rw) */
|
|
||||||
#define STA_FREQHOLD 0x0080 /* hold frequency (rw) */
|
|
||||||
|
|
||||||
#define STA_PPSSIGNAL 0x0100 /* PPS signal present (ro) */
|
|
||||||
#define STA_PPSJITTER 0x0200 /* PPS signal jitter exceeded (ro) */
|
|
||||||
#define STA_PPSWANDER 0x0400 /* PPS signal wander exceeded (ro) */
|
|
||||||
#define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */
|
|
||||||
|
|
||||||
#define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */
|
|
||||||
#define STA_NANO 0x2000 /* resolution (0 = us, 1 = ns) (ro) */
|
|
||||||
|
|
||||||
/* This doesn't seem to be in any include files !! */
|
|
||||||
|
|
||||||
extern int adjtimex(struct timex *);
|
|
||||||
|
|
||||||
#endif /* CHRONY_TIMEX_H */
|
|
|
@ -22,18 +22,33 @@
|
||||||
|
|
||||||
=======================================================================
|
=======================================================================
|
||||||
|
|
||||||
This is a wrapper around the Linux adjtimex system call. It isolates the
|
This is a wrapper around the Linux adjtimex system call.
|
||||||
inclusion of <linux/adjtimex.h> from the need to include other header files,
|
|
||||||
many of which conflict with those in <linux/...> on some recent distributions
|
|
||||||
(as of Jul 2000) using kernels around 2.2.16 onwards.
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "chrony_timex.h"
|
|
||||||
#include "wrap_adjtimex.h"
|
#include "wrap_adjtimex.h"
|
||||||
|
|
||||||
|
#include <sys/timex.h>
|
||||||
|
|
||||||
|
/* Definitions used if missing in the system headers */
|
||||||
|
#ifndef ADJ_TAI
|
||||||
|
#define ADJ_TAI 0x0080 /* set TAI offset */
|
||||||
|
#endif
|
||||||
|
#ifndef ADJ_SETOFFSET
|
||||||
|
#define ADJ_SETOFFSET 0x0100 /* add 'time' to current time */
|
||||||
|
#endif
|
||||||
|
#ifndef ADJ_NANO
|
||||||
|
#define ADJ_NANO 0x2000 /* select nanosecond resolution */
|
||||||
|
#endif
|
||||||
|
#ifndef ADJ_OFFSET_SS_READ
|
||||||
|
#define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Frequency offset scale (shift) */
|
||||||
|
#define SHIFT_USEC 16
|
||||||
|
|
||||||
static int status = 0;
|
static int status = 0;
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Reference in a new issue