FreeBSD/sys/kern/kern_clocksource.c
/*
 * Calculate nearest frequency supported by hardware timer.
 */
Calculate nearest frequency supported by hardware timer.
Calculate nearest frequency supported by hardware timer .
static int
round_freq(struct eventtimer *et, int freq)
{
	uint64_t div;
	if (et->et_frequency != 0) {
		div = lmax((et->et_frequency + freq / 2) / freq, 1);
		if (et->et_flags & ET_FLAGS_POW2DIV)
			div = 1 << (flsl(div + div / 2) - 1);
		freq = (et->et_frequency + div / 2) / div;
	}
	if (et->et_min_period > SBT_1S)
		panic("Event timer \"%s\" doesn't support sub-second periods!",
		    et->et_name);
	else if (et->et_min_period != 0)
		freq = min(freq, SBT2FREQ(et->et_min_period));
	if (et->et_max_period < SBT_1S && et->et_max_period != 0)
		freq = max(freq, SBT2FREQ(et->et_max_period));
	return (freq);
}
static int round_freq ( struct eventtimer * et , int freq ) { uint64_t div ; if ( et -> et_frequency != 0 ) { div = lmax ( ( et -> et_frequency + freq / 2 ) / freq , 1 ) ; if ( et -> et_flags & ET_FLAGS_POW2DIV ) div = 1 << ( flsl ( div + div / 2 ) - 1 ) ; freq = ( et -> et_frequency + div / 2 ) / div ; } if ( et -> et_min_period > SBT_1S ) panic ( " \" \" " , et -> et_name ) ; else if ( et -> et_min_period != 0 ) freq = min ( freq , SBT2FREQ ( et -> et_min_period ) ) ; if ( et -> et_max_period < SBT_1S && et -> et_max_period != 0 ) freq = max ( freq , SBT2FREQ ( et -> et_max_period ) ) ; return ( freq ) ; }
Calculate nearest frequency supported by hardware timer.
Calculate nearest frequency supported by hardware timer .