FreeBSD/sys/kern/kern_tc.c
/*
 * Convert a sysclock snapshot into a struct bintime based on the specified
 * clock source and flags.
 */
Convert a sysclock snapshot into a struct bintime based on the specified
clock source and flags.
Convert a sysclock snapshot into a struct bintime based on the specified clock source and flags .
int
sysclock_snap2bintime(struct sysclock_snap *cs, struct bintime *bt,
    int whichclock, uint32_t flags)
{
#ifdef FFCLOCK
	struct bintime bt2;
	uint64_t period;
#endif
	switch (whichclock) {
	case SYSCLOCK_FBCK:
		*bt = cs->fb_info.tick_time;
		if (cs->delta > 0)
			bintime_addx(bt, cs->fb_info.th_scale * cs->delta);
		if ((flags & FBCLOCK_UPTIME) == 0)
			bintime_add(bt, &boottimebin);
		break;
#ifdef FFCLOCK
	case SYSCLOCK_FFWD:
		if (flags & FFCLOCK_LERP) {
			*bt = cs->ff_info.tick_time_lerp;
			period = cs->ff_info.period_lerp;
		} else {
			*bt = cs->ff_info.tick_time;
			period = cs->ff_info.period;
		}
		if (cs->delta > 0) {
			ffclock_convert_delta(cs->delta, period, &bt2);
			bintime_add(bt, &bt2);
		}
		if (flags & FFCLOCK_LEAPSEC)
			bt->sec -= cs->ff_info.leapsec_adjustment;
		if (flags & FFCLOCK_UPTIME)
			bintime_sub(bt, &ffclock_boottime);
		break;
#endif
	default:
		return (EINVAL);
		break;
	}
	return (0);
}
int sysclock_snap2bintime ( struct sysclock_snap * cs , struct bintime * bt , int whichclock , uint32_t flags ) { #ifdef FFCLOCK struct bintime bt2 ; uint64_t period ; #endif switch ( whichclock ) { case SYSCLOCK_FBCK : * bt = cs -> fb_info . tick_time ; if ( cs -> delta > 0 ) bintime_addx ( bt , cs -> fb_info . th_scale * cs -> delta ) ; if ( ( flags & FBCLOCK_UPTIME ) == 0 ) bintime_add ( bt , & boottimebin ) ; break ; #ifdef FFCLOCK case SYSCLOCK_FFWD : if ( flags & FFCLOCK_LERP ) { * bt = cs -> ff_info . tick_time_lerp ; period = cs -> ff_info . period_lerp ; } else { * bt = cs -> ff_info . tick_time ; period = cs -> ff_info . period ; } if ( cs -> delta > 0 ) { ffclock_convert_delta ( cs -> delta , period , & bt2 ) ; bintime_add ( bt , & bt2 ) ; } if ( flags & FFCLOCK_LEAPSEC ) bt -> sec -= cs -> ff_info . leapsec_adjustment ; if ( flags & FFCLOCK_UPTIME ) bintime_sub ( bt , & ffclock_boottime ) ; break ; #endif default : return ( EINVAL ) ; break ; } return ( 0 ) ; }
Convert a sysclock snapshot into a struct bintime based on the specified
 clock source and flags.
Convert a sysclock snapshot into a struct bintime based on the specified clock source and flags .
/* If snapshot was created with !fast, delta will be >0. */ /* If snapshot was created with !fast, delta will be >0. */ /* Leap second adjustment. */ /* Boot time adjustment, for uptime/monotonic clocks. */