Revision 338b922e qemu-timer.h

b/qemu-timer.h
59 59
    return 1000000000LL;
60 60
}
61 61

  
62
/* compute with 96 bit intermediate result: (a*b)/c */
63
static inline uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c)
64
{
65
    union {
66
        uint64_t ll;
67
        struct {
68
#ifdef HOST_WORDS_BIGENDIAN
69
            uint32_t high, low;
70
#else
71
            uint32_t low, high;
72
#endif
73
        } l;
74
    } u, res;
75
    uint64_t rl, rh;
76

  
77
    u.ll = a;
78
    rl = (uint64_t)u.l.low * (uint64_t)b;
79
    rh = (uint64_t)u.l.high * (uint64_t)b;
80
    rh += (rl >> 32);
81
    res.l.high = rh / c;
82
    res.l.low = (((rh % c) << 32) + (rl & 0xffffffff)) / c;
83
    return res.ll;
84
}
85

  
86 62
/* real time host monotonic timer */
87 63
static inline int64_t get_clock_realtime(void)
88 64
{

Also available in: Unified diff