summaryrefslogtreecommitdiff
path: root/net/openntpd/files/adjfreq.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/openntpd/files/adjfreq.c')
-rw-r--r--net/openntpd/files/adjfreq.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/net/openntpd/files/adjfreq.c b/net/openntpd/files/adjfreq.c
new file mode 100644
index 000000000000..6141f25cdd6f
--- /dev/null
+++ b/net/openntpd/files/adjfreq.c
@@ -0,0 +1,30 @@
+/*
+ * This file is in the public domain.
+ *
+ * $FreeBSD$
+ */
+
+#include <sys/types.h>
+#include <sys/timex.h>
+
+#include "ntpd.h"
+
+int
+adjfreq(const int64_t *freq, int64_t *oldfreq)
+{
+ struct timex t;
+
+ if (oldfreq) {
+ t.modes = 0;
+ if (ntp_adjtime(&t) == -1)
+ return -1;
+ *oldfreq = (int64_t)t.freq * (1<<16) * 1000;
+ }
+ if (freq) {
+ t.modes = MOD_FREQUENCY;
+ t.freq = *freq / ((1<<16) * 1000);
+ if (ntp_adjtime(&t) == -1)
+ return -1;
+ }
+ return 0;
+}