OSDN Git Service

8146479d842dfae2cbbd3a6bb6a5af05e8ecee6b
[uclinux-h8/uClibc.git] / libc / sysdeps / linux / powerpc / bits / fenvinline.h
1 /* Inline floating-point environment handling functions for powerpc.
2    Copyright (C) 1995, 1996, 1997, 1998, 1999, 2006
3    Free Software Foundation, Inc.
4    This file is part of the GNU C Library.
5
6    The GNU C Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
10
11    The GNU C Library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
15
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library; if not, write to the Free
18    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19    02111-1307 USA.  */
20
21 #include <features.h>
22
23 #if defined __GNUC__ && !defined _SOFT_FLOAT && !defined __NO_MATH_INLINES
24
25 /* Inline definition for fegetround.  */
26 # define fegetround() \
27   (__extension__  ({ int __fegetround_result;                                 \
28                      __asm__ __volatile__                                     \
29                        ("mcrfs 7,7 ; mfcr %0"                                 \
30                         : "=r"(__fegetround_result) : : "cr7");               \
31                      __fegetround_result & 3; }))
32
33 /* The weird 'i#*X' constraints on the following suppress a gcc
34    warning when __excepts is not a constant.  Otherwise, they mean the
35    same as just plain 'i'.  */
36
37 /* Inline definition for feraiseexcept.  */
38 # define feraiseexcept(__excepts) \
39   ((__builtin_constant_p (__excepts)                                          \
40     && ((__excepts) & ((__excepts)-1)) == 0                                   \
41     && (__excepts) != FE_INVALID)                                             \
42    ? ((__excepts) != 0                                                        \
43       ? (__extension__ ({ __asm__ __volatile__                                \
44                           ("mtfsb1 %s0"                                       \
45                            : : "i#*X"(__builtin_ffs (__excepts)));            \
46                           0; }))                                              \
47       : 0)                                                                    \
48    : (feraiseexcept) (__excepts))
49
50 /* Inline definition for feclearexcept.  */
51 # define feclearexcept(__excepts) \
52   ((__builtin_constant_p (__excepts)                                          \
53     && ((__excepts) & ((__excepts)-1)) == 0                                   \
54     && (__excepts) != FE_INVALID)                                             \
55    ? ((__excepts) != 0                                                        \
56       ? (__extension__ ({ __asm__ __volatile__                                \
57                           ("mtfsb0 %s0"                                       \
58                            : : "i#*X"(__builtin_ffs (__excepts)));            \
59                           0; }))                                              \
60       : 0)                                                                    \
61    : (feclearexcept) (__excepts))
62
63 #endif /* __GNUC__ && !_SOFT_FLOAT */
64