-static inline int divs128(int64_t *plow, int64_t *phigh, int64_t divisor)
+static inline void divs128(int64_t *plow, int64_t *phigh, int64_t divisor)
{
- if (divisor == 0) {
- return 1;
- } else {
- __int128_t dividend = ((__int128_t)*phigh << 64) | *plow;
- __int128_t result = dividend / divisor;
- *plow = result;
- *phigh = dividend % divisor;
- return result != *plow;
- }
+ __int128_t dividend = ((__int128_t)*phigh << 64) | *plow;
@@ -97,13 +101,11 @@ int divu128(uint64_t *plow, uint64_t *phigh, uint64_t
divisor)
uint64_t carry = 0;
if (divisor == 0) {
- return 1;
+ /* intentionally cause a division by 0 */
+ *plow = 1 / divisor;
} else if (dhi == 0) {
*plow = dlo / divisor;
*phigh = dlo % divisor;