]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/sparc/fpu/bits/mathinline.h
1 /* Inline math functions for SPARC.
2 Copyright (C) 1999-2017 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Jakub Jelinek <jakub@redhat.com>.
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.
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.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
21 # error "Never use <bits/mathinline.h> directly; include <math.h> instead."
24 #include <bits/wordsize.h>
28 #if (!defined __NO_MATH_INLINES || defined __LIBC_INTERNAL_MATH_INLINES) && defined __OPTIMIZE__
30 # ifndef __extern_inline
31 # define __MATH_INLINE __inline
33 # define __MATH_INLINE __extern_inline
34 # endif /* __cplusplus */
36 /* The gcc, version 2.7 or below, has problems with all this inlining
37 code. So disable it for this version of the compiler. */
38 # if __GNUC_PREREQ (2, 8)
42 /* Test for negative number. Used in the signbit() macro. */
44 __NTH (__signbitf (float __x
))
46 __extension__
union { float __f
; int __i
; } __u
= { __f
: __x
};
53 __NTH (__signbit (double __x
))
55 __extension__
union { double __d
; int __i
[2]; } __u
= { __d
: __x
};
56 return __u
.__i
[0] < 0;
59 # ifndef __NO_LONG_DOUBLE_MATH
61 __NTH (__signbitl (long double __x
))
63 __extension__
union { long double __l
; int __i
[4]; } __u
= { __l
: __x
};
64 return __u
.__i
[0] < 0;
68 __NTH (__signbitl (long double __x
))
70 return __signbit ((double)__x
);
77 __NTH (__signbit (double __x
))
79 __extension__
union { double __d
; long int __i
; } __u
= { __d
: __x
};
84 __NTH (__signbitl (long double __x
))
86 __extension__
union { long double __l
; long int __i
[2]; } __u
= { __l
: __x
};
87 return __u
.__i
[0] < 0;
92 # endif /* __USE_ISOC99 */
94 # if !defined __NO_MATH_INLINES && !__GNUC_PREREQ (3, 2)
97 __NTH (sqrt (double __x
))
100 __asm ("fsqrtd %1,%0" : "=f" (__r
) : "f" (__x
));
105 __NTH (sqrtf (float __x
))
108 __asm ("fsqrts %1,%0" : "=f" (__r
) : "f" (__x
));
112 # if __WORDSIZE == 64
113 __MATH_INLINE
long double
114 __NTH (sqrtl (long double __x
))
117 extern void _Qp_sqrt (long double *, const long double *);
118 _Qp_sqrt (&__r
, &__x
);
121 # elif !defined __NO_LONG_DOUBLE_MATH
122 __MATH_INLINE
long double
123 sqrtl (long double __x
) __THROW
125 extern long double _Q_sqrt (const long double);
126 return _Q_sqrt (__x
);
128 # endif /* sparc64 */
130 # endif /* !__NO_MATH_INLINES && !GCC 3.2+ */
132 /* This code is used internally in the GNU libc. */
133 # ifdef __LIBC_INTERNAL_MATH_INLINES
135 __ieee754_sqrt (double __x
)
138 __asm ("fsqrtd %1,%0" : "=f" (__r
) : "f" (__x
));
143 __ieee754_sqrtf (float __x
)
146 __asm ("fsqrts %1,%0" : "=f" (__r
) : "f" (__x
));
150 # if __WORDSIZE == 64
151 __MATH_INLINE
long double
152 __ieee754_sqrtl (long double __x
)
155 extern void _Qp_sqrt (long double *, const long double *);
156 _Qp_sqrt(&__r
, &__x
);
159 # elif !defined __NO_LONG_DOUBLE_MATH
160 __MATH_INLINE
long double
161 __ieee754_sqrtl (long double __x
)
163 extern long double _Q_sqrt (const long double);
164 return _Q_sqrt (__x
);
166 # endif /* sparc64 */
167 # endif /* __LIBC_INTERNAL_MATH_INLINES */
168 # endif /* gcc 2.8+ */
172 # ifndef __NO_MATH_INLINES
174 __MATH_INLINE
double __NTH (fdim (double __x
, double __y
));
176 __NTH (fdim (double __x
, double __y
))
178 return __x
<= __y
? 0 : __x
- __y
;
181 __MATH_INLINE
float __NTH (fdimf (float __x
, float __y
));
183 __NTH (fdimf (float __x
, float __y
))
185 return __x
<= __y
? 0 : __x
- __y
;
188 # endif /* !__NO_MATH_INLINES */
189 # endif /* __USE_ISOC99 */
190 #endif /* !__NO_MATH_INLINES && __OPTIMIZE__ */
191 #endif /* __GNUC__ */