diff options
Diffstat (limited to 'REORG.TODO/sysdeps/sh/sh4/fpu')
-rw-r--r-- | REORG.TODO/sysdeps/sh/sh4/fpu/fclrexcpt.c | 42 | ||||
-rw-r--r-- | REORG.TODO/sysdeps/sh/sh4/fpu/fedisblxcpt.c | 39 | ||||
-rw-r--r-- | REORG.TODO/sysdeps/sh/sh4/fpu/feenablxcpt.c | 38 | ||||
-rw-r--r-- | REORG.TODO/sysdeps/sh/sh4/fpu/fegetenv.c | 34 | ||||
-rw-r--r-- | REORG.TODO/sysdeps/sh/sh4/fpu/fegetexcept.c | 32 | ||||
-rw-r--r-- | REORG.TODO/sysdeps/sh/sh4/fpu/fegetmode.c | 27 | ||||
-rw-r--r-- | REORG.TODO/sysdeps/sh/sh4/fpu/fegetround.c | 35 | ||||
-rw-r--r-- | REORG.TODO/sysdeps/sh/sh4/fpu/feholdexcpt.c | 44 | ||||
-rw-r--r-- | REORG.TODO/sysdeps/sh/sh4/fpu/fesetenv.c | 36 | ||||
-rw-r--r-- | REORG.TODO/sysdeps/sh/sh4/fpu/fesetexcept.c | 32 | ||||
-rw-r--r-- | REORG.TODO/sysdeps/sh/sh4/fpu/fesetmode.c | 38 | ||||
-rw-r--r-- | REORG.TODO/sysdeps/sh/sh4/fpu/fesetround.c | 45 | ||||
-rw-r--r-- | REORG.TODO/sysdeps/sh/sh4/fpu/feupdateenv.c | 41 | ||||
-rw-r--r-- | REORG.TODO/sysdeps/sh/sh4/fpu/fgetexcptflg.c | 38 | ||||
-rw-r--r-- | REORG.TODO/sysdeps/sh/sh4/fpu/fraiseexcpt.c | 75 | ||||
-rw-r--r-- | REORG.TODO/sysdeps/sh/sh4/fpu/fsetexcptflg.c | 39 | ||||
-rw-r--r-- | REORG.TODO/sysdeps/sh/sh4/fpu/ftestexcept.c | 32 |
17 files changed, 667 insertions, 0 deletions
diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/fclrexcpt.c b/REORG.TODO/sysdeps/sh/sh4/fpu/fclrexcpt.c new file mode 100644 index 0000000000..5a430f6655 --- /dev/null +++ b/REORG.TODO/sysdeps/sh/sh4/fpu/fclrexcpt.c @@ -0,0 +1,42 @@ +/* Clear given exceptions in current floating-point environment. + Copyright (C) 1998-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Andreas Jaeger <aj@arthur.rhein-neckar.de>, 1998. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fpu_control.h> + +int +feclearexcept (int excepts) +{ + fpu_control_t cw; + + /* Mask out unsupported bits/exceptions. */ + excepts &= FE_ALL_EXCEPT; + + /* Read the complete control word. */ + _FPU_GETCW (cw); + + /* Clear exception bits. */ + cw &= ~excepts; + + /* Put the new data in effect. */ + _FPU_SETCW (cw); + + return 0; +} +libm_hidden_def (feclearexcept) diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/fedisblxcpt.c b/REORG.TODO/sysdeps/sh/sh4/fpu/fedisblxcpt.c new file mode 100644 index 0000000000..718ae70899 --- /dev/null +++ b/REORG.TODO/sysdeps/sh/sh4/fpu/fedisblxcpt.c @@ -0,0 +1,39 @@ +/* Disable floating-point exceptions. + Copyright (C) 2012-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Nobuhiro Iwamatsu <iwamatsu@nigauri.org>, 2012. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fpu_control.h> + +int +fedisableexcept (int excepts) +{ + fpu_control_t temp, old_exc; + + /* Get the current control register contents. */ + _FPU_GETCW (temp); + + old_exc = (temp >> 5) & FE_ALL_EXCEPT; + + excepts &= FE_ALL_EXCEPT; + + temp &= ~(excepts << 5); + _FPU_SETCW (temp); + + return old_exc; +} diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/feenablxcpt.c b/REORG.TODO/sysdeps/sh/sh4/fpu/feenablxcpt.c new file mode 100644 index 0000000000..d638714149 --- /dev/null +++ b/REORG.TODO/sysdeps/sh/sh4/fpu/feenablxcpt.c @@ -0,0 +1,38 @@ +/* Enable floating-point exceptions. + Copyright (C) 2012-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Nobuhiro Iwamatsu <iwamatsu@nigauri.org>, 2012. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fpu_control.h> + +int +feenableexcept (int excepts) +{ + fpu_control_t temp, old_flag; + + /* Get current exceptions. */ + _FPU_GETCW (temp); + + old_flag = (temp >> 5) & FE_ALL_EXCEPT; + excepts &= FE_ALL_EXCEPT; + + temp |= excepts << 5; + _FPU_SETCW (temp); + + return old_flag; +} diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/fegetenv.c b/REORG.TODO/sysdeps/sh/sh4/fpu/fegetenv.c new file mode 100644 index 0000000000..00945f1072 --- /dev/null +++ b/REORG.TODO/sysdeps/sh/sh4/fpu/fegetenv.c @@ -0,0 +1,34 @@ +/* Store current floating-point environment. + Copyright (C) 1997-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fpu_control.h> + +int +__fegetenv (fenv_t *envp) +{ + fpu_control_t temp; + _FPU_GETCW (temp); + + envp->__fpscr = temp; + + return 0; +} +libm_hidden_def (__fegetenv) +weak_alias (__fegetenv, fegetenv) +libm_hidden_weak (fegetenv) diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/fegetexcept.c b/REORG.TODO/sysdeps/sh/sh4/fpu/fegetexcept.c new file mode 100644 index 0000000000..4d1299e310 --- /dev/null +++ b/REORG.TODO/sysdeps/sh/sh4/fpu/fegetexcept.c @@ -0,0 +1,32 @@ +/* Get enabled floating-point exceptions. + Copyright (C) 2012-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Nobuhiro Iwamatsu <iwamatsu@nigauri.org>, 2012. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fpu_control.h> + +int +fegetexcept (void) +{ + fpu_control_t temp; + + /* Get current exceptions. */ + _FPU_GETCW (temp); + + return (temp >> 5) & FE_ALL_EXCEPT; +} diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/fegetmode.c b/REORG.TODO/sysdeps/sh/sh4/fpu/fegetmode.c new file mode 100644 index 0000000000..e839a9b25f --- /dev/null +++ b/REORG.TODO/sysdeps/sh/sh4/fpu/fegetmode.c @@ -0,0 +1,27 @@ +/* Store current floating-point control modes. SH4 version. + Copyright (C) 2016-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fpu_control.h> + +int +fegetmode (femode_t *modep) +{ + _FPU_GETCW (*modep); + return 0; +} diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/fegetround.c b/REORG.TODO/sysdeps/sh/sh4/fpu/fegetround.c new file mode 100644 index 0000000000..4c97d23e12 --- /dev/null +++ b/REORG.TODO/sysdeps/sh/sh4/fpu/fegetround.c @@ -0,0 +1,35 @@ +/* Return current rounding direction. + Copyright (C) 1998-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Andreas Jaeger <aj@arthur.rhein-neckar.de>, 1998. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fpu_control.h> + +int +__fegetround (void) +{ + fpu_control_t cw; + + /* Get control word. */ + _FPU_GETCW (cw); + + return cw & 0x1; +} +libm_hidden_def (__fegetround) +weak_alias (__fegetround, fegetround) +libm_hidden_weak (fegetround) diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/feholdexcpt.c b/REORG.TODO/sysdeps/sh/sh4/fpu/feholdexcpt.c new file mode 100644 index 0000000000..b905e594cd --- /dev/null +++ b/REORG.TODO/sysdeps/sh/sh4/fpu/feholdexcpt.c @@ -0,0 +1,44 @@ +/* Store current floating-point environment and clear exceptions. + Copyright (C) 1997-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fpu_control.h> + +int +__feholdexcept (fenv_t *envp) +{ + fpu_control_t temp; + + /* Store the environment. */ + _FPU_GETCW (temp); + envp->__fpscr = temp; + + /* Clear the status flags. */ + temp &= ~FE_ALL_EXCEPT; + + /* Now set all exceptions to non-stop. */ + temp &= ~(FE_ALL_EXCEPT << 5); + + _FPU_SETCW (temp); + + /* Success. */ + return 0; +} +libm_hidden_def (__feholdexcept) +weak_alias (__feholdexcept, feholdexcept) +libm_hidden_weak (feholdexcept) diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/fesetenv.c b/REORG.TODO/sysdeps/sh/sh4/fpu/fesetenv.c new file mode 100644 index 0000000000..8628c508e5 --- /dev/null +++ b/REORG.TODO/sysdeps/sh/sh4/fpu/fesetenv.c @@ -0,0 +1,36 @@ +/* Install given floating-point environment. + Copyright (C) 1997-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fpu_control.h> + +int +__fesetenv (const fenv_t *envp) +{ + if (envp == FE_DFL_ENV) + _FPU_SETCW (_FPU_DEFAULT); + else + { + fpu_control_t temp = envp->__fpscr; + _FPU_SETCW (temp); + } + return 0; +} +libm_hidden_def (__fesetenv) +weak_alias (__fesetenv, fesetenv) +libm_hidden_weak (fesetenv) diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/fesetexcept.c b/REORG.TODO/sysdeps/sh/sh4/fpu/fesetexcept.c new file mode 100644 index 0000000000..ecfad75fff --- /dev/null +++ b/REORG.TODO/sysdeps/sh/sh4/fpu/fesetexcept.c @@ -0,0 +1,32 @@ +/* Set given exception flags. SH4 version. + Copyright (C) 2016-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fpu_control.h> + +int +fesetexcept (int excepts) +{ + fpu_control_t temp; + + _FPU_GETCW (temp); + temp |= (excepts & FE_ALL_EXCEPT); + _FPU_SETCW (temp); + + return 0; +} diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/fesetmode.c b/REORG.TODO/sysdeps/sh/sh4/fpu/fesetmode.c new file mode 100644 index 0000000000..d2b9e05128 --- /dev/null +++ b/REORG.TODO/sysdeps/sh/sh4/fpu/fesetmode.c @@ -0,0 +1,38 @@ +/* Install given floating-point control modes. SH4 version. + Copyright (C) 2016-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fpu_control.h> + +#define FPU_STATUS 0x3f07c + +int +fesetmode (const femode_t *modep) +{ + fpu_control_t fpscr; + + _FPU_GETCW (fpscr); + fpscr &= FPU_STATUS; + if (modep == FE_DFL_MODE) + fpscr |= _FPU_DEFAULT; + else + fpscr |= *modep & ~FPU_STATUS; + _FPU_SETCW (fpscr); + + return 0; +} diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/fesetround.c b/REORG.TODO/sysdeps/sh/sh4/fpu/fesetround.c new file mode 100644 index 0000000000..20acb7c5e9 --- /dev/null +++ b/REORG.TODO/sysdeps/sh/sh4/fpu/fesetround.c @@ -0,0 +1,45 @@ +/* Set current rounding direction. + Copyright (C) 1998-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Andreas Jaeger <aj@arthur.rhein-neckar.de>, 1998. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fpu_control.h> + +int +__fesetround (int round) +{ + fpu_control_t cw; + + if ((round & ~0x1) != 0) + /* ROUND is no valid rounding mode. */ + return 1; + + /* Get current state. */ + _FPU_GETCW (cw); + + /* Set rounding bits. */ + cw &= ~0x1; + cw |= round; + /* Set new state. */ + _FPU_SETCW (cw); + + return 0; +} +libm_hidden_def (__fesetround) +weak_alias (__fesetround, fesetround) +libm_hidden_weak (fesetround) diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/feupdateenv.c b/REORG.TODO/sysdeps/sh/sh4/fpu/feupdateenv.c new file mode 100644 index 0000000000..3b886a2235 --- /dev/null +++ b/REORG.TODO/sysdeps/sh/sh4/fpu/feupdateenv.c @@ -0,0 +1,41 @@ +/* Install given floating-point environment and raise exceptions. + Copyright (C) 2012-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Nobuhiro Iwamatsu <iwamatsu@nigauri.org>, 2012. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fpu_control.h> + +int +__feupdateenv (const fenv_t *envp) +{ + fpu_control_t temp; + + _FPU_GETCW (temp); + temp = (temp & FE_ALL_EXCEPT); + + /* 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. */ + __fesetenv (envp); + __feraiseexcept ((int) temp); + + return 0; +} +libm_hidden_def (__feupdateenv) +weak_alias (__feupdateenv, feupdateenv) +libm_hidden_weak (feupdateenv) diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/fgetexcptflg.c b/REORG.TODO/sysdeps/sh/sh4/fpu/fgetexcptflg.c new file mode 100644 index 0000000000..02fc3948bc --- /dev/null +++ b/REORG.TODO/sysdeps/sh/sh4/fpu/fgetexcptflg.c @@ -0,0 +1,38 @@ +/* Store current representation for exceptions. + Copyright (C) 2013-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fpu_control.h> + +int +fegetexceptflag (fexcept_t *flagp, int excepts) +{ + fpu_control_t temp; + + /* Get the current exceptions. */ + _FPU_GETCW (temp); + + /* We only save the relevant bits here. In particular, care has to be + taken with the CAUSE bits, as an inadvertent restore later on could + generate unexpected exceptions. */ + + *flagp = temp & excepts & FE_ALL_EXCEPT; + + /* Success. */ + return 0; +} diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/fraiseexcpt.c b/REORG.TODO/sysdeps/sh/sh4/fpu/fraiseexcpt.c new file mode 100644 index 0000000000..4bd0eb9ef5 --- /dev/null +++ b/REORG.TODO/sysdeps/sh/sh4/fpu/fraiseexcpt.c @@ -0,0 +1,75 @@ +/* Raise given exceptions. + Copyright (C) 1997-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Nobuhiro Iwamatsu <iwamatsu@nigauri.org>, 2012. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <float.h> +#include <fpu_control.h> +#include <math.h> + +int +__feraiseexcept (int excepts) +{ + if (excepts == 0) + return 0; + + /* Raise exceptions represented by EXPECTS. */ + + if (excepts & FE_INEXACT) + { + double d = 1.0, x = 3.0; + __asm__ __volatile__ ("fdiv %1, %0" : "+d" (d) : "d" (x)); + } + + if (excepts & FE_UNDERFLOW) + { + long double d = LDBL_MIN, x = 10; + __asm__ __volatile__ ("fdiv %1, %0" : "+d" (d) : "d" (x)); + } + + if (excepts & FE_OVERFLOW) + { + long double d = LDBL_MAX; + __asm__ __volatile__ ("fmul %0, %0" : "+d" (d) : "d" (d)); + } + + if (excepts & FE_DIVBYZERO) + { + double d = 1.0, x = 0.0; + __asm__ __volatile__ ("fdiv %1, %0" : "+d" (d) : "d" (x)); + } + + if (excepts & FE_INVALID) + { + double d = HUGE_VAL, x = 0.0; + __asm__ __volatile__ ("fmul %1, %0" : "+d" (d) : "d" (x)); + } + + { + /* Restore flag fields. */ + fpu_control_t cw; + _FPU_GETCW (cw); + cw |= (excepts & FE_ALL_EXCEPT); + _FPU_SETCW (cw); + } + + return 0; +} +libm_hidden_def (__feraiseexcept) +weak_alias (__feraiseexcept, feraiseexcept) +libm_hidden_weak (feraiseexcept) diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/fsetexcptflg.c b/REORG.TODO/sysdeps/sh/sh4/fpu/fsetexcptflg.c new file mode 100644 index 0000000000..3a6ea33c26 --- /dev/null +++ b/REORG.TODO/sysdeps/sh/sh4/fpu/fsetexcptflg.c @@ -0,0 +1,39 @@ +/* Set floating-point environment exception handling. + Copyright (C) 1997-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <math.h> +#include <fpu_control.h> + +int +fesetexceptflag (const fexcept_t *flagp, int excepts) +{ + fpu_control_t temp; + + /* Get the current environment. */ + _FPU_GETCW (temp); + + /* Set the desired exception mask. */ + temp &= ~(excepts & FE_ALL_EXCEPT); + temp |= (*flagp & excepts & FE_ALL_EXCEPT); + + /* Save state back to the FPU. */ + _FPU_SETCW (temp); + + return 0; +} diff --git a/REORG.TODO/sysdeps/sh/sh4/fpu/ftestexcept.c b/REORG.TODO/sysdeps/sh/sh4/fpu/ftestexcept.c new file mode 100644 index 0000000000..fa2c011825 --- /dev/null +++ b/REORG.TODO/sysdeps/sh/sh4/fpu/ftestexcept.c @@ -0,0 +1,32 @@ +/* Test exception in current environment. + Copyright (C) 1997-2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <fenv.h> +#include <fpu_control.h> + +int +fetestexcept (int excepts) +{ + fpu_control_t temp; + + /* Get current exceptions. */ + _FPU_GETCW (temp); + + return temp & excepts & FE_ALL_EXCEPT; +} +libm_hidden_def (fetestexcept) |