summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/sparc/bits/mathinline.h
diff options
context:
space:
mode:
Diffstat (limited to 'libc/sysdeps/linux/sparc/bits/mathinline.h')
-rw-r--r--libc/sysdeps/linux/sparc/bits/mathinline.h97
1 files changed, 78 insertions, 19 deletions
diff --git a/libc/sysdeps/linux/sparc/bits/mathinline.h b/libc/sysdeps/linux/sparc/bits/mathinline.h
index f4bb278ed..9dd784d12 100644
--- a/libc/sysdeps/linux/sparc/bits/mathinline.h
+++ b/libc/sysdeps/linux/sparc/bits/mathinline.h
@@ -1,5 +1,6 @@
/* Inline math functions for SPARC.
- Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001, 2002, 2004, 2006
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com>.
@@ -26,27 +27,62 @@
#ifdef __GNUC__
-#ifdef __USE_ISOC99
+#if defined __USE_ISOC99 && !__GNUC_PREREQ (3, 0)
+# undef isgreater
+# undef isgreaterequal
+# undef isless
+# undef islessequal
+# undef islessgreater
+# undef isunordered
# if __WORDSIZE == 32
-# define __unordered_cmp(x, y) \
+# ifndef __NO_LONG_DOUBLE_MATH
+
+# define __unordered_cmp(x, y) \
+ (__extension__ \
+ ({ unsigned __r; \
+ if (sizeof (x) == 4 && sizeof (y) == 4) \
+ { \
+ float __x = (x); float __y = (y); \
+ __asm__ ("fcmps %1,%2; st %%fsr, %0" : "=m" (__r) : "f" (__x), \
+ "f" (__y) : "cc"); \
+ } \
+ else if (sizeof (x) <= 8 && sizeof (y) <= 8) \
+ { \
+ double __x = (x); double __y = (y); \
+ __asm__ ("fcmpd\t%1,%2\n\tst\t%%fsr,%0" : "=m" (__r) : "f" (__x), \
+ "f" (__y) : "cc"); \
+ } \
+ else \
+ { \
+ long double __x = (x); long double __y = (y); \
+ extern int _Q_cmp (const long double a, const long double b); \
+ __r = _Q_cmp (__x, __y) << 10; \
+ } \
+ __r; }))
+
+# else
+
+# define __unordered_cmp(x, y) \
(__extension__ \
({ unsigned __r; \
- if (sizeof(x) == 4 && sizeof(y) == 4) \
+ if (sizeof (x) == 4 && sizeof (y) == 4) \
{ \
float __x = (x); float __y = (y); \
- __asm__("fcmps %1,%2; st %%fsr, %0" : "=m" (__r) : "f" (__x), \
- "f" (__y) : "cc"); \
+ __asm__ ("fcmps %1,%2; st %%fsr, %0" : "=m" (__r) : "f" (__x), \
+ "f" (__y) : "cc"); \
} \
else \
{ \
double __x = (x); double __y = (y); \
- __asm__("fcmpd\t%1,%2\n\tst\t%%fsr,%0" : "=m" (__r) : "f" (__x), \
- "f" (__y) : "cc"); \
+ __asm__ ("fcmpd\t%1,%2\n\tst\t%%fsr,%0" : "=m" (__r) : "f" (__x), \
+ "f" (__y) : "cc"); \
} \
__r; }))
+# endif
+
# define isgreater(x, y) ((__unordered_cmp (x, y) & (3 << 10)) == (2 << 10))
# define isgreaterequal(x, y) ((__unordered_cmp (x, y) & (1 << 10)) == 0)
# define isless(x, y) ((__unordered_cmp (x, y) & (3 << 10)) == (1 << 10))
@@ -59,22 +95,22 @@
# define __unordered_v9cmp(x, y, op, qop) \
(__extension__ \
({ unsigned __r; \
- if (sizeof(x) == 4 && sizeof(y) == 4) \
+ if (sizeof (x) == 4 && sizeof (y) == 4) \
{ \
float __x = (x); float __y = (y); \
- __asm__("fcmps\t%%fcc3,%1,%2\n\tmov" op "\t%%fcc3,1,%0" \
- : "=r" (__r) : "f" (__x), "f" (__y), "0" (0) : "cc"); \
+ __asm__ ("fcmps\t%%fcc3,%1,%2\n\tmov" op "\t%%fcc3,1,%0" \
+ : "=r" (__r) : "f" (__x), "f" (__y), "0" (0) : "cc"); \
} \
- else if (sizeof(x) <= 8 && sizeof(y) <= 8) \
+ else if (sizeof (x) <= 8 && sizeof (y) <= 8) \
{ \
double __x = (x); double __y = (y); \
- __asm__("fcmpd\t%%fcc3,%1,%2\n\tmov" op "\t%%fcc3,1,%0" \
- : "=r" (__r) : "f" (__x), "f" (__y), "0" (0) : "cc"); \
+ __asm__ ("fcmpd\t%%fcc3,%1,%2\n\tmov" op "\t%%fcc3,1,%0" \
+ : "=r" (__r) : "f" (__x), "f" (__y), "0" (0) : "cc"); \
} \
else \
{ \
long double __x = (x); long double __y = (y); \
- extern int _Qp_cmp(const long double *a, const long double *b); \
+ extern int _Qp_cmp (const long double *a, const long double *b); \
__r = qop; \
} \
__r; }))
@@ -121,11 +157,20 @@ __NTH (__signbit (double __x))
return __u.__i[0] < 0;
}
+# ifndef __NO_LONG_DOUBLE_MATH
+__MATH_INLINE int
+__NTH (__signbitl (long double __x))
+{
+ __extension__ union { long double __l; int __i[4]; } __u = { __l: __x };
+ return __u.__i[0] < 0;
+}
+# else
__MATH_INLINE int
__NTH (__signbitl (long double __x))
{
return __signbit ((double)__x);
}
+# endif
# else /* sparc64 */
@@ -147,7 +192,7 @@ __NTH (__signbitl (long double __x))
# endif /* __USE_ISOC99 */
-# ifndef __NO_MATH_INLINES
+# if !defined __NO_MATH_INLINES && !__GNUC_PREREQ (3, 2)
__MATH_INLINE double
__NTH (sqrt (double __x))
@@ -174,9 +219,16 @@ __NTH (sqrtl (long double __x))
_Qp_sqrt (&__r, &__x);
return __r;
}
+# elif !defined __NO_LONG_DOUBLE_MATH
+__MATH_INLINE long double
+sqrtl (long double __x) __THROW
+{
+ extern long double _Q_sqrt (__const__ long double);
+ return _Q_sqrt (__x);
+}
# endif /* sparc64 */
-# endif /* !__NO_MATH_INLINES */
+# endif /* !__NO_MATH_INLINES && !GCC 3.2+ */
/* This code is used internally in the GNU libc. */
# ifdef __LIBC_INTERNAL_MATH_INLINES
@@ -205,6 +257,13 @@ __ieee754_sqrtl (long double __x)
_Qp_sqrt(&__r, &__x);
return __r;
}
+# elif !defined __NO_LONG_DOUBLE_MATH
+__MATH_INLINE long double
+__ieee754_sqrtl (long double __x)
+{
+ extern long double _Q_sqrt (__const__ long double);
+ return _Q_sqrt (__x);
+}
# endif /* sparc64 */
# endif /* __LIBC_INTERNAL_MATH_INLINES */
# endif /* gcc 2.8+ */
@@ -217,14 +276,14 @@ __MATH_INLINE double __NTH (fdim (double __x, double __y));
__MATH_INLINE double
__NTH (fdim (double __x, double __y))
{
- return __x < __y ? 0 : __x - __y;
+ return __x <= __y ? 0 : __x - __y;
}
__MATH_INLINE float __NTH (fdimf (float __x, float __y));
__MATH_INLINE float
__NTH (fdimf (float __x, float __y))
{
- return __x < __y ? 0 : __x - __y;
+ return __x <= __y ? 0 : __x - __y;
}
# endif /* !__NO_MATH_INLINES */