diff options
| author | Charles.Forsyth <devnull@localhost> | 2009-03-25 16:00:23 +0000 |
|---|---|---|
| committer | Charles.Forsyth <devnull@localhost> | 2009-03-25 16:00:23 +0000 |
| commit | 3374b8a099ace1ac6a583a5c7c080b0942ba6e50 (patch) | |
| tree | 16c5974bffa2a06bbfb1275e8402079e963d0394 /Linux/386/include/fpuctl.h | |
| parent | dfd1934d5e1ddbeb326f77fc0e52307c801a1a3e (diff) | |
x20090325-1559
Diffstat (limited to 'Linux/386/include/fpuctl.h')
| -rw-r--r-- | Linux/386/include/fpuctl.h | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/Linux/386/include/fpuctl.h b/Linux/386/include/fpuctl.h new file mode 100644 index 00000000..8389f6ee --- /dev/null +++ b/Linux/386/include/fpuctl.h @@ -0,0 +1,76 @@ +/* + * Linux 386 fpu support + * Mimic Plan9 floating point support + */ + +static void +setfcr(ulong fcr) +{ + __asm__( "xorb $0x3f, %%al\n\t" + "pushw %%ax\n\t" + "fwait\n\t" + "fldcw (%%esp)\n\t" + "popw %%ax\n\t" + : /* no output */ + : "al" (fcr) + ); +} + +static ulong +getfcr(void) +{ + ulong fcr = 0; + + __asm__( "pushl %%eax\n\t" + "fwait\n\t" + "fstcw (%%esp)\n\t" + "popl %%eax\n\t" + "xorb $0x3f, %%al\n\t" + : "=a" (fcr) + : "eax" (fcr) + ); + return fcr; +} + +static ulong +getfsr(void) +{ + ulong fsr = -1; + + __asm__( "fwait\n\t" + "fstsw (%%eax)\n\t" + "movl (%%eax), %%eax\n\t" + "andl $0xffff, %%eax\n\t" + : "=a" (fsr) + : "eax" (&fsr) + ); + return fsr; +} + +static void +setfsr(ulong fsr) +{ + __asm__("fclex\n\t"); +} + +/* FCR */ +#define FPINEX (1<<5) +#define FPUNFL ((1<<4)|(1<<1)) +#define FPOVFL (1<<3) +#define FPZDIV (1<<2) +#define FPINVAL (1<<0) +#define FPRNR (0<<10) +#define FPRZ (3<<10) +#define FPRPINF (2<<10) +#define FPRNINF (1<<10) +#define FPRMASK (3<<10) +#define FPPEXT (3<<8) +#define FPPSGL (0<<8) +#define FPPDBL (2<<8) +#define FPPMASK (3<<8) +/* FSR */ +#define FPAINEX FPINEX +#define FPAOVFL FPOVFL +#define FPAUNFL FPUNFL +#define FPAZDIV FPZDIV +#define FPAINVAL FPINVAL |
