From 6fc32ef8ee8e173059ecd759b722dcc4d730ef0e Mon Sep 17 00:00:00 2001 From: Dima Ruban Date: Mon, 19 Oct 1998 20:48:08 +0000 Subject: [PATCH] Use sysctl() rather than kvm_read() when getting information about clock stuff from kernel. This fixes xntpd on alpha. --- usr.sbin/xntpd/include/ntp_machine.h | 1 + usr.sbin/xntpd/xntpd/ntp_unixclock.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/usr.sbin/xntpd/include/ntp_machine.h b/usr.sbin/xntpd/include/ntp_machine.h index 25de0213b931..0d4267c452a6 100644 --- a/usr.sbin/xntpd/include/ntp_machine.h +++ b/usr.sbin/xntpd/include/ntp_machine.h @@ -373,6 +373,7 @@ in this file. #if defined(SYS_44BSD) #define HAVE_SIGNALED_IO #define HAVE_LIBKVM +#define HAVE_SYSCTL #define NTP_POSIX_SOURCE #define HAVE_BSD_NICE #define USE_PROTOTYPES diff --git a/usr.sbin/xntpd/xntpd/ntp_unixclock.c b/usr.sbin/xntpd/xntpd/ntp_unixclock.c index bc771b6b717f..557ce25eddcb 100644 --- a/usr.sbin/xntpd/xntpd/ntp_unixclock.c +++ b/usr.sbin/xntpd/xntpd/ntp_unixclock.c @@ -40,6 +40,12 @@ #undef hz #endif /* RS6000 */ +#ifdef HAVE_SYSCTL +#include +#include +#include +#endif + extern int debug; /* * These routines (init_systime, get_systime, step_systime, adj_systime) @@ -176,6 +182,27 @@ init_systime() L_CLR(&sys_clock_offset); } +#if defined(HAVE_SYSCTL) && defined(KERN_CLOCKRATE) +static void +clock_parms(tickadj, tick) + u_long *tickadj; + u_long *tick; +{ + int mib[2]; + size_t len; + struct clockinfo x; + + mib[0] = CTL_KERN; + mib[1] = KERN_CLOCKRATE; + len = sizeof(x); + if (sysctl(mib, 2, &x, &len, NULL, 0) == -1) { + syslog(LOG_NOTICE, "sysctl(KERN_CLOCKRATE) failed: %m"); + exit(3); + } + *tickadj = x.tickadj; + *tick = x.tick; +} +#else #ifdef HAVE_LIBKVM /* * clock_parms - return the local clock tickadj and tick parameters @@ -604,3 +631,4 @@ clock_parms(tickadj, tick) *tick = (u_long)txc.tick; } #endif /* SYS_LINUX */ +#endif