Back to index

glibc  2.9
Functions
setfpucw.c File Reference
#include <fpu_control.h>
#include <asm/fpu.h>

Go to the source code of this file.

Functions

void __ieee_set_fp_control (unsigned long)
 libc_hidden_proto (__ieee_set_fp_control)
static void wrfpcr (unsigned long fpcr)
void __setfpucw (fpu_control_t fpu_control)

Function Documentation

void __ieee_set_fp_control ( unsigned  long)
void __setfpucw ( fpu_control_t  fpu_control)

Definition at line 46 of file setfpucw.c.

{
  unsigned long fpcr = 0, fpcw = 0;

  if (!fpu_control)
    fpu_control = _FPU_DEFAULT;

  /* first, set dynamic rounding mode: */

  fpcr = rdfpcr();
  fpcr &= ~FPCR_DYN_MASK;
  switch (fpu_control & 0xc00)
    {
    case _FPU_RC_NEAREST:   fpcr |= FPCR_DYN_NORMAL; break;
    case _FPU_RC_DOWN:             fpcr |= FPCR_DYN_MINUS; break;
    case _FPU_RC_UP:        fpcr |= FPCR_DYN_PLUS; break;
    case _FPU_RC_ZERO:             fpcr |= FPCR_DYN_CHOPPED; break;
    }
  wrfpcr(fpcr);

  /* now tell kernel about traps that we like to hear about: */

  fpcw = __ieee_get_fp_control();
  fpcw &= ~IEEE_TRAP_ENABLE_MASK;

  if (!(fpu_control & _FPU_MASK_IM)) fpcw |= IEEE_TRAP_ENABLE_INV;
  if (!(fpu_control & _FPU_MASK_DM)) fpcw |= IEEE_TRAP_ENABLE_UNF;
  if (!(fpu_control & _FPU_MASK_ZM)) fpcw |= IEEE_TRAP_ENABLE_DZE;
  if (!(fpu_control & _FPU_MASK_OM)) fpcw |= IEEE_TRAP_ENABLE_OVF;
  if (!(fpu_control & _FPU_MASK_PM)) fpcw |= IEEE_TRAP_ENABLE_INE;

  __fpu_control = fpu_control;     /* update global copy */

  __ieee_set_fp_control(fpcw);
}

Here is the call graph for this function:

Definition at line 24 of file setfpucw.c.

{
  unsigned long fpcr;
  asm ("excb; mf_fpcr %0" : "=f"(fpcr));
  return fpcr;
}
static void wrfpcr ( unsigned long  fpcr) [inline, static]

Definition at line 39 of file setfpucw.c.

{
  asm volatile ("mt_fpcr %0; excb" : : "f"(fpcr));
}

Here is the caller graph for this function: