aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv')
-rw-r--r--sysdeps/unix/sysv/linux/Makefile2
-rw-r--r--sysdeps/unix/sysv/linux/Versions3
-rw-r--r--sysdeps/unix/sysv/linux/ntp_adjtime.c34
-rw-r--r--sysdeps/unix/sysv/linux/ntp_gettime.c38
-rw-r--r--sysdeps/unix/sysv/linux/sys/timex.h44
5 files changed, 104 insertions, 17 deletions
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index ac99436a8d..64baeb10d6 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -53,6 +53,8 @@ endif
ifeq ($(subdir),time)
sysdep_headers += sys/timex.h
+
+sysdep_routines += ntp_adjtime ntp_gettime
endif
ifeq ($(subdir),socket)
diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
index eeaed93fc3..6210830cce 100644
--- a/sysdeps/unix/sysv/linux/Versions
+++ b/sysdeps/unix/sysv/linux/Versions
@@ -73,6 +73,9 @@ libc {
# c*
capget; capset;
+ # n*
+ ntp_adjtime; ntp_gettime;
+
# s*
sendfile;
diff --git a/sysdeps/unix/sysv/linux/ntp_adjtime.c b/sysdeps/unix/sysv/linux/ntp_adjtime.c
new file mode 100644
index 0000000000..d9f3ca7b9c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/ntp_adjtime.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sys/timex.h>
+
+#ifndef MOD_OFFSET
+# define modes mode
+#endif
+
+int
+ntp_adjtime (amode, tntx)
+ int amode;
+ struct timex *tntx;
+{
+ /* Relies on the fact that C lib's struct timex corresponds to kernel's
+ struct timex. Otherwise you'll need a wrapper. */
+ tntx->modes = amode;
+ return __adjtimex (tntx);
+}
diff --git a/sysdeps/unix/sysv/linux/ntp_gettime.c b/sysdeps/unix/sysv/linux/ntp_gettime.c
new file mode 100644
index 0000000000..664d85f92f
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/ntp_gettime.c
@@ -0,0 +1,38 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <sys/timex.h>
+
+#ifndef MOD_OFFSET
+# define modes mode
+#endif
+
+int
+ntp_gettime (ntv)
+ struct ntptimeval *ntv;
+{
+ struct timex tntx;
+ int result;
+
+ tntx.modes = 0;
+ result = __adjtimex (&tntx);
+ ntv->time = tntx.time;
+ ntv->maxerror = tntx.maxerror;
+ ntv->esterror = tntx.esterror;
+ return result;
+}
diff --git a/sysdeps/unix/sysv/linux/sys/timex.h b/sysdeps/unix/sysv/linux/sys/timex.h
index aa3ee39d22..da1e33e85a 100644
--- a/sysdeps/unix/sysv/linux/sys/timex.h
+++ b/sysdeps/unix/sysv/linux/sys/timex.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -24,28 +24,35 @@
/* These definitions from linux/timex.h as of 2.1.130. */
+struct ntptimeval
+{
+ struct timeval time; /* current time (ro) */
+ long int maxerror; /* maximum error (us) (ro) */
+ long int esterror; /* estimated error (us) (ro) */
+};
+
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) */
+ long int offset; /* time offset (usec) */
+ long int freq; /* frequency offset (scaled ppm) */
+ long int maxerror; /* maximum error (usec) */
+ long int 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) */
+ long int constant; /* pll time constant */
+ long int precision; /* clock precision (usec) (read only) */
+ long int tolerance; /* clock frequency tolerance (ppm) (read only) */
struct timeval time; /* (read only) */
- long tick; /* (modified) usecs between clock ticks */
+ long int 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) */
+ long int ppsfreq; /* pps frequency (scaled ppm) (ro) */
+ long int jitter; /* pps jitter (us) (ro) */
+ int shift; /* interval duration (s) (shift) (ro) */
+ long int stabil; /* pps stability (scaled ppm) (ro) */
+ long int jitcnt; /* jitter limit exceeded (ro) */
+ long int calcnt; /* calibration intervals (ro) */
+ long int errcnt; /* calibration errors (ro) */
+ long int stbcnt; /* stability limit exceeded (ro) */
/* ??? */
int :32; int :32; int :32; int :32;
@@ -109,6 +116,9 @@ __BEGIN_DECLS
extern int __adjtimex __P ((struct timex *__ntx));
extern int adjtimex __P ((struct timex *__ntx));
+extern int ntp_gettime __P ((struct ntptimeval *__ntv));
+extern int ntp_adjtime __P ((int __amode, struct timex *__tntx));
+
__END_DECLS
#endif /* sys/timex.h */