Back to index

glibc  2.9
fenvinline.h
Go to the documentation of this file.
00001 /* Inline floating-point environment handling functions for powerpc.
00002    Copyright (C) 1995, 1996, 1997, 1998, 1999, 2006
00003    Free Software Foundation, Inc.
00004    This file is part of the GNU C Library.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #if defined __GNUC__ && !defined _SOFT_FLOAT && !defined __NO_MATH_INLINES
00022 
00023 /* Inline definition for fegetround.  */
00024 # define fegetround() \
00025   (__extension__  ({ int __fegetround_result;                               \
00026                    __asm__ __volatile__                              \
00027                      ("mcrfs 7,7 ; mfcr %0"                                 \
00028                      : "=r"(__fegetround_result) : : "cr7");                \
00029                    __fegetround_result & 3; }))
00030 
00031 /* The weird 'i#*X' constraints on the following suppress a gcc
00032    warning when __excepts is not a constant.  Otherwise, they mean the
00033    same as just plain 'i'.  */
00034 
00035 /* Inline definition for feraiseexcept.  */
00036 # define feraiseexcept(__excepts) \
00037   ((__builtin_constant_p (__excepts)                                        \
00038     && ((__excepts) & ((__excepts)-1)) == 0                                 \
00039     && (__excepts) != FE_INVALID)                                    \
00040    ? ((__excepts) != 0                                                      \
00041       ? (__extension__ ({ __asm__ __volatile__                              \
00042                        ("mtfsb1 %s0"                                        \
00043                         : : "i#*X"(__builtin_ffs (__excepts)));             \
00044                        0; }))                                        \
00045       : 0)                                                           \
00046    : (feraiseexcept) (__excepts))
00047 
00048 /* Inline definition for feclearexcept.  */
00049 # define feclearexcept(__excepts) \
00050   ((__builtin_constant_p (__excepts)                                        \
00051     && ((__excepts) & ((__excepts)-1)) == 0                                 \
00052     && (__excepts) != FE_INVALID)                                    \
00053    ? ((__excepts) != 0                                                      \
00054       ? (__extension__ ({ __asm__ __volatile__                              \
00055                        ("mtfsb0 %s0"                                        \
00056                         : : "i#*X"(__builtin_ffs (__excepts)));             \
00057                        0; }))                                        \
00058       : 0)                                                           \
00059    : (feclearexcept) (__excepts))
00060 
00061 #endif /* __GNUC__ && !_SOFT_FLOAT */