NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: port-amd64/57949: fetestexcept disables all floating-point exception traps as a side effect



The following reply was made to PR port-amd64/57949; it has been noted by GNATS.

From: Taylor R Campbell <riastradh%NetBSD.org@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: netbsd-bugs%NetBSD.org@localhost
Subject: Re: port-amd64/57949: fetestexcept disables all floating-point exception traps as a side effect
Date: Mon, 19 Feb 2024 23:58:07 +0000

 This is a multi-part message in MIME format.
 --=_fvz4bw6Sgb7EvIjKFB6Nr1oMeWUc8Daj
 
 The attached patch should fix this -- I'll commit once the releng
 testbed has confirmed my test is working to detect the problem.
 
 --=_fvz4bw6Sgb7EvIjKFB6Nr1oMeWUc8Daj
 Content-Type: text/plain; charset="ISO-8859-1"; name="pr57949-x86fetestexcept"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment; filename="pr57949-x86fetestexcept.patch"
 
 From 8af3bc587abd07af6d32acf4f5dc7803ac28ec23 Mon Sep 17 00:00:00 2001
 From: Taylor R Campbell <riastradh%NetBSD.org@localhost>
 Date: Mon, 19 Feb 2024 23:24:13 +0000
 Subject: [PATCH] fenv(3): Fix fetestexcept to avoid side effects on trap
  state.
 
 PR port-amd64/57949
 ---
  lib/libm/arch/x86_64/fenv.c | 10 +---------
  tests/lib/libm/t_fenv.c     |  3 ---
  2 files changed, 1 insertion(+), 12 deletions(-)
 
 diff --git a/lib/libm/arch/x86_64/fenv.c b/lib/libm/arch/x86_64/fenv.c
 index cd09c8bbd597..7d1816c15a72 100644
 --- a/lib/libm/arch/x86_64/fenv.c
 +++ b/lib/libm/arch/x86_64/fenv.c
 @@ -259,7 +259,6 @@ fesetexceptflag(const fexcept_t *flagp, int excepts)
  int
  fetestexcept(int excepts)
  {
 -	fenv_t fenv;
  	uint32_t mxcsr;
  	uint16_t status;
  	int ex;
 @@ -268,17 +267,10 @@ fetestexcept(int excepts)
 =20
  	ex =3D excepts & FE_ALL_EXCEPT;
 =20
 -	/* Store the current x87 floating-point environment */
 -	memset(&fenv, 0, sizeof(fenv));
 -
 -	__fnstenv(&fenv);
  	__fnstsw(&status);
 -
 -	/* Store the MXCSR register state */
 -	__stmxcsr(&fenv.mxcsr);
  	__stmxcsr(&mxcsr);
 =20
 -	return ((fenv.x87.status | fenv.mxcsr) & ex);
 +	return ((status | mxcsr) & ex);
  }
 =20
  /*
 diff --git a/tests/lib/libm/t_fenv.c b/tests/lib/libm/t_fenv.c
 index 038da828c7c6..deacead62b6f 100644
 --- a/tests/lib/libm/t_fenv.c
 +++ b/tests/lib/libm/t_fenv.c
 @@ -364,9 +364,6 @@ ATF_TC_BODY(fetestexcept_trap, tc)
  	    "fegetexcept()=3D0x%x FE_ALL_EXCEPT=3D0x%x", except, FE_ALL_EXCEPT);
 =20
  	(void)fetestexcept(FE_ALL_EXCEPT);
 -#ifdef __x86_64__
 -	atf_tc_expect_fail("PR port-amd64/57949");
 -#endif
  	ATF_CHECK_EQ_MSG((except =3D fegetexcept()), FE_ALL_EXCEPT,
  	    "fegetexcept()=3D0x%x FE_ALL_EXCEPT=3D0x%x", except, FE_ALL_EXCEPT);
  }
 
 --=_fvz4bw6Sgb7EvIjKFB6Nr1oMeWUc8Daj--
 


Home | Main Index | Thread Index | Old Index