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.2.1
|
|
|
|
The feclearexcept function clears the supported exceptions
|
|
|
|
represented by its argument. */
|
|
|
|
|
2005-08-25 10:39:54 +02:00
|
|
|
int feclearexcept (int excepts)
|
2002-06-13 12:20:48 +02:00
|
|
|
{
|
|
|
|
fenv_t _env;
|
2006-07-03 12:32:58 +02:00
|
|
|
excepts &= FE_ALL_EXCEPT;
|
2002-06-13 12:20:48 +02:00
|
|
|
__asm__ volatile ("fnstenv %0;" : "=m" (_env)); /* get the env */
|
2006-07-03 12:32:58 +02:00
|
|
|
_env.__status_word &= ~excepts; /* clear the except */
|
2002-06-13 12:20:48 +02:00
|
|
|
__asm__ volatile ("fldenv %0;" :: "m" (_env)); /*set the env */
|
2005-08-25 10:39:54 +02:00
|
|
|
|
2006-07-03 12:32:58 +02:00
|
|
|
if (__HAS_SSE)
|
|
|
|
{
|
|
|
|
unsigned _csr;
|
|
|
|
__asm__ volatile("stmxcsr %0" : "=m" (_csr)); /* get the register */
|
|
|
|
_csr &= ~excepts; /* clear the except */
|
|
|
|
__asm__ volatile("ldmxcsr %0" : : "m" (_csr)); /* set the register */
|
|
|
|
}
|
2005-08-25 10:39:54 +02:00
|
|
|
return 0;
|
2002-06-13 12:20:48 +02:00
|
|
|
}
|