summaryrefslogtreecommitdiff
path: root/lib/libc/alpha/gen/fpsetround.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/alpha/gen/fpsetround.c')
-rw-r--r--lib/libc/alpha/gen/fpsetround.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/libc/alpha/gen/fpsetround.c b/lib/libc/alpha/gen/fpsetround.c
index 0d8f40af6d651..c28093cad87c1 100644
--- a/lib/libc/alpha/gen/fpsetround.c
+++ b/lib/libc/alpha/gen/fpsetround.c
@@ -33,7 +33,6 @@
#include <sys/types.h>
#include <ieeefp.h>
-#include <machine/fpu.h>
fp_rnd
fpsetround(rnd_dir)
@@ -42,14 +41,18 @@ fpsetround(rnd_dir)
double fpcrval;
u_int64_t old, new;
- GET_FPCR(fpcrval);
+ __asm__("trapb");
+ __asm__("mf_fpcr %0" : "=f" (fpcrval));
+ __asm__("trapb");
old = *(u_int64_t *)&fpcrval;
- new = old & (~FPCR_DYN_MASK);
- new |= ((long) rnd_dir << FPCR_DYN_SHIFT) & FPCR_DYN_MASK;
-
+ new = old & ~(long)0x0c00000000000000;
+ new = (long)rnd_dir << 58;
*(u_int64_t *)&fpcrval = new;
- SET_FPCR(fpcrval);
- return ((old & FPCR_DYN_MASK) >> FPCR_DYN_SHIFT);
+ __asm__("trapb");
+ __asm__("mt_fpcr %0" : : "f" (fpcrval));
+ __asm__("trapb");
+
+ return ((old >> 58) & 0x3);
}