aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/alpha/fpu
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1997-05-31 00:47:04 +0000
committerUlrich Drepper <drepper@redhat.com>1997-05-31 00:47:04 +0000
commitf671aeab4e17d6dc1c3ca96ac5cb2c3e04570082 (patch)
tree4e9817a3ff486d961a430f8fd3ee39c5fdff32b2 /sysdeps/alpha/fpu
parentd951286f645cc1d6f719c0c715620fc395c049d4 (diff)
downloadglibc-f671aeab4e17d6dc1c3ca96ac5cb2c3e04570082.tar
glibc-f671aeab4e17d6dc1c3ca96ac5cb2c3e04570082.tar.gz
glibc-f671aeab4e17d6dc1c3ca96ac5cb2c3e04570082.tar.bz2
glibc-f671aeab4e17d6dc1c3ca96ac5cb2c3e04570082.zip
1997-05-31 02:33 Ulrich Drepper <drepper@cygnus.com> * io/ftwtest-sh: More tests. * misc/tsearch.c: Rewrite tdestroy_recursive. * libio/libio.h: Define bits for libg++-2.8. 1997-05-30 22:21 Thorsten Kukuk <kukuk@vt.uni-paderborn.de> * nis/nss_nis/nis-hosts.c: Same changes as in nss/nss_files/files-hosts.c (Always use inet_pton). * nis/nss_nisplus/nisplus-hosts.c: Likewise. 1997-05-30 09:50 Richard Henderson <rth@tamu.edu> * manual/maint.texi: ECOFF hasn't been tested in ages and I don't plan on doing so ever again. Don't say alpha-linuxecoff is known to work. * elf/dl-lookup.c: Include <alloca.h>. * misc/tsearch.c: Include <string.h>. * posix/execle.c: Include <alloca.h>. * posix/execlp.c: Likewise. * stdio-common/printf_fphex.c: Include <string.h>. * sunrpc/xdr.c: Include <string.h>. * sysdeps/generic/memccpy.c: Include only <string.h>. * sunrpc/clnt_udp.c (clntudp_call): Make fromlen a size_t to fix parameters to network functions. * sunrpc/pmap_rmt.c (clnt_broadcast): Likewise. * sunrpc/svc_tcp.c (svctcp_create): Likewise with `len'. (rendezvous_request): Likewise. * sunrpc/svc_udp.c (svcudp_bufcreate): Likewise. (svcudp_recv): Similar, but go through a local variable. The old code used &xprt->xp_addrlen. Someone should determine if the type of the structure member should be changed instead. * sunrpc/xdr_rec.c (xdrrec_create): Expunge a ptr->int cast warning and transform a nonsense for-loop to a closed form calculation. (fill_input_buf): Another ptr->int warning. * sysdeps/alpha/Makefile: Temporarily turn on -mieee globally. This will last until I figure out how to build a parallel libm_ieee. * sysdeps/alpha/fpu/fclrexcpt.c, * sysdeps/alpha/fpu/fegetenv.c, * sysdeps/alpha/fpu/fegetround.c, * sysdeps/alpha/fpu/feholdexcpt.c, * sysdeps/alpha/fpu/fenvbits.h, * sysdeps/alpha/fpu/fesetenv.c, * sysdeps/alpha/fpu/fesetround.c, * sysdeps/alpha/fpu/feupdateenv.c, * sysdeps/alpha/fpu/fgetexcptflg.c, * sysdeps/alpha/fpu/fraiseexcpt.c, * sysdeps/alpha/fpu/fsetexcptflg.c, * sysdeps/alpha/fpu/ftestexcept.c: New files. There is, btw, a small kernel patch that must be applied as of 2.0.31-pre1 and 2.1.41 for this to work properly. * sysdeps/alpha/fpu/fpu_control.h: Update copyright. Change default FP mode to round to nearest, no exceptions as for Intel. * sysdeps/unix/sysv/linux/alpha/setfpucw.c: Add copyright. (rdfpcr): Use excb rather than trapb. Be more efficient about getting at the fpcr. (wrfpcr): Likewise. (__setfpucw): Reformat. * sysdeps/ieee754/huge_val.h: Change GCC's HUGE_VAL definition to use a single DI-mode integer instead of bytes. This produces better code on Alpha. Similar for HUGE_VALF. * sysdeps/ieee754/nan.h: Similar for NAN. Add NANF and NANL. * sysdeps/libm-ieee754/s_log2.c: Missing */ and weak_alias. * sysdeps/unix/alpha/sysdep.S: Tiny cleanups. * sysdeps/unix/sysv/linux/alpha/syscall.S: Likewise. * sysdeps/unix/sysv/linux/alpha/brk.S: Don't use jmp macro to make sure the stack frame is released the very instruction before the real jump out. * sysdeps/unix/sysv/linux/alpha/ieee_get_fp_control.S: Likewise. * sysdeps/unix/sysv/linux/alpha/ieee_set_fp_control.S: Likewise. * sysdeps/unix/sysv/linux/alpha/gnu/types.h: Undef some bits we may have gotten from <linux/posix_types.h>. * sysdeps/unix/sysv/linux/alpha/ioperm.c: Add definition for Miata. 1997-05-30 13:05 Ulrich Drepper <drepper@cygnus.com> * misc/tst-tsearch.c (mangle_tree): Update casts to prevent warnings. 1997-05-29 14:02 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/unix/sysv/linux/sys/ttydefaults.h (CEOL, CSTATUS): Use correct value for _POSIX_VDISABLE. 1997-05-29 13:59 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * Makefile (manual/dir-add.texi): Force execution. 1997-05-29 13:57 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysexits.h: New file. 1997-05-29 13:55 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * stdlib/strfmon.c: Don't run past EOS after `='. 1997-02-27 10:34 Richard Henderson <rth@tamu.edu>
Diffstat (limited to 'sysdeps/alpha/fpu')
-rw-r--r--sysdeps/alpha/fpu/fclrexcpt.c36
-rw-r--r--sysdeps/alpha/fpu/fegetenv.c37
-rw-r--r--sysdeps/alpha/fpu/fegetround.c31
-rw-r--r--sysdeps/alpha/fpu/feholdexcpt.c33
-rw-r--r--sysdeps/alpha/fpu/fenvbits.h107
-rw-r--r--sysdeps/alpha/fpu/fesetenv.c45
-rw-r--r--sysdeps/alpha/fpu/fesetround.c41
-rw-r--r--sysdeps/alpha/fpu/feupdateenv.c38
-rw-r--r--sysdeps/alpha/fpu/fgetexcptflg.c33
-rw-r--r--sysdeps/alpha/fpu/fpu_control.h46
-rw-r--r--sysdeps/alpha/fpu/fraiseexcpt.c72
-rw-r--r--sysdeps/alpha/fpu/fsetexcptflg.c36
-rw-r--r--sysdeps/alpha/fpu/ftestexcept.c32
13 files changed, 564 insertions, 23 deletions
diff --git a/sysdeps/alpha/fpu/fclrexcpt.c b/sysdeps/alpha/fpu/fclrexcpt.c
new file mode 100644
index 0000000000..7aa79af100
--- /dev/null
+++ b/sysdeps/alpha/fpu/fclrexcpt.c
@@ -0,0 +1,36 @@
+/* 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 Richard Henderson <rth@tamu.edu>, 1997.
+
+ 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)
+{
+ unsigned long swcr;
+
+ /* Get the current state. */
+ swcr = __ieee_get_fp_control();
+
+ /* Clear the relevant bits. */
+ swcr &= ~((unsigned long)excepts & FE_ALL_EXCEPT);
+
+ /* Put the new state in effect. */
+ __ieee_set_fp_control(swcr);
+}
diff --git a/sysdeps/alpha/fpu/fegetenv.c b/sysdeps/alpha/fpu/fegetenv.c
new file mode 100644
index 0000000000..c8b705d230
--- /dev/null
+++ b/sysdeps/alpha/fpu/fegetenv.c
@@ -0,0 +1,37 @@
+/* Store current floating-point environment.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson <rth@tamu.edu>, 1997
+
+ 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)
+{
+ unsigned long fpcr, swcr;
+
+ /* Get status from software and hardware. Note that we don't need an
+ excb because the callsys is an implied trap barrier. */
+ swcr = __ieee_get_fp_control();
+ __asm__ __volatile__("mf_fpcr %0" : "=f"(fpcr));
+
+ /* Merge the two bits of information. The magic number at the end is
+ the exception enable mask. */
+
+ *envp = (fpcr & (3UL << 58)) | (swcr & (FE_ALL_EXCEPT | 0x3e));
+}
diff --git a/sysdeps/alpha/fpu/fegetround.c b/sysdeps/alpha/fpu/fegetround.c
new file mode 100644
index 0000000000..623e2ce358
--- /dev/null
+++ b/sysdeps/alpha/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 Richard Henderson <rth@tamu.edu>, 1997
+
+ 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)
+{
+ unsigned long fpcr;
+
+ __asm__ __volatile__("excb; mf_fpcr %0" : "=f"(fpcr));
+
+ return (fpcr >> 58) & 3;
+}
diff --git a/sysdeps/alpha/fpu/feholdexcpt.c b/sysdeps/alpha/fpu/feholdexcpt.c
new file mode 100644
index 0000000000..493d6a18eb
--- /dev/null
+++ b/sysdeps/alpha/fpu/feholdexcpt.c
@@ -0,0 +1,33 @@
+/* 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 Richard Henderson <rth@tamu.edu>, 1997
+
+ 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)
+{
+ /* Save the current state. */
+ fegetenv(envp);
+
+ /* Clear all exception status bits and exception enable bits. */
+ __ieee_set_fp_control(0);
+
+ return 1;
+}
diff --git a/sysdeps/alpha/fpu/fenvbits.h b/sysdeps/alpha/fpu/fenvbits.h
new file mode 100644
index 0000000000..02414e4c30
--- /dev/null
+++ b/sysdeps/alpha/fpu/fenvbits.h
@@ -0,0 +1,107 @@
+/* Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson <rth@tamu.edu>, 1997
+
+ 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 the bits representing the exception.
+
+ Note that these are the bit positions as defined by the OSF/1
+ ieee_{get,set}_control_word interface and not by the hardware fpcr.
+
+ See the Alpha Architecture Handbook section 4.7.7.3 for details,
+ but in summary, trap shadows mean the hardware register can acquire
+ extra exception bits so for proper IEEE support the tracking has to
+ be done in software -- in this case with kernel support.
+
+ As to why the system call interface isn't in the same format as
+ the hardware register, only those crazy folks at DEC can tell you. */
+
+enum
+ {
+ FE_INEXACT = 1UL << 21,
+#define FE_INEXACT FE_INEXACT
+
+ FE_UNDERFLOW = 1UL << 20,
+#define FE_UNDERFLOW FE_UNDERFLOW
+
+ FE_OVERFLOW = 1UL << 19,
+#define FE_OVERFLOW FE_OVERFLOW
+
+ FE_DIVBYZERO = 1UL << 18,
+#define FE_DIVBYZERO FE_DIVBYZERO
+
+ FE_INVALID = 1UL << 17,
+#define FE_INVALID FE_INVALID
+
+ FE_ALL_EXCEPT =
+ (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
+#define FE_ALL_EXCEPT FE_ALL_EXCEPT
+ };
+
+
+/* Alpha chips support all four defined rouding modes.
+
+ Note that code must be compiled to use dynamic rounding (/d) instructions
+ to see these changes. For gcc this is -mfp-rounding-mode=d; for DEC cc
+ this is -fprm d. The default for both is static rounding to nearest.
+
+ These are shifted down 58 bits from the hardware fpcr because the
+ functions are declared to take integers. */
+
+enum
+ {
+ FE_TOWARDSZERO = 0,
+#define FE_TOWARDSZERO FE_TOWARDSZERO
+
+ FE_DOWNWARD = 1,
+#define FE_DOWNWARD FE_DOWNWARD
+
+ FE_TONEAREST = 2,
+#define FE_TONEAREST FE_TONEAREST
+
+ FE_UPWARD = 3,
+#define FE_UPWARD FE_UPWARD
+ };
+
+
+/* Type representing exception flags. */
+typedef unsigned long fexcept_t;
+
+/* Type representing floating-point environment. */
+typedef unsigned long fenv_t;
+
+/* If the default argument is used we use this value. Note that due to
+ architecture-specified page mappings, no user-space pointer will ever
+ have its two high bits set. Co-opt one. */
+#define FE_DFL_ENV ((fenv_t *) 0x8800000000000000UL)
+
+#ifdef __USE_GNU
+/* Floating-point environment where none of the exceptions are masked. */
+# define FE_NOMASK_ENV ((fenv_t *) 0x880000000000003eUL)
+#endif
+
+/* The system calls to talk to the kernel's FP code. */
+extern unsigned long __ieee_get_fp_control(void);
+extern void __ieee_set_fp_control(unsigned long);
+
+
+#endif /* fenvbits.h */
diff --git a/sysdeps/alpha/fpu/fesetenv.c b/sysdeps/alpha/fpu/fesetenv.c
new file mode 100644
index 0000000000..3692967a5b
--- /dev/null
+++ b/sysdeps/alpha/fpu/fesetenv.c
@@ -0,0 +1,45 @@
+/* Install given floating-point environment.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson <rth@tamu.edu>, 1997
+
+ 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)
+{
+ unsigned long fpcr;
+ fenv_t env;
+
+ /* Magic encoding of default values: high bit set (never possible for a
+ user-space address) is not indirect. And we don't even have to get
+ rid of it since we mask things around just below. */
+ if ((long)envp >= 0)
+ env = *envp;
+ else
+ env = (unsigned long)envp;
+
+ /* Reset the rounding mode with the hardware fpcr. Note that the following
+ system call is an implied trap barrier for our modification. */
+ __asm__ __volatile__("excb; mf_fpcr %0" : "=f"(fpcr));
+ fpcr = (fpcr & ~(3UL << 58)) | (env & (3UL << 58));
+ __asm__ __volatile__("mt_fpcr %0" : : "f"(fpcr));
+
+ /* Reset the exception status and mask with the kernel's FP code. */
+ __ieee_set_fp_control(env & (FE_ALL_EXCEPT | 0x3e));
+}
diff --git a/sysdeps/alpha/fpu/fesetround.c b/sysdeps/alpha/fpu/fesetround.c
new file mode 100644
index 0000000000..f49586cf8b
--- /dev/null
+++ b/sysdeps/alpha/fpu/fesetround.c
@@ -0,0 +1,41 @@
+/* Set current rounding direction.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson <rth@tamu.edu>, 1997
+
+ 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)
+{
+ unsigned long fpcr;
+
+ if (round & ~3)
+ return 0;
+
+ /* Get the current state. */
+ __asm__ __volatile__("excb; mf_fpcr %0" : "=f"(fpcr));
+
+ /* Set the relevant bits. */
+ fpcr = (fpcr & ~(3UL << 58)) | ((unsigned long)round << 58);
+
+ /* Put the new state in effect. */
+ __asm__ __volatile__("mt_fpcr %0; excb" : : "f"(fpcr));
+
+ return 1;
+}
diff --git a/sysdeps/alpha/fpu/feupdateenv.c b/sysdeps/alpha/fpu/feupdateenv.c
new file mode 100644
index 0000000000..816575a134
--- /dev/null
+++ b/sysdeps/alpha/fpu/feupdateenv.c
@@ -0,0 +1,38 @@
+/* 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 Richard Henderson <rth@tamu.edu>, 1997.
+
+ 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)
+{
+ unsigned long tmp;
+
+ /* Get the current exception state. */
+ tmp = __ieee_get_fp_control();
+
+ /* 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)tmp & FE_ALL_EXCEPT);
+}
diff --git a/sysdeps/alpha/fpu/fgetexcptflg.c b/sysdeps/alpha/fpu/fgetexcptflg.c
new file mode 100644
index 0000000000..28d9e129b1
--- /dev/null
+++ b/sysdeps/alpha/fpu/fgetexcptflg.c
@@ -0,0 +1,33 @@
+/* Store current representation for exceptions.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson <rth@tamu.edu>, 1997.
+
+ 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)
+{
+ unsigned long tmp;
+
+ /* Get the current state. */
+ tmp = __ieee_get_fp_control();
+
+ /* Return that portion that corresponds to the requested exceptions. */
+ *flagp = tmp & excepts & FE_ALL_EXCEPT;
+}
diff --git a/sysdeps/alpha/fpu/fpu_control.h b/sysdeps/alpha/fpu/fpu_control.h
index 219ea55f24..bcf73e857e 100644
--- a/sysdeps/alpha/fpu/fpu_control.h
+++ b/sysdeps/alpha/fpu/fpu_control.h
@@ -1,23 +1,22 @@
-/* FPU control word bits. Alpha version.
-Copyright (C) 1996 Free Software Foundation, Inc.
-Contributed by Olaf Flebbe.
-
-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., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
+/* FPU control word bits. Alpha-maped-to-Intel version.
+ Copyright (C) 1996 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Olaf Flebbe.
+
+ 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 _ALPHA_FPU_CONTROL_H
#define _ALPHA_FPU_CONTROL_H
@@ -91,11 +90,12 @@ Cambridge, MA 02139, USA. */
qualifier. By setting the dynamic rounding mode to +infinity,
one can use /d to get round to +infinity with no extra overhead
(so long as the default isn't changed, of course...)
- - exceptions on overflow, zero divide and NaN */
-#define _FPU_DEFAULT 0x1f72
+ - no exceptions enabled. */
+
+#define _FPU_DEFAULT 0x137f
/* IEEE: same as above, but exceptions */
-#define _FPU_IEEE 0x1f7f
+#define _FPU_IEEE 0x137f
/* Type of the control word. */
typedef unsigned int fpu_control_t;
diff --git a/sysdeps/alpha/fpu/fraiseexcpt.c b/sysdeps/alpha/fpu/fraiseexcpt.c
new file mode 100644
index 0000000000..6a53e55e7d
--- /dev/null
+++ b/sysdeps/alpha/fpu/fraiseexcpt.c
@@ -0,0 +1,72 @@
+/* Raise given exceptions.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson <rth@tamu.edu>, 1997.
+
+ 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)
+{
+ double tmp;
+
+ /* Raise exceptions represented by EXPECTS. But we must raise only
+ one signal at a time. It is important the if the overflow/underflow
+ exception and the inexact exception are given at the same time,
+ the overflow/underflow exception precedes the inexact exception. */
+
+ /* We do these bits in assembly to be certain GCC doesn't optimize
+ away something important. */
+
+ /* First: invalid exception. */
+ if (FE_INVALID & excepts)
+ {
+ /* One example of a invalid operation is 0 * Infinity. */
+ __asm__ __volatile__("mult/sui $f31,%1,%0; trapb"
+ : "=f"(tmp) : "f"(HUGE_VAL));
+ }
+
+ /* Next: division by zero. */
+ if (FE_DIVBYZERO & excepts)
+ {
+ __asm__ __volatile__("cmpteq $f31,$f31,%0; divt/sui %0,$f31,%0; trapb"
+ : "=f"(tmp));
+ }
+
+ /* Next: overflow. */
+ if (FE_OVERFLOW & excepts)
+ {
+ __asm__ __volatile__("mult/sui %1,%1,%0; trapb"
+ : "=f"(tmp) : "f"(DBL_MAX));
+ }
+
+ /* Next: underflow. */
+ if (FE_UNDERFLOW & excepts)
+ {
+ __asm__ __volatile__("divt/sui %1,%2,%0; trapb"
+ : "=f"(tmp) : "f"(DBL_MIN), "f"(16.0));
+ }
+
+ /* Last: inexact. */
+ if (FE_INEXACT & excepts)
+ {
+ __asm__ __volatile__("divt/sui %1,%2,%0; trapb"
+ : "=f"(tmp) : "f"(1.0), "f"(M_PI));
+ }
+}
diff --git a/sysdeps/alpha/fpu/fsetexcptflg.c b/sysdeps/alpha/fpu/fsetexcptflg.c
new file mode 100644
index 0000000000..7e373bea6f
--- /dev/null
+++ b/sysdeps/alpha/fpu/fsetexcptflg.c
@@ -0,0 +1,36 @@
+/* Set floating-point environment exception handling.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Richard Henderson <rth@tamu.edu>, 1997.
+
+ 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
+fesetexceptflag (const fexcept_t *flagp, int excepts)
+{
+ unsigned long tmp;
+
+ /* Get the current exception state. */
+ tmp = __ieee_get_fp_control();
+
+ /* Set all the bits that were called for. */
+ tmp = tmp & ~FE_ALL_EXCEPT | *flagp & excepts & FE_ALL_EXCEPT;
+
+ /* And store it back. */
+ __ieee_set_fp_control(tmp);
+}
diff --git a/sysdeps/alpha/fpu/ftestexcept.c b/sysdeps/alpha/fpu/ftestexcept.c
new file mode 100644
index 0000000000..9ee9dc9c55
--- /dev/null
+++ b/sysdeps/alpha/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 Richard Henderson <rth@tamu.edu>, 1997.
+
+ 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)
+{
+ unsigned long tmp;
+
+ /* Get current exceptions. */
+ tmp = __ieee_get_fp_control();
+
+ return tmp & excepts & FE_ALL_EXCEPT;
+}