Back to index

glibc  2.9
Functions
fraiseexcpt.c File Reference
#include <fenv_libc.h>
#include <bp-sym.h>
#include <shlib-compat.h>

Go to the source code of this file.

Functions

int __feraiseexcept (int excepts)

Function Documentation

int __feraiseexcept ( int  excepts)

Definition at line 25 of file fraiseexcpt.c.

{
  fenv_union_t u;

  /* Raise exceptions represented by EXCEPTS.  It is the responsibility of
     the OS to ensure that if multiple exceptions occur they are fed back
     to this process in the proper way; this can happen in hardware,
     anyway (in particular, inexact with overflow or underflow). */

  /* Get the current state.  */
  u.fenv = fegetenv_register ();

  /* Add the exceptions */
  u.l[1] = (u.l[1]
           | (excepts & FPSCR_STICKY_BITS)
           /* Turn FE_INVALID into FE_INVALID_SOFTWARE.  */
           | (excepts >> ((31 - FPSCR_VX) - (31 - FPSCR_VXSOFT))
              & FE_INVALID_SOFTWARE));

  /* Store the new status word (along with the rest of the environment),
     triggering any appropriate exceptions.  */
  fesetenv_register (u.fenv);

  if ((excepts & FE_INVALID))
    {
      /* For some reason, some PowerPC chips (the 601, in particular)
        don't have FE_INVALID_SOFTWARE implemented.  Detect this
        case and raise FE_INVALID_SNAN instead.  */
      u.fenv = fegetenv_register ();
      if ((u.l[1] & FE_INVALID) == 0)
       set_fpscr_bit (FPSCR_VXSNAN);
    }

  /* Success.  */
  return 0;
}