* 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. */
| 567 | * extra cycles. |
| 568 | */ |
| 569 | static void |
| 570 | ffclock_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. |
no test coverage detected