summaryrefslogtreecommitdiff
path: root/emu/Nt/fp.c
diff options
context:
space:
mode:
authorCharles.Forsyth <devnull@localhost>2006-12-22 17:07:39 +0000
committerCharles.Forsyth <devnull@localhost>2006-12-22 17:07:39 +0000
commit37da2899f40661e3e9631e497da8dc59b971cbd0 (patch)
treecbc6d4680e347d906f5fa7fca73214418741df72 /emu/Nt/fp.c
parent54bc8ff236ac10b3eaa928fd6bcfc0cdb2ba46ae (diff)
20060303a
Diffstat (limited to 'emu/Nt/fp.c')
-rw-r--r--emu/Nt/fp.c107
1 files changed, 107 insertions, 0 deletions
diff --git a/emu/Nt/fp.c b/emu/Nt/fp.c
new file mode 100644
index 00000000..586c5964
--- /dev/null
+++ b/emu/Nt/fp.c
@@ -0,0 +1,107 @@
+typedef unsigned long ulong;
+typedef unsigned int uint;
+typedef unsigned short ushort;
+typedef unsigned char uchar;
+typedef signed char schar;
+
+#include <float.h>
+#include "mathi.h"
+
+#define NANEXP (2047<<20)
+#define NANMASK (2047<<20)
+#define NANSIGN (1<<31)
+
+int isInf(double, int);
+
+double
+NaN(void)
+{
+ union
+ {
+ double d;
+ long x[2];
+ } a;
+
+ a.x[1] = NANEXP;
+ a.x[0] = 1;
+ return a.d;
+}
+
+int
+isNaN(double d)
+{
+ union
+ {
+ double d;
+ long x[2];
+ } a;
+
+ a.d = d;
+ if((a.x[1] & NANMASK) != NANEXP)
+ return 0;
+ return !isInf(d, 0);
+}
+
+double
+Inf(int sign)
+{
+ union
+ {
+ double d;
+ long x[2];
+ } a;
+
+ a.x[1] = NANEXP;
+ a.x[0] = 0;
+ if(sign < 0)
+ a.x[1] |= NANSIGN;
+ return a.d;
+}
+
+int
+isInf(double d, int sign)
+{
+ union
+ {
+ double d;
+ long x[2];
+ } a;
+
+ a.d = d;
+ if(a.x[0] != 0)
+ return 0;
+ if(a.x[1] == NANEXP)
+ return sign >= 0;
+ if(a.x[1] == (NANEXP|NANSIGN))
+ return sign <= 0;
+ return 0;
+}
+
+ulong
+getfcr(void)
+{
+ return getFPcontrol();
+}
+
+void
+setfcr(ulong m)
+{
+ FPcontrol(m, ~0);
+}
+
+ulong
+getfsr(void)
+{
+ return getFPstatus();
+}
+
+void
+setfsr(ulong m)
+{
+ FPstatus(m, ~0);
+}
+
+
+
+
+