diff options
Diffstat (limited to 'sysdeps')
27 files changed, 701 insertions, 99 deletions
diff --git a/sysdeps/alpha/Makefile b/sysdeps/alpha/Makefile index 841dc98..5fe8e4e 100644 --- a/sysdeps/alpha/Makefile +++ b/sysdeps/alpha/Makefile @@ -44,3 +44,7 @@ sysdep-CFLAGS += -mno-fp-regs endif divrem := divl divq reml remq + +# For now, build everything with full IEEE math support. +# TODO: build separate libm and libm-ieee. +sysdep-CFLAGS += -mieee diff --git a/sysdeps/alpha/fpu/fclrexcpt.c b/sysdeps/alpha/fpu/fclrexcpt.c new file mode 100644 index 0000000..7aa79af --- /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 0000000..c8b705d --- /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 0000000..623e2ce --- /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 0000000..493d6a1 --- /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 0000000..02414e4 --- /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 0000000..3692967 --- /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 0000000..f49586c --- /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 0000000..816575a --- /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 0000000..28d9e12 --- /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 219ea55..bcf73e8 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 0000000..6a53e55 --- /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 0000000..7e373be --- /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 0000000..9ee9dc9 --- /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; +} diff --git a/sysdeps/generic/memccpy.c b/sysdeps/generic/memccpy.c index 7c2d443..6d85a79 100644 --- a/sysdeps/generic/memccpy.c +++ b/sysdeps/generic/memccpy.c @@ -16,7 +16,6 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <stddef.h> /* For size_t and NULL. */ #include <string.h> /* diff --git a/sysdeps/ieee754/huge_val.h b/sysdeps/ieee754/huge_val.h index 9d1785b..a252085 100644 --- a/sysdeps/ieee754/huge_val.h +++ b/sysdeps/ieee754/huge_val.h @@ -27,6 +27,17 @@ /* IEEE positive infinity (-HUGE_VAL is negative infinity). */ +#ifdef __GNUC__ + +#define HUGE_VAL \ + (__extension__ \ + ((union { unsigned __l __attribute__((__mode__(__DI__))); double __d; }) \ + { __l: 0x7ff0000000000000ULL }).__d) + +#else /* not GCC */ + +typedef union { unsigned char __c[8]; double __d; } __huge_val_t; + #if __BYTE_ORDER == __BIG_ENDIAN #define __HUGE_VAL_bytes { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } #endif @@ -34,13 +45,9 @@ #define __HUGE_VAL_bytes { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } #endif -#define __huge_val_t union { unsigned char __c[8]; double __d; } -#ifdef __GNUC__ -#define HUGE_VAL (__extension__ \ - ((__huge_val_t) { __c: __HUGE_VAL_bytes }).__d) -#else /* Not GCC. */ static __huge_val_t __huge_val = { __HUGE_VAL_bytes }; #define HUGE_VAL (__huge_val.__d) + #endif /* GCC. */ @@ -48,6 +55,17 @@ static __huge_val_t __huge_val = { __HUGE_VAL_bytes }; #ifdef __USE_ISOC9X +#ifdef __GNUC__ + +#define HUGE_VALF \ + (__extension__ \ + ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) \ + { __l: 0x7f800000UL }).__d) + +#else /* not GCC */ + +typedef union { unsigned char __c[4]; float __f; } __huge_valf_t; + #if __BYTE_ORDER == __BIG_ENDIAN #define __HUGE_VALF_bytes { 0x7f, 0x80, 0, 0 } #endif @@ -55,13 +73,9 @@ static __huge_val_t __huge_val = { __HUGE_VAL_bytes }; #define __HUGE_VALF_bytes { 0, 0, 0x80, 0x7f } #endif -#define __huge_valf_t union { unsigned char __c[4]; float __f; } -#ifdef __GNUC__ -#define HUGE_VALF (__extension__ \ - ((__huge_valf_t) { __c: __HUGE_VALF_bytes }).__f) -#else /* Not GCC. */ static __huge_valf_t __huge_valf = { __HUGE_VALF_bytes }; #define HUGE_VALF (__huge_valf.__f) + #endif /* GCC. */ @@ -69,6 +83,6 @@ static __huge_valf_t __huge_valf = { __HUGE_VALF_bytes }; same as `double'. */ #define HUGE_VALL HUGE_VAL -#endif /* __USE_ISOC9X. */ +#endif /* __USE_ISOC9X. */ -#endif /* huge_val.h */ +#endif /* huge_val.h */ diff --git a/sysdeps/ieee754/nan.h b/sysdeps/ieee754/nan.h index bea98d9..d4e6842 100644 --- a/sysdeps/ieee754/nan.h +++ b/sysdeps/ieee754/nan.h @@ -1,5 +1,5 @@ /* `NAN' constant for IEEE 754 machines. - Copyright (C) 1992, 1996 Free Software Foundation, Inc. + Copyright (C) 1992, 1996, 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 @@ -23,23 +23,42 @@ /* IEEE Not A Number. */ +#ifdef __GNUC__ + +#define NAN \ + (__extension__ \ + ((union { unsigned __l __attribute__((__mode__(__DI__))); double __d; }) \ + { __l: 0x7ff8000000000000ULL }).__d) + +#define NANF \ + (__extension__ \ + ((union { unsigned __l __attribute__((__mode__(__SI__))); flaot __d; }) \ + { __l: 0x7fc00000UL }).__d) + +#else + #include <endian.h> #if __BYTE_ORDER == __BIG_ENDIAN #define __nan_bytes { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 } +#define __nanf_bytes { 0x7f, 0xc0, 0, 0 } #endif #if __BYTE_ORDER == __LITTLE_ENDIAN #define __nan_bytes { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f } +#define __nanf_bytes { 0, 0, 0xc0, 0x7f } #endif -#ifdef __GNUC__ -#define NAN \ - (__extension__ ((union { unsigned char __c[8]; \ - double __d; }) \ - { __nan_bytes }).__d) -#else /* Not GCC. */ -static CONST char __nan[8] = __nan_bytes; -#define NAN (*(CONST double *) __nan) +static union { unsigned char __c[8]; double __d; } __nan = { __nan_bytes }; +#define NAN (__nan.__d) + +static union { unsigned char __c[4]; double __d; } __nanf = { __nanf_bytes }; +#define NANF (__nanf.__d) + #endif /* GCC. */ +/* Generally there is no separate `long double' format and it is the + same as `double'. */ + +#define NANL NAN + #endif /* nan.h */ diff --git a/sysdeps/libm-ieee754/s_log2.c b/sysdeps/libm-ieee754/s_log2.c index 03a7dea..7950dfa 100644 --- a/sysdeps/libm-ieee754/s_log2.c +++ b/sysdeps/libm-ieee754/s_log2.c @@ -1,4 +1,4 @@ -/* Adapted for log2 by Ulrich Drepper <drepper@cygnus.com>. +/* Adapted for log2 by Ulrich Drepper <drepper@cygnus.com>. */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. @@ -127,3 +127,5 @@ static double zero = 0.0; return dk-((s*(f-R))-f); } } + +weak_alias (__log2, log2) diff --git a/sysdeps/unix/alpha/sysdep.S b/sysdeps/unix/alpha/sysdep.S index 9df3134..fc5cc04 100644 --- a/sysdeps/unix/alpha/sysdep.S +++ b/sysdeps/unix/alpha/sysdep.S @@ -38,7 +38,7 @@ __errno = errno .globl __syscall_error .ent __syscall_error __syscall_error: - ldgp gp, 0(t12) + ldgp gp, 0(pv) lda sp, -16(sp) .frame sp, 16, ra, 0 stq ra, 0(sp) @@ -53,7 +53,7 @@ __syscall_error: jsr ra, __errno_location /* Store the error value. */ - ldl t0, 8(sp) + ldq t0, 8(sp) stl t0, 0(v0) /* And kick back a -1. */ diff --git a/sysdeps/unix/sysv/linux/alpha/brk.S b/sysdeps/unix/sysv/linux/alpha/brk.S index 74fef64..be0539b 100644 --- a/sysdeps/unix/sysv/linux/alpha/brk.S +++ b/sysdeps/unix/sysv/linux/alpha/brk.S @@ -73,8 +73,9 @@ $ok: stq a0, __curbrk /* What a horrible way to die. */ $err0: ldi v0, ENOMEM -$err1: addq sp, 8, sp - jmp zero, __syscall_error +$err1: lda pv, __syscall_error + addq sp, 8, sp + jmp zero, (pv), __syscall_error END(__brk) diff --git a/sysdeps/unix/sysv/linux/alpha/gnu/types.h b/sysdeps/unix/sysv/linux/alpha/gnu/types.h index 5c1e407..b23deb8 100644 --- a/sysdeps/unix/sysv/linux/alpha/gnu/types.h +++ b/sysdeps/unix/sysv/linux/alpha/gnu/types.h @@ -68,6 +68,11 @@ typedef long int __clock_t; /* One element in the file descriptor mask array. */ typedef unsigned int __fd_mask; +/* Due to incaution, we may have gotten these from a kernel header file. */ +#undef __FD_SETSIZE +#undef __NFDBITS +#undef __FDMASK + /* Number of descriptors that can fit in an `fd_set'. */ #define __FD_SETSIZE 1024 diff --git a/sysdeps/unix/sysv/linux/alpha/ieee_get_fp_control.S b/sysdeps/unix/sysv/linux/alpha/ieee_get_fp_control.S index dbc25bc..e118ff1 100644 --- a/sysdeps/unix/sysv/linux/alpha/ieee_get_fp_control.S +++ b/sysdeps/unix/sysv/linux/alpha/ieee_get_fp_control.S @@ -41,18 +41,20 @@ LEAF(__ieee_get_fp_control, 16) ldi a0, GSI_IEEE_FP_CONTROL ldi v0, __NR_osf_getsysinfo call_pal PAL_callsys - bne a3, error + bne a3, $error ldq v0, 0(sp) lda sp, 16(sp) ret -error: lda sp, 16(sp) +$error: #ifndef PROF br gp, 1f 1: ldgp gp, 0(gp) #endif - jmp zero, __syscall_error + lda pv, __syscall_error + lda sp, 16(sp) + jmp zero, (pv), __syscall_error END(__ieee_get_fp_control) diff --git a/sysdeps/unix/sysv/linux/alpha/ieee_set_fp_control.S b/sysdeps/unix/sysv/linux/alpha/ieee_set_fp_control.S index d2d2add..b38d67e 100644 --- a/sysdeps/unix/sysv/linux/alpha/ieee_set_fp_control.S +++ b/sysdeps/unix/sysv/linux/alpha/ieee_set_fp_control.S @@ -41,17 +41,19 @@ LEAF(__ieee_set_fp_control, 16) ldi v0, __NR_osf_setsysinfo call_pal PAL_callsys - lda sp, 16(sp) + bne a3, $error - bne a3, error + lda sp, 16(sp) ret -error: +$error: #ifndef PROF br gp, 1f 1: ldgp gp, 0(gp) #endif - jmp zero, __syscall_error + lda pv, __syscall_error + lda sp, 16(sp) + jmp zero, (pv), __syscall_error END(__ieee_set_fp_control) diff --git a/sysdeps/unix/sysv/linux/alpha/ioperm.c b/sysdeps/unix/sysv/linux/alpha/ioperm.c index 63bf175..76a744d 100644 --- a/sysdeps/unix/sysv/linux/alpha/ioperm.c +++ b/sysdeps/unix/sysv/linux/alpha/ioperm.c @@ -55,14 +55,13 @@ #define JENSEN_IO_BASE (0xfffffc0300000000UL) #define JENSEN_SPARSE_MEM (0xfffffc0200000000UL) -/* - * With respect to the I/O architecture, APECS and LCA are identical, - * so the following defines apply to LCA as well. - */ +/* With respect to the I/O architecture, APECS and LCA are identical, + so the following defines apply to LCA as well. */ #define APECS_IO_BASE (0xfffffc01c0000000UL) #define APECS_SPARSE_MEM (0xfffffc0200000000UL) #define APECS_DENSE_MEM (0xfffffc0300000000UL) +/* The same holds for CIA and PYXIS. */ #define CIA_IO_BASE (0xfffffc8580000000UL) #define CIA_SPARSE_MEM (0xfffffc8000000000UL) #define CIA_DENSE_MEM (0xfffffc8600000000UL) @@ -104,6 +103,7 @@ static struct platform { {"Mustang", IOSYS_APECS, 5, APECS_DENSE_MEM, APECS_SPARSE_MEM}, {"Noname", IOSYS_APECS, 5, APECS_DENSE_MEM, APECS_SPARSE_MEM}, {"Sable", IOSYS_T2, 5, T2_DENSE_MEM, T2_SPARSE_MEM}, + {"Miata", IOSYS_CIA, 5, CIA_DENSE_MEM, CIA_SPARSE_MEM}, }; diff --git a/sysdeps/unix/sysv/linux/alpha/setfpucw.c b/sysdeps/unix/sysv/linux/alpha/setfpucw.c index 43e8536..9133c81 100644 --- a/sysdeps/unix/sysv/linux/alpha/setfpucw.c +++ b/sysdeps/unix/sysv/linux/alpha/setfpucw.c @@ -1,65 +1,78 @@ -#include <fpu_control.h> +/* Set FP exception mask and rounding mode. + Copyright (C) 1996, 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. */ +#include <fpu_control.h> #include <asm/fpu.h> + extern void __ieee_set_fp_control (unsigned long); extern unsigned long __ieee_get_fp_control (void); - static inline unsigned long rdfpcr (void) { - unsigned long fpcr; - - asm ("trapb; mf_fpcr $f0; trapb; stt $f0,%0" : "m="(fpcr)); - return fpcr; + unsigned long fpcr; + asm ("excb; mf_fpcr %0" : "=f"(fpcr)); + return fpcr; } static inline void wrfpcr (unsigned long fpcr) { - asm volatile ("ldt $f0,%0; trapb; mt_fpcr $f0; trapb" :: "m"(fpcr)); + asm volatile ("mt_fpcr %0; excb" : : "f"(fpcr)); } void __setfpucw (unsigned short fpu_control) { - unsigned long fpcr = 0, fpcw = 0; + unsigned long fpcr = 0, fpcw = 0; - if (!fpu_control) - fpu_control = _FPU_DEFAULT; + if (!fpu_control) + fpu_control = _FPU_DEFAULT; - /* first, set dynamic rounding mode: */ + /* first, set dynamic rounding mode: */ - fpcr = rdfpcr(); - fpcr &= ~FPCR_DYN_MASK; - switch (fpu_control & 0xc00) { - case _FPU_RC_NEAREST: fpcr |= FPCR_DYN_NORMAL; break; - case _FPU_RC_DOWN: fpcr |= FPCR_DYN_MINUS; break; - case _FPU_RC_UP: fpcr |= FPCR_DYN_PLUS; break; - case _FPU_RC_ZERO: fpcr |= FPCR_DYN_CHOPPED; break; + fpcr = rdfpcr(); + fpcr &= ~FPCR_DYN_MASK; + switch (fpu_control & 0xc00) + { + case _FPU_RC_NEAREST: fpcr |= FPCR_DYN_NORMAL; break; + case _FPU_RC_DOWN: fpcr |= FPCR_DYN_MINUS; break; + case _FPU_RC_UP: fpcr |= FPCR_DYN_PLUS; break; + case _FPU_RC_ZERO: fpcr |= FPCR_DYN_CHOPPED; break; } - wrfpcr(fpcr); + wrfpcr(fpcr); - /* now tell kernel about traps that we like to hear about: */ + /* now tell kernel about traps that we like to hear about: */ - fpcw = __ieee_get_fp_control(); - fpcw &= ~IEEE_TRAP_ENABLE_MASK; + fpcw = __ieee_get_fp_control(); + fpcw &= ~IEEE_TRAP_ENABLE_MASK; - if (!(fpu_control & _FPU_MASK_IM)) - fpcw |= IEEE_TRAP_ENABLE_INV; - if (!(fpu_control & _FPU_MASK_DM)) - fpcw |= IEEE_TRAP_ENABLE_UNF; - if (!(fpu_control & _FPU_MASK_ZM)) - fpcw |= IEEE_TRAP_ENABLE_DZE; - if (!(fpu_control & _FPU_MASK_OM)) - fpcw |= IEEE_TRAP_ENABLE_OVF; - if (!(fpu_control & _FPU_MASK_PM)) - fpcw |= IEEE_TRAP_ENABLE_INE; + if (!(fpu_control & _FPU_MASK_IM)) fpcw |= IEEE_TRAP_ENABLE_INV; + if (!(fpu_control & _FPU_MASK_DM)) fpcw |= IEEE_TRAP_ENABLE_UNF; + if (!(fpu_control & _FPU_MASK_ZM)) fpcw |= IEEE_TRAP_ENABLE_DZE; + if (!(fpu_control & _FPU_MASK_OM)) fpcw |= IEEE_TRAP_ENABLE_OVF; + if (!(fpu_control & _FPU_MASK_PM)) fpcw |= IEEE_TRAP_ENABLE_INE; - __ieee_set_fp_control(fpcw); + __fpu_control = fpu_control; /* update global copy */ - __fpu_control = fpu_control; /* update global copy */ + __ieee_set_fp_control(fpcw); } diff --git a/sysdeps/unix/sysv/linux/alpha/syscall.S b/sysdeps/unix/sysv/linux/alpha/syscall.S index 75e1260..d25dd6b 100644 --- a/sysdeps/unix/sysv/linux/alpha/syscall.S +++ b/sysdeps/unix/sysv/linux/alpha/syscall.S @@ -62,10 +62,10 @@ LEAF(__syscall, 0) mov a5, a4 call_pal PAL_callsys /* Invoke system call */ - bne a3, error + bne a3, $error ret -error: +$error: #ifndef PROF br gp, 2f 2: ldgp gp, 0(gp) diff --git a/sysdeps/unix/sysv/linux/sys/ttydefaults.h b/sysdeps/unix/sysv/linux/sys/ttydefaults.h index 28512eb..b21c6d5 100644 --- a/sysdeps/unix/sysv/linux/sys/ttydefaults.h +++ b/sysdeps/unix/sysv/linux/sys/ttydefaults.h @@ -61,14 +61,14 @@ #ifdef _POSIX_VDISABLE # define CEOL _POSIX_VDISABLE #else -# define CEOL ((unsigned char)'\377') /* XXX avoid _POSIX_VDISABLE */ +# define CEOL '\0' /* XXX avoid _POSIX_VDISABLE */ #endif #define CERASE 0177 #define CINTR CTRL('c') #ifdef _POSIX_VDISABLE # define CSTATUS _POSIX_VDISABLE #else -# define CSTATUS ((unsigned char)'\377') /* XXX avoid _POSIX_VDISABLE */ +# define CSTATUS '\0' /* XXX avoid _POSIX_VDISABLE */ #endif #define CKILL CTRL('u') #define CMIN 1 |