Back to index

glibc  2.9
Defines | Enumerations | Functions | Variables
fenv_libc.h File Reference
#include <fenv.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define FPSCR_STICKY_BITS   ((FE_ALL_EXCEPT | FE_ALL_INVALID) & ~FE_INVALID)
#define fegetenv_register()   ({ fenv_t env; asm volatile ("mffs %0" : "=f" (env)); env; })
#define fesetenv_register(env)   ({ double d = (env); asm volatile ("mtfsf 0xff,%0" : : "f" (d)); })
#define relax_fenv_state()   asm ("mtfsfi 7,0")
#define set_fpscr_bit(x)   asm volatile ("mtfsb1 %0" : : "i"(x))
#define reset_fpscr_bit(x)   asm volatile ("mtfsb0 %0" : : "i"(x))
#define fegetround()   __fegetround()
#define fesetround(mode)   __fesetround(mode)
#define f_wash(x)
#define f_washf(x)

Enumerations

enum  {
  FPSCR_FX = 0, FPSCR_FEX, FPSCR_VX, FPSCR_OX,
  FPSCR_UX, FPSCR_ZX, FPSCR_XX, FPSCR_VXSNAN,
  FPSCR_VXISI, FPSCR_VXIDI, FPSCR_VXZDZ, FPSCR_VXIMZ,
  FPSCR_VXVC, FPSCR_FR, FPSCR_FI, FPSCR_FPRF_C,
  FPSCR_FPRF_FL, FPSCR_FPRF_FG, FPSCR_FPRF_FE, FPSCR_FPRF_FU,
  FPSCR_20, FPSCR_VXSOFT, FPSCR_VXSQRT, FPSCR_VXCVI,
  FPSCR_VE, FPSCR_OE, FPSCR_UE, FPSCR_ZE,
  FPSCR_XE, FPSCR_NI
}

Functions

 libm_hidden_proto (__fe_nomask_env) typedef union
static int __fegetround (void)
static int __fesetround (int round)

Variables

 fenv_union_t

Define Documentation

#define f_wash (   x)
Value:
({ double d; asm volatile ("fmul %0,%1,%2" \
                           : "=f"(d) \
                           : "f" (x), "f"((float)1.0)); d; })

Definition at line 134 of file fenv_libc.h.

#define f_washf (   x)
Value:
({ float f; asm volatile ("fmuls %0,%1,%2" \
                          : "=f"(f) \
                          : "f" (x), "f"((float)1.0)); f; })

Definition at line 138 of file fenv_libc.h.

#define fegetenv_register ( )    ({ fenv_t env; asm volatile ("mffs %0" : "=f" (env)); env; })
#define fegetround (   void)    __fegetround()

Definition at line 68 of file fenv_libc.h.

#define fesetenv_register (   env)    ({ double d = (env); asm volatile ("mtfsf 0xff,%0" : : "f" (d)); })
#define fesetround (   mode)    __fesetround(mode)

Definition at line 92 of file fenv_libc.h.

#define FPSCR_STICKY_BITS   ((FE_ALL_EXCEPT | FE_ALL_INVALID) & ~FE_INVALID)
#define relax_fenv_state ( )    asm ("mtfsfi 7,0")
#define reset_fpscr_bit (   x)    asm volatile ("mtfsb0 %0" : : "i"(x))
#define set_fpscr_bit (   x)    asm volatile ("mtfsb1 %0" : : "i"(x))

Enumeration Type Documentation

anonymous enum
Enumerator:
FPSCR_FX 
FPSCR_FEX 
FPSCR_VX 
FPSCR_OX 
FPSCR_UX 
FPSCR_ZX 
FPSCR_XX 
FPSCR_VXSNAN 
FPSCR_VXISI 
FPSCR_VXIDI 
FPSCR_VXZDZ 
FPSCR_VXIMZ 
FPSCR_VXVC 
FPSCR_FR 
FPSCR_FI 
FPSCR_FPRF_C 
FPSCR_FPRF_FL 
FPSCR_FPRF_FG 
FPSCR_FPRF_FE 
FPSCR_FPRF_FU 
FPSCR_20 
FPSCR_VXSOFT 
FPSCR_VXSQRT 
FPSCR_VXCVI 
FPSCR_VE 
FPSCR_OE 
FPSCR_UE 
FPSCR_ZE 
FPSCR_XE 
FPSCR_NI 

