Revision 338b922e qemu-common.h
b/qemu-common.h | ||
---|---|---|
309 | 309 |
return ((val >> 4) * 10) + (val & 0x0f); |
310 | 310 |
} |
311 | 311 |
|
312 |
/* compute with 96 bit intermediate result: (a*b)/c */ |
|
313 |
static inline uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c) |
|
314 |
{ |
|
315 |
union { |
|
316 |
uint64_t ll; |
|
317 |
struct { |
|
318 |
#ifdef HOST_WORDS_BIGENDIAN |
|
319 |
uint32_t high, low; |
|
320 |
#else |
|
321 |
uint32_t low, high; |
|
322 |
#endif |
|
323 |
} l; |
|
324 |
} u, res; |
|
325 |
uint64_t rl, rh; |
|
326 |
|
|
327 |
u.ll = a; |
|
328 |
rl = (uint64_t)u.l.low * (uint64_t)b; |
|
329 |
rh = (uint64_t)u.l.high * (uint64_t)b; |
|
330 |
rh += (rl >> 32); |
|
331 |
res.l.high = rh / c; |
|
332 |
res.l.low = (((rh % c) << 32) + (rl & 0xffffffff)) / c; |
|
333 |
return res.ll; |
|
334 |
} |
|
335 |
|
|
312 | 336 |
#include "module.h" |
313 | 337 |
|
314 | 338 |
#endif |
Also available in: Unified diff