From 12e4d1b0831d292b320ec4fc2b0b1ed9b77872e0 Mon Sep 17 00:00:00 2001 From: OBattler Date: Tue, 26 Mar 2024 23:29:06 +0100 Subject: [PATCH] SoftFloat: Correctly treat +INF and -INF as equal on 8087 and 287, fixes 287 detection in MCPDiag. --- src/cpu/softfloat/softfloatx80.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/cpu/softfloat/softfloatx80.cc b/src/cpu/softfloat/softfloatx80.cc index 3ac3e61b3..b4ce88b3f 100644 --- a/src/cpu/softfloat/softfloatx80.cc +++ b/src/cpu/softfloat/softfloatx80.cc @@ -23,6 +23,11 @@ these four paragraphs for those parts of this code that are retained. * Stanislav Shwartsman [sshwarts at sourceforge net] * ==========================================================================*/ +#include +#include +#include <86box/86box.h> +#include "../cpu.h" + #include "softfloatx80.h" #include "softfloat-round-pack.h" #include "softfloat-macros.h" @@ -305,6 +310,18 @@ int floatx80_compare(floatx80 a, floatx80 b, int quiet, struct float_status_t *s float_class_t aClass = floatx80_class(a); float_class_t bClass = floatx80_class(b); + if (fpu_type < FPU_287XL) { + if ((aClass == float_positive_inf) || (bClass == float_negative_inf)) + { + return float_relation_equal; + } + + if ((aClass == float_negative_inf) || (bClass == float_positive_inf)) + { + return float_relation_equal; + } + } + if (aClass == float_SNaN || bClass == float_SNaN) { /* unsupported reported as SNaN */