Back to index

glibc  2.9
feholdexcpt.c
Go to the documentation of this file.
00001 /* Store current floating-point environment and clear exceptions.
00002    Copyright (C) 1997, 1998, 1999, 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 feholdexcept (fenv_t *envp)
00030 {
00031   if (GLRO (dl_hwcap) & HWCAP_ARM_VFP)
00032     {
00033       unsigned long int temp;
00034 
00035       /* Store the environment.  */
00036       _FPU_GETCW(temp);
00037       envp->__cw = temp;
00038 
00039       /* Now set all exceptions to non-stop.  */
00040       temp &= ~(FE_ALL_EXCEPT << FE_EXCEPT_SHIFT);
00041 
00042       /* And clear all exception flags.  */
00043       temp &= ~FE_ALL_EXCEPT;
00044 
00045       _FPU_SETCW(temp);
00046 
00047       return 0;
00048     }
00049 
00050   /* Unsupported, so fail.  */
00051   return 1;
00052 }
00053 
00054 libm_hidden_def (feholdexcept)