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)
40 # if !defined __NO_MATH_INLINES && !__GNUC_PREREQ (3, 2)
43 __NTH (sqrt (double __x
))
46 __asm ("fsqrtd %1,%0" : "=f" (__r
) : "f" (__x
));
51 __NTH (sqrtf (float __x
))
54 __asm ("fsqrts %1,%0" : "=f" (__r
) : "f" (__x
));
59 __MATH_INLINE
long double
60 __NTH (sqrtl (long double __x
))
63 extern void _Qp_sqrt (long double *, const long double *);
64 _Qp_sqrt (&__r
, &__x
);
67 # elif !defined __NO_LONG_DOUBLE_MATH
68 __MATH_INLINE
long double
69 sqrtl (long double __x
) __THROW
71 extern long double _Q_sqrt (const long double);
76 # endif /* !__NO_MATH_INLINES && !GCC 3.2+ */
78 /* This code is used internally in the GNU libc. */
79 # ifdef __LIBC_INTERNAL_MATH_INLINES
81 __ieee754_sqrt (double __x
)
84 __asm ("fsqrtd %1,%0" : "=f" (__r
) : "f" (__x
));
89 __ieee754_sqrtf (float __x
)
92 __asm ("fsqrts %1,%0" : "=f" (__r
) : "f" (__x
));
97 __MATH_INLINE
long double
98 __ieee754_sqrtl (long double __x
)
101 extern void _Qp_sqrt (long double *, const long double *);
102 _Qp_sqrt(&__r
, &__x
);
105 # elif !defined __NO_LONG_DOUBLE_MATH
106 __MATH_INLINE
long double
107 __ieee754_sqrtl (long double __x
)
109 extern long double _Q_sqrt (const long double);
110 return _Q_sqrt (__x
);
112 # endif /* sparc64 */
113 # endif /* __LIBC_INTERNAL_MATH_INLINES */
114 # endif /* gcc 2.8+ */
118 # ifndef __NO_MATH_INLINES
120 __MATH_INLINE
double __NTH (fdim (double __x
, double __y
));
122 __NTH (fdim (double __x
, double __y
))
124 return __x
<= __y
? 0 : __x
- __y
;
127 __MATH_INLINE
float __NTH (fdimf (float __x
, float __y
));
129 __NTH (fdimf (float __x
, float __y
))
131 return __x
<= __y
? 0 : __x
- __y
;
134 # endif /* !__NO_MATH_INLINES */
135 # endif /* __USE_ISOC99 */
136 #endif /* !__NO_MATH_INLINES && __OPTIMIZE__ */
137 #endif /* __GNUC__ */