Pastey better ARM be_runtime.c patch
- Posted by rkdavis
Feb 18, 2013
--- source/be_runtime.c 2013-02-18 15:21:25.101155083 +0000
+++ /home/ukscone/euphoria-4.1.0/source/be_runtime.c 2013-02-18 15:21:14.940488926 +0000
@@ -439,7 +439,13 @@
buff[dbg_dbl_len - 1] = 0; // ensure NULL
debug_msg(buff);
}
-
+#ifdef ARM
+uintptr_t doubletouintptrdiscardhighbits(double d)
+{
+double maxplus1 = ((double)UINTPTR_MAX) + 1;
+ return d-(maxplus1*floor(d/maxplus1));
+}
+#endif
#ifdef ERUNTIME
int color_trace = 1;
@@ -1748,19 +1754,25 @@
return (object)NewDouble(fmod(a->dbl, b->dbl)); /* for now */
}
-
object and_bits(uintptr_t a, uintptr_t b)
/* integer a AND b */
{
- a = a & b;
- return MAKE_UINT(a);
+ a = a & b;
+ return MAKE_UINT(a);
}
-
+#ifdef ARM
object Dand_bits(d_ptr a, d_ptr b)
/* double a AND b */
{
- return and_bits( (uintptr_t)(a->dbl), (uintptr_t)(b->dbl));
+return and_bits(doubletouintptrdiscardhighbits(a->dbl), doubletouintptrdiscardhighbits(b->dbl));
}
+#else
+object Dand_bits(d_ptr a, d_ptr b)
+/* double a AND b */
+{
+return and_bits( (uintptr_t)(a->dbl), (uintptr_t)(b->dbl));
+}
+#endif
object or_bits(uintptr_t a, uintptr_t b)
/* integer a OR b */
@@ -1772,7 +1784,8 @@
object Dor_bits(d_ptr a, d_ptr b)
/* double a OR b */
{
- return or_bits( (uintptr_t)(a->dbl), (uintptr_t)(b->dbl));
+double maxplus1 = ((double)UINTPTR_MAX) + 1;
+ return or_bits( (uintptr_t)fmod(a->dbl,maxplus1), (uintptr_t)fmod(b->dbl,maxplus1));
}
object xor_bits(uintptr_t a, uintptr_t b)