Back to index

glibc  2.9
fesetenv.c File Reference
#include <fenv_libc.h>
#include <shlib-compat.h>

Go to the source code of this file.


int __fesetenv (const fenv_t *envp)

Function Documentation

int __fesetenv ( const fenv_t envp)

Definition at line 24 of file fesetenv.c.

  unsigned long int fpcr;
  fenv_t env;

  /* Magic encoding of default values: high bit set (never possible for a
     user-space address) is not indirect.  And we don't even have to get
     rid of it since we mask things around just below.  */
  if ((long int) envp >= 0)
    env = *envp;
    env = (unsigned long int) envp;

  /* Reset the rounding mode with the hardware fpcr.  Note that the following
     system call is an implied trap barrier for our modification.  */
  __asm__ __volatile__ ("excb; mf_fpcr %0" : "=f" (fpcr));
  fpcr = (fpcr & ~FPCR_ROUND_MASK) | (env & FPCR_ROUND_MASK);
  __asm__ __volatile__ ("mt_fpcr %0" : : "f" (fpcr));

  /* Reset the exception status and mask with the kernel's FP code.  */
  __ieee_set_fp_control (env & SWCR_ALL_MASK);

  /* Success.  */
  return 0;

Here is the call graph for this function: