Pull up following revision(s) (requested by riastradh in ticket #1801):
tests/lib/libm/t_fenv.c: revision 1.14 tests/lib/libm/t_fenv.c: revision 1.15 lib/libm/arch/x86_64/fenv.c: revision 1.11 fenv(3): Add test for PR port-amd64/57949. fenv(3): Fix fetestexcept to avoid side effects on trap state. PR port-amd64/57949
This commit is contained in:
parent
197ac4a649
commit
95c762f12c
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: fenv.c,v 1.7 2017/03/22 23:11:09 chs Exp $ */
|
||||
/* $NetBSD: fenv.c,v 1.7.14.1 2024/02/23 18:13:54 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004-2005 David Schultz <das (at) FreeBSD.ORG>
|
||||
|
@ -27,7 +27,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: fenv.c,v 1.7 2017/03/22 23:11:09 chs Exp $");
|
||||
__RCSID("$NetBSD: fenv.c,v 1.7.14.1 2024/02/23 18:13:54 martin Exp $");
|
||||
|
||||
#include "namespace.h"
|
||||
|
||||
|
@ -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)
|
|||
|
||||
ex = excepts & FE_ALL_EXCEPT;
|
||||
|
||||
/* 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);
|
||||
|
||||
return ((fenv.x87.status | fenv.mxcsr) & ex);
|
||||
return ((status | mxcsr) & ex);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: t_fenv.c,v 1.6 2019/04/25 20:48:54 kamil Exp $ */
|
||||
/* $NetBSD: t_fenv.c,v 1.6.2.1 2024/02/23 18:13:54 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2014 The NetBSD Foundation, Inc.
|
||||
|
@ -29,7 +29,7 @@
|
|||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: t_fenv.c,v 1.6 2019/04/25 20:48:54 kamil Exp $");
|
||||
__RCSID("$NetBSD: t_fenv.c,v 1.6.2.1 2024/02/23 18:13:54 martin Exp $");
|
||||
|
||||
#include <atf-c.h>
|
||||
|
||||
|
@ -185,12 +185,40 @@ ATF_TC_BODY(feenableexcept, tc)
|
|||
ATF_CHECK(fpgetmask() == FP_X_INV);
|
||||
}
|
||||
|
||||
ATF_TC(fetestexcept_trap);
|
||||
ATF_TC_HEAD(fetestexcept_trap, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr",
|
||||
"Verify fetestexcept doesn't affect the trapped excpetions");
|
||||
}
|
||||
ATF_TC_BODY(fetestexcept_trap, tc)
|
||||
{
|
||||
int except;
|
||||
|
||||
fedisableexcept(FE_ALL_EXCEPT);
|
||||
ATF_CHECK_EQ_MSG((except = fegetexcept()), 0,
|
||||
"fegetexcept()=0x%x", except);
|
||||
|
||||
(void)fetestexcept(FE_ALL_EXCEPT);
|
||||
ATF_CHECK_EQ_MSG((except = fegetexcept()), 0,
|
||||
"fegetexcept()=0x%x", except);
|
||||
|
||||
feenableexcept(FE_ALL_EXCEPT);
|
||||
ATF_CHECK_EQ_MSG((except = fegetexcept()), FE_ALL_EXCEPT,
|
||||
"fegetexcept()=0x%x FE_ALL_EXCEPT=0x%x", except, FE_ALL_EXCEPT);
|
||||
|
||||
(void)fetestexcept(FE_ALL_EXCEPT);
|
||||
ATF_CHECK_EQ_MSG((except = fegetexcept()), FE_ALL_EXCEPT,
|
||||
"fegetexcept()=0x%x FE_ALL_EXCEPT=0x%x", except, FE_ALL_EXCEPT);
|
||||
}
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
ATF_TP_ADD_TC(tp, fegetround);
|
||||
ATF_TP_ADD_TC(tp, fesetround);
|
||||
ATF_TP_ADD_TC(tp, fegetexcept);
|
||||
ATF_TP_ADD_TC(tp, feenableexcept);
|
||||
ATF_TP_ADD_TC(tp, fetestexcept_trap);
|
||||
|
||||
return atf_no_error();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue