From 61bb66bccd82bac6290ba8efa505ceea0e8c2021 Mon Sep 17 00:00:00 2001 From: Dan Olson Date: Fri, 11 Mar 2016 07:08:05 +0000 Subject: [PATCH] Use build host D compiler real type D needs to compile itself on non-x86 hosts where real type might be something other than 80-bit extended precision. The simplest approach is to use the existing D compiler real type as it must already have correct real.nan and snan intializer. Note this does not work for cross-compiling to alternate targets and is only intended as transitional until that capability is added. Upstream commit: a776514edc914e2e09bd4298fb07f2ac99e86f45 --- ddmd/root/port.d | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/ddmd/root/port.d b/ddmd/root/port.d index 944681fb29..dff213d3be 100644 --- a/ddmd/root/port.d +++ b/ddmd/root/port.d @@ -84,20 +84,6 @@ extern (C++) struct Port static __gshared bool yl2xp1_supported = false; } static __gshared real snan; - static this() - { - /* - * Use a payload which is different from the machine NaN, - * so that uninitialised variables can be - * detected even if exceptions are disabled. - */ - ushort* us = cast(ushort*)&snan; - us[0] = 0; - us[1] = 0; - us[2] = 0; - us[3] = 0xA000; - us[4] = 0x7FFF; - } static bool isNan(double r) { @@ -114,9 +100,11 @@ extern (C++) struct Port return a % b; } - static real fequal(real a, real b) + static bool fequal(real a, real b) { - return memcmp(&a, &b, 10) == 0; + // don't compare pad bytes in extended precision + enum sz = (real.mant_dig == 64) ? 10 : real.sizeof; + return memcmp(&a, &b, sz) == 0; } static int memicmp(const char* s1, const char* s2, size_t n)