fenv.h: Change fexcept_t to integral type for compatibility

On Linux and in Mingw-w64, fexcept_t is defined as type unsigned short.
There are packages in the wild which rely on the fact that fexcept_t is
an integral type.  We're changing the internal handling to use the bits
just as in GLibc, so only the 6 lowest bits are used to reflect the hw
bits.  We even change the header file guard to reflect GLibc for compatibility.

	* include/fenv.h (_FENV_H): Rename from _FENV_H_ and set to 1 as in
	GLibc's header.
	(fexcept_t): Change to __uint16_t to be an integral type as in GLibc.
	* fenv.cc (fegetexceptflag): Align to the *flagp's type change.
	(fesetexceptflag): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen
2016-03-30 00:12:22 +02:00
parent fbc4a0827b
commit 279aaeb5c7
2 changed files with 9 additions and 14 deletions

View File

@@ -295,9 +295,8 @@ fegetexceptflag (fexcept_t *flagp, int excepts)
if (use_sse)
__asm__ volatile ("stmxcsr %0" : "=m" (mxcsr) : );
/* Mask undesired bits out and set result struct. */
flagp->_fpu_exceptions = (sw & excepts);
flagp->_sse_exceptions = (mxcsr & excepts);
/* Mask undesired bits out and set result. */
*flagp = (sw | mxcsr) & excepts;
return 0;
}
@@ -317,9 +316,9 @@ fesetexceptflag (const fexcept_t *flagp, int excepts)
/* Set/Clear desired exception bits. */
fenv._fpu._fpu_sw &= ~excepts;
fenv._fpu._fpu_sw |= (excepts & flagp->_fpu_exceptions);
fenv._fpu._fpu_sw |= excepts & *flagp;
fenv._sse_mxcsr &= ~excepts;
fenv._sse_mxcsr |= (excepts & flagp->_sse_exceptions);
fenv._sse_mxcsr |= excepts & *flagp;
/* Set back into FPU state. */
return fesetenv (&fenv);