Back to index

glibc  2.9
fsetexcptflg.c File Reference
#include <fenv.h>
#include <fpu_control.h>
#include <shlib-compat.h>

Go to the source code of this file.


int __fesetexceptflag (const fexcept_t *flagp, int excepts)
 versioned_symbol (libm, __fesetexceptflag, fesetexceptflag, GLIBC_2_2)

Function Documentation

int __fesetexceptflag ( const fexcept_t flagp,
int  excepts 

Definition at line 27 of file fsetexcptflg.c.

  fpu_control_t cw, temp;

  /* Get the current exceptions.  */
  _FPU_GETCW (cw);

  /* Make sure the flags we want restored are legal.  */
  excepts &= FE_ALL_EXCEPT;
  temp = *flagp & excepts;

  /* If EF bits are clear and the user requests them to be set,
     we have to fail, because there's no way to do it.  */
  if (~(cw & excepts) & temp)
    return -1;

  /* We clear EF bits by storing a 1 in them, so flip the
     FE_ALL_EXCEPT bits.  */
  temp = (~temp & FE_ALL_EXCEPT);

  /* Now clear the bits called for, and copy them in from flagp. Note that
     we ignore all non-flag bits from *flagp, so they don't matter.  */
  cw = (cw & ~FE_ALL_EXCEPT) | temp;

  _FPU_SETFCW (cw);

  /* Success.  */
  return 0;
versioned_symbol ( libm  ,
__fesetexceptflag  ,
fesetexceptflag  ,