Module Name: src Committed By: martin Date: Sun Dec 8 13:37:46 UTC 2019
Modified Files: src/lib/libm/arch/aarch64 [netbsd-9]: fenv.c Log Message: Pull up following revision(s) (requested by riastradh in ticket #507): lib/libm/arch/aarch64/fenv.c: revision 1.5 lib/libm/arch/aarch64/fenv.c: revision 1.6 Fix fesetenv and feupdateenv. - fesetenv is supposed to set the stored rounding mode (and stored trap settings, but they have no effect on any ARMv8 I know). - feupdateenv is supposed to re-raise the exceptions that were raised in the environment when it was called. XXX atf test XXX pullup-9 Fix feraiseexcept. - Don't touch the trap flags (though on all ARMv8 I know they have no effect anyway). - Don't clear any existing raised exception flags; just add to them. XXX atf test XXX pullup-9 To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.4.2.1 src/lib/libm/arch/aarch64/fenv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libm/arch/aarch64/fenv.c diff -u src/lib/libm/arch/aarch64/fenv.c:1.4 src/lib/libm/arch/aarch64/fenv.c:1.4.2.1 --- src/lib/libm/arch/aarch64/fenv.c:1.4 Wed Nov 7 06:47:38 2018 +++ src/lib/libm/arch/aarch64/fenv.c Sun Dec 8 13:37:46 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: fenv.c,v 1.4 2018/11/07 06:47:38 riastradh Exp $ */ +/* $NetBSD: fenv.c,v 1.4.2.1 2019/12/08 13:37:46 martin Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: fenv.c,v 1.4 2018/11/07 06:47:38 riastradh Exp $"); +__RCSID("$NetBSD: fenv.c,v 1.4.2.1 2019/12/08 13:37:46 martin Exp $"); #include "namespace.h" @@ -107,11 +107,9 @@ feraiseexcept(int excepts) _DIAGASSERT((except & ~FE_ALL_EXCEPT) == 0); #endif unsigned int fpsr = reg_fpsr_read(); - fpsr = (fpsr & ~FPSR_CSUM) | __SHIFTIN(excepts, FPSR_CSUM); + excepts &= FE_ALL_EXCEPT; /* paranoia */ + fpsr |= __SHIFTIN(excepts, FPSR_CSUM); reg_fpsr_write(fpsr); - unsigned int fpcr = reg_fpcr_read(); - fpcr = (fpcr & ~FPCR_ESUM) | __SHIFTIN(excepts, FPCR_ESUM); - reg_fpcr_write(fpcr); return 0; } @@ -213,6 +211,7 @@ int fesetenv(const fenv_t *envp) { reg_fpsr_write(envp->__fpsr); + reg_fpcr_write(envp->__fpcr); return 0; } @@ -225,11 +224,10 @@ fesetenv(const fenv_t *envp) int feupdateenv(const fenv_t *envp) { -#ifndef lint - _DIAGASSERT(envp != NULL); -#endif - reg_fpsr_write(envp->__fpsr); - reg_fpcr_write(envp->__fpcr); + int except = fetestexcept(FE_ALL_EXCEPT); + + fesetenv(envp); + feraiseexcept(except); /* Success */ return 0;