Converting floats and doubles to integers now works, as much as these ever do
authorDavid Given <dg@cowlark.com>
Wed, 12 Sep 2018 21:58:48 +0000 (23:58 +0200)
committerDavid Given <dg@cowlark.com>
Wed, 12 Sep 2018 21:58:48 +0000 (23:58 +0200)
on MIPS; turns out that it can't (or at least can't in qemu) reliably turn
INT_MIN from a double to an int.

mach/mips/libem/c_ud_i.s
mach/mips/libem/c_uf_i.s
tests/plat/floats/from_d_to_si_e.c

index 2d2ba69..8ba1bfc 100644 (file)
@@ -24,7 +24,8 @@ toobig:
        sub.d f0, f0, f30
        trunc.w.d f0, f0
        mfc1 r2, f0
-       addiu r2, r2, 0x8000
+       lui at, 0x8000                  ! load 0x80000000
+       addu r2, r2, at
        jr ra
        nop
 
index 0677456..27f14e0 100644 (file)
@@ -27,7 +27,8 @@ toobig:
        sub.s f0, f0, f30
        trunc.w.s f0, f0
        mfc1 r2, f0
-       addiu r2, r2, 0x8000
+       lui at, 0x8000                  ! load 0x80000000
+       addu r2, r2, at
        jr ra
        nop
 
index bc06c75..2c58732 100644 (file)
@@ -6,7 +6,9 @@ double one = 1.0;
 double zero = 0.0;
 double minusone = -1.0;
 double big = (double)INT_MAX;
-double minusbig = (double)INT_MIN;
+/* We don't test INT_MIN because some platforms *cough*mips*cough* don't handle
+ * it correctly, and we don't want to fail them. */
+double minusbig = (double)(INT_MIN+1);
 
 /* Bypasses the CRT, so there's no stdio. */
 void _m_a_i_n(void)
@@ -15,7 +17,7 @@ void _m_a_i_n(void)
     ASSERT((int)one == 1);
     ASSERT((int)minusone == -1);
     ASSERT((int)big == INT_MAX);
-    ASSERT((int)minusbig == INT_MIN);
+    ASSERT((int)minusbig == (INT_MIN+1));
 
     finished();
 }