aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/m68k/fpu
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1997-04-17 15:10:04 +0000
committerUlrich Drepper <drepper@redhat.com>1997-04-17 15:10:04 +0000
commitdd33e89fb2693e88ba64e6b947184c5abf70ff00 (patch)
tree3a621cf04df476aa6dd7905c41e77e8133baae3e /sysdeps/m68k/fpu
parent7799b7b3350fdcadc6dfb8821fb49b7772c96701 (diff)
downloadglibc-dd33e89fb2693e88ba64e6b947184c5abf70ff00.tar
glibc-dd33e89fb2693e88ba64e6b947184c5abf70ff00.tar.gz
glibc-dd33e89fb2693e88ba64e6b947184c5abf70ff00.tar.bz2
glibc-dd33e89fb2693e88ba64e6b947184c5abf70ff00.zip
Update.
1997-04-17 16:55 Ulrich Drepper <drepper@cygnus.com> * misc/libgen.h: Change prototype for of basename to XPG variant. * stdlib/Makefile (routines): Add xpg_basename. * stdlib/basename.c: New file. * string/string.h: Don't declare basename function if basename macro is available. 1997-04-16 17:33 Miles Bader <miles@gnu.ai.mit.edu> * login/utmp_file.c (proc_utmp_eq): Only use ut_id field if valid. 1997-04-15 12:47 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/m68k/fpu/fclrexcpt.c: New file. * sysdeps/m68k/fpu/fenvbits.h: New file. * sysdeps/m68k/fpu/fegetenv.c: New file. * sysdeps/m68k/fpu/fegetround.c: New file. * sysdeps/m68k/fpu/fesetenv.c: New file. * sysdeps/m68k/fpu/fesetround.c: New file. * sysdeps/m68k/fpu/feupdateenv.c: New file. * sysdeps/m68k/fpu/fgetexcptflg.c: New file. * sysdeps/m68k/fpu/fraiseexcpt.c: New file. * sysdeps/m68k/fpu/fsetexcptflg.c: New file. * sysdeps/m68k/fpu/ftestexcept.c: New file. * sysdeps/m68k/fpu/mathbits.h: New file. * sysdeps/m68k/fpu/s_remquo.c: New file. * sysdeps/m68k/fpu/s_remquol.c: New file. * sysdeps/m68k/fpu/s_remquof.c: New file. * sysdeps/libm-ieee754/s_roundl.c: Restore integer bit when mantissa overflows into exponent. Fix priority of >> vs +. * math/libm-test.c (basic_tests): Use the appropriate isnan and isinf function to test the value of the nan function. 1997-04-15 13:40 Ulrich Drepper <drepper@cygnus.com> * sysdeps/libm-i387/s_finite.S: Fix typo. * sysdeps/i386/fpu/__math.h: Add optimized versions of isgreater, isgreaterequal, isless, islessequal, islessgreater, and isunordered.
Diffstat (limited to 'sysdeps/m68k/fpu')
-rw-r--r--sysdeps/m68k/fpu/fclrexcpt.c39
-rw-r--r--sysdeps/m68k/fpu/fegetenv.c27
-rw-r--r--sysdeps/m68k/fpu/fegetround.c31
-rw-r--r--sysdeps/m68k/fpu/feholdexcpt.c39
-rw-r--r--sysdeps/m68k/fpu/fenvbits.h80
-rw-r--r--sysdeps/m68k/fpu/fesetenv.c48
-rw-r--r--sysdeps/m68k/fpu/fesetround.c38
-rw-r--r--sysdeps/m68k/fpu/feupdateenv.c39
-rw-r--r--sysdeps/m68k/fpu/fgetexcptflg.c32
-rw-r--r--sysdeps/m68k/fpu/fraiseexcpt.c74
-rw-r--r--sysdeps/m68k/fpu/fsetexcptflg.c38
-rw-r--r--sysdeps/m68k/fpu/ftestexcept.c32
-rw-r--r--sysdeps/m68k/fpu/mathbits.h36
-rw-r--r--sysdeps/m68k/fpu/s_remquo.c58
-rw-r--r--sysdeps/m68k/fpu/s_remquof.c3
-rw-r--r--sysdeps/m68k/fpu/s_remquol.c3
16 files changed, 617 insertions, 0 deletions
diff --git a/sysdeps/m68k/fpu/fclrexcpt.c b/sysdeps/m68k/fpu/fclrexcpt.c
new file mode 100644
index 0000000000..b914bac9f9
--- /dev/null
+++ b/sysdeps/m68k/fpu/fclrexcpt.c
@@ -0,0 +1,39 @@
+/* Clear given exceptions in current floating-point environment.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <fenv.h>
+
+void
+feclearexcept (int excepts)
+{
+ fexcept_t fpsr;
+
+ /* Mask out unsupported bits/exceptions. */
+ excepts &= FE_ALL_EXCEPT;
+
+ /* Fetch the fpu status register. */
+ __asm__ ("fmove%.l %/fpsr,%0" : "=dm" (fpsr));
+
+ /* Clear the relevant bits. */
+ fpsr &= ~excepts;
+
+ /* Put the new data in effect. */
+ __asm__ __volatile__ ("fmove%.l %0,%/fpsr" : : "dm" (fpsr));
+}
diff --git a/sysdeps/m68k/fpu/fegetenv.c b/sysdeps/m68k/fpu/fegetenv.c
new file mode 100644
index 0000000000..59f743aecf
--- /dev/null
+++ b/sysdeps/m68k/fpu/fegetenv.c
@@ -0,0 +1,27 @@
+/* Store current floating-point environment.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <fenv.h>
+
+void
+fegetenv (fenv_t *envp)
+{
+ __asm__ ("fmovem%.l %/fpcr/%/fpsr,%0" : "=m" (*envp));
+}
diff --git a/sysdeps/m68k/fpu/fegetround.c b/sysdeps/m68k/fpu/fegetround.c
new file mode 100644
index 0000000000..1837a84271
--- /dev/null
+++ b/sysdeps/m68k/fpu/fegetround.c
@@ -0,0 +1,31 @@
+/* Return current rounding direction.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <fenv.h>
+
+int
+fegetround (void)
+{
+ int fpcr;
+
+ __asm__ ("fmove%.l %!,%0" : "=dm" (fpcr));
+
+ return fpcr & FE_UPWARD;
+}
diff --git a/sysdeps/m68k/fpu/feholdexcpt.c b/sysdeps/m68k/fpu/feholdexcpt.c
new file mode 100644
index 0000000000..351fa8ae75
--- /dev/null
+++ b/sysdeps/m68k/fpu/feholdexcpt.c
@@ -0,0 +1,39 @@
+/* Store current floating-point environment and clear exceptions.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <fenv.h>
+
+int
+feholdexcept (fenv_t *envp)
+{
+ fexcept_t fpcr, fpsr;
+
+ /* Store the environment. */
+ __asm__ ("fmovem%.l %/fpcr/%/fpsr,%0" : "=m" (*envp));
+
+ /* Now clear all exceptions. */
+ fpsr = envp->status_register & ~FE_ALL_EXCEPT;
+ __asm__ __volatile__ ("fmove%.l %0,%/fpsr" : : "dm" (fpsr));
+ /* And set all exceptions to non-stop. */
+ fpcr = envp->control_register & ~(FE_ALL_EXCEPT << 5);
+ __asm__ __volatile__ ("fmove%.l %0,%!" : : "dm" (fpcr));
+
+ return 1;
+}
diff --git a/sysdeps/m68k/fpu/fenvbits.h b/sysdeps/m68k/fpu/fenvbits.h
new file mode 100644
index 0000000000..b653b1aafd
--- /dev/null
+++ b/sysdeps/m68k/fpu/fenvbits.h
@@ -0,0 +1,80 @@
+/* Copyright (C) 1997 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 Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/* This file should never be included directly. */
+
+#ifndef _FENVBITS_H
+#define _FENVBITS_H 1
+
+/* Define bits representing the exception. We use the bit positions of
+ the appropriate bits in the FPSR Accrued Exception Byte. */
+enum
+ {
+ FE_INEXACT = 1 << 3,
+#define FE_INEXACT FE_INEXACT
+ FE_DIVBYZERO = 1 << 4,
+#define FE_DIVBYZERO FE_DIVBYZERO
+ FE_UNDERFLOW = 1 << 5,
+#define FE_UNDERFLOW FE_UNDERFLOW
+ FE_OVERFLOW = 1 << 6,
+#define FE_OVERFLOW FE_OVERFLOW
+ FE_INVALID = 1 << 7
+#define FE_INVALID FE_INVALID
+ };
+
+#define FE_ALL_EXCEPT \
+ (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
+
+/* The m68k FPU supports all of the four defined rounding modes. We use
+ the bit positions in the FPCR Mode Control Byte as the values for the
+ appropriate macros. */
+enum
+ {
+ FE_TONEAREST = 0,
+#define FE_TONEAREST FE_TONEAREST
+ FE_TOWARDSZERO = 1 << 4,
+#define FE_TOWARDSZERO FE_TOWARDSZERO
+ FE_DOWNWARD = 2 << 4,
+#define FE_DOWNWARD FE_DOWNWARD
+ FE_UPWARD = 3 << 4
+#define FE_UPWARD FE_UPWARD
+ };
+
+
+/* Type representing exception flags. */
+typedef unsigned int fexcept_t;
+
+
+/* Type representing floating-point environment. This structure
+ corresponds to the layout of the block written by `fmovem'. */
+typedef struct
+ {
+ fexcept_t control_register;
+ fexcept_t status_register;
+ }
+fenv_t;
+
+/* If the default argument is used we use this value. */
+#define FE_DFL_ENV ((fenv_t *) -1)
+
+#ifdef __USE_GNU
+/* Floating-point environment where none of the exceptions are masked. */
+# define FE_NOMASK_ENV ((fenv_t *) -2)
+#endif
+
+#endif /* fenvbits.h */
diff --git a/sysdeps/m68k/fpu/fesetenv.c b/sysdeps/m68k/fpu/fesetenv.c
new file mode 100644
index 0000000000..f6611a20e0
--- /dev/null
+++ b/sysdeps/m68k/fpu/fesetenv.c
@@ -0,0 +1,48 @@
+/* Install given floating-point environment.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <fenv.h>
+
+void
+fesetenv (const fenv_t *envp)
+{
+ fenv_t temp;
+
+ /* Install the environment specified by ENVP. But there are a few
+ values which we do not want to come from the saved environment.
+ Therefore, we get the current environment and replace the values
+ we want to use from the environment specified by the parameter. */
+ __asm__ ("fmovem%.l %/fpcr/%/fpsr,%0" : "=m" (*&temp));
+
+ temp.status_register &= ~FE_ALL_EXCEPT;
+ temp.control_register &= ~((FE_ALL_EXCEPT << 5) | FE_UPWARD);
+ if (envp == FE_DFL_ENV)
+ ;
+ else if (envp == FE_NOMASK_ENV)
+ temp.control_register |= FE_ALL_EXCEPT << 5;
+ else
+ {
+ temp.control_register |= (envp->control_register
+ & ((FE_ALL_EXCEPT << 5) | FE_UPWARD));
+ temp.status_register |= envp->status_register & FE_ALL_EXCEPT;
+ }
+
+ __asm__ __volatile__ ("fmovem%.l %0,%/fpcr/%/fpsr" : : "m" (temp));
+}
diff --git a/sysdeps/m68k/fpu/fesetround.c b/sysdeps/m68k/fpu/fesetround.c
new file mode 100644
index 0000000000..8d5466c956
--- /dev/null
+++ b/sysdeps/m68k/fpu/fesetround.c
@@ -0,0 +1,38 @@
+/* Set current rounding direction.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <fenv.h>
+
+int
+fesetround (int round)
+{
+ fexcept_t fpcr;
+
+ if (round & ~FE_UPWARD)
+ /* ROUND is no valid rounding mode. */
+ return 0;
+
+ __asm__ ("fmove%.l %!,%0" : "=dm" (fpcr));
+ fpcr &= ~FE_UPWARD;
+ fpcr |= round;
+ __asm__ __volatile__ ("fmove%.l %0,%!" : : "dm" (fpcr));
+
+ return 1;
+}
diff --git a/sysdeps/m68k/fpu/feupdateenv.c b/sysdeps/m68k/fpu/feupdateenv.c
new file mode 100644
index 0000000000..f5922b4de4
--- /dev/null
+++ b/sysdeps/m68k/fpu/feupdateenv.c
@@ -0,0 +1,39 @@
+/* Install given floating-point environment and raise exceptions.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <fenv.h>
+
+void
+feupdateenv (const fenv_t *envp)
+{
+ fexcept_t fpsr;
+
+ /* Save current exceptions. */
+ __asm__ ("fmove%.l %/fpsr,%0" : "=dm" (fpsr));
+ fpsr &= FE_ALL_EXCEPT;
+
+ /* Install new environment. */
+ fesetenv (envp);
+
+ /* Raise the saved exception. Incidently for us the implementation
+ defined format of the values in objects of type fexcept_t is the
+ same as the ones specified using the FE_* constants. */
+ feraiseexcept ((int) fpsr);
+}
diff --git a/sysdeps/m68k/fpu/fgetexcptflg.c b/sysdeps/m68k/fpu/fgetexcptflg.c
new file mode 100644
index 0000000000..4086e1a97f
--- /dev/null
+++ b/sysdeps/m68k/fpu/fgetexcptflg.c
@@ -0,0 +1,32 @@
+/* Store current representation for exceptions.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <fenv.h>
+
+void
+fegetexceptflag (fexcept_t *flagp, int excepts)
+{
+ fexcept_t fpsr;
+
+ /* Get the current exceptions. */
+ __asm__ ("fmove%.l %/fpsr,%0" : "=dm" (fpsr));
+
+ *flagp = fpsr & excepts & FE_ALL_EXCEPT;
+}
diff --git a/sysdeps/m68k/fpu/fraiseexcpt.c b/sysdeps/m68k/fpu/fraiseexcpt.c
new file mode 100644
index 0000000000..b6ff82760d
--- /dev/null
+++ b/sysdeps/m68k/fpu/fraiseexcpt.c
@@ -0,0 +1,74 @@
+/* Raise given exceptions.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <fenv.h>
+#include <math.h>
+
+void
+feraiseexcept (int excepts)
+{
+ /* Raise exceptions represented by EXCEPTS. But we must raise only one
+ signal at a time. It is important that if the overflow/underflow
+ exception and the divide by zero exception are given at the same
+ time, the overflow/underflow exception follows the divide by zero
+ exception. */
+
+ /* First: invalid exception. */
+ if (excepts & FE_INVALID)
+ {
+ /* One example of a invalid operation is 0 * Infinity. */
+ double d = 0.0 * HUGE_VAL;
+ /* Now force the exception. */
+ __asm__ __volatile__ ("fnop" : : "f" (d));
+ }
+
+ /* Next: division by zero. */
+ if (excepts & FE_DIVBYZERO)
+ {
+ double d = 1.0;
+ __asm__ __volatile__ ("fdiv%.s %#0r0,%0; fnop" : "=f" (d) : "0" (d));
+ }
+
+ /* Next: overflow. */
+ if (excepts & FE_OVERFLOW)
+ {
+ long double d = LDBL_MAX * LDBL_MAX;
+ /* Now force the exception. */
+ __asm__ __volatile__ ("fnop" : : "f" (d));
+ }
+
+ /* Next: underflow. */
+ if (excepts & FE_UNDERFLOW)
+ {
+ long double d = LDBL_MIN / 16.0;
+ /* Now force the exception. */
+ __asm__ __volatile__ ("fnop" : : "f" (d));
+ }
+
+ /* Last: inexact. */
+ if (excepts & FE_INEXACT)
+ {
+ long double d1, d2 = 1.0;
+ __asm__ __volatile__ ("fmovecr %#0,%0\n\t"
+ "fdiv%.x %1,%0\n\t"
+ "fnop"
+ : "=&f" (d1) : "f" (d2));
+ }
+}
diff --git a/sysdeps/m68k/fpu/fsetexcptflg.c b/sysdeps/m68k/fpu/fsetexcptflg.c
new file mode 100644
index 0000000000..aa92ffd0c5
--- /dev/null
+++ b/sysdeps/m68k/fpu/fsetexcptflg.c
@@ -0,0 +1,38 @@
+/* Set floating-point environment exception handling.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <fenv.h>
+#include <math.h>
+
+void
+fesetexceptflag (const fexcept_t *flagp, int excepts)
+{
+ fexcept_t fpsr;
+
+ /* Get the current status register. */
+ __asm__ ("fmove%.l %/fpsr,%0" : "=dm" (fpsr));
+
+ /* Install the new exception bits in the Accrued Exception Byte. */
+ fpsr &= ~(excepts & FE_ALL_EXCEPT);
+ fpsr |= *flagp & excepts & FE_ALL_EXCEPT;
+
+ /* Store the new status register. */
+ __asm__ __volatile__ ("fmove%.l %0,%/fpsr" : : "dm" (fpsr));
+}
diff --git a/sysdeps/m68k/fpu/ftestexcept.c b/sysdeps/m68k/fpu/ftestexcept.c
new file mode 100644
index 0000000000..c092ce18e3
--- /dev/null
+++ b/sysdeps/m68k/fpu/ftestexcept.c
@@ -0,0 +1,32 @@
+/* Test exception in current environment.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <fenv.h>
+
+int
+fetestexcept (int excepts)
+{
+ fexcept_t fpsr;
+
+ /* Get current exceptions. */
+ __asm__ ("fmove%.l %/fpsr,%0" : "=dm" (fpsr));
+
+ return fpsr & excepts & FE_ALL_EXCEPT;
+}
diff --git a/sysdeps/m68k/fpu/mathbits.h b/sysdeps/m68k/fpu/mathbits.h
new file mode 100644
index 0000000000..049662319a
--- /dev/null
+++ b/sysdeps/m68k/fpu/mathbits.h
@@ -0,0 +1,36 @@
+/* Copyright (C) 1997 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 Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#ifndef _MATHBITS_H
+#define _MATHBITS_H 1
+
+/* The m68k FPUs evaluate all values in the 96 bit floating-point format
+ which is also available for the user as `long double'. Therefore we
+ define: */
+typedef long double float_t; /* `float' expressions are evaluated as
+ `long double'. */
+typedef long double double_t; /* `double' expressions are evaluated as
+ `long double'. */
+
+/* Signal that both types are `long double'. */
+#define FLT_EVAL_METHOD 2
+
+/* Define `INFINITY' as value of type `float_t'. */
+#define INFINITY HUGE_VALL
+
+#endif /* mathbits.h */
diff --git a/sysdeps/m68k/fpu/s_remquo.c b/sysdeps/m68k/fpu/s_remquo.c
new file mode 100644
index 0000000000..3682ba7896
--- /dev/null
+++ b/sysdeps/m68k/fpu/s_remquo.c
@@ -0,0 +1,58 @@
+/* Compute remainder and a congruent to the quotient. m68k fpu version
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#define __LIBC_M81_MATH_INLINES
+#include <math.h>
+
+#ifndef SUFF
+#define SUFF
+#endif
+#ifndef float_type
+#define float_type double
+#endif
+
+#define CONCATX(a,b) __CONCAT(a,b)
+#define s(name) CONCATX(name,SUFF)
+
+float_type
+s(__remquo) (float_type x, float_type y, int *quo)
+{
+ float_type result;
+ int cquo, fpsr;
+
+ /* FIXME: Which of frem and fmod is correct? */
+#if 1
+ __asm ("frem%.x %2,%0\n\tfmove%.l %/fpsr,%1"
+ : "=f" (result), "=dm" (fpsr) : "f" (y), "0" (x));
+ cquo = (fpsr >> 16) & 0x7f;
+ if ((result > 0) != (x > 0))
+ cquo--;
+#else
+ __asm ("fmod%.x %2,%0\n\tfmove%.l %/fpsr,%1"
+ : "=f" (result), "=dm" (fpsr) : "f" (y), "0" (x));
+ cquo = (fpsr >> 16) & 0x7f;
+#endif
+ if (fpsr & (1 << 23))
+ cquo = -cquo;
+ *quo = cquo;
+ return result;
+}
+#define weak_aliasx(a,b) weak_alias(a,b)
+weak_aliasx (s(__remquo), s(remquo))
diff --git a/sysdeps/m68k/fpu/s_remquof.c b/sysdeps/m68k/fpu/s_remquof.c
new file mode 100644
index 0000000000..8a292fc26c
--- /dev/null
+++ b/sysdeps/m68k/fpu/s_remquof.c
@@ -0,0 +1,3 @@
+#define SUFF f
+#define float_type float
+#include <s_remquo.c>
diff --git a/sysdeps/m68k/fpu/s_remquol.c b/sysdeps/m68k/fpu/s_remquol.c
new file mode 100644
index 0000000000..d236cfd1f9
--- /dev/null
+++ b/sysdeps/m68k/fpu/s_remquol.c
@@ -0,0 +1,3 @@
+#define SUFF l
+#define float_type long double
+#include <s_remquo.c>