Back to index

glibc  2.9
fesetenv.c
Go to the documentation of this file.
00001 /* Install given floating-point environment.
00002    Copyright (C) 2004, 2005 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with GCC; see the file COPYING.  If not, write to the Free
00017    Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
00018    02110-1301, USA.  */
00019 
00020 #include <fenv.h>
00021 #include <fpu_control.h>
00022 
00023 #include <unistd.h>
00024 #include <ldsodefs.h>
00025 #include <dl-procinfo.h>
00026 #include <sysdep.h>
00027 
00028 int
00029 __fesetenv (const fenv_t *envp)
00030 {
00031   if (GLRO (dl_hwcap) & HWCAP_ARM_VFP)
00032     {
00033       unsigned int temp;
00034 
00035       _FPU_GETCW (temp);
00036       temp &= _FPU_RESERVED;
00037 
00038       if (envp == FE_DFL_ENV)
00039        temp |= _FPU_DEFAULT;
00040       else if (envp == FE_NOMASK_ENV)
00041        temp |= _FPU_IEEE;
00042       else
00043        temp |= envp->__cw & ~_FPU_RESERVED;
00044 
00045       _FPU_SETCW (temp);
00046 
00047       /* Success.  */
00048       return 0;
00049     }
00050 
00051   /* Unsupported, so fail.  */
00052   return 1;
00053 }
00054 
00055 #include <shlib-compat.h>
00056 libm_hidden_ver (__fesetenv, fesetenv)
00057 versioned_symbol (libm, __fesetenv, fesetenv, GLIBC_2_2);