aboutsummaryrefslogtreecommitdiff
path: root/REORG.TODO/sysdeps/sh/sh4
diff options
context:
space:
mode:
Diffstat (limited to 'REORG.TODO/sysdeps/sh/sh4')
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/Makefile3
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/Versions5
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/__longjmp.S73
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/dl-trampoline.S4
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/fclrexcpt.c42
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/fedisblxcpt.c39
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/feenablxcpt.c38
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/fegetenv.c34
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/fegetexcept.c32
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/fegetmode.c27
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/fegetround.c35
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/feholdexcpt.c44
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/fesetenv.c36
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/fesetexcept.c32
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/fesetmode.c38
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/fesetround.c45
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/feupdateenv.c41
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/fgetexcptflg.c38
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/fraiseexcpt.c75
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/fsetexcptflg.c39
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/fpu/ftestexcept.c32
-rw-r--r--REORG.TODO/sysdeps/sh/sh4/setjmp.S90
22 files changed, 842 insertions, 0 deletions
diff --git a/REORG.TODO/sysdeps/sh/sh4/Makefile b/REORG.TODO/sysdeps/sh/sh4/Makefile
new file mode 100644
index 0000000000..ccac91432a
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh4/Makefile
@@ -0,0 +1,3 @@
+# Build everything with full IEEE math support. -mieee isn't
+# default for the older SH compilers.
+sysdep-CFLAGS += -mieee
diff --git a/REORG.TODO/sysdeps/sh/sh4/Versions b/REORG.TODO/sysdeps/sh/sh4/Versions
new file mode 100644
index 0000000000..8cc1c7b7d4
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh4/Versions
@@ -0,0 +1,5 @@
+ld {
+ GLIBC_PRIVATE {
+ __fpscr_values;
+ }
+}
diff --git a/REORG.TODO/sysdeps/sh/sh4/__longjmp.S b/REORG.TODO/sysdeps/sh/sh4/__longjmp.S
new file mode 100644
index 0000000000..2a5c25da32
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh4/__longjmp.S
@@ -0,0 +1,73 @@
+/* longjmp for SH.
+ Copyright (C) 1999-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 <sysdep.h>
+#define _SETJMP_H
+#define _ASM
+#include <bits/setjmp.h>
+
+/* __longjmp(jmpbuf, val) */
+
+ENTRY (__longjmp)
+ mov.l @r4+, r8
+ mov.l @r4+, r9
+ mov.l @r4+, r10
+ mov.l @r4+, r11
+ mov.l @r4+, r12
+ mov r5, r0 /* get the return value in place */
+ tst r0, r0
+ bf.s 1f
+ mov.l @r4+, r13
+ mov #1,r0 /* can't let setjmp() return zero! */
+1:
+#ifdef PTR_DEMANGLE
+ mov.l @r4+, r2
+ PTR_DEMANGLE (r2, r1)
+ mov r2, r14
+ mov.l @r4+, r2
+ PTR_DEMANGLE2 (r2, r1)
+# ifdef CHECK_SP
+ CHECK_SP (r2)
+# endif
+ mov r2, r15
+ mov.l @r4+, r2
+ PTR_DEMANGLE2 (r2, r1)
+ lds r2, pr
+ mov #0, r1
+#else
+ mov.l @r4+, r14
+# ifdef CHECK_SP
+ mov.l @r4, r2
+ CHECK_SP (r2)
+# endif
+ mov.l @r4+, r15
+ lds.l @r4+, pr
+#endif
+#ifdef __SH_FPU_ANY__
+ ldc.l @r4+, gbr
+ lds.l @r4+, fpscr
+ fmov.s @r4+, fr12
+ fmov.s @r4+, fr13
+ fmov.s @r4+, fr14
+ rts
+ fmov.s @r4+, fr15
+#else
+ rts
+ ldc.l @r4+, gbr
+#endif /* !__SH_FPU_ANY__ */
+END (__longjmp)
diff --git a/REORG.TODO/sysdeps/sh/sh4/dl-trampoline.S b/REORG.TODO/sysdeps/sh/sh4/dl-trampoline.S
new file mode 100644
index 0000000000..bd9bb7e5bd
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh4/dl-trampoline.S
@@ -0,0 +1,4 @@
+#ifdef __SH_FPU_ANY__
+# define HAVE_FPU
+#endif
+#include <sysdeps/sh/dl-trampoline.S>
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)
diff --git a/REORG.TODO/sysdeps/sh/sh4/setjmp.S b/REORG.TODO/sysdeps/sh/sh4/setjmp.S
new file mode 100644
index 0000000000..a09ffab627
--- /dev/null
+++ b/REORG.TODO/sysdeps/sh/sh4/setjmp.S
@@ -0,0 +1,90 @@
+/* setjmp for SH4.
+ Copyright (C) 1999-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 <sysdep.h>
+#include <jmpbuf-offsets.h>
+
+ENTRY (__sigsetjmp)
+ /* Save registers */
+#ifdef __SH_FPU_ANY__
+ add #JB_SIZE, r4
+ fmov.s fr15, @-r4
+ fmov.s fr14, @-r4
+ fmov.s fr13, @-r4
+ fmov.s fr12, @-r4
+ sts.l fpscr, @-r4
+#else
+ add #(JB_SIZE - 4 * 5), r4
+#endif /* __SH_FPU_ANY__ */
+ stc.l gbr, @-r4
+#ifdef PTR_MANGLE
+ sts pr, r2
+ PTR_MANGLE (r2, r1)
+ mov.l r2, @-r4
+ mov r15, r2
+ PTR_MANGLE2 (r2, r1)
+ mov.l r2, @-r4
+ mov r14, r2
+ PTR_MANGLE2 (r2, r1)
+ mov.l r2, @-r4
+ mov #0, r1
+#else
+ sts.l pr, @-r4
+ mov.l r15, @-r4
+ mov.l r14, @-r4
+#endif
+ mov.l r13, @-r4
+ mov.l r12, @-r4
+ mov.l r11, @-r4
+ mov.l r10, @-r4
+ mov.l r9, @-r4
+ mov.l r8, @-r4
+
+#if IS_IN (rtld)
+ /* In ld.so we never save the signal mask. */
+ rts
+ mov #0, r0
+#else
+ /* Make a tail call to __sigjmp_save; it takes the same args. */
+# ifdef SHARED
+ mov.l 1f, r1
+ mova 1f, r0
+ bra 2f
+ add r1, r0
+ .align 2
+1:
+ .long _GLOBAL_OFFSET_TABLE_
+2:
+ mov.l .L1, r1
+ mov.l @(r0,r1), r1
+ jmp @r1
+ nop
+ .align 2
+.L1:
+ .long C_SYMBOL_NAME(__sigjmp_save@GOT)
+# else
+ mov.l .L1, r1
+ jmp @r1
+ nop
+ .align 2
+.L1:
+ .long C_SYMBOL_NAME(__sigjmp_save)
+# endif
+#endif
+END (__sigsetjmp)
+hidden_def (__sigsetjmp)