summaryrefslogtreecommitdiffstats
path: root/libc-top-half/musl/src/fenv/sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 13:54:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 13:54:38 +0000
commit8c1ab65c0f548d20b7f177bdb736daaf603340e1 (patch)
treedf55b7e75bf43f2bf500845b105afe3ac3a5157e /libc-top-half/musl/src/fenv/sh
parentInitial commit. (diff)
downloadwasi-libc-8c1ab65c0f548d20b7f177bdb736daaf603340e1.tar.xz
wasi-libc-8c1ab65c0f548d20b7f177bdb736daaf603340e1.zip
Adding upstream version 0.0~git20221206.8b7148f.upstream/0.0_git20221206.8b7148f
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libc-top-half/musl/src/fenv/sh')
-rw-r--r--libc-top-half/musl/src/fenv/sh/fenv-nofpu.c3
-rw-r--r--libc-top-half/musl/src/fenv/sh/fenv.S81
2 files changed, 84 insertions, 0 deletions
diff --git a/libc-top-half/musl/src/fenv/sh/fenv-nofpu.c b/libc-top-half/musl/src/fenv/sh/fenv-nofpu.c
new file mode 100644
index 0000000..b2495a6
--- /dev/null
+++ b/libc-top-half/musl/src/fenv/sh/fenv-nofpu.c
@@ -0,0 +1,3 @@
+#if !__SH_FPU_ANY__ && !__SH4__
+#include "../fenv.c"
+#endif
diff --git a/libc-top-half/musl/src/fenv/sh/fenv.S b/libc-top-half/musl/src/fenv/sh/fenv.S
new file mode 100644
index 0000000..b3b7d66
--- /dev/null
+++ b/libc-top-half/musl/src/fenv/sh/fenv.S
@@ -0,0 +1,81 @@
+#if __SH_FPU_ANY__ || __SH4__
+
+.global fegetround
+.type fegetround, @function
+fegetround:
+ sts fpscr, r0
+ rts
+ and #3, r0
+
+.global __fesetround
+.hidden __fesetround
+.type __fesetround, @function
+__fesetround:
+ sts fpscr, r0
+ mov #-4, r1
+ and r1, r0
+ or r4, r0
+ lds r0, fpscr
+ rts
+ mov #0, r0
+
+.global fetestexcept
+.type fetestexcept, @function
+fetestexcept:
+ sts fpscr, r0
+ and r4, r0
+ rts
+ and #0x7c, r0
+
+.global feclearexcept
+.type feclearexcept, @function
+feclearexcept:
+ mov r4, r0
+ and #0x7c, r0
+ not r0, r4
+ sts fpscr, r0
+ and r4, r0
+ lds r0, fpscr
+ rts
+ mov #0, r0
+
+.global feraiseexcept
+.type feraiseexcept, @function
+feraiseexcept:
+ mov r4, r0
+ and #0x7c, r0
+ sts fpscr, r4
+ or r4, r0
+ lds r0, fpscr
+ rts
+ mov #0, r0
+
+.global fegetenv
+.type fegetenv, @function
+fegetenv:
+ sts fpscr, r0
+ mov.l r0, @r4
+ rts
+ mov #0, r0
+
+.global fesetenv
+.type fesetenv, @function
+fesetenv:
+ mov r4, r0
+ cmp/eq #-1, r0
+ bf 1f
+
+ ! the default environment is complicated by the fact that we need to
+ ! preserve the current precision bit, which we do not know a priori
+ sts fpscr, r0
+ mov #8, r1
+ swap.w r1, r1
+ bra 2f
+ and r1, r0
+
+1: mov.l @r4, r0 ! non-default environment
+2: lds r0, fpscr
+ rts
+ mov #0, r0
+
+#endif