2002-06-13 12:20:48 +02:00
|
|
|
#include <fenv.h>
|
2006-07-03 12:32:58 +02:00
|
|
|
#include "cpu_features.h"
|
2002-06-13 12:20:48 +02:00
|
|
|
|
|
|
|
/* 7.6.4.4
|
|
|
|
The feupdateenv function saves the currently raised exceptions in
|
|
|
|
its automatic storage, installs the floating-point environment
|
|
|
|
represented by the object pointed to by envp, and then raises the
|
|
|
|
saved exceptions. The argument envp shall point to an object
|
|
|
|
set by a call to feholdexcept or fegetenv, or equal the macro
|
|
|
|
FE_DFL_ENV or an implementation-defined environment macro. */
|
|
|
|
|
|
|
|
|
2005-08-25 10:39:54 +02:00
|
|
|
int feupdateenv (const fenv_t * envp)
|
2002-06-13 12:20:48 +02:00
|
|
|
{
|
2006-07-03 12:32:58 +02:00
|
|
|
unsigned int _fexcept;
|
|
|
|
__asm__ ("fnstsw %%ax" : "=a" (_fexcept)); /*save excepts */
|
|
|
|
if (__HAS_SSE)
|
|
|
|
{
|
|
|
|
unsigned int _csr;
|
|
|
|
__asm__ ("stmxcsr %0" : "=m" (_csr));
|
|
|
|
_fexcept |= _csr;
|
|
|
|
}
|
2002-06-13 12:20:48 +02:00
|
|
|
fesetenv (envp); /* install the env */
|
2006-07-03 12:32:58 +02:00
|
|
|
feraiseexcept (_fexcept & FE_ALL_EXCEPT); /* raise the execeptions */
|
2005-08-25 10:39:54 +02:00
|
|
|
return 0;
|
2002-06-13 12:20:48 +02:00
|
|
|
}
|