Back to index

glibc  2.9
Defines | Functions
setfpucw.c File Reference
#include <fpu_control.h>

Go to the source code of this file.

Defines

#define FPCR_DYN_SHIFT   58 /* first dynamic rounding mode bit */
#define FPCR_DYN_CHOPPED   (0x0UL << FPCR_DYN_SHIFT) /* towards 0 */
#define FPCR_DYN_MINUS   (0x1UL << FPCR_DYN_SHIFT) /* towards -INF */
#define FPCR_DYN_NORMAL   (0x2UL << FPCR_DYN_SHIFT) /* towards nearest */
#define FPCR_DYN_PLUS   (0x3UL << FPCR_DYN_SHIFT) /* towards +INF */
#define FPCR_DYN_MASK   (0x3UL << FPCR_DYN_SHIFT)

Functions

static unsigned long rdfpcr (void)
static void wrfpcr (unsigned long fpcr)
void __setfpucw (fpu_control_t fpu_control)

Define Documentation

#define FPCR_DYN_CHOPPED   (0x0UL << FPCR_DYN_SHIFT) /* towards 0 */

Definition at line 24 of file setfpucw.c.

#define FPCR_DYN_MASK   (0x3UL << FPCR_DYN_SHIFT)

Definition at line 28 of file setfpucw.c.

#define FPCR_DYN_MINUS   (0x1UL << FPCR_DYN_SHIFT) /* towards -INF */

Definition at line 25 of file setfpucw.c.

#define FPCR_DYN_NORMAL   (0x2UL << FPCR_DYN_SHIFT) /* towards nearest */

Definition at line 26 of file setfpucw.c.

#define FPCR_DYN_PLUS   (0x3UL << FPCR_DYN_SHIFT) /* towards +INF */

Definition at line 27 of file setfpucw.c.

#define FPCR_DYN_SHIFT   58 /* first dynamic rounding mode bit */

Definition at line 23 of file setfpucw.c.


Function Documentation

void __setfpucw ( fpu_control_t  fpu_control)

Definition at line 46 of file setfpucw.c.

{
  unsigned long fpcr;

  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);

  /* XXX trap bits? */

  __fpu_control = fpu_control;     /* update global copy */
}

Here is the call graph for this function:

static unsigned long rdfpcr ( void  ) [inline, static]

Definition at line 31 of file setfpucw.c.

{
  unsigned long fpcr;
  asm ("excb; mf_fpcr %0" : "=f"(fpcr));
  return fpcr;
}

Here is the caller graph for this function:

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: