diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-04-14 17:19:50 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-04-14 17:19:50 -0700 |
commit | 6749401c21206655e57db30664faff12cdfae138 (patch) | |
tree | e2e3dc2ee59a4f6a74ad705a7451e2415489af12 /system/lib/compiler-rt/divdi3.c | |
parent | 84c58ecc4abb7af1c88cce1af3d86ffa106f22d2 (diff) |
use compiled i64 div and rem
Diffstat (limited to 'system/lib/compiler-rt/divdi3.c')
-rw-r--r-- | system/lib/compiler-rt/divdi3.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/system/lib/compiler-rt/divdi3.c b/system/lib/compiler-rt/divdi3.c index 2c2bcc26..09f4a04e 100644 --- a/system/lib/compiler-rt/divdi3.c +++ b/system/lib/compiler-rt/divdi3.c @@ -29,3 +29,19 @@ __divdi3(di_int a, di_int b) s_a ^= s_b; /*sign of quotient */ return (__udivmoddi4(a, b, (du_int*)0) ^ s_a) - s_a; /* negate if s_a == -1 */ } + +/* XXX EMSCRIPTEN */ + +COMPILER_RT_ABI di_int +__remdi3(di_int a, di_int b) +{ + const int bits_in_dword_m1 = (int)(sizeof(di_int) * CHAR_BIT) - 1; + di_int s_a = a >> bits_in_dword_m1; /* s_a = a < 0 ? -1 : 0 */ + di_int s_b = b >> bits_in_dword_m1; /* s_b = b < 0 ? -1 : 0 */ + a = (a ^ s_a) - s_a; /* negate if s_a == -1 */ + b = (b ^ s_b) - s_b; /* negate if s_b == -1 */ + du_int rem; + __udivmoddi4(a, b, &rem); + return (rem ^ s_a) - s_a; /* negate if s_a == -1 */ +} + |