From: David Given Date: Wed, 12 Sep 2018 21:58:48 +0000 (+0200) Subject: Converting floats and doubles to integers now works, as much as these ever do X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=ecb3395abae5c62529a58507279c9cfe091e7406;p=ack.git Converting floats and doubles to integers now works, as much as these ever do 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. --- diff --git a/mach/mips/libem/c_ud_i.s b/mach/mips/libem/c_ud_i.s index 2d2ba6992..8ba1bfc04 100644 --- a/mach/mips/libem/c_ud_i.s +++ b/mach/mips/libem/c_ud_i.s @@ -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 diff --git a/mach/mips/libem/c_uf_i.s b/mach/mips/libem/c_uf_i.s index 0677456ae..27f14e03e 100644 --- a/mach/mips/libem/c_uf_i.s +++ b/mach/mips/libem/c_uf_i.s @@ -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 diff --git a/tests/plat/floats/from_d_to_si_e.c b/tests/plat/floats/from_d_to_si_e.c index bc06c755c..2c587322a 100644 --- a/tests/plat/floats/from_d_to_si_e.c +++ b/tests/plat/floats/from_d_to_si_e.c @@ -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(); }