summaryrefslogtreecommitdiffstats
path: root/lib/libc/sparc64/gen/fpsetround.c
diff options
context:
space:
mode:
authortmm <tmm@FreeBSD.org>2002-09-14 18:06:21 +0000
committertmm <tmm@FreeBSD.org>2002-09-14 18:06:21 +0000
commit6bea77d590307633b95e834cc12e81d7c2dfbb86 (patch)
treee57beed0d3e33cdd96593d665a5d3d8fd13cb79e /lib/libc/sparc64/gen/fpsetround.c
parent69c3f107e2c8a2eef56249a87c8e192d8f6abe5c (diff)
downloadFreeBSD-src-6bea77d590307633b95e834cc12e81d7c2dfbb86.zip
FreeBSD-src-6bea77d590307633b95e834cc12e81d7c2dfbb86.tar.gz
Add implementations of fpgetmask(), fpgetround(), fpgetsticky(),
fpsetround(), fpsetsticky(), obtained from NetBSD and tweaked a little to use definitions from machine/fsr.h instead of magic numbers.
Diffstat (limited to 'lib/libc/sparc64/gen/fpsetround.c')
-rw-r--r--lib/libc/sparc64/gen/fpsetround.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/libc/sparc64/gen/fpsetround.c b/lib/libc/sparc64/gen/fpsetround.c
new file mode 100644
index 0000000..1e27f59
--- /dev/null
+++ b/lib/libc/sparc64/gen/fpsetround.c
@@ -0,0 +1,30 @@
+/* $NetBSD: fpsetround.c,v 1.2 2002/01/13 21:45:51 thorpej Exp $ */
+
+/*
+ * Written by J.T. Conklin, Apr 10, 1995
+ * Public domain.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <machine/fsr.h>
+#include <ieeefp.h>
+
+fp_rnd_t
+fpsetround(rnd_dir)
+ fp_rnd_t rnd_dir;
+{
+ unsigned int old;
+ unsigned int new;
+
+ __asm__("st %%fsr,%0" : "=m" (old));
+
+ new = old;
+ new &= ~FSR_RD_MASK;
+ new |= FSR_RD((unsigned int)rnd_dir & 0x03);
+
+ __asm__("ld %0,%%fsr" : : "m" (new));
+
+ return ((fp_rnd_t)FSR_GET_RD(old));
+}
OpenPOWER on IntegriCloud