aboutsummaryrefslogtreecommitdiff
path: root/system/lib/compiler-rt
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-04-14 17:19:50 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-04-14 17:19:50 -0700
commit6749401c21206655e57db30664faff12cdfae138 (patch)
treee2e3dc2ee59a4f6a74ad705a7451e2415489af12 /system/lib/compiler-rt
parent84c58ecc4abb7af1c88cce1af3d86ffa106f22d2 (diff)
use compiled i64 div and rem
Diffstat (limited to 'system/lib/compiler-rt')
-rw-r--r--system/lib/compiler-rt/divdi3.c16
-rw-r--r--system/lib/compiler-rt/readme.txt5
-rw-r--r--system/lib/compiler-rt/udivdi3.c11
3 files changed, 31 insertions, 1 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 */
+}
+
diff --git a/system/lib/compiler-rt/readme.txt b/system/lib/compiler-rt/readme.txt
index d32e4600..d10f53e4 100644
--- a/system/lib/compiler-rt/readme.txt
+++ b/system/lib/compiler-rt/readme.txt
@@ -5,7 +5,10 @@ Last Changed Date: 2013-04-12 07:57:03 -0700 (Fri, 12 Apr 2013)
===========================================================================
-Changes: add emscripten endianness to int_endianness.h
+Changes:
+
+ * add emscripten endianness to int_endianness.h
+ * add rem functions
===========================================================================
diff --git a/system/lib/compiler-rt/udivdi3.c b/system/lib/compiler-rt/udivdi3.c
index 6c0303df..3d55785c 100644
--- a/system/lib/compiler-rt/udivdi3.c
+++ b/system/lib/compiler-rt/udivdi3.c
@@ -23,3 +23,14 @@ __udivdi3(du_int a, du_int b)
{
return __udivmoddi4(a, b, 0);
}
+
+/* XXX EMSCRIPTEN */
+
+COMPILER_RT_ABI du_int
+__uremdi3(du_int a, du_int b)
+{
+ du_int rem;
+ __udivmoddi4(a, b, &rem);
+ return rem;
+}
+