summaryrefslogtreecommitdiff
path: root/libm
diff options
context:
space:
mode:
Diffstat (limited to 'libm')
-rw-r--r--libm/m68k/Makefile.arch16
-rw-r--r--libm/m68k/fclrexcpt.c39
-rw-r--r--libm/m68k/fedisblxcpt.c36
-rw-r--r--libm/m68k/feenablxcpt.c36
-rw-r--r--libm/m68k/fegetenv.c33
-rw-r--r--libm/m68k/fegetexcept.c29
-rw-r--r--libm/m68k/fegetmode.c26
-rw-r--r--libm/m68k/fegetround.c28
-rw-r--r--libm/m68k/feholdexcpt.c42
-rw-r--r--libm/m68k/fesetenv.c63
-rw-r--r--libm/m68k/fesetexcept.c30
-rw-r--r--libm/m68k/fesetmode.c31
-rw-r--r--libm/m68k/fesetround.c35
-rw-r--r--libm/m68k/feupdateenv.c39
-rw-r--r--libm/m68k/fgetexcptflg.c32
-rw-r--r--libm/m68k/fraiseexcpt.c106
-rw-r--r--libm/m68k/fsetexcptflg.c38
-rw-r--r--libm/m68k/ftestexcept.c29
-rw-r--r--libm/or1k/Makefile.arch16
-rw-r--r--libm/or1k/fclrexcpt.c42
-rw-r--r--libm/or1k/fegetenv.c28
-rw-r--r--libm/or1k/fegetmode.c28
-rw-r--r--libm/or1k/fegetround.c25
-rw-r--r--libm/or1k/feholdexcpt.c29
-rw-r--r--libm/or1k/fenv_private.h196
-rw-r--r--libm/or1k/fesetenv.c28
-rw-r--r--libm/or1k/fesetexcept.c34
-rw-r--r--libm/or1k/fesetmode.c38
-rw-r--r--libm/or1k/fesetround.c35
-rw-r--r--libm/or1k/feupdateenv.c29
-rw-r--r--libm/or1k/fgetexcptflg.c28
-rw-r--r--libm/or1k/fraiseexcpt.c63
-rw-r--r--libm/or1k/fsetexcptflg.c42
-rw-r--r--libm/or1k/ftestexcept.c25
-rw-r--r--libm/or1k/get-rounding-mode.h36
-rw-r--r--libm/riscv32/Makefile.arch16
-rw-r--r--libm/riscv32/fclrexcpt.c26
-rw-r--r--libm/riscv32/fegetenv.c28
-rw-r--r--libm/riscv32/fegetmode.c26
-rw-r--r--libm/riscv32/fegetround.c25
-rw-r--r--libm/riscv32/feholdexcpt.c26
-rw-r--r--libm/riscv32/fenv_private.h156
-rw-r--r--libm/riscv32/fesetenv.c26
-rw-r--r--libm/riscv32/fesetexcept.c25
-rw-r--r--libm/riscv32/fesetmode.c30
-rw-r--r--libm/riscv32/fesetround.c35
-rw-r--r--libm/riscv32/feupdateenv.c26
-rw-r--r--libm/riscv32/fgetexcptflg.c29
-rw-r--r--libm/riscv32/fraiseexcpt.c26
-rw-r--r--libm/riscv32/fsetexcptflg.c29
-rw-r--r--libm/riscv32/ftestexcept.c25
-rw-r--r--libm/riscv32/get-rounding-mode.h32
-rw-r--r--libm/riscv64/Makefile.arch16
-rw-r--r--libm/riscv64/fclrexcpt.c26
-rw-r--r--libm/riscv64/fegetenv.c28
-rw-r--r--libm/riscv64/fegetmode.c26
-rw-r--r--libm/riscv64/fegetround.c25
-rw-r--r--libm/riscv64/feholdexcpt.c26
-rw-r--r--libm/riscv64/fenv_private.h156
-rw-r--r--libm/riscv64/fesetenv.c26
-rw-r--r--libm/riscv64/fesetexcept.c25
-rw-r--r--libm/riscv64/fesetmode.c30
-rw-r--r--libm/riscv64/fesetround.c35
-rw-r--r--libm/riscv64/feupdateenv.c26
-rw-r--r--libm/riscv64/fgetexcptflg.c29
-rw-r--r--libm/riscv64/fraiseexcpt.c26
-rw-r--r--libm/riscv64/fsetexcptflg.c29
-rw-r--r--libm/riscv64/ftestexcept.c25
-rw-r--r--libm/riscv64/get-rounding-mode.h32
-rw-r--r--libm/sparc/Makefile.arch16
-rw-r--r--libm/sparc/fclrexcpt.c34
-rw-r--r--libm/sparc/fedisblxcpt.c34
-rw-r--r--libm/sparc/feenablxcpt.c34
-rw-r--r--libm/sparc/fegetenv.c28
-rw-r--r--libm/sparc/fegetexcept.c28
-rw-r--r--libm/sparc/fegetmode.c26
-rw-r--r--libm/sparc/fegetround.c29
-rw-r--r--libm/sparc/feholdexcpt.c34
-rw-r--r--libm/sparc/fenv_private.h187
-rw-r--r--libm/sparc/fesetenv.c45
-rw-r--r--libm/sparc/fesetexcept.c31
-rw-r--r--libm/sparc/fesetmode.c38
-rw-r--r--libm/sparc/fesetround.c36
-rw-r--r--libm/sparc/feupdateenv.c40
-rw-r--r--libm/sparc/fgetexcptflg.c33
-rw-r--r--libm/sparc/fpu_control.h75
-rw-r--r--libm/sparc/fraiseexcpt.c81
-rw-r--r--libm/sparc/fsetexcptflg.c36
-rw-r--r--libm/sparc/ftestexcept.c29
-rw-r--r--libm/sparc/math-barriers.h36
90 files changed, 3512 insertions, 0 deletions
diff --git a/libm/m68k/Makefile.arch b/libm/m68k/Makefile.arch
new file mode 100644
index 000000000..bd38690be
--- /dev/null
+++ b/libm/m68k/Makefile.arch
@@ -0,0 +1,16 @@
+# Makefile for uClibc-ng
+# Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
+
+ifeq ($(UCLIBC_HAS_FENV),y)
+libm_ARCH_SRC:=$(wildcard $(libm_ARCH_DIR)/*.c)
+libm_ARCH_OBJ:=$(patsubst $(libm_ARCH_DIR)/%.c,$(libm_ARCH_OUT)/%.o,$(libm_ARCH_SRC))
+endif
+
+libm_ARCH_OBJS:=$(libm_ARCH_OBJ)
+
+ifeq ($(DOPIC),y)
+libm-a-y+=$(libm_ARCH_OBJS:.o=.os)
+else
+libm-a-y+=$(libm_ARCH_OBJS)
+endif
+libm-so-y+=$(libm_ARCH_OBJS:.o=.os)
diff --git a/libm/m68k/fclrexcpt.c b/libm/m68k/fclrexcpt.c
new file mode 100644
index 000000000..904ba5a19
--- /dev/null
+++ b/libm/m68k/fclrexcpt.c
@@ -0,0 +1,39 @@
+/* Clear given exceptions in current floating-point environment.
+ Copyright (C) 1997-2025 Free Software Foundation, Inc.
+
+ 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
+ <https://www.gnu.org/licenses/>. */
+
+#include <fenv.h>
+
+int
+feclearexcept (int excepts)
+{
+ fexcept_t fpsr;
+
+ /* Mask out unsupported bits/exceptions. */
+ excepts &= FE_ALL_EXCEPT;
+
+ /* Fetch the fpu status register. */
+ __asm__ ("fmove%.l %/fpsr,%0" : "=dm" (fpsr));
+
+ /* Clear the relevant bits. */
+ fpsr &= ~excepts;
+
+ /* Put the new data in effect. */
+ __asm__ __volatile__ ("fmove%.l %0,%/fpsr" : : "dm" (fpsr));
+
+ /* Success. */
+ return 0;
+}
diff --git a/libm/m68k/fedisblxcpt.c b/libm/m68k/fedisblxcpt.c
new file mode 100644
index 000000000..c2c593e38
--- /dev/null
+++ b/libm/m68k/fedisblxcpt.c
@@ -0,0 +1,36 @@
+/* Disable floating-point exceptions.
+ Copyright (C) 2000-2025 Free Software Foundation, Inc.
+
+ 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
+ <https://www.gnu.org/licenses/>. */
+
+#include <fenv.h>
+
+int
+fedisableexcept (int excepts)
+{
+ unsigned int old_exc, new_exc;
+
+ /* Get the current control register contents. */
+ __asm__ ("fmove%.l %!,%0" : "=dm" (new_exc));
+
+ old_exc = (new_exc >> 6) & FE_ALL_EXCEPT;
+
+ excepts &= FE_ALL_EXCEPT;
+
+ new_exc &= ~(excepts << 6);
+ __asm__ ("fmove%.l %0,%!" : : "dm" (new_exc));
+
+ return old_exc;
+}
diff --git a/libm/m68k/feenablxcpt.c b/libm/m68k/feenablxcpt.c
new file mode 100644
index 000000000..9c01dc28b
--- /dev/null
+++ b/libm/m68k/feenablxcpt.c
@@ -0,0 +1,36 @@
+/* Enable floating-point exceptions.
+ Copyright (C) 2000-2025 Free Software Foundation, Inc.
+
+ 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
+ <https://www.gnu.org/licenses/>. */
+
+#include <fenv.h>
+
+int
+feenableexcept (int excepts)
+{
+ unsigned int new_exc, old_exc;
+
+ /* Get the current control register contents. */
+ __asm__ ("fmove%.l %!,%0" : "=dm" (new_exc));
+
+ old_exc = (new_exc >> 6) & FE_ALL_EXCEPT;
+
+ excepts &= FE_ALL_EXCEPT;
+
+ new_exc |= excepts << 6;
+ __asm__ ("fmove%.l %0,%!" : : "dm" (new_exc));
+
+ return old_exc;
+}
diff --git a/libm/m68k/fegetenv.c b/libm/m68k/fegetenv.c
new file mode 100644
index 000000000..2cd0a7c88
--- /dev/null
+++ b/libm/m68k/fegetenv.c
@@ -0,0 +1,33 @@
+/* Store current floating-point environment.
+ Copyright (C) 1997-2025 Free Software Foundation, Inc.
+
+ 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
+ <https://www.gnu.org/licenses/>. */
+
+#include <fenv.h>
+
+int
+fegetenv (fenv_t *envp)
+{
+#ifdef __mcoldfire__
+ __asm__ ("fmove%.l %/fpcr,%0" : "=dm" (envp->__control_register));
+ __asm__ ("fmove%.l %/fpsr,%0" : "=dm" (envp->__status_register));
+ __asm__ ("fmove%.l %/fpiar,%0" : "=dm" (envp->__instruction_address));
+#else
+ __asm__ ("fmovem%.l %/fpcr/%/fpsr/%/fpiar,%0" : "=m" (*envp));
+#endif
+
+ /* Success. */
+ return 0;
+}
diff --git a/libm/m68k/fegetexcept.c b/libm/m68k/fegetexcept.c
new file mode 100644
index 000000000..1be3f8bf5
--- /dev/null
+++ b/libm/m68k/fegetexcept.c
@@ -0,0 +1,29 @@
+/* Get enabled floating-point exceptions.
+ Copyright (C) 2000-2025 Free Software Foundation, Inc.
+
+ 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
+ <https://www.gnu.org/licenses/>. */
+
+#include <fenv.h>
+
+int
+fegetexcept (void)
+{
+ unsigned int exc;
+
+ /* Get the current control register contents. */
+ __asm__ ("fmove%.l %!,%0" : "=dm" (exc));
+
+ return (exc >> 6) & FE_ALL_EXCEPT;
+}
diff --git a/libm/m68k/fegetmode.c b/libm/m68k/fegetmode.c
new file mode 100644
index 000000000..19f49922a
--- /dev/null
+++ b/libm/m68k/fegetmode.c
@@ -0,0 +1,26 @@
+/* Store current floating-point control modes. M68K version.
+ Copyright (C) 2016-2025 Free Software Foundation, Inc.
+
+ 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
+ <https://www.gnu.org/licenses/>. */
+
+#include <fenv.h>
+#include <fpu_control.h>
+
+int
+fegetmode (femode_t *modep)
+{
+ _FPU_GETCW (*modep);
+ return 0;
+}
diff --git a/libm/m68k/fegetround.c b/libm/m68k/fegetround.c
new file mode 100644
index 000000000..02f6c4c41
--- /dev/null
+++ b/libm/m68k/fegetround.c
@@ -0,0 +1,28 @@
+/* Return current rounding direction.
+ Copyright (C) 1997-2025 Free Software Foundation, Inc.
+
+ 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
+ <https://www.gnu.org/licenses/>. */
+
+#include <fenv.h>
+
+int
+fegetround (void)
+{
+ int fpcr;
+
+ __asm__ ("fmove%.l %!,%0" : "=dm" (fpcr));
+
+ return fpcr & FE_UPWARD;
+}
diff --git a/libm/m68k/feholdexcpt.c b/libm/m68k/feholdexcpt.c
new file mode 100644
index 000000000..c0891969a
--- /dev/null
+++ b/libm/m68k/feholdexcpt.c
@@ -0,0 +1,42 @@
+/* Store current floating-point environment and clear exceptions.
+ Copyright (C) 1997-2025 Free Software Foundation, Inc.
+
+ 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
+ <https://www.gnu.org/licenses/>. */
+
+#include <fenv.h>
+
+int
+feholdexcept (fenv_t *envp)
+{
+ fexcept_t fpcr, fpsr;
+
+ /* Store the environment. */
+#ifdef __mcoldfire__
+ __asm__ ("fmove%.l %/fpcr,%0" : "=dm" (envp->__control_register));
+ __asm__ ("fmove%.l %/fpsr,%0" : "=dm" (envp->__status_register));
+ __asm__ ("fmove%.l %/fpiar,%0" : "=dm" (envp->__instruction_address));
+#else
+ __asm__ ("fmovem%.l %/fpcr/%/fpsr/%/fpiar,%0" : "=m" (*envp));
+#endif
+
+ /* Now clear all exceptions. */
+ fpsr = envp->__status_register & ~FE_ALL_EXCEPT;
+ __asm__ __volatile__ ("fmove%.l %0,%/fpsr" : : "dm" (fpsr));
+ /* And set all exceptions to non-stop. */
+ fpcr = envp->__control_register & ~(FE_ALL_EXCEPT << 6);
+ __asm__ __volatile__ ("fmove%.l %0,%!" : : "dm" (fpcr));
+
+ return 0;
+}
diff --git a/libm/m68k/fesetenv.c b/libm/m68k/fesetenv.c
new file mode 100644
index 000000000..873eb9abe
--- /dev/null
+++ b/libm/m68k/fesetenv.c
@@ -0,0 +1,63 @@
+/* Install given floating-point environment.
+ Copyright (C) 1997-2025 Free Software Foundation, Inc.
+
+ 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
+ <https://www.gnu.org/licenses/>. */
+
+#include <fenv.h>
+
+int
+fesetenv (const fenv_t *envp)
+{
+ fenv_t temp;
+
+ /* Install the environment specified by ENVP. But there are a few
+ values which we do not want to come from the saved environment.
+ Therefore, we get the current environment and replace the values
+ we want to use from the environment specified by the parameter. */
+#ifdef __mcoldfire__
+ __asm__ ("fmove%.l %/fpcr,%0" : "=dm" (temp.__control_register));
+ __asm__ ("fmove%.l %/fpsr,%0" : "=dm" (temp.__status_register));
+ __asm__ ("fmove%.l %/fpiar,%0" : "=dm" (temp.__instruction_address));
+#else
+ __asm__ ("fmovem%.l %/fpcr/%/fpsr/%/fpiar,%0" : "=m" (*&temp));
+#endif
+
+ temp.__status_register &= ~FE_ALL_EXCEPT;
+ temp.__control_register &= ~((FE_ALL_EXCEPT << 6) | FE_UPWARD);
+ if (envp == FE_DFL_ENV)
+ ;
+ else if (envp == FE_NOMASK_ENV)
+ temp.__control_register |= FE_ALL_EXCEPT << 6;
+ else
+ {
+ temp.__control_register |= (envp->__control_register
+ & ((FE_ALL_EXCEPT << 6) | FE_UPWARD));
+ temp.__status_register |= envp->__status_register & FE_ALL_EXCEPT;
+ }
+
+#ifdef __mcoldfire__
+ __asm__ __volatile__ ("fmove%.l %0,%/fpiar"
+ :: "dm" (temp.__instruction_address));
+ __asm__ __volatile__ (