Back to index

glibc  2.9
fesetround.c
Go to the documentation of this file.
00001 /* Set current rounding direction.
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 fesetround (int round)
00030 {
00031   if (GLRO (dl_hwcap) & HWCAP_ARM_VFP)
00032     {
00033       fpu_control_t temp;
00034 
00035       switch (round)
00036        {
00037        case FE_TONEAREST:
00038        case FE_UPWARD:
00039        case FE_DOWNWARD:
00040        case FE_TOWARDZERO:
00041          _FPU_GETCW (temp);
00042          temp = (temp & ~FE_TOWARDZERO) | round;
00043          _FPU_SETCW (temp);
00044          return 0;
00045        default:
00046          return 1;
00047        }
00048     }
00049   else if (round == FE_TONEAREST)
00050     /* This is the only supported rounding mode for soft-fp.  */
00051     return 0;
00052 
00053   /* Unsupported, so fail.  */
00054   return 1;
00055 }
00056 
00057 libm_hidden_def (fesetround)