Received: from eggs.gnu.org ([2001:4830:134:3::10]:56136) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0I9q-00077F-Sx for qemu-devel@nongnu.org; Sun, 14 Dec 2014 18:01:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y0I9l-0001XT-NX for qemu-devel@nongnu.org; Sun, 14 Dec 2014 18:00:58 -0500 Received: from mail-oi0-x229.google.com ([2607:f8b0:4003:c06::229]:35868) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0I9l-0001XO-IT for qemu-devel@nongnu.org; Sun, 14 Dec 2014 18:00:53 -0500 Received: by mail-oi0-f41.google.com with SMTP id a3so7404903oib.0 for ; Sun, 14 Dec 2014 15:00:53 -0800 (PST) Sender: Richard Henderson From: Richard Henderson Date: Sun, 14 Dec 2014 17:00:46 -0600 Message-Id: <1418598048-21995-2-git-send-email-rth@twiddle.net> In-Reply-To: <1418598048-21995-1-git-send-email-rth@twiddle.net> References: <1418598048-21995-1-git-send-email-rth@twiddle.net> Subject: [Qemu-devel] [PULL 1/3] target-i386: Wrong conversion infinity from float80 to int32/int64 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Dmitry Poletaev , peter.maydell@linaro.org From: Dmitry Poletaev Signed-off-by: Dmitry Poletaev Signed-off-by: Richard Henderson --- target-i386/fpu_helper.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/target-i386/fpu_helper.c b/target-i386/fpu_helper.c index 1d4eee3..8768e1c 100644 --- a/target-i386/fpu_helper.c +++ b/target-i386/fpu_helper.c @@ -251,16 +251,34 @@ int32_t helper_fist_ST0(CPUX86State *env) int32_t helper_fistl_ST0(CPUX86State *env) { int32_t val; + signed char old_exp_flags; + + old_exp_flags = get_float_exception_flags(&env->fp_status); + set_float_exception_flags(0, &env->fp_status); val = floatx80_to_int32(ST0, &env->fp_status); + if (get_float_exception_flags(&env->fp_status) & float_flag_invalid) { + val = 0x80000000; + } + set_float_exception_flags(get_float_exception_flags(&env->fp_status) + | old_exp_flags, &env->fp_status); return val; } int64_t helper_fistll_ST0(CPUX86State *env) { int64_t val; + signed char old_exp_flags; - val = floatx80_to_int64(ST0, &env->fp_status); + old_exp_flags = get_float_exception_flags(&env->fp_status); + set_float_exception_flags(0, &env->fp_status); + + val = floatx80_to_int32(ST0, &env->fp_status); + if (get_float_exception_flags(&env->fp_status) & float_flag_invalid) { + val = 0x8000000000000000ULL; + } + set_float_exception_flags(get_float_exception_flags(&env->fp_status) + | old_exp_flags, &env->fp_status); return val; } -- 2.1.0