MCPcopy Create free account
hub / github.com/F-Stack/f-stack / read_clocks

Function read_clocks

freebsd/kern/subr_rtc.c:291–319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

289}
290
291static int
292read_clocks(struct timespec *ts, bool debug_read)
293{
294 struct rtc_instance *rtc;
295 int error;
296
297 error = ENXIO;
298 sx_xlock(&rtc_list_lock);
299 LIST_FOREACH(rtc, &rtc_list, rtc_entries) {
300 if ((error = CLOCK_GETTIME(rtc->clockdev, ts)) != 0)
301 continue;
302 if (ts->tv_sec < 0 || ts->tv_nsec < 0) {
303 error = EINVAL;
304 continue;
305 }
306 if (!(rtc->flags & CLOCKF_GETTIME_NO_ADJ)) {
307 timespecadd(ts, &rtc->resadj, ts);
308 ts->tv_sec += utc_offset();
309 }
310 if (!debug_read) {
311 if (bootverbose)
312 device_printf(rtc->clockdev,
313 "providing initial system time\n");
314 break;
315 }
316 }
317 sx_xunlock(&rtc_list_lock);
318 return (error);
319}
320
321/*
322 * Initialize the system time. Must be called from a context which does not

Callers 2

inittodrFunction · 0.85
sysctl_clock_do_ioFunction · 0.85

Calls 2

utc_offsetFunction · 0.85
device_printfFunction · 0.85

Tested by

no test coverage detected