This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Linux NTP API update


Hi,

This patch updates the Linux NTP API to match the kernel. The kernel 
patches should be merged during the next merge window and appear in 
2.6.26.
This isn't a final patch, mainly because it changes the user space API, 
specifically ntp_gettime() sets an additional field. My question is now 
how do I produce two version of this function?
Thanks.

bye, Roman

Index: glibc-2.7/sysdeps/unix/sysv/linux/ntp_gettime.c
===================================================================
--- glibc-2.7.orig/sysdeps/unix/sysv/linux/ntp_gettime.c	2008-03-04 21:28:45.000000000 +0100
+++ glibc-2.7/sysdeps/unix/sysv/linux/ntp_gettime.c	2008-03-04 21:29:13.000000000 +0100
@@ -38,5 +38,6 @@
   ntv->time = tntx.time;
   ntv->maxerror = tntx.maxerror;
   ntv->esterror = tntx.esterror;
+  ntv->tai = tntx.tai;
   return result;
 }
Index: glibc-2.7/sysdeps/unix/sysv/linux/sys/timex.h
===================================================================
--- glibc-2.7.orig/sysdeps/unix/sysv/linux/sys/timex.h	2008-03-04 21:26:50.000000000 +0100
+++ glibc-2.7/sysdeps/unix/sysv/linux/sys/timex.h	2008-03-04 21:27:02.000000000 +0100
@@ -22,13 +22,16 @@
 #include <features.h>
 #include <sys/time.h>
 
-/* These definitions from linux/timex.h as of 2.2.0.  */
+/* These definitions from linux/timex.h as of 2.6.26.  */
+
+#define NTP_API		4	/* NTP API version */
 
 struct ntptimeval
 {
   struct timeval time;	/* current time (ro) */
   long int maxerror;	/* maximum error (us) (ro) */
   long int esterror;	/* estimated error (us) (ro) */
+  long tai;		/* TAI offset (ro) */
 };
 
 struct timex
@@ -54,10 +57,12 @@
   long int errcnt;	/* calibration errors (ro) */
   long int stbcnt;	/* stability limit exceeded (ro) */
 
+  int tai;		/* TAI offset (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;
+  int  :32; int  :32; int  :32;
 };
 
 /* Mode codes (timex.mode) */
@@ -67,6 +72,9 @@
 #define ADJ_ESTERROR		0x0008	/* estimated time error */
 #define ADJ_STATUS		0x0010	/* clock status */
 #define ADJ_TIMECONST		0x0020	/* pll time constant */
+#define ADJ_TAI			0x0080	/* set TAI offset */
+#define ADJ_MICRO		0x1000	/* select microsecond resolution */
+#define ADJ_NANO		0x2000	/* select nanosecond resolution */
 #define ADJ_TICK		0x4000	/* tick value */
 #define ADJ_OFFSET_SINGLESHOT	0x8001	/* old-fashioned adjtime */
 
@@ -77,8 +85,9 @@
 #define MOD_ESTERROR	ADJ_ESTERROR
 #define MOD_STATUS	ADJ_STATUS
 #define MOD_TIMECONST	ADJ_TIMECONST
-#define MOD_CLKB	ADJ_TICK
-#define MOD_CLKA	ADJ_OFFSET_SINGLESHOT /* 0x8000 in original */
+#define MOD_TAI		ADJ_TAI
+#define MOD_MICRO	ADJ_MICRO
+#define MOD_NANO	ADJ_NANO
 
 
 /* Status codes (timex.status) */
@@ -98,9 +107,12 @@
 #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) */
+#define STA_MODE	0x4000	/* mode (0 = PLL, 1 = FLL) (ro) */
+#define STA_CLK		0x8000	/* clock source (0 = A, 1 = B) (ro) */
 
 #define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \
-    STA_PPSERROR | STA_CLOCKERR) /* read-only bits */
+	STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK)
 
 /* Clock states (time_state) */
 #define TIME_OK		0	/* clock synchronized, no leap second */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]