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    (soft-float edition).
00003    Copyright (C) 2002, 2007, 2008 Free Software Foundation, Inc.
00004    Contributed by Aldy Hernandez <aldyh@redhat.com>, 2002.
00005    This file is part of the GNU C Library.
00006 
00007    The GNU C Library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Lesser General Public
00009    License as published by the Free Software Foundation; either
00010    version 2.1 of the License, or (at your option) any later version.
00011 
00012    The GNU C Library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Lesser General Public License for more details.
00016 
00017    You should have received a copy of the GNU Lesser General Public
00018    License along with the GNU C Library; if not, write to the Free
00019    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00020    02111-1307 USA.  */
00021 
00022 #include "soft-fp.h"
00023 #include "soft-supp.h"
00024 
00025 int
00026 feholdexcept (fenv_t *envp)
00027 {
00028   fenv_union_t u;
00029 
00030   /* Get the current state.  */
00031   __fegetenv (envp);
00032 
00033   u.fenv = *envp;
00034   /* Clear everything except the rounding mode.  */
00035   u.l[0] &= 0x3;
00036   /* Disable exceptions */
00037   u.l[1] = FE_ALL_EXCEPT;
00038 
00039   /* Put the new state in effect.  */
00040   fesetenv (&u.fenv);
00041 
00042   return 0;
00043 }
00044 libm_hidden_def (feholdexcept)