* sysdeps/mips/mips64/n32/Implies: Add mips/mips64/soft-fp.
authorDaniel Jacobowitz <dan@codesourcery.com>
Wed, 23 May 2007 17:13:59 +0000 (17:13 +0000)
committerDaniel Jacobowitz <dan@codesourcery.com>
Wed, 23 May 2007 17:13:59 +0000 (17:13 +0000)
* sysdeps/mips/mips64/n64/Implies: Likewise.
* sysdeps/mips/mips64/soft-fp/Makefile: New.
* sysdeps/mips/mips64/soft-fp/e_sqrtl.c: New.
* sysdeps/mips/mips64/soft-fp/sfp-machine.h: Include <fenv.h> and
<fpu_control.h>.  Use hardware exception and rounding mode
settings.

ChangeLog.mips
sysdeps/mips/mips64/n32/Implies
sysdeps/mips/mips64/n64/Implies
sysdeps/mips/mips64/soft-fp/Makefile [new file with mode: 0644]
sysdeps/mips/mips64/soft-fp/e_sqrtl.c [new file with mode: 0644]
sysdeps/mips/mips64/soft-fp/sfp-machine.h

index 097f7e2..2b5754f 100644 (file)
@@ -1,3 +1,13 @@
+2007-05-23  Joseph Myers  <joseph@codesourcery.com>
+
+       * sysdeps/mips/mips64/n32/Implies: Add mips/mips64/soft-fp.
+       * sysdeps/mips/mips64/n64/Implies: Likewise.
+       * sysdeps/mips/mips64/soft-fp/Makefile: New.
+       * sysdeps/mips/mips64/soft-fp/e_sqrtl.c: New.
+       * sysdeps/mips/mips64/soft-fp/sfp-machine.h: Include <fenv.h> and
+       <fpu_control.h>.  Use hardware exception and rounding mode
+       settings.
+
 2007-05-23  Richard Sandiford  <rsandifo@nildram.co.uk>
 
        * sysdeps/mips/dl-machine.h (elf_machine_reloc): Change type of
index a7cb280..bed8f14 100644 (file)
@@ -1,4 +1,5 @@
 ieee754/ldbl-128
+mips/mips64/soft-fp
 mips/mips64
 mips
 wordsize-32
index e507786..214b85c 100644 (file)
@@ -1,4 +1,5 @@
 ieee754/ldbl-128
+mips/mips64/soft-fp
 mips/mips64
 mips
 wordsize-64
diff --git a/sysdeps/mips/mips64/soft-fp/Makefile b/sysdeps/mips/mips64/soft-fp/Makefile
new file mode 100644 (file)
index 0000000..ada13e8
--- /dev/null
@@ -0,0 +1,3 @@
+ifeq ($(subdir),math)
+CPPFLAGS += -I../soft-fp
+endif
diff --git a/sysdeps/mips/mips64/soft-fp/e_sqrtl.c b/sysdeps/mips/mips64/soft-fp/e_sqrtl.c
new file mode 100644 (file)
index 0000000..81fd58a
--- /dev/null
@@ -0,0 +1,39 @@
+/* long double square root in software floating-point emulation.
+   Copyright (C) 1997, 1999, 2006 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Richard Henderson (rth@cygnus.com) and
+                 Jakub Jelinek (jj@ultra.linux.cz).
+
+   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 <stdlib.h>
+#include <soft-fp.h>
+#include <quad.h>
+
+long double
+__ieee754_sqrtl (const long double a)
+{
+  FP_DECL_EX;
+  FP_DECL_Q(A); FP_DECL_Q(C);
+  long double c;
+
+  FP_INIT_ROUNDMODE;
+  FP_UNPACK_Q(A, a);
+  FP_SQRT_Q(C, A);
+  FP_PACK_Q(c, C);
+  FP_HANDLE_EXCEPTIONS;
+  return c;
+}
index 309a14a..9c1ee3b 100644 (file)
@@ -1,3 +1,6 @@
+#include <fenv.h>
+#include <fpu_control.h>
+
 #define _FP_W_TYPE_SIZE                64
 #define _FP_W_TYPE             unsigned long long
 #define _FP_WS_TYPE            signed long long
     R##_c = FP_CLS_NAN;                                                \
   } while (0)
 
-#define FP_EX_INVALID           (1 << 4)
-#define FP_EX_DIVZERO           (1 << 3)
-#define FP_EX_OVERFLOW          (1 << 2)
-#define FP_EX_UNDERFLOW         (1 << 1)
-#define FP_EX_INEXACT           (1 << 0)
+#define _FP_DECL_EX            fpu_control_t _fcw
+
+#define FP_ROUNDMODE           (_fcw & 0x3)
+
+#define FP_RND_NEAREST         FE_TONEAREST
+#define FP_RND_ZERO            FE_TOWARDZERO
+#define FP_RND_PINF            FE_UPWARD
+#define FP_RND_MINF            FE_DOWNWARD
+
+#define FP_EX_INVALID          FE_INVALID
+#define FP_EX_OVERFLOW         FE_OVERFLOW
+#define FP_EX_UNDERFLOW                FE_UNDERFLOW
+#define FP_EX_DIVZERO          FE_DIVBYZERO
+#define FP_EX_INEXACT          FE_INEXACT
+
+#ifdef __mips_hard_float
+#define FP_INIT_ROUNDMODE                      \
+do {                                           \
+  _FPU_GETCW (_fcw);                           \
+} while (0)
+
+#define FP_HANDLE_EXCEPTIONS                   \
+do {                                           \
+  if (__builtin_expect (_fex, 0))              \
+    _FPU_SETCW (_fcw | _fex | (_fex << 10));   \
+} while (0)
+#else
+#define FP_INIT_ROUNDMODE      _fcw = FP_RND_NEAREST
+#endif