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

Function ffclock_convert_delta

freebsd/kern/kern_tc.c:569–588  ·  view source on GitHub ↗

* Sub-routine to convert a time interval measured in RAW counter units to time * in seconds stored in bintime format. * NOTE: bintime_mul requires u_int, but the value of the ffcounter may be * larger than the max value of u_int (on 32 bit architecture). Loop to consume * extra cycles. */

Source from the content-addressed store, hash-verified

567 * extra cycles.
568 */
569static void
570ffclock_convert_delta(ffcounter ffdelta, uint64_t period, struct bintime *bt)
571{
572 struct bintime bt2;
573 ffcounter delta, delta_max;
574
575 delta_max = (1ULL << (8 * sizeof(unsigned int))) - 1;
576 bintime_clear(bt);
577 do {
578 if (ffdelta > delta_max)
579 delta = delta_max;
580 else
581 delta = ffdelta;
582 bt2.sec = 0;
583 bt2.frac = period;
584 bintime_mul(&bt2, (unsigned int)delta);
585 bintime_add(bt, &bt2);
586 ffdelta -= delta;
587 } while (ffdelta > 0);
588}
589
590/*
591 * Update the fftimehands.

Callers 6

ffclock_windupFunction · 0.85
ffclock_convert_absFunction · 0.85
ffclock_convert_diffFunction · 0.85
sysclock_getsnapshotFunction · 0.85
sysclock_snap2bintimeFunction · 0.85
pps_eventFunction · 0.85

Calls 2

bintime_mulFunction · 0.85
bintime_addFunction · 0.85

Tested by

no test coverage detected