Back to index

glibc  2.9
fsetexcptflg.c File Reference
#include <fenv_libc.h>
#include <math.h>
#include <fpu_control.h>

Go to the source code of this file.


int fesetexceptflag (const fexcept_t *flagp, int excepts)

Function Documentation

int fesetexceptflag ( const fexcept_t flagp,
int  excepts 

Definition at line 26 of file fsetexcptflg.c.

  fexcept_t temp,newexcepts;

  /* Get the current environment.  We have to do this since we cannot
     separately set the status word.  */
  _FPU_GETCW (temp);
  /* Install the new exception bits in the Accrued Exception Byte.  */
  excepts = excepts & FE_ALL_EXCEPT;
  newexcepts = (excepts << FPC_DXC_SHIFT) | (excepts << FPC_FLAGS_SHIFT);
  temp &= ~newexcepts;
  temp |= *flagp & newexcepts;

  /* Store the new status word (along with the rest of the environment.
     Possibly new exceptions are set but they won't get executed unless
     the next floating-point instruction.  */
  _FPU_SETCW (temp);

  /* Success.  */
  return 0;