Revision e44259b6 include/qemu/host-utils.h
b/include/qemu/host-utils.h | ||
---|---|---|
57 | 57 |
return result > UINT64_MAX; |
58 | 58 |
} |
59 | 59 |
} |
60 |
|
|
61 |
static inline int divs128(int64_t *plow, int64_t *phigh, int64_t divisor) |
|
62 |
{ |
|
63 |
if (divisor == 0) { |
|
64 |
return 1; |
|
65 |
} else { |
|
66 |
__int128_t dividend = ((__int128_t)*phigh << 64) | *plow; |
|
67 |
__int128_t result = dividend / divisor; |
|
68 |
*plow = result; |
|
69 |
*phigh = dividend % divisor; |
|
70 |
return result != *plow; |
|
71 |
} |
|
72 |
} |
|
60 | 73 |
#else |
61 | 74 |
void muls64(uint64_t *phigh, uint64_t *plow, int64_t a, int64_t b); |
62 | 75 |
void mulu64(uint64_t *phigh, uint64_t *plow, uint64_t a, uint64_t b); |
63 | 76 |
int divu128(uint64_t *plow, uint64_t *phigh, uint64_t divisor); |
77 |
int divs128(int64_t *plow, int64_t *phigh, int64_t divisor); |
|
64 | 78 |
#endif |
65 | 79 |
|
66 | 80 |
/** |
Also available in: Unified diff