Module Name: src Committed By: martin Date: Sat Dec 27 17:54:24 UTC 2014
Modified Files: src/lib/libm/arch/arm: fenv.c Log Message: Add our common non standard extensions and fix typo (FE_EXCEPT_ALL -> FE_ALL_EXCEPT). To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/lib/libm/arch/arm/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/arm/fenv.c diff -u src/lib/libm/arch/arm/fenv.c:1.3 src/lib/libm/arch/arm/fenv.c:1.4 --- src/lib/libm/arch/arm/fenv.c:1.3 Wed May 1 04:04:54 2013 +++ src/lib/libm/arch/arm/fenv.c Sat Dec 27 17:54:24 2014 @@ -28,7 +28,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: fenv.c,v 1.3 2013/05/01 04:04:54 matt Exp $"); +__RCSID("$NetBSD: fenv.c,v 1.4 2014/12/27 17:54:24 martin Exp $"); #include <sys/types.h> #include <assert.h> @@ -57,7 +57,7 @@ int feclearexcept(int excepts) { #ifndef lint - _DIAGASSERT((except & ~FE_EXCEPT_ALL) == 0); + _DIAGASSERT((except & ~FE_ALL_EXCEPT) == 0); #endif #ifdef __SOFTFP__ fpsetsticky(fpgetsticky() & ~excepts); @@ -78,7 +78,7 @@ feclearexcept(int excepts) int fegetexceptflag(fexcept_t *flagp, int excepts) { - _DIAGASSERT((except & ~FE_EXCEPT_ALL) == 0); + _DIAGASSERT((except & ~FE_ALL_EXCEPT) == 0); #ifdef __SOFTFP__ *flagp = fpgetsticky() & excepts; #else @@ -96,7 +96,7 @@ int feraiseexcept(int excepts) { #ifndef lint - _DIAGASSERT((except & ~FE_EXCEPT_ALL) == 0); + _DIAGASSERT((except & ~FE_ALL_EXCEPT) == 0); #endif #ifdef __SOFTFP__ excepts &= fpgetsticky(); @@ -140,7 +140,7 @@ int fesetexceptflag(const fexcept_t *flagp, int excepts) { #ifndef lint - _DIAGASSERT((except & ~FE_EXCEPT_ALL) == 0); + _DIAGASSERT((except & ~FE_ALL_EXCEPT) == 0); #endif #ifdef __SOFTFP__ fpsetsticky((fpgetsticky() & ~excepts) | (excepts & *flagp)); @@ -153,6 +153,39 @@ fesetexceptflag(const fexcept_t *flagp, return 0; } +int +feenableexcept(int excepts) +{ +#ifndef lint + _DIAGASSERT((except & ~FE_ALL_EXCEPT) == 0); +#endif +#ifdef __SOFTFP__ + int old = fpgetsticky(); + fpsetsticky(old | excepts); +#else + int fpscr = armreg_fpscr_read(); + armreg_fpscr_write(fpscr | __SHIFTIN((excepts), VFP_FPSCR_CSUM)); + return __SHIFTOUT(fpscr, VFP_FPSCR_CSUM) & FE_ALL_EXCEPT; +#endif +} + +int +fedisableexcept(int excepts) +{ +#ifndef lint + _DIAGASSERT((except & ~FE_ALL_EXCEPT) == 0); +#endif +#ifdef __SOFTFP__ + int old = fpgetsticky(); + fpsetsticky(old & ~excepts); + return old; +#else + int fpscr = armreg_fpscr_read(); + armreg_fpscr_write(fpscr & ~__SHIFTIN((excepts), VFP_FPSCR_CSUM)); + return __SHIFTOUT(fpscr, VFP_FPSCR_CSUM) & FE_ALL_EXCEPT; +#endif +} + /* * The fetestexcept() function shall determine which of a specified subset of * the floating-point exception flags are currently set. The excepts argument @@ -161,7 +194,7 @@ fesetexceptflag(const fexcept_t *flagp, int fetestexcept(int excepts) { - _DIAGASSERT((except & ~FE_EXCEPT_ALL) == 0); + _DIAGASSERT((except & ~FE_ALL_EXCEPT) == 0); #ifdef __SOFTFP__ return fpgetsticky() & excepts; #else @@ -169,6 +202,12 @@ fetestexcept(int excepts) #endif } +int +fegetexcept(void) +{ + return fetestexcept(FE_ALL_EXCEPT); +} + /* * The fegetround() function shall get the current rounding direction. */