newlib/winsup/mingw/mingwex/fesetenv.c
Danny Smith 48051a71ce Get rid of some warnings
* mingwex/dirent.c (_topendir): Eliminate signed/unsigned warning.
	* mingwex/strtoimax.c (strtoimax): Likewise.
	* mingwex/wcstoimax.c (wcstoimax): Likewise.
	* mingwex/wtoll.c (wtoll): Remove unnecessary ';'
	* mingwex/fesentenv.c: Include float.h.
	* mingwex/math/powl.c: Eliminate type punning/strict aliasing 
	warning.
	* mingwex/math/tanhl.c: Eliminate signed/unsigned warning in
	constants.
	* mingwex/math/tgammal.c: Likewise.
2003-03-17 01:03:43 +00:00

43 lines
1.1 KiB
C

#include <fenv.h>
#include <float.h>
/* 7.6.4.3
The fesetenv function establishes the floating-point environment
represented by the object pointed to by envp. The argument envp
points to an object set by a call to fegetenv or feholdexcept, or
equal the macro FE_DFL_ENV or an implementation-defined environment
macro. Note that fesetenv merely installs the state of the exception
flags represented through its argument, and does not raise these
exceptions.
*/
extern void (*_imp___fpreset)( void ) ;
int fesetenv (const fenv_t * envp)
{
if (envp == FE_PC64_ENV)
/*
* fninit initializes the control register to 0x37f,
* the status register to zero and the tag word to 0FFFFh.
* The other registers are unaffected.
*/
__asm__ ("fninit");
else if (envp == FE_PC53_ENV)
/*
* MS _fpreset() does same *except* it sets control word
* to 0x27f (53-bit precison).
* We force calling _fpreset in msvcrt.dll
*/
(*_imp___fpreset)();
else if (envp == FE_DFL_ENV)
/* Use the choice made at app startup */
_fpreset();
else
__asm__ ("fldenv %0;" : : "m" (*envp));
return 0;
}