Definition at line 95 of file fenv_libc.h.

     {
  FPSCR_FX = 0,    /* exception summary */
  FPSCR_FEX,       /* enabled exception summary */
  FPSCR_VX,        /* invalid operation summary */
  FPSCR_OX,        /* overflow */
  FPSCR_UX,        /* underflow */
  FPSCR_ZX,        /* zero divide */
  FPSCR_XX,        /* inexact */
  FPSCR_VXSNAN,    /* invalid operation for SNaN */
  FPSCR_VXISI,     /* invalid operation for Inf-Inf */
  FPSCR_VXIDI,     /* invalid operation for Inf/Inf */
  FPSCR_VXZDZ,     /* invalid operation for 0/0 */
  FPSCR_VXIMZ,     /* invalid operation for Inf*0 */
  FPSCR_VXVC,      /* invalid operation for invalid compare */
  FPSCR_FR,        /* fraction rounded [fraction was incremented by round] */
  FPSCR_FI,        /* fraction inexact */
  FPSCR_FPRF_C,    /* result class descriptor */
  FPSCR_FPRF_FL,   /* result less than (usually, less than 0) */
  FPSCR_FPRF_FG,   /* result greater than */
  FPSCR_FPRF_FE,   /* result equal to */
  FPSCR_FPRF_FU,   /* result unordered */
  FPSCR_20,        /* reserved */
  FPSCR_VXSOFT,    /* invalid operation set by software */
  FPSCR_VXSQRT,    /* invalid operation for square root */
  FPSCR_VXCVI,     /* invalid operation for invalid integer convert */
  FPSCR_VE,        /* invalid operation exception enable */
  FPSCR_OE,        /* overflow exception enable */
  FPSCR_UE,        /* underflow exception enable */
  FPSCR_ZE,        /* zero divide exception enable */
  FPSCR_XE,        /* inexact exception enable */
  FPSCR_NI         /* non-IEEE mode (typically, no denormalised numbers) */
  /* the remaining two least-significant bits keep the rounding mode */
};

Function Documentation

static int __fegetround ( void  ) [inline, static]

Definition at line 61 of file fenv_libc.h.

{
  int result;
  asm volatile ("mcrfs 7,7\n\t"
              "mfcr  %0" : "=r"(result) : : "cr7");
  return result & 3;
}

Here is the caller graph for this function:

static int __fesetround ( int  round) [inline, static]

Definition at line 71 of file fenv_libc.h.

{
  if ((unsigned int) round < 2)
    {
       asm volatile ("mtfsb0 30");
       if ((unsigned int) round == 0)
         asm volatile ("mtfsb0 31");
       else
         asm volatile ("mtfsb1 31");
    }
  else
    {
       asm volatile ("mtfsb1 30");
       if ((unsigned int) round == 2)
         asm volatile ("mtfsb0 31");
       else
         asm volatile ("mtfsb1 31");
    }

  return 0;
}

Here is the caller graph for this function:

Definition at line 25 of file fenv_libc.h.

         { fenv_t env; asm volatile ("mffs %0" : "=f" (env)); env; })

/* Equivalent to fesetenv, but takes a fenv_t instead of a pointer.  */
#define fesetenv_register(env) \
        ({ double d = (env); asm volatile ("mtfsf 0xff,%0" : : "f" (d)); })

/* This very handy macro:
   - Sets the rounding mode to 'round to nearest';
   - Sets the processor into IEEE mode; and
   - Prevents exceptions from being raised for inexact results.
   These things happen to be exactly what you need for typical elementary
   functions.  */
#define relax_fenv_state() asm ("mtfsfi 7,0")

/* Set/clear a particular FPSCR bit (for instance,
   reset_fpscr_bit(FPSCR_VE);
   prevents INVALID exceptions from being raised).  */
#define set_fpscr_bit(x) asm volatile ("mtfsb1 %0" : : "i"(x))
#define reset_fpscr_bit(x) asm volatile ("mtfsb0 %0" : : "i"(x))

typedef union
{
  fenv_t fenv;
  unsigned int l[2];
} fenv_union_t;

Variable Documentation

Definition at line 57 of file fenv_libc.h.