aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1997-05-07 15:26:19 +0000
committerUlrich Drepper <drepper@redhat.com>1997-05-07 15:26:19 +0000
commit08c2dbb9a20fa10e3b596d5fbbed8d7a54a71f5d (patch)
tree47145844c345d2c360cee00e1fb8fb8be0184260
parente9b08b8835394745ba31ec3ff4ca9e1fd14631b2 (diff)
downloadglibc-08c2dbb9a20fa10e3b596d5fbbed8d7a54a71f5d.tar.xz
glibc-08c2dbb9a20fa10e3b596d5fbbed8d7a54a71f5d.zip
(__frexp): Don't raise invalid exception on infinite value.
(__m81_test, __M81_COND_NAN, __M81_COND_INF, __M81_COND_NEG, __M81_COND_ZERO): New definitions.
-rw-r--r--sysdeps/m68k/fpu/__math.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/sysdeps/m68k/fpu/__math.h b/sysdeps/m68k/fpu/__math.h
index 92487f9b04..5dc4d2e066 100644
--- a/sysdeps/m68k/fpu/__math.h
+++ b/sysdeps/m68k/fpu/__math.h
@@ -153,6 +153,21 @@ __internal_inline_functions (float,f)
__internal_inline_functions (long double,l)
#undef __internal_inline_functions
+/* Get the m68881 condition codes, to quickly check multiple conditions. */
+static __inline__ unsigned long
+__m81_test (long double __val)
+{
+ unsigned long __fpsr;
+ __asm ("ftst%.x %1; fmove%.l %/fpsr,%0" : "=dm" (__fpsr) : "f" (__val));
+ return __fpsr;
+}
+
+/* Bit values returned by __m81_test. */
+#define __M81_COND_NAN (1 << 24)
+#define __M81_COND_INF (2 << 24)
+#define __M81_COND_ZERO (4 << 24)
+#define __M81_COND_NEG (8 << 24)
+
#endif /* __LIBC_M81_MATH_INLINES */
/* The rest of the functions are available to the user. */
@@ -163,8 +178,12 @@ __m81_u(__CONCAT(__frexp,s))(float_type __value, int *__expptr) \
{ \
float_type __mantissa, __exponent; \
int __iexponent; \
- if (__value == 0.0) \
+ unsigned long __fpsr; \
+ __asm("ftst%.x %1\n" \
+ "fmove%.l %/fpsr, %0" : "=dm" (__fpsr) : "f" (__value)); \
+ if (__fpsr & (7 << 24)) \
{ \
+ /* Not finite or zero. */ \
*__expptr = 0; \
return __value; \
} \