Back to index

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

Go to the source code of this file.


int __fesetenv (const fenv_t *envp)

Function Documentation

int __fesetenv ( const fenv_t envp)

Definition at line 27 of file fesetenv.c.

  fpu_control_t cw;

  /* We want to clear all EF bits for the default end IEEE.  */

  if (envp == FE_DFL_ENV)
  else if (envp == FE_NOMASK_ENV)
      fpu_control_t temp;

      _FPU_GETCW (temp);
      cw = *envp;

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

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

  /* Success.  */
  return 0;