summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@suse.de>2003-06-26 16:18:13 +0000
committerAndreas Schwab <schwab@suse.de>2003-06-26 16:18:13 +0000
commita2c8310fb086cf1f3827b31217c5bb106b8080cd (patch)
treeaa12abf2d049626555480989542bd764eacde069 /sysdeps
parent1e2e27fd8b59b073d1ef3e7475bc5e39fafd3577 (diff)
downloadglibc-a2c8310fb086cf1f3827b31217c5bb106b8080cd.tar.gz
glibc-a2c8310fb086cf1f3827b31217c5bb106b8080cd.tar.xz
glibc-a2c8310fb086cf1f3827b31217c5bb106b8080cd.zip
* sysdeps/m68k/fpu/bits/mathinline.h: Don't inline frexp.
* sysdeps/m68k/fpu/s_frexp.c: Put implementation here. 
* sysdeps/m68k/fpu/s_frexpl.c: Fix to handle unnormalized numbers.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/m68k/fpu/bits/mathinline.h31
-rw-r--r--sysdeps/m68k/fpu/s_frexp.c27
-rw-r--r--sysdeps/m68k/fpu/s_frexpl.c62
3 files changed, 83 insertions, 37 deletions
diff --git a/sysdeps/m68k/fpu/bits/mathinline.h b/sysdeps/m68k/fpu/bits/mathinline.h
index 4b1bfeaf13..ec00b4b711 100644
--- a/sysdeps/m68k/fpu/bits/mathinline.h
+++ b/sysdeps/m68k/fpu/bits/mathinline.h
@@ -1,5 +1,6 @@
 /* Definitions of inline math functions implemented by the m68881/2.
-   Copyright (C) 1991,92,93,94,96,97,98,99,2000,2002 Free Software Foundation, Inc.
+   Copyright (C) 1991,92,93,94,96,97,98,99,2000,2002, 2003
+     Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -176,28 +177,6 @@ __inline_mathop(trunc, intrz)
    for the function names.  */
 
 #define __inline_functions(float_type, s)				  \
-__m81_inline float_type							  \
-__m81_u(__CONCAT(__frexp,s))(float_type __value, int *__expptr)	__THROW	  \
-{									  \
-  float_type __mantissa, __exponent;					  \
-  int __iexponent;							  \
-  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;							  \
-    }									  \
-  __asm("fgetexp%.x %1, %0" : "=f" (__exponent) : "f" (__value));	  \
-  __iexponent = (int) __exponent + 1;					  \
-  *__expptr = __iexponent;						  \
-  __asm("fscale%.l %2, %0" : "=f" (__mantissa)				  \
-	: "0" (__value), "dmi" (-__iexponent));				  \
-  return __mantissa;							  \
-}									  \
-									  \
 __m81_defun (float_type, __CONCAT(__floor,s), (float_type __x))	__THROW	  \
 {									  \
   float_type __result;							  \
@@ -386,8 +365,6 @@ extern __inline rettype name args1 __THROW		\
   return __CONCAT(__,name) args2;			\
 }
 
-__inline_forward(double,frexp, (double __value, int *__expptr),
-		 (__value, __expptr))
 __inline_forward_c(double,floor, (double __x), (__x))
 __inline_forward_c(double,ceil, (double __x), (__x))
 # ifdef __USE_MISC
@@ -416,8 +393,6 @@ __inline_forward(void,sincos, (double __x, double *__sinx, double *__cosx),
 
 # if defined __USE_MISC || defined __USE_ISOC99
 
-__inline_forward(float,frexpf, (float __value, int *__expptr),
-		 (__value, __expptr))
 __inline_forward_c(float,floorf, (float __x), (__x))
 __inline_forward_c(float,ceilf, (float __x), (__x))
 #  ifdef __USE_MISC
@@ -438,8 +413,6 @@ __inline_forward(void,sincosf, (float __x, float *__sinx, float *__cosx),
 		 (__x, __sinx, __cosx))
 # endif
 
-__inline_forward(long double,frexpl, (long double __value, int *__expptr),
-		 (__value, __expptr))
 __inline_forward_c(long double,floorl, (long double __x), (__x))
 __inline_forward_c(long double,ceill, (long double __x), (__x))
 # ifdef __USE_MISC
diff --git a/sysdeps/m68k/fpu/s_frexp.c b/sysdeps/m68k/fpu/s_frexp.c
index 0cdb5778ee..b06141283c 100644
--- a/sysdeps/m68k/fpu/s_frexp.c
+++ b/sysdeps/m68k/fpu/s_frexp.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 2003 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -28,11 +28,28 @@
 #define __CONCATX(a,b) __CONCAT(a,b)
 
 float_type
-__CONCATX(__,FUNC) (value, expptr)
-     float_type value;
-     int *expptr;
+__CONCATX(__,FUNC) (float_type value, int *expptr)
 {
-  return __m81_u(__CONCATX(__,FUNC))(value, expptr);
+  float_type mantissa, exponent;
+  int iexponent;
+  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;
+    }
+  __asm ("fgetexp%.x %1, %0" : "=f" (exponent) : "f" (value));
+  iexponent = (int) exponent + 1;
+  *expptr = iexponent;
+  __asm ("fscale%.l %2, %0"
+	 : "=f" (mantissa)
+	 : "0" (value), "dmi" (-iexponent));
+  return mantissa;
 }
 
 #define weak_aliasx(a,b) weak_alias(a,b)
diff --git a/sysdeps/m68k/fpu/s_frexpl.c b/sysdeps/m68k/fpu/s_frexpl.c
index fe9466f3be..f9a5315265 100644
--- a/sysdeps/m68k/fpu/s_frexpl.c
+++ b/sysdeps/m68k/fpu/s_frexpl.c
@@ -1,3 +1,59 @@
-#define FUNC frexpl
-#define float_type long double
-#include <s_frexp.c>
+/* Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <math.h>
+
+long double
+__frexpl (long double value, int *expptr)
+{
+  long double mantissa, exponent;
+  int iexponent;
+  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;
+    }
+  __asm ("fgetexp%.x %1, %0" : "=f" (exponent) : "f" (value));
+  iexponent = (int) exponent + 1;
+  *expptr = iexponent;
+  /* Unnormalized numbers must be handled specially, otherwise fscale
+     results in overflow.  */
+  if (iexponent <= -16384)
+    {
+      value *= 0x1p16383L;
+      iexponent += 16383;
+    }
+  else if (iexponent >= 16384)
+    {
+      value *= 0x1p-16383L;
+      iexponent -= 16383;
+    }
+
+  __asm ("fscale%.l %2, %0"
+	 : "=f" (mantissa)
+	 : "0" (value), "dmi" (-iexponent));
+  return mantissa;
+}
+
+weak_alias (__frexpl, frexpl)