Pastey ARM patch (and_, or_, xor_,... fixes)
- Posted by rkdavis
Feb 18, 2013
--- source/be_runtime.c 2013-02-18 17:06:25.056488384 +0000
+++ /home/ukscone/euphoria-4.1.0/source/be_runtime.c 2013-02-18 17:05:59.794991725 +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(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 */
@@ -1769,11 +1781,19 @@
return MAKE_UINT(a);
}
+#ifdef ARM
+object Dor_bits(d_ptr a, d_ptr b)
+/* double a OR b */
+{
+ return or_bits(doubletouintptrdiscardhighbits(a->dbl), doubletouintptrdiscardhighbits(b->dbl));
+}
+#else
object Dor_bits(d_ptr a, d_ptr b)
/* double a OR b */
{
- return or_bits( (uintptr_t)(a->dbl), (uintptr_t)(b->dbl));
+ return or_bits( (uintptr_t)(a->dbl), (uintptr_t)(b->dbl));
}
+#endif
object xor_bits(uintptr_t a, uintptr_t b)
/* integer a XOR b */
@@ -1782,12 +1802,19 @@
return MAKE_UINT(a);
}
+#ifdef ARM
object Dxor_bits(d_ptr a, d_ptr b)
/* double a XOR b */
{
-
- return xor_bits((uintptr_t)(a->dbl), (uintptr_t)(b->dbl));
+ return xor_bits(doubletouintptrdiscardhighbits(a->dbl), doubletouintptrdiscardhighbits(b->dbl));
+}
+#else
+object Dxor_bits(d_ptr a, d_ptr b)
+/* double a XOR b */
+{
+ return xor_bits((uintptr_t)(a->dbl), (uintptr_t)(b->dbl));
}
+#endif
object not_bits(uintptr_t a)
/* integer bitwise NOT of a */
@@ -1796,11 +1823,19 @@
return MAKE_UINT(a);
}
+#ifdef ARM
+object Dnot_bits(d_ptr a)
+/* double bitwise NOT of a */
+{
+ return not_bits(doubletouintptrdiscardhighbits(a->dbl));
+}
+#else
object Dnot_bits(d_ptr a)
/* double bitwise NOT of a */
{
- return not_bits((uintptr_t)(a->dbl));
+ return not_bits((uintptr_t)(a->dbl));
}
+#endif
object power(object a, object b)
/* integer a to the power b */