Revision c57c846a vl.c
b/vl.c | ||
---|---|---|
289 | 289 |
/***********************************************************/ |
290 | 290 |
/* real time host monotonic timer */ |
291 | 291 |
|
292 |
/* compute with 96 bit intermediate result: (a*b)/c */ |
|
293 |
uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c) |
|
294 |
{ |
|
295 |
union { |
|
296 |
uint64_t ll; |
|
297 |
struct { |
|
298 |
#ifdef HOST_WORDS_BIGENDIAN |
|
299 |
uint32_t high, low; |
|
300 |
#else |
|
301 |
uint32_t low, high; |
|
302 |
#endif |
|
303 |
} l; |
|
304 |
} u, res; |
|
305 |
uint64_t rl, rh; |
|
306 |
|
|
307 |
u.ll = a; |
|
308 |
rl = (uint64_t)u.l.low * (uint64_t)b; |
|
309 |
rh = (uint64_t)u.l.high * (uint64_t)b; |
|
310 |
rh += (rl >> 32); |
|
311 |
res.l.high = rh / c; |
|
312 |
res.l.low = (((rh % c) << 32) + (rl & 0xffffffff)) / c; |
|
313 |
return res.ll; |
|
314 |
} |
|
315 |
|
|
316 | 292 |
/***********************************************************/ |
317 | 293 |
/* host time/date access */ |
318 | 294 |
void qemu_get_timedate(struct tm *tm, int offset) |
Also available in: Unified diff