Back to index

glibc  2.9
Functions
fesetround.c File Reference
#include <fenv.h>
#include <unistd.h>
#include <ldsodefs.h>
#include <dl-procinfo.h>

Go to the source code of this file.

Functions

int fesetround (int round)

Function Documentation

int fesetround ( int  round)

Definition at line 27 of file fesetround.c.

{
  unsigned short int cw;

  if ((round & ~0xc00) != 0)
    /* ROUND is no valid rounding mode.  */
    return 1;

  __asm__ ("fnstcw %0" : "=m" (*&cw));
  cw &= ~0xc00;
  cw |= round;
  __asm__ ("fldcw %0" : : "m" (*&cw));

  /* If the CPU supports SSE we set the MXCSR as well.  */
  if ((GLRO(dl_hwcap) & HWCAP_I386_XMM) != 0)
    {
      unsigned int xcw;

      __asm__ ("stmxcsr %0" : "=m" (*&xcw));
      xcw &= ~0x6000;
      xcw |= round << 3;
      __asm__ ("ldmxcsr %0" : : "m" (*&xcw));
    }

  return 0;
}

Here is the call graph for this function: