Back to index

glibc  2.9
Functions
fenv.h File Reference
#include <features.h>
#include <bits/fenv.h>

Go to the source code of this file.

Functions

__BEGIN_DECLS int feclearexcept (int __excepts) __THROW
int fegetexceptflag (fexcept_t *__flagp, int __excepts) __THROW
int feraiseexcept (int __excepts) __THROW
int fesetexceptflag (__const fexcept_t *__flagp, int __excepts) __THROW
int fetestexcept (int __excepts) __THROW
int fegetround (void) __THROW
int fesetround (int __rounding_direction) __THROW
int fegetenv (fenv_t *__envp) __THROW
int feholdexcept (fenv_t *__envp) __THROW
int fesetenv (__const fenv_t *__envp) __THROW
int feupdateenv (__const fenv_t *__envp) __THROW

Function Documentation

Definition at line 24 of file fclrexcpt.c.

{
  union { unsigned long long l; unsigned int sw[2]; } s;

  /* Get the current status word. */
  __asm__ ("fstd %%fr0,0(%1)" : "=m" (s.l) : "r" (&s.l) : "%r0");
  /* Clear all the relevant bits. */
  s.sw[0] &= ~((excepts & FE_ALL_EXCEPT) << 27);
  __asm__ ("fldd 0(%0),%%fr0" : : "r" (&s.l), "m" (s.l) : "%r0");

  /* Success.  */
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int fegetenv ( fenv_t __envp)

Definition at line 25 of file fegetenv.c.

{
  unsigned long long buf[4], *bufptr = buf;
  
  __asm__ (
          "fstd,ma %%fr0,8(%1)     \n\t"
          "fldd -8(%1),%%fr0       \n\t"
          : "=m" (buf), "+r" (bufptr) : : "%r0");
  memcpy(envp, buf, sizeof (*envp));
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int fegetexceptflag ( fexcept_t __flagp,
int  __excepts 
)

Definition at line 24 of file fgetexcptflg.c.

{
  union { unsigned long long l; unsigned int sw[2]; } s;

  /* Get the current status word. */
  __asm__ ("fstd %%fr0,0(%1)       \n\t" 
           "fldd 0(%1),%%fr0       \n\t" 
          : "=m" (s.l) : "r" (&s.l) : "%r0");

  *flagp = (s.sw[0] >> 27) & excepts & FE_ALL_EXCEPT;

  /* Success.  */
  return 0;
}

Here is the call graph for this function:

int fegetround ( void  )

Definition at line 24 of file fegetround.c.

{
  return 0;
}

Here is the call graph for this function:

int feholdexcept ( fenv_t __envp)

Definition at line 24 of file feholdexcpt.c.

{
  return 1;          /* Signal failure.  */
}

Here is the call graph for this function:

Here is the caller graph for this function:

int feraiseexcept ( int  __excepts)

Definition at line 30 of file fraiseexcpt.c.

{
  if (GLRO (dl_hwcap) & HWCAP_ARM_VFP)
    {
      int fpscr;
      const float fp_zero = 0.0, fp_one = 1.0, fp_max = FLT_MAX,
                  fp_min = FLT_MIN, fp_1e32 = 1.0e32f, fp_two = 2.0,
                fp_three = 3.0;

      /* Raise exceptions represented by EXPECTS.  But we must raise only
        one signal at a time.  It is important that if the overflow/underflow
        exception and the inexact exception are given at the same time,
        the overflow/underflow exception follows the inexact exception.  After
        each exception we read from the fpscr, to force the exception to be
        raised immediately.  */

      /* There are additional complications because this file may be compiled
         without VFP support enabled, and we also can't assume that the
        assembler has VFP instructions enabled. To get around this we use the
        generic coprocessor mnemonics and avoid asking GCC to put float values
        in VFP registers.  */

      /* First: invalid exception.  */
      if (FE_INVALID & excepts)
       __asm__ __volatile__ (
         "ldc p10, cr0, %1\n\t"                        /* flds s0, %1  */
         "cdp p10, 8, cr0, cr0, cr0, 0\n\t"            /* fdivs s0, s0, s0  */
         "mrc p10, 7, %0, cr1, cr0, 0" : "=r" (fpscr)  /* fmrx %0, fpscr  */
                                     : "m" (fp_zero)
                                   : "s0");

      /* Next: division by zero.  */
      if (FE_DIVBYZERO & excepts)
       __asm__ __volatile__ (
         "ldc p10, cr0, %1\n\t"                        /* flds s0, %1  */
         "ldcl p10, cr0, %2\n\t"                       /* flds s1, %2  */
         "cdp p10, 8, cr0, cr0, cr0, 1\n\t"            /* fdivs s0, s0, s1  */
         "mrc p10, 7, %0, cr1, cr0, 0" : "=r" (fpscr)  /* fmrx %0, fpscr  */
                                     : "m" (fp_one), "m" (fp_zero)
                                   : "s0", "s1");

      /* Next: overflow.  */
      if (FE_OVERFLOW & excepts)
       /* There's no way to raise overflow without also raising inexact.  */
       __asm__ __volatile__ (
         "ldc p10, cr0, %1\n\t"                        /* flds s0, %1  */
         "ldcl p10, cr0, %2\n\t"                       /* flds s1, %2  */
         "cdp p10, 3, cr0, cr0, cr0, 1\n\t"            /* fadds s0, s0, s1  */
         "mrc p10, 7, %0, cr1, cr0, 0" : "=r" (fpscr)  /* fmrx %0, fpscr  */
                                     : "m" (fp_max), "m" (fp_1e32)
                                   : "s0", "s1");

      /* Next: underflow.  */
      if (FE_UNDERFLOW & excepts)
       __asm__ __volatile__ (
         "ldc p10, cr0, %1\n\t"                        /* flds s0, %1  */
         "ldcl p10, cr0, %2\n\t"                       /* flds s1, %2  */
         "cdp p10, 8, cr0, cr0, cr0, 1\n\t"            /* fdivs s0, s0, s1  */
         "mrc p10, 7, %0, cr1, cr0, 0" : "=r" (fpscr)  /* fmrx %0, fpscr  */
                                     : "m" (fp_min), "m" (fp_three)
                                   : "s0", "s1");

      /* Last: inexact.  */
      if (FE_INEXACT & excepts)
       __asm__ __volatile__ (
         "ldc p10, cr0, %1\n\t"                        /* flds s0, %1  */
         "ldcl p10, cr0, %2\n\t"                       /* flds s1, %2  */
         "cdp p10, 8, cr0, cr0, cr0, 1\n\t"            /* fdivs s0, s0, s1  */
         "mrc p10, 7, %0, cr1, cr0, 0" : "=r" (fpscr)  /* fmrx %0, fpscr  */
                                     : "m" (fp_two), "m" (fp_three)
                                   : "s0", "s1");

      /* Success.  */
      return 0;
    }

  /* Unsupported, so fail.  */
  return 1;
}

Here is the call graph for this function:

int fesetenv ( __const fenv_t __envp)

Here is the caller graph for this function:

int fesetexceptflag ( __const fexcept_t __flagp,
int  __excepts 
)
int fesetround ( int  __rounding_direction)

Definition at line 24 of file fesetround.c.

{
  return 1;   /* Signal we are unable to set the direction.  */
}

Here is the call graph for this function:

int fetestexcept ( int  __excepts)

Definition at line 24 of file ftestexcept.c.

{
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int feupdateenv ( __const fenv_t __envp)

Here is the caller graph for this function: