Received: from eggs.gnu.org ([2001:4830:134:3::10]:60877) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAGiO-0000OZ-H7 for qemu-devel@nongnu.org; Thu, 24 Jul 2014 06:57:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XAGiI-00085r-1K for qemu-devel@nongnu.org; Thu, 24 Jul 2014 06:57:36 -0400 Received: from forward12.mail.yandex.net ([95.108.130.94]:38808) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAGiH-00085l-Nm for qemu-devel@nongnu.org; Thu, 24 Jul 2014 06:57:29 -0400 From: Dmitry Poletaev In-Reply-To: References: <3936561405348528@web11m.yandex.ru> <5212091406116528@web27m.yandex.ru> <3654261406127876@web2h.yandex.ru> MIME-Version: 1.0 Message-Id: <14098881406199446@web16j.yandex.ru> Date: Thu, 24 Jul 2014 14:57:26 +0400 Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] target-i386/FPU: wrong conversion infinity from float80 to int32/int64 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: QEMU Developers 23.07.2014, 21:13, "Peter Maydell" : > =9AOn 23 July 2014 16:04, Dmitry Poletaev wro= te: >> =9A=9AI'm understood. So, am I right? > =9APretty much, except it's better to use the accessor functions > =9Aget_float_exception_flags() and set_float_exception_flags(). >> =9A=9A+ =9A=9A=9Aif (env->fp_status.float_exception_flags & FPUS_IE) { >> =9A=9A+ =9A=9A=9A=9A=9A=9A=9Aval =3D 0x8000000000000000; > =9AAlso this constant needs a "ULL" suffix or it won't build on > =9A32 bit hosts. > > =9Athanks > =9A-- PMM Done. From: Dmitry Poletaev Signed-off-by: Dmitry Poletaev --- target-i386/fpu_helper.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/target-i386/fpu_helper.c b/target-i386/fpu_helper.c index 1b2900d..e3543a8 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; + =20 + old_exp_flags =3D get_float_exception_flags(&env->fp_status); + set_float_exception_flags(0, &env->fp_status); + =20 val =3D floatx80_to_int32(ST0, &env->fp_status); + if (get_float_exception_flags(&env->fp_status) & FPUS_IE) { + val =3D 0x80000000; + } + set_float_exception_flags(get_float_exception_flags(&env->fp_status) + | old_exp_flags, &env->fp_status); return val; } =20 int64_t helper_fistll_ST0(CPUX86State *env) { int64_t val; - - val =3D floatx80_to_int64(ST0, &env->fp_status); + signed char old_exp_flags; + =20 + old_exp_flags =3D get_float_exception_flags(&env->fp_status); + set_float_exception_flags(0, &env->fp_status); + =20 + val =3D floatx80_to_int32(ST0, &env->fp_status); + if (get_float_exception_flags(&env->fp_status) & FPUS_IE) { + val =3D 0x8000000000000000ULL; + } + set_float_exception_flags(get_float_exception_flags(&env->fp_status) + | old_exp_flags, &env->fp_status); return val; } =20 --=20 1.8.4.msysgit.0