2 Copyright © 2009-2014, The AROS Development Team. All rights reserved.
8 void __attribute__((noreturn
)) __aeabi_ldiv0(uint64_t);
10 int64_t __ldiv(int64_t a
, int64_t b
)
12 int32_t sign
= ((int32_t)(a
>> 32))^((int32_t)(b
>> 32));
30 int first_bit_a
= __builtin_clz(a
>> 32);
31 int first_bit_b
= __builtin_clz(b
>> 32);
33 if (first_bit_a
== 32)
34 first_bit_a
+= __builtin_clz(a
& 0xffffffff);
35 if (first_bit_b
== 32)
36 first_bit_b
+= __builtin_clz(b
& 0xffffffff);
38 uint64_t mask
= 0x00000001ULL
<< (first_bit_b
-first_bit_a
);
39 b
<<= (first_bit_b
- first_bit_a
);
60 int64_t __ldivmod_helper(int64_t a
, int64_t b
, int64_t *remainder
)
64 quotient
= __ldiv(a
, b
);
66 *remainder
= a
- b
* quotient
;