Back to index

glibc  2.9
Functions
fraiseexcpt.c File Reference
#include <fenv.h>
#include <float.h>
#include <math.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 28 of file fraiseexcpt.c.

{
  /* Raise exceptions represented by EXCEPTS.  But we must raise only one
     signal at a time.  It is important that if the overflow/underflow
     exception and the divide by zero exception are given at the same
     time, the overflow/underflow exception follows the divide by zero
     exception.  */

  /* First: invalid exception.  */
  if (excepts & FE_INVALID)
    {
      /* One example of a invalid operation is 0 * Infinity.  */
      float x = HUGE_VALF, y = 0.0f;
      __asm__ __volatile__ ("fmul %1,%0" : "+f" (x) : "f" (y));
    }

  /* Next: division by zero.  */
  if (excepts & FE_DIVBYZERO)
    {
      float x = 1.0f, y = 0.0f;
      __asm__ __volatile__ ("fdiv %1,%0" : "+f" (x) : "f" (y));
    }

  /* Next: overflow.  */
  if (excepts & FE_OVERFLOW)
    {
      float x = FLT_MAX;

      __asm__ __volatile__ ("fmul %0,%0" : "+f" (x));
    }

  /* Next: underflow.  */
  if (excepts & FE_UNDERFLOW)
    {
      float x = -FLT_MIN;

      __asm__ __volatile__ ("fmul %0,%0" : "+f" (x));
    }

  /* Last: inexact.  */
  if (excepts & FE_INEXACT)
    {
      float x = 1.0f, y = 3.0f;
      __asm__ __volatile__ ("fdiv %1,%0" : "=f" (x) : "f" (y));
    }

  /* Success.  */
  return 0;
}

Here is the call graph for this function: