I have C code for Linux that, among other things, caches the difference between 
the rtc and system time. I want to port this code to FreeBSD/Mac. Linux has the 
utility hwclock which reads /dev/rtc and anyway getting the cmos clock time 
directly from this interface can be done in a few lines of code.

I've been looking around for how to read the cmos/rtc on FreeBSD. There is no 
hwclock utility in FreeBSD that I can read sources for to see how it is done.
http://www.wraith.sf.ca.us/ntp/not-hwclock.c.txt is supposed to be C code to 
read the software time and then set the cmos clock to match. This code implies 
that, on FreeBSD, gettimeofday reads the software time and settimeofday sets 
the 
cmos clock. On Linux gettimeofday does indeed read the software time.

BUT the source to adjkerntz.c for FreeBSD says that gettimeofday reads the CMOS 
clock not the system time:

/* get local CMOS clock and possible kernel offset */
if (gettimeofday(&tv, &tz)) {
    syslog(LOG_ERR, "gettimeofday: %m");
    return 1;
}

Which is it? Does gettimeofday read the cmos clock/rtc on FreeBSD? If not, how 
do I read the battery-backed clock on FreeBSD?

To further confuse matters there appears to be a common misconception on the 
web 
that the cmos time is automatically synced to system time on FreeBSD. This is 
incorrect: see msg03414 on freebsd-hardw...@freebsd.org.

Thanks




_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"

Reply via email to