x86: lindent arch/i386/math-emu
Ingo Molnar [Wed, 30 Jan 2008 12:30:11 +0000 (13:30 +0100)]
lindent these files:
                                       errors   lines of code   errors/KLOC
 arch/x86/math-emu/                      2236            9424         237.2
 arch/x86/math-emu/                       128            8706          14.7

no other changes. No code changed:

   text    data     bss     dec     hex filename
   5589802  612739 3833856 10036397         9924ad vmlinux.before
   5589802  612739 3833856 10036397         9924ad vmlinux.after

the intent of this patch is to ease the automated tracking of kernel
code quality - it's just much easier for us to maintain it if every file
in arch/x86 is supposed to be clean.

NOTE: it is a known problem of lindent that it causes some style damage
of its own, but it's a safe tool (well, except for the gcc array range
initializers extension), so we did the bulk of the changes via lindent,
and did the manual fixups in a followup patch.

the resulting math-emu code has been tested by Thomas Gleixner on a real
386 DX CPU as well, and it works fine.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

27 files changed:
arch/x86/math-emu/errors.c
arch/x86/math-emu/exception.h
arch/x86/math-emu/fpu_arith.c
arch/x86/math-emu/fpu_asm.h
arch/x86/math-emu/fpu_aux.c
arch/x86/math-emu/fpu_emu.h
arch/x86/math-emu/fpu_entry.c
arch/x86/math-emu/fpu_etc.c
arch/x86/math-emu/fpu_proto.h
arch/x86/math-emu/fpu_tags.c
arch/x86/math-emu/fpu_trig.c
arch/x86/math-emu/get_address.c
arch/x86/math-emu/load_store.c
arch/x86/math-emu/poly.h
arch/x86/math-emu/poly_2xm1.c
arch/x86/math-emu/poly_atan.c
arch/x86/math-emu/poly_l2.c
arch/x86/math-emu/poly_sin.c
arch/x86/math-emu/poly_tan.c
arch/x86/math-emu/reg_add_sub.c
arch/x86/math-emu/reg_compare.c
arch/x86/math-emu/reg_constant.c
arch/x86/math-emu/reg_convert.c
arch/x86/math-emu/reg_divide.c
arch/x86/math-emu/reg_ld_str.c
arch/x86/math-emu/reg_mul.c
arch/x86/math-emu/status_w.h

index a1b0d22..7cb5bf3 100644 (file)
 #undef PRINT_MESSAGES
 /* */
 
-
 #if 0
 void Un_impl(void)
 {
-  u_char byte1, FPU_modrm;
-  unsigned long address = FPU_ORIG_EIP;
-
-  RE_ENTRANT_CHECK_OFF;
-  /* No need to check access_ok(), we have previously fetched these bytes. */
-  printk("Unimplemented FPU Opcode at eip=%p : ", (void __user *) address);
-  if ( FPU_CS == __USER_CS )
-    {
-      while ( 1 )
-       {
-         FPU_get_user(byte1, (u_char __user *) address);
-         if ( (byte1 & 0xf8) == 0xd8 ) break;
-         printk("[%02x]", byte1);
-         address++;
+       u_char byte1, FPU_modrm;
+       unsigned long address = FPU_ORIG_EIP;
+
+       RE_ENTRANT_CHECK_OFF;
+       /* No need to check access_ok(), we have previously fetched these bytes. */
+       printk("Unimplemented FPU Opcode at eip=%p : ", (void __user *)address);
+       if (FPU_CS == __USER_CS) {
+               while (1) {
+                       FPU_get_user(byte1, (u_char __user *) address);
+                       if ((byte1 & 0xf8) == 0xd8)
+                               break;
+                       printk("[%02x]", byte1);
+                       address++;
+               }
+               printk("%02x ", byte1);
+               FPU_get_user(FPU_modrm, 1 + (u_char __user *) address);
+
+               if (FPU_modrm >= 0300)
+                       printk("%02x (%02x+%d)\n", FPU_modrm, FPU_modrm & 0xf8,
+                              FPU_modrm & 7);
+               else
+                       printk("/%d\n", (FPU_modrm >> 3) & 7);
+       } else {
+               printk("cs selector = %04x\n", FPU_CS);
        }
-      printk("%02x ", byte1);
-      FPU_get_user(FPU_modrm, 1 + (u_char __user *) address);
-      
-      if (FPU_modrm >= 0300)
-       printk("%02x (%02x+%d)\n", FPU_modrm, FPU_modrm & 0xf8, FPU_modrm & 7);
-      else
-       printk("/%d\n", (FPU_modrm >> 3) & 7);
-    }
-  else
-    {
-      printk("cs selector = %04x\n", FPU_CS);
-    }
-
-  RE_ENTRANT_CHECK_ON;
-
-  EXCEPTION(EX_Invalid);
 
-}
-#endif  /*  0  */
+       RE_ENTRANT_CHECK_ON;
 
+       EXCEPTION(EX_Invalid);
+
+}
+#endif /*  0  */
 
 /*
    Called for opcodes which are illegal and which are known to result in a
@@ -79,139 +75,152 @@ void Un_impl(void)
    */
 void FPU_illegal(void)
 {
-  math_abort(FPU_info,SIGILL);
+       math_abort(FPU_info, SIGILL);
 }
 
-
-
 void FPU_printall(void)
 {
-  int i;
-  static const char *tag_desc[] = { "Valid", "Zero", "ERROR", "Empty",
-                              "DeNorm", "Inf", "NaN" };
-  u_char byte1, FPU_modrm;
-  unsigned long address = FPU_ORIG_EIP;
-
-  RE_ENTRANT_CHECK_OFF;
-  /* No need to check access_ok(), we have previously fetched these bytes. */
-  printk("At %p:", (void *) address);
-  if ( FPU_CS == __USER_CS )
-    {
+       int i;
+       static const char *tag_desc[] = { "Valid", "Zero", "ERROR", "Empty",
+               "DeNorm", "Inf", "NaN"
+       };
+       u_char byte1, FPU_modrm;
+       unsigned long address = FPU_ORIG_EIP;
+
+       RE_ENTRANT_CHECK_OFF;
+       /* No need to check access_ok(), we have previously fetched these bytes. */
+       printk("At %p:", (void *)address);
+       if (FPU_CS == __USER_CS) {
 #define MAX_PRINTED_BYTES 20
-      for ( i = 0; i < MAX_PRINTED_BYTES; i++ )
-       {
-         FPU_get_user(byte1, (u_char __user *) address);
-         if ( (byte1 & 0xf8) == 0xd8 )
-           {
-             printk(" %02x", byte1);
-             break;
-           }
-         printk(" [%02x]", byte1);
-         address++;
-       }
-      if ( i == MAX_PRINTED_BYTES )
-       printk(" [more..]\n");
-      else
-       {
-         FPU_get_user(FPU_modrm, 1 + (u_char __user *) address);
-         
-         if (FPU_modrm >= 0300)
-           printk(" %02x (%02x+%d)\n", FPU_modrm, FPU_modrm & 0xf8, FPU_modrm & 7);
-         else
-           printk(" /%d, mod=%d rm=%d\n",
-                  (FPU_modrm >> 3) & 7, (FPU_modrm >> 6) & 3, FPU_modrm & 7);
+               for (i = 0; i < MAX_PRINTED_BYTES; i++) {
+                       FPU_get_user(byte1, (u_char __user *) address);
+                       if ((byte1 & 0xf8) == 0xd8) {
+                               printk(" %02x", byte1);
+                               break;
+                       }
+                       printk(" [%02x]", byte1);
+                       address++;
+               }
+               if (i == MAX_PRINTED_BYTES)
+                       printk(" [more..]\n");
+               else {
+                       FPU_get_user(FPU_modrm, 1 + (u_char __user *) address);
+
+                       if (FPU_modrm >= 0300)
+                               printk(" %02x (%02x+%d)\n", FPU_modrm,
+                                      FPU_modrm & 0xf8, FPU_modrm & 7);
+                       else
+                               printk(" /%d, mod=%d rm=%d\n",
+                                      (FPU_modrm >> 3) & 7,
+                                      (FPU_modrm >> 6) & 3, FPU_modrm & 7);
+               }
+       } else {
+               printk("%04x\n", FPU_CS);
        }
-    }
-  else
-    {
-      printk("%04x\n", FPU_CS);
-    }
 
-  partial_status = status_word();
+       partial_status = status_word();
 
 #ifdef DEBUGGING
-if ( partial_status & SW_Backward )    printk("SW: backward compatibility\n");
-if ( partial_status & SW_C3 )          printk("SW: condition bit 3\n");
-if ( partial_status & SW_C2 )          printk("SW: condition bit 2\n");
-if ( partial_status & SW_C1 )          printk("SW: condition bit 1\n");
-if ( partial_status & SW_C0 )          printk("SW: condition bit 0\n");
-if ( partial_status & SW_Summary )     printk("SW: exception summary\n");
-if ( partial_status & SW_Stack_Fault ) printk("SW: stack fault\n");
-if ( partial_status & SW_Precision )   printk("SW: loss of precision\n");
-if ( partial_status & SW_Underflow )   printk("SW: underflow\n");
-if ( partial_status & SW_Overflow )    printk("SW: overflow\n");
-if ( partial_status & SW_Zero_Div )    printk("SW: divide by zero\n");
-if ( partial_status & SW_Denorm_Op )   printk("SW: denormalized operand\n");
-if ( partial_status & SW_Invalid )     printk("SW: invalid operation\n");
+       if (partial_status & SW_Backward)
+               printk("SW: backward compatibility\n");
+       if (partial_status & SW_C3)
+               printk("SW: condition bit 3\n");
+       if (partial_status & SW_C2)
+               printk("SW: condition bit 2\n");
+       if (partial_status & SW_C1)
+               printk("SW: condition bit 1\n");
+       if (partial_status & SW_C0)
+               printk("SW: condition bit 0\n");
+       if (partial_status & SW_Summary)
+               printk("SW: exception summary\n");
+       if (partial_status & SW_Stack_Fault)
+               printk("SW: stack fault\n");
+       if (partial_status & SW_Precision)
+               printk("SW: loss of precision\n");
+       if (partial_status & SW_Underflow)
+               printk("SW: underflow\n");
+       if (partial_status & SW_Overflow)
+               printk("SW: overflow\n");
+       if (partial_status & SW_Zero_Div)
+               printk("SW: divide by zero\n");
+       if (partial_status & SW_Denorm_Op)
+               printk("SW: denormalized operand\n");
+       if (partial_status & SW_Invalid)
+               printk("SW: invalid operation\n");
 #endif /* DEBUGGING */
 
-  printk(" SW: b=%d st=%ld es=%d sf=%d cc=%d%d%d%d ef=%d%d%d%d%d%d\n",
-        partial_status & 0x8000 ? 1 : 0,   /* busy */
-        (partial_status & 0x3800) >> 11,   /* stack top pointer */
-        partial_status & 0x80 ? 1 : 0,     /* Error summary status */
-        partial_status & 0x40 ? 1 : 0,     /* Stack flag */
-        partial_status & SW_C3?1:0, partial_status & SW_C2?1:0, /* cc */
-        partial_status & SW_C1?1:0, partial_status & SW_C0?1:0, /* cc */
-        partial_status & SW_Precision?1:0, partial_status & SW_Underflow?1:0,
-        partial_status & SW_Overflow?1:0, partial_status & SW_Zero_Div?1:0,
-        partial_status & SW_Denorm_Op?1:0, partial_status & SW_Invalid?1:0);
-  
-printk(" CW: ic=%d rc=%ld%ld pc=%ld%ld iem=%d     ef=%d%d%d%d%d%d\n",
-        control_word & 0x1000 ? 1 : 0,
-        (control_word & 0x800) >> 11, (control_word & 0x400) >> 10,
-        (control_word & 0x200) >> 9, (control_word & 0x100) >> 8,
-        control_word & 0x80 ? 1 : 0,
-        control_word & SW_Precision?1:0, control_word & SW_Underflow?1:0,
-        control_word & SW_Overflow?1:0, control_word & SW_Zero_Div?1:0,
-        control_word & SW_Denorm_Op?1:0, control_word & SW_Invalid?1:0);
-
-  for ( i = 0; i < 8; i++ )
-    {
-      FPU_REG *r = &st(i);
-      u_char tagi = FPU_gettagi(i);
-      switch (tagi)
-       {
-       case TAG_Empty:
-         continue;
-         break;
-       case TAG_Zero:
-       case TAG_Special:
-         tagi = FPU_Special(r);
-       case TAG_Valid:
-         printk("st(%d)  %c .%04lx %04lx %04lx %04lx e%+-6d ", i,
-                getsign(r) ? '-' : '+',
-                (long)(r->sigh >> 16),
-                (long)(r->sigh & 0xFFFF),
-                (long)(r->sigl >> 16),
-                (long)(r->sigl & 0xFFFF),
-                exponent(r) - EXP_BIAS + 1);
-         break;
-       default:
-         printk("Whoops! Error in errors.c: tag%d is %d ", i, tagi);
-         continue;
-         break;
+       printk(" SW: b=%d st=%ld es=%d sf=%d cc=%d%d%d%d ef=%d%d%d%d%d%d\n", partial_status & 0x8000 ? 1 : 0,   /* busy */
+              (partial_status & 0x3800) >> 11, /* stack top pointer */
+              partial_status & 0x80 ? 1 : 0,   /* Error summary status */
+              partial_status & 0x40 ? 1 : 0,   /* Stack flag */
+              partial_status & SW_C3 ? 1 : 0, partial_status & SW_C2 ? 1 : 0,  /* cc */
+              partial_status & SW_C1 ? 1 : 0, partial_status & SW_C0 ? 1 : 0,  /* cc */
+              partial_status & SW_Precision ? 1 : 0,
+              partial_status & SW_Underflow ? 1 : 0,
+              partial_status & SW_Overflow ? 1 : 0,
+              partial_status & SW_Zero_Div ? 1 : 0,
+              partial_status & SW_Denorm_Op ? 1 : 0,
+              partial_status & SW_Invalid ? 1 : 0);
+
+       printk(" CW: ic=%d rc=%ld%ld pc=%ld%ld iem=%d     ef=%d%d%d%d%d%d\n",
+              control_word & 0x1000 ? 1 : 0,
+              (control_word & 0x800) >> 11, (control_word & 0x400) >> 10,
+              (control_word & 0x200) >> 9, (control_word & 0x100) >> 8,
+              control_word & 0x80 ? 1 : 0,
+              control_word & SW_Precision ? 1 : 0,
+              control_word & SW_Underflow ? 1 : 0,
+              control_word & SW_Overflow ? 1 : 0,
+              control_word & SW_Zero_Div ? 1 : 0,
+              control_word & SW_Denorm_Op ? 1 : 0,
+              control_word & SW_Invalid ? 1 : 0);
+
+       for (i = 0; i < 8; i++) {
+               FPU_REG *r = &st(i);
+               u_char tagi = FPU_gettagi(i);
+               switch (tagi) {
+               case TAG_Empty:
+                       continue;
+                       break;
+               case TAG_Zero:
+               case TAG_Special:
+                       tagi = FPU_Special(r);
+               case TAG_Valid:
+                       printk("st(%d)  %c .%04lx %04lx %04lx %04lx e%+-6d ", i,
+                              getsign(r) ? '-' : '+',
+                              (long)(r->sigh >> 16),
+                              (long)(r->sigh & 0xFFFF),
+                              (long)(r->sigl >> 16),
+                              (long)(r->sigl & 0xFFFF),
+                              exponent(r) - EXP_BIAS + 1);
+                       break;
+               default:
+                       printk("Whoops! Error in errors.c: tag%d is %d ", i,
+                              tagi);
+                       continue;
+                       break;
+               }
+               printk("%s\n", tag_desc[(int)(unsigned)tagi]);
        }
-      printk("%s\n", tag_desc[(int) (unsigned) tagi]);
-    }
 
-  RE_ENTRANT_CHECK_ON;
+       RE_ENTRANT_CHECK_ON;
 
 }
 
 static struct {
-  int type;
-  const char *name;
+       int type;
+       const char *name;
 } exception_names[] = {
-  { EX_StackOver, "stack overflow" },
-  { EX_StackUnder, "stack underflow" },
-  { EX_Precision, "loss of precision" },
-  { EX_Underflow, "underflow" },
-  { EX_Overflow, "overflow" },
-  { EX_ZeroDiv, "divide by zero" },
-  { EX_Denormal, "denormalized operand" },
-  { EX_Invalid, "invalid operation" },
-  { EX_INTERNAL, "INTERNAL BUG in "FPU_VERSION },
-  { 0, NULL }
+       {
+       EX_StackOver, "stack overflow"}, {
+       EX_StackUnder, "stack underflow"}, {
+       EX_Precision, "loss of precision"}, {
+       EX_Underflow, "underflow"}, {
+       EX_Overflow, "overflow"}, {
+       EX_ZeroDiv, "divide by zero"}, {
+       EX_Denormal, "denormalized operand"}, {
+       EX_Invalid, "invalid operation"}, {
+       EX_INTERNAL, "INTERNAL BUG in " FPU_VERSION}, {
+       0, NULL}
 };
 
 /*
@@ -295,445 +304,386 @@ static struct {
 
 asmlinkage void FPU_exception(int n)
 {
-  int i, int_type;
-
-  int_type = 0;         /* Needed only to stop compiler warnings */
-  if ( n & EX_INTERNAL )
-    {
-      int_type = n - EX_INTERNAL;
-      n = EX_INTERNAL;
-      /* Set lots of exception bits! */
-      partial_status |= (SW_Exc_Mask | SW_Summary | SW_Backward);
-    }
-  else
-    {
-      /* Extract only the bits which we use to set the status word */
-      n &= (SW_Exc_Mask);
-      /* Set the corresponding exception bit */
-      partial_status |= n;
-      /* Set summary bits iff exception isn't masked */
-      if ( partial_status & ~control_word & CW_Exceptions )
-       partial_status |= (SW_Summary | SW_Backward);
-      if ( n & (SW_Stack_Fault | EX_Precision) )
-       {
-         if ( !(n & SW_C1) )
-           /* This bit distinguishes over- from underflow for a stack fault,
-              and roundup from round-down for precision loss. */
-           partial_status &= ~SW_C1;
+       int i, int_type;
+
+       int_type = 0;           /* Needed only to stop compiler warnings */
+       if (n & EX_INTERNAL) {
+               int_type = n - EX_INTERNAL;
+               n = EX_INTERNAL;
+               /* Set lots of exception bits! */
+               partial_status |= (SW_Exc_Mask | SW_Summary | SW_Backward);
+       } else {
+               /* Extract only the bits which we use to set the status word */
+               n &= (SW_Exc_Mask);
+               /* Set the corresponding exception bit */
+               partial_status |= n;
+               /* Set summary bits iff exception isn't masked */
+               if (partial_status & ~control_word & CW_Exceptions)
+                       partial_status |= (SW_Summary | SW_Backward);
+               if (n & (SW_Stack_Fault | EX_Precision)) {
+                       if (!(n & SW_C1))
+                               /* This bit distinguishes over- from underflow for a stack fault,
+                                  and roundup from round-down for precision loss. */
+                               partial_status &= ~SW_C1;
+               }
        }
-    }
 
-  RE_ENTRANT_CHECK_OFF;
-  if ( (~control_word & n & CW_Exceptions) || (n == EX_INTERNAL) )
-    {
+       RE_ENTRANT_CHECK_OFF;
+       if ((~control_word & n & CW_Exceptions) || (n == EX_INTERNAL)) {
 #ifdef PRINT_MESSAGES
-      /* My message from the sponsor */
-      printk(FPU_VERSION" "__DATE__" (C) W. Metzenthen.\n");
+               /* My message from the sponsor */
+               printk(FPU_VERSION " " __DATE__ " (C) W. Metzenthen.\n");
 #endif /* PRINT_MESSAGES */
-      
-      /* Get a name string for error reporting */
-      for (i=0; exception_names[i].type; i++)
-       if ( (exception_names[i].type & n) == exception_names[i].type )
-         break;
-      
-      if (exception_names[i].type)
-       {
+
+               /* Get a name string for error reporting */
+               for (i = 0; exception_names[i].type; i++)
+                       if ((exception_names[i].type & n) ==
+                           exception_names[i].type)
+                               break;
+
+               if (exception_names[i].type) {
 #ifdef PRINT_MESSAGES
-         printk("FP Exception: %s!\n", exception_names[i].name);
+                       printk("FP Exception: %s!\n", exception_names[i].name);
 #endif /* PRINT_MESSAGES */
-       }
-      else
-       printk("FPU emulator: Unknown Exception: 0x%04x!\n", n);
-      
-      if ( n == EX_INTERNAL )
-       {
-         printk("FPU emulator: Internal error type 0x%04x\n", int_type);
-         FPU_printall();
-       }
+               } else
+                       printk("FPU emulator: Unknown Exception: 0x%04x!\n", n);
+
+               if (n == EX_INTERNAL) {
+                       printk("FPU emulator: Internal error type 0x%04x\n",
+                              int_type);
+                       FPU_printall();
+               }
 #ifdef PRINT_MESSAGES
-      else
-       FPU_printall();
+               else
+                       FPU_printall();
 #endif /* PRINT_MESSAGES */
 
-      /*
-       * The 80486 generates an interrupt on the next non-control FPU
-       * instruction. So we need some means of flagging it.
-       * We use the ES (Error Summary) bit for this.
-       */
-    }
-  RE_ENTRANT_CHECK_ON;
+               /*
+                * The 80486 generates an interrupt on the next non-control FPU
+                * instruction. So we need some means of flagging it.
+                * We use the ES (Error Summary) bit for this.
+                */
+       }
+       RE_ENTRANT_CHECK_ON;
 
 #ifdef __DEBUG__
-  math_abort(FPU_info,SIGFPE);
+       math_abort(FPU_info, SIGFPE);
 #endif /* __DEBUG__ */
 
 }
 
-
 /* Real operation attempted on a NaN. */
 /* Returns < 0 if the exception is unmasked */
-int real_1op_NaN(FPU_REG *a)
+int real_1op_NaN(FPU_REG * a)
 {
-  int signalling, isNaN;
-
-  isNaN = (exponent(a) == EXP_OVER) && (a->sigh & 0x80000000);
-
-  /* The default result for the case of two "equal" NaNs (signs may
-     differ) is chosen to reproduce 80486 behaviour */
-  signalling = isNaN && !(a->sigh & 0x40000000);
-
-  if ( !signalling )
-    {
-      if ( !isNaN )  /* pseudo-NaN, or other unsupported? */
-       {
-         if ( control_word & CW_Invalid )
-           {
-             /* Masked response */
-             reg_copy(&CONST_QNaN, a);
-           }
-         EXCEPTION(EX_Invalid);
-         return (!(control_word & CW_Invalid) ? FPU_Exception : 0) | TAG_Special;
+       int signalling, isNaN;
+
+       isNaN = (exponent(a) == EXP_OVER) && (a->sigh & 0x80000000);
+
+       /* The default result for the case of two "equal" NaNs (signs may
+          differ) is chosen to reproduce 80486 behaviour */
+       signalling = isNaN && !(a->sigh & 0x40000000);
+
+       if (!signalling) {
+               if (!isNaN) {   /* pseudo-NaN, or other unsupported? */
+                       if (control_word & CW_Invalid) {
+                               /* Masked response */
+                               reg_copy(&CONST_QNaN, a);
+                       }
+                       EXCEPTION(EX_Invalid);
+                       return (!(control_word & CW_Invalid) ? FPU_Exception :
+                               0) | TAG_Special;
+               }
+               return TAG_Special;
        }
-      return TAG_Special;
-    }
 
-  if ( control_word & CW_Invalid )
-    {
-      /* The masked response */
-      if ( !(a->sigh & 0x80000000) )  /* pseudo-NaN ? */
-       {
-         reg_copy(&CONST_QNaN, a);
+       if (control_word & CW_Invalid) {
+               /* The masked response */
+               if (!(a->sigh & 0x80000000)) {  /* pseudo-NaN ? */
+                       reg_copy(&CONST_QNaN, a);
+               }
+               /* ensure a Quiet NaN */
+               a->sigh |= 0x40000000;
        }
-      /* ensure a Quiet NaN */
-      a->sigh |= 0x40000000;
-    }
 
-  EXCEPTION(EX_Invalid);
+       EXCEPTION(EX_Invalid);
 
-  return (!(control_word & CW_Invalid) ? FPU_Exception : 0) | TAG_Special;
+       return (!(control_word & CW_Invalid) ? FPU_Exception : 0) | TAG_Special;
 }
 
-
 /* Real operation attempted on two operands, one a NaN. */
 /* Returns < 0 if the exception is unmasked */
 int real_2op_NaN(FPU_REG const *b, u_char tagb,
-                int deststnr,
-                FPU_REG const *defaultNaN)
+                int deststnr, FPU_REG const *defaultNaN)
 {
-  FPU_REG *dest = &st(deststnr);
-  FPU_REG const *a = dest;
-  u_char taga = FPU_gettagi(deststnr);
-  FPU_REG const *x;
-  int signalling, unsupported;
-
-  if ( taga == TAG_Special )
-    taga = FPU_Special(a);
-  if ( tagb == TAG_Special )
-    tagb = FPU_Special(b);
-
-  /* TW_NaN is also used for unsupported data types. */
-  unsupported = ((taga == TW_NaN)
-                && !((exponent(a) == EXP_OVER) && (a->sigh & 0x80000000)))
-    || ((tagb == TW_NaN)
-       && !((exponent(b) == EXP_OVER) && (b->sigh & 0x80000000)));
-  if ( unsupported )
-    {
-      if ( control_word & CW_Invalid )
-       {
-         /* Masked response */
-         FPU_copy_to_regi(&CONST_QNaN, TAG_Special, deststnr);
-       }
-      EXCEPTION(EX_Invalid);
-      return (!(control_word & CW_Invalid) ? FPU_Exception : 0) | TAG_Special;
-    }
-
-  if (taga == TW_NaN)
-    {
-      x = a;
-      if (tagb == TW_NaN)
-       {
-         signalling = !(a->sigh & b->sigh & 0x40000000);
-         if ( significand(b) > significand(a) )
-           x = b;
-         else if ( significand(b) == significand(a) )
-           {
-             /* The default result for the case of two "equal" NaNs (signs may
-                differ) is chosen to reproduce 80486 behaviour */
-             x = defaultNaN;
-           }
-       }
-      else
-       {
-         /* return the quiet version of the NaN in a */
-         signalling = !(a->sigh & 0x40000000);
+       FPU_REG *dest = &st(deststnr);
+       FPU_REG const *a = dest;
+       u_char taga = FPU_gettagi(deststnr);
+       FPU_REG const *x;
+       int signalling, unsupported;
+
+       if (taga == TAG_Special)
+               taga = FPU_Special(a);
+       if (tagb == TAG_Special)
+               tagb = FPU_Special(b);
+
+       /* TW_NaN is also used for unsupported data types. */
+       unsupported = ((taga == TW_NaN)
+                      && !((exponent(a) == EXP_OVER)
+                           && (a->sigh & 0x80000000)))
+           || ((tagb == TW_NaN)
+               && !((exponent(b) == EXP_OVER) && (b->sigh & 0x80000000)));
+       if (unsupported) {
+               if (control_word & CW_Invalid) {
+                       /* Masked response */
+                       FPU_copy_to_regi(&CONST_QNaN, TAG_Special, deststnr);
+               }
+               EXCEPTION(EX_Invalid);
+               return (!(control_word & CW_Invalid) ? FPU_Exception : 0) |
+                   TAG_Special;
        }
-    }
-  else
+
+       if (taga == TW_NaN) {
+               x = a;
+               if (tagb == TW_NaN) {
+                       signalling = !(a->sigh & b->sigh & 0x40000000);
+                       if (significand(b) > significand(a))
+                               x = b;
+                       else if (significand(b) == significand(a)) {
+                               /* The default result for the case of two "equal" NaNs (signs may
+                                  differ) is chosen to reproduce 80486 behaviour */
+                               x = defaultNaN;
+                       }
+               } else {
+                       /* return the quiet version of the NaN in a */
+                       signalling = !(a->sigh & 0x40000000);
+               }
+       } else
 #ifdef PARANOID
-    if (tagb == TW_NaN)
+       if (tagb == TW_NaN)
 #endif /* PARANOID */
-    {
-      signalling = !(b->sigh & 0x40000000);
-      x = b;
-    }
+       {
+               signalling = !(b->sigh & 0x40000000);
+               x = b;
+       }
 #ifdef PARANOID
-  else
-    {
-      signalling = 0;
-      EXCEPTION(EX_INTERNAL|0x113);
-      x = &CONST_QNaN;
-    }
+       else {
+               signalling = 0;
+               EXCEPTION(EX_INTERNAL | 0x113);
+               x = &CONST_QNaN;
+       }
 #endif /* PARANOID */
 
-  if ( (!signalling) || (control_word & CW_Invalid) )
-    {
-      if ( ! x )
-       x = b;
+       if ((!signalling) || (control_word & CW_Invalid)) {
+               if (!x)
+                       x = b;
 
-      if ( !(x->sigh & 0x80000000) )  /* pseudo-NaN ? */
-       x = &CONST_QNaN;
+               if (!(x->sigh & 0x80000000))    /* pseudo-NaN ? */
+                       x = &CONST_QNaN;
 
-      FPU_copy_to_regi(x, TAG_Special, deststnr);
+               FPU_copy_to_regi(x, TAG_Special, deststnr);
 
-      if ( !signalling )
-       return TAG_Special;
+               if (!signalling)
+                       return TAG_Special;
 
-      /* ensure a Quiet NaN */
-      dest->sigh |= 0x40000000;
-    }
+               /* ensure a Quiet NaN */
+               dest->sigh |= 0x40000000;
+       }
 
-  EXCEPTION(EX_Invalid);
+       EXCEPTION(EX_Invalid);
 
-  return (!(control_word & CW_Invalid) ? FPU_Exception : 0) | TAG_Special;
+       return (!(control_word & CW_Invalid) ? FPU_Exception : 0) | TAG_Special;
 }
 
-
 /* Invalid arith operation on Valid registers */
 /* Returns < 0 if the exception is unmasked */
 asmlinkage int arith_invalid(int deststnr)
 {
 
-  EXCEPTION(EX_Invalid);
-  
-  if ( control_word & CW_Invalid )
-    {
-      /* The masked response */
-      FPU_copy_to_regi(&CONST_QNaN, TAG_Special, deststnr);
-    }
-  
-  return (!(control_word & CW_Invalid) ? FPU_Exception : 0) | TAG_Valid;
+       EXCEPTION(EX_Invalid);
 
-}
+       if (control_word & CW_Invalid) {
+               /* The masked response */
+               FPU_copy_to_regi(&CONST_QNaN, TAG_Special, deststnr);
+       }
 
+       return (!(control_word & CW_Invalid) ? FPU_Exception : 0) | TAG_Valid;
+
+}
 
 /* Divide a finite number by zero */
 asmlinkage int FPU_divide_by_zero(int deststnr, u_char sign)
 {
-  FPU_REG *dest = &st(deststnr);
-  int tag = TAG_Valid;
+       FPU_REG *dest = &st(deststnr);
+       int tag = TAG_Valid;
+
+       if (control_word & CW_ZeroDiv) {
+               /* The masked response */
+               FPU_copy_to_regi(&CONST_INF, TAG_Special, deststnr);
+               setsign(dest, sign);
+               tag = TAG_Special;
+       }
 
-  if ( control_word & CW_ZeroDiv )
-    {
-      /* The masked response */
-      FPU_copy_to_regi(&CONST_INF, TAG_Special, deststnr);
-      setsign(dest, sign);
-      tag = TAG_Special;
-    }
-  EXCEPTION(EX_ZeroDiv);
+       EXCEPTION(EX_ZeroDiv);
 
-  return (!(control_word & CW_ZeroDiv) ? FPU_Exception : 0) | tag;
+       return (!(control_word & CW_ZeroDiv) ? FPU_Exception : 0) | tag;
 
 }
 
-
 /* This may be called often, so keep it lean */
 int set_precision_flag(int flags)
 {
-  if ( control_word & CW_Precision )
-    {
-      partial_status &= ~(SW_C1 & flags);
-      partial_status |= flags;   /* The masked response */
-      return 0;
-    }
-  else
-    {
-      EXCEPTION(flags);
-      return 1;
-    }
+       if (control_word & CW_Precision) {
+               partial_status &= ~(SW_C1 & flags);
+               partial_status |= flags;        /* The masked response */
+               return 0;
+       } else {
+               EXCEPTION(flags);
+               return 1;
+       }
 }
 
-
 /* This may be called often, so keep it lean */
 asmlinkage void set_precision_flag_up(void)
 {
-  if ( control_word & CW_Precision )
-    partial_status |= (SW_Precision | SW_C1);   /* The masked response */
-  else
-    EXCEPTION(EX_Precision | SW_C1);
+       if (control_word & CW_Precision)
+               partial_status |= (SW_Precision | SW_C1);       /* The masked response */
+       else
+               EXCEPTION(EX_Precision | SW_C1);
 }
 
-
 /* This may be called often, so keep it lean */
 asmlinkage void set_precision_flag_down(void)
 {
-  if ( control_word & CW_Precision )
-    {   /* The masked response */
-      partial_status &= ~SW_C1;
-      partial_status |= SW_Precision;
-    }
-  else
-    EXCEPTION(EX_Precision);
+       if (control_word & CW_Precision) {      /* The masked response */
+               partial_status &= ~SW_C1;
+               partial_status |= SW_Precision;
+       } else
+               EXCEPTION(EX_Precision);
 }
 
-
 asmlinkage int denormal_operand(void)
 {
-  if ( control_word & CW_Denormal )
-    {   /* The masked response */
-      partial_status |= SW_Denorm_Op;
-      return TAG_Special;
-    }
-  else
-    {
-      EXCEPTION(EX_Denormal);
-      return TAG_Special | FPU_Exception;
-    }
+       if (control_word & CW_Denormal) {       /* The masked response */
+               partial_status |= SW_Denorm_Op;
+               return TAG_Special;
+       } else {
+               EXCEPTION(EX_Denormal);
+               return TAG_Special | FPU_Exception;
+       }
 }
 
-
-asmlinkage int arith_overflow(FPU_REG *dest)
+asmlinkage int arith_overflow(FPU_REG * dest)
 {
-  int tag = TAG_Valid;
+       int tag = TAG_Valid;
 
-  if ( control_word & CW_Overflow )
-    {
-      /* The masked response */
+       if (control_word & CW_Overflow) {
+               /* The masked response */
 /* ###### The response here depends upon the rounding mode */
-      reg_copy(&CONST_INF, dest);
-      tag = TAG_Special;
-    }
-  else
-    {
-      /* Subtract the magic number from the exponent */
-      addexponent(dest, (-3 * (1 << 13)));
-    }
-
-  EXCEPTION(EX_Overflow);
-  if ( control_word & CW_Overflow )
-    {
-      /* The overflow exception is masked. */
-      /* By definition, precision is lost.
-        The roundup bit (C1) is also set because we have
-        "rounded" upwards to Infinity. */
-      EXCEPTION(EX_Precision | SW_C1);
-      return tag;
-    }
-
-  return tag;
+               reg_copy(&CONST_INF, dest);
+               tag = TAG_Special;
+       } else {
+               /* Subtract the magic number from the exponent */
+               addexponent(dest, (-3 * (1 << 13)));
+       }
 
-}
+       EXCEPTION(EX_Overflow);
+       if (control_word & CW_Overflow) {
+               /* The overflow exception is masked. */
+               /* By definition, precision is lost.
+                  The roundup bit (C1) is also set because we have
+                  "rounded" upwards to Infinity. */
+               EXCEPTION(EX_Precision | SW_C1);
+               return tag;
+       }
 
+       return tag;
 
-asmlinkage int arith_underflow(FPU_REG *dest)
-{
-  int tag = TAG_Valid;
+}
 
-  if ( control_word & CW_Underflow )
-    {
-      /* The masked response */
-      if ( exponent16(dest) <= EXP_UNDER - 63 )
-       {
-         reg_copy(&CONST_Z, dest);
-         partial_status &= ~SW_C1;       /* Round down. */
-         tag = TAG_Zero;
+asmlinkage int arith_underflow(FPU_REG * dest)
+{
+       int tag = TAG_Valid;
+
+       if (control_word & CW_Underflow) {
+               /* The masked response */
+               if (exponent16(dest) <= EXP_UNDER - 63) {
+                       reg_copy(&CONST_Z, dest);
+                       partial_status &= ~SW_C1;       /* Round down. */
+                       tag = TAG_Zero;
+               } else {
+                       stdexp(dest);
+               }
+       } else {
+               /* Add the magic number to the exponent. */
+               addexponent(dest, (3 * (1 << 13)) + EXTENDED_Ebias);
        }
-      else
-       {
-         stdexp(dest);
+
+       EXCEPTION(EX_Underflow);
+       if (control_word & CW_Underflow) {
+               /* The underflow exception is masked. */
+               EXCEPTION(EX_Precision);
+               return tag;
        }
-    }
-  else
-    {
-      /* Add the magic number to the exponent. */
-      addexponent(dest, (3 * (1 << 13)) + EXTENDED_Ebias);
-    }
-
-  EXCEPTION(EX_Underflow);
-  if ( control_word & CW_Underflow )
-    {
-      /* The underflow exception is masked. */
-      EXCEPTION(EX_Precision);
-      return tag;
-    }
-
-  return tag;
 
-}
+       return tag;
 
+}
 
 void FPU_stack_overflow(void)
 {
 
- if ( control_word & CW_Invalid )
-    {
-      /* The masked response */
-      top--;
-      FPU_copy_to_reg0(&CONST_QNaN, TAG_Special);
-    }
+       if (control_word & CW_Invalid) {
+               /* The masked response */
+               top--;
+               FPU_copy_to_reg0(&CONST_QNaN, TAG_Special);
+       }
 
-  EXCEPTION(EX_StackOver);
+       EXCEPTION(EX_StackOver);
 
-  return;
+       return;
 
 }
 
-
 void FPU_stack_underflow(void)
 {
 
- if ( control_word & CW_Invalid )
-    {
-      /* The masked response */
-      FPU_copy_to_reg0(&CONST_QNaN, TAG_Special);
-    }
+       if (control_word & CW_Invalid) {
+               /* The masked response */
+               FPU_copy_to_reg0(&CONST_QNaN, TAG_Special);
+       }
 
-  EXCEPTION(EX_StackUnder);
+       EXCEPTION(EX_StackUnder);
 
-  return;
+       return;
 
 }
 
-
 void FPU_stack_underflow_i(int i)
 {
 
- if ( control_word & CW_Invalid )
-    {
-      /* The masked response */
-      FPU_copy_to_regi(&CONST_QNaN, TAG_Special, i);
-    }
+       if (control_word & CW_Invalid) {
+               /* The masked response */
+               FPU_copy_to_regi(&CONST_QNaN, TAG_Special, i);
+       }
 
-  EXCEPTION(EX_StackUnder);
+       EXCEPTION(EX_StackUnder);
 
-  return;
+       return;
 
 }
 
-
 void FPU_stack_underflow_pop(int i)
 {
 
- if ( control_word & CW_Invalid )
-    {
-      /* The masked response */
-      FPU_copy_to_regi(&CONST_QNaN, TAG_Special, i);
-      FPU_pop();
-    }
+       if (control_word & CW_Invalid) {
+               /* The masked response */
+               FPU_copy_to_regi(&CONST_QNaN, TAG_Special, i);
+               FPU_pop();
+       }
 
-  EXCEPTION(EX_StackUnder);
+       EXCEPTION(EX_StackUnder);
 
-  return;
+       return;
 
 }
-
index b463f21..67f43a4 100644 (file)
@@ -9,7 +9,6 @@
 #ifndef _EXCEPTION_H_
 #define _EXCEPTION_H_
 
-
 #ifdef __ASSEMBLY__
 #define        Const_(x)       $##x
 #else
@@ -20,8 +19,8 @@
 #include "fpu_emu.h"
 #endif /* SW_C1 */
 
-#define FPU_BUSY        Const_(0x8000)   /* FPU busy bit (8087 compatibility) */
-#define EX_ErrorSummary Const_(0x0080)   /* Error summary status */
+#define FPU_BUSY        Const_(0x8000) /* FPU busy bit (8087 compatibility) */
+#define EX_ErrorSummary Const_(0x0080) /* Error summary status */
 /* Special exceptions: */
 #define        EX_INTERNAL     Const_(0x8000)  /* Internal error in wm-FPU-emu */
 #define EX_StackOver   Const_(0x0041|SW_C1)    /* stack overflow */
 #define EX_Denormal    Const_(0x0002)  /* denormalized operand */
 #define EX_Invalid     Const_(0x0001)  /* invalid operation */
 
-
 #define PRECISION_LOST_UP    Const_((EX_Precision | SW_C1))
 #define PRECISION_LOST_DOWN  Const_(EX_Precision)
 
-
 #ifndef __ASSEMBLY__
 
 #ifdef DEBUG
@@ -48,6 +45,6 @@
 #define        EXCEPTION(x)    FPU_exception(x)
 #endif
 
-#endif /* __ASSEMBLY__ */ 
+#endif /* __ASSEMBLY__ */
 
 #endif /* _EXCEPTION_H_ */
index 6972dec..aeab24e 100644 (file)
 #include "control_w.h"
 #include "status_w.h"
 
-
 void fadd__(void)
 {
-  /* fadd st,st(i) */
-  int i = FPU_rm;
-  clear_C1();
-  FPU_add(&st(i), FPU_gettagi(i), 0, control_word);
+       /* fadd st,st(i) */
+       int i = FPU_rm;
+       clear_C1();
+       FPU_add(&st(i), FPU_gettagi(i), 0, control_word);
 }
 
-
 void fmul__(void)
 {
-  /* fmul st,st(i) */
-  int i = FPU_rm;
-  clear_C1();
-  FPU_mul(&st(i), FPU_gettagi(i), 0, control_word);
+       /* fmul st,st(i) */
+       int i = FPU_rm;
+       clear_C1();
+       FPU_mul(&st(i), FPU_gettagi(i), 0, control_word);
 }
 
-
-
 void fsub__(void)
 {
-  /* fsub st,st(i) */
-  clear_C1();
-  FPU_sub(0, FPU_rm, control_word);
+       /* fsub st,st(i) */
+       clear_C1();
+       FPU_sub(0, FPU_rm, control_word);
 }
 
-
 void fsubr_(void)
 {
-  /* fsubr st,st(i) */
-  clear_C1();
-  FPU_sub(REV, FPU_rm, control_word);
+       /* fsubr st,st(i) */
+       clear_C1();
+       FPU_sub(REV, FPU_rm, control_word);
 }
 
-
 void fdiv__(void)
 {
-  /* fdiv st,st(i) */
-  clear_C1();
-  FPU_div(0, FPU_rm, control_word);
+       /* fdiv st,st(i) */
+       clear_C1();
+       FPU_div(0, FPU_rm, control_word);
 }
 
-
 void fdivr_(void)
 {
-  /* fdivr st,st(i) */
-  clear_C1();
-  FPU_div(REV, FPU_rm, control_word);
+       /* fdivr st,st(i) */
+       clear_C1();
+       FPU_div(REV, FPU_rm, control_word);
 }
 
-
-
 void fadd_i(void)
 {
-  /* fadd st(i),st */
-  int i = FPU_rm;
-  clear_C1();
-  FPU_add(&st(i), FPU_gettagi(i), i, control_word);
+       /* fadd st(i),st */
+       int i = FPU_rm;
+       clear_C1();
+       FPU_add(&st(i), FPU_gettagi(i), i, control_word);
 }
 
-
 void fmul_i(void)
 {
-  /* fmul st(i),st */
-  clear_C1();
-  FPU_mul(&st(0), FPU_gettag0(), FPU_rm, control_word);
+       /* fmul st(i),st */
+       clear_C1();
+       FPU_mul(&st(0), FPU_gettag0(), FPU_rm, control_word);
 }
 
-
 void fsubri(void)
 {
-  /* fsubr st(i),st */
-  clear_C1();
-  FPU_sub(DEST_RM, FPU_rm, control_word);
+       /* fsubr st(i),st */
+       clear_C1();
+       FPU_sub(DEST_RM, FPU_rm, control_word);
 }
 
-
 void fsub_i(void)
 {
-  /* fsub st(i),st */
-  clear_C1();
-  FPU_sub(REV|DEST_RM, FPU_rm, control_word);
+       /* fsub st(i),st */
+       clear_C1();
+       FPU_sub(REV | DEST_RM, FPU_rm, control_word);
 }
 
-
 void fdivri(void)
 {
-  /* fdivr st(i),st */
-  clear_C1();
-  FPU_div(DEST_RM, FPU_rm, control_word);
+       /* fdivr st(i),st */
+       clear_C1();
+       FPU_div(DEST_RM, FPU_rm, control_word);
 }
 
-
 void fdiv_i(void)
 {
-  /* fdiv st(i),st */
-  clear_C1();
-  FPU_div(REV|DEST_RM, FPU_rm, control_word);
+       /* fdiv st(i),st */
+       clear_C1();
+       FPU_div(REV | DEST_RM, FPU_rm, control_word);
 }
 
-
-
 void faddp_(void)
 {
-  /* faddp st(i),st */
-  int i = FPU_rm;
-  clear_C1();
-  if ( FPU_add(&st(i), FPU_gettagi(i), i, control_word) >= 0 )
-    FPU_pop();
+       /* faddp st(i),st */
+       int i = FPU_rm;
+       clear_C1();
+       if (FPU_add(&st(i), FPU_gettagi(i), i, control_word) >= 0)
+               FPU_pop();
 }
 
-
 void fmulp_(void)
 {
-  /* fmulp st(i),st */
-  clear_C1();
-  if ( FPU_mul(&st(0), FPU_gettag0(), FPU_rm, control_word) >= 0 )
-    FPU_pop();
+       /* fmulp st(i),st */
+       clear_C1();
+       if (FPU_mul(&st(0), FPU_gettag0(), FPU_rm, control_word) >= 0)
+               FPU_pop();
 }
 
-
-
 void fsubrp(void)
 {
-  /* fsubrp st(i),st */
-  clear_C1();
-  if ( FPU_sub(DEST_RM, FPU_rm, control_word) >= 0 )
-    FPU_pop();
+       /* fsubrp st(i),st */
+       clear_C1();
+       if (FPU_sub(DEST_RM, FPU_rm, control_word) >= 0)
+               FPU_pop();
 }
 
-
 void fsubp_(void)
 {
-  /* fsubp st(i),st */
-  clear_C1();
-  if ( FPU_sub(REV|DEST_RM, FPU_rm, control_word) >= 0 )
-    FPU_pop();
+       /* fsubp st(i),st */
+       clear_C1();
+       if (FPU_sub(REV | DEST_RM, FPU_rm, control_word) >= 0)
+               FPU_pop();
 }
 
-
 void fdivrp(void)
 {
-  /* fdivrp st(i),st */
-  clear_C1();
-  if ( FPU_div(DEST_RM, FPU_rm, control_word) >= 0 )
-    FPU_pop();
+       /* fdivrp st(i),st */
+       clear_C1();
+       if (FPU_div(DEST_RM, FPU_rm, control_word) >= 0)
+               FPU_pop();
 }
 
-
 void fdivp_(void)
 {
-  /* fdivp st(i),st */
-  clear_C1();
-  if ( FPU_div(REV|DEST_RM, FPU_rm, control_word) >= 0 )
-    FPU_pop();
+       /* fdivp st(i),st */
+       clear_C1();
+       if (FPU_div(REV | DEST_RM, FPU_rm, control_word) >= 0)
+               FPU_pop();
 }
index 9ba1241..955b932 100644 (file)
@@ -14,7 +14,6 @@
 
 #define        EXCEPTION       FPU_exception
 
-
 #define PARAM1 8(%ebp)
 #define        PARAM2  12(%ebp)
 #define        PARAM3  16(%ebp)
index 20886cf..491e737 100644 (file)
 #include "status_w.h"
 #include "control_w.h"
 
-
 static void fnop(void)
 {
 }
 
 static void fclex(void)
 {
-  partial_status &= ~(SW_Backward|SW_Summary|SW_Stack_Fault|SW_Precision|
-                  SW_Underflow|SW_Overflow|SW_Zero_Div|SW_Denorm_Op|
-                  SW_Invalid);
-  no_ip_update = 1;
+       partial_status &=
+           ~(SW_Backward | SW_Summary | SW_Stack_Fault | SW_Precision |
+             SW_Underflow | SW_Overflow | SW_Zero_Div | SW_Denorm_Op |
+             SW_Invalid);
+       no_ip_update = 1;
 }
 
 /* Needs to be externally visible */
 void finit(void)
 {
-  control_word = 0x037f;
-  partial_status = 0;
-  top = 0;            /* We don't keep top in the status word internally. */
-  fpu_tag_word = 0xffff;
-  /* The behaviour is different from that detailed in
-     Section 15.1.6 of the Intel manual */
-  operand_address.offset = 0;
-  operand_address.selector = 0;
-  instruction_address.offset = 0;
-  instruction_address.selector = 0;
-  instruction_address.opcode = 0;
-  no_ip_update = 1;
+       control_word = 0x037f;
+       partial_status = 0;
+       top = 0;                /* We don't keep top in the status word internally. */
+       fpu_tag_word = 0xffff;
+       /* The behaviour is different from that detailed in
+          Section 15.1.6 of the Intel manual */
+       operand_address.offset = 0;
+       operand_address.selector = 0;
+       instruction_address.offset = 0;
+       instruction_address.selector = 0;
+       instruction_address.opcode = 0;
+       no_ip_update = 1;
 }
 
 /*
@@ -54,151 +54,134 @@ void finit(void)
 #define fsetpm fnop
 
 static FUNC const finit_table[] = {
-  feni, fdisi, fclex, finit,
-  fsetpm, FPU_illegal, FPU_illegal, FPU_illegal
+       feni, fdisi, fclex, finit,
+       fsetpm, FPU_illegal, FPU_illegal, FPU_illegal
 };
 
 void finit_(void)
 {
-  (finit_table[FPU_rm])();
+       (finit_table[FPU_rm]) ();
 }
 
-
 static void fstsw_ax(void)
 {
-  *(short *) &FPU_EAX = status_word();
-  no_ip_update = 1;
+       *(short *)&FPU_EAX = status_word();
+       no_ip_update = 1;
 }
 
 static FUNC const fstsw_table[] = {
-  fstsw_ax, FPU_illegal, FPU_illegal, FPU_illegal,
-  FPU_illegal, FPU_illegal, FPU_illegal, FPU_illegal
+       fstsw_ax, FPU_illegal, FPU_illegal, FPU_illegal,
+       FPU_illegal, FPU_illegal, FPU_illegal, FPU_illegal
 };
 
 void fstsw_(void)
 {
-  (fstsw_table[FPU_rm])();
+       (fstsw_table[FPU_rm]) ();
 }
 
-
 static FUNC const fp_nop_table[] = {
-  fnop, FPU_illegal, FPU_illegal, FPU_illegal,
-  FPU_illegal, FPU_illegal, FPU_illegal, FPU_illegal
+       fnop, FPU_illegal, FPU_illegal, FPU_illegal,
+       FPU_illegal, FPU_illegal, FPU_illegal, FPU_illegal
 };
 
 void fp_nop(void)
 {
-  (fp_nop_table[FPU_rm])();
+       (fp_nop_table[FPU_rm]) ();
 }
 
-
 void fld_i_(void)
 {
-  FPU_REG *st_new_ptr;
-  int i;
-  u_char tag;
-
-  if ( STACK_OVERFLOW )
-    { FPU_stack_overflow(); return; }
-
-  /* fld st(i) */
-  i = FPU_rm;
-  if ( NOT_EMPTY(i) )
-    {
-      reg_copy(&st(i), st_new_ptr);
-      tag = FPU_gettagi(i);
-      push();
-      FPU_settag0(tag);
-    }
-  else
-    {
-      if ( control_word & CW_Invalid )
-       {
-         /* The masked response */
-         FPU_stack_underflow();
+       FPU_REG *st_new_ptr;
+       int i;
+       u_char tag;
+
+       if (STACK_OVERFLOW) {
+               FPU_stack_overflow();
+               return;
        }
-      else
-       EXCEPTION(EX_StackUnder);
-    }
 
-}
+       /* fld st(i) */
+       i = FPU_rm;
+       if (NOT_EMPTY(i)) {
+               reg_copy(&st(i), st_new_ptr);
+               tag = FPU_gettagi(i);
+               push();
+               FPU_settag0(tag);
+       } else {
+               if (control_word & CW_Invalid) {
+                       /* The masked response */
+                       FPU_stack_underflow();
+               } else
+                       EXCEPTION(EX_StackUnder);
+       }
 
+}
 
 void fxch_i(void)
 {
-  /* fxch st(i) */
-  FPU_REG t;
-  int i = FPU_rm;
-  FPU_REG *st0_ptr = &st(0), *sti_ptr = &st(i);
-  long tag_word = fpu_tag_word;
-  int regnr = top & 7, regnri = ((regnr + i) & 7);
-  u_char st0_tag = (tag_word >> (regnr*2)) & 3;
-  u_char sti_tag = (tag_word >> (regnri*2)) & 3;
-
-  if ( st0_tag == TAG_Empty )
-    {
-      if ( sti_tag == TAG_Empty )
-       {
-         FPU_stack_underflow();
-         FPU_stack_underflow_i(i);
-         return;
+       /* fxch st(i) */
+       FPU_REG t;
+       int i = FPU_rm;
+       FPU_REG *st0_ptr = &st(0), *sti_ptr = &st(i);
+       long tag_word = fpu_tag_word;
+       int regnr = top & 7, regnri = ((regnr + i) & 7);
+       u_char st0_tag = (tag_word >> (regnr * 2)) & 3;
+       u_char sti_tag = (tag_word >> (regnri * 2)) & 3;
+
+       if (st0_tag == TAG_Empty) {
+               if (sti_tag == TAG_Empty) {
+                       FPU_stack_underflow();
+                       FPU_stack_underflow_i(i);
+                       return;
+               }
+               if (control_word & CW_Invalid) {
+                       /* Masked response */
+                       FPU_copy_to_reg0(sti_ptr, sti_tag);
+               }
+               FPU_stack_underflow_i(i);
+               return;
        }
-      if ( control_word & CW_Invalid )
-       {
-         /* Masked response */
-         FPU_copy_to_reg0(sti_ptr, sti_tag);
+       if (sti_tag == TAG_Empty) {
+               if (control_word & CW_Invalid) {
+                       /* Masked response */
+                       FPU_copy_to_regi(st0_ptr, st0_tag, i);
+               }
+               FPU_stack_underflow();
+               return;
        }
-      FPU_stack_underflow_i(i);
-      return;
-    }
-  if ( sti_tag == TAG_Empty )
-    {
-      if ( control_word & CW_Invalid )
-       {
-         /* Masked response */
-         FPU_copy_to_regi(st0_ptr, st0_tag, i);
-       }
-      FPU_stack_underflow();
-      return;
-    }
-  clear_C1();
-
-  reg_copy(st0_ptr, &t);
-  reg_copy(sti_ptr, st0_ptr);
-  reg_copy(&t, sti_ptr);
-
-  tag_word &= ~(3 << (regnr*2)) & ~(3 << (regnri*2));
-  tag_word |= (sti_tag << (regnr*2)) | (st0_tag << (regnri*2));
-  fpu_tag_word = tag_word;
-}
+       clear_C1();
 
+       reg_copy(st0_ptr, &t);
+       reg_copy(sti_ptr, st0_ptr);
+       reg_copy(&t, sti_ptr);
+
+       tag_word &= ~(3 << (regnr * 2)) & ~(3 << (regnri * 2));
+       tag_word |= (sti_tag << (regnr * 2)) | (st0_tag << (regnri * 2));
+       fpu_tag_word = tag_word;
+}
 
 void ffree_(void)
 {
-  /* ffree st(i) */
-  FPU_settagi(FPU_rm, TAG_Empty);
+       /* ffree st(i) */
+       FPU_settagi(FPU_rm, TAG_Empty);
 }
 
-
 void ffreep(void)
 {
-  /* ffree st(i) + pop - unofficial code */
-  FPU_settagi(FPU_rm, TAG_Empty);
-  FPU_pop();
+       /* ffree st(i) + pop - unofficial code */
+       FPU_settagi(FPU_rm, TAG_Empty);
+       FPU_pop();
 }
 
-
 void fst_i_(void)
 {
-  /* fst st(i) */
-  FPU_copy_to_regi(&st(0), FPU_gettag0(), FPU_rm);
+       /* fst st(i) */
+       FPU_copy_to_regi(&st(0), FPU_gettag0(), FPU_rm);
 }
 
-
 void fstp_i(void)
 {
-  /* fstp st(i) */
-  FPU_copy_to_regi(&st(0), FPU_gettag0(), FPU_rm);
-  FPU_pop();
+       /* fstp st(i) */
+       FPU_copy_to_regi(&st(0), FPU_gettag0(), FPU_rm);
+       FPU_pop();
 }
-
index 65120f5..656dd4c 100644 (file)
@@ -7,7 +7,6 @@
  |                                                                           |
  +---------------------------------------------------------------------------*/
 
-
 #ifndef _FPU_EMU_H_
 #define _FPU_EMU_H_
 
 #endif
 
 #define EXP_BIAS       Const(0)
-#define EXP_OVER       Const(0x4000)    /* smallest invalid large exponent */
-#define        EXP_UNDER       Const(-0x3fff)   /* largest invalid small exponent */
-#define EXP_WAY_UNDER   Const(-0x6000)   /* Below the smallest denormal, but
-                                           still a 16 bit nr. */
+#define EXP_OVER       Const(0x4000)   /* smallest invalid large exponent */
+#define        EXP_UNDER       Const(-0x3fff)  /* largest invalid small exponent */
+#define EXP_WAY_UNDER   Const(-0x6000) /* Below the smallest denormal, but
+                                          still a 16 bit nr. */
 #define EXP_Infinity    EXP_OVER
 #define EXP_NaN         EXP_OVER
 
 #define EXTENDED_Ebias Const(0x3fff)
-#define EXTENDED_Emin (-0x3ffe)  /* smallest valid exponent */
+#define EXTENDED_Emin (-0x3ffe)        /* smallest valid exponent */
 
 #define SIGN_POS       Const(0)
 #define SIGN_NEG       Const(0x80)
 #define SIGN_Positive  Const(0)
 #define SIGN_Negative  Const(0x8000)
 
-
 /* Keep the order TAG_Valid, TAG_Zero, TW_Denormal */
 /* The following fold to 2 (Special) in the Tag Word */
-#define TW_Denormal     Const(4)        /* De-normal */
+#define TW_Denormal     Const(4)       /* De-normal */
 #define TW_Infinity    Const(5)        /* + or - infinity */
 #define        TW_NaN          Const(6)        /* Not a Number */
 #define        TW_Unsupported  Const(7)        /* Not supported by an 80486 */
 #define DEST_RM         0x20
 #define LOADED          0x40
 
-#define FPU_Exception   Const(0x80000000)   /* Added to tag returns. */
-
+#define FPU_Exception   Const(0x80000000)      /* Added to tag returns. */
 
 #ifndef __ASSEMBLY__
 
 #include "fpu_system.h"
 
-#include <asm/sigcontext.h>   /* for struct _fpstate */
+#include <asm/sigcontext.h>    /* for struct _fpstate */
 #include <asm/math_emu.h>
 #include <linux/linkage.h>
 
@@ -112,30 +109,33 @@ extern u_char emulating;
 #define PREFIX_DEFAULT 7
 
 struct address {
-  unsigned int offset;
-  unsigned int selector:16;
-  unsigned int opcode:11;
-  unsigned int empty:5;
+       unsigned int offset;
+       unsigned int selector:16;
+       unsigned int opcode:11;
+       unsigned int empty:5;
 };
 struct fpu__reg {
-  unsigned sigl;
-  unsigned sigh;
-  short exp;
+       unsigned sigl;
+       unsigned sigh;
+       short exp;
 };
 
-typedef void (*FUNC)(void);
+typedef void (*FUNC) (void);
 typedef struct fpu__reg FPU_REG;
-typedef void (*FUNC_ST0)(FPU_REG *st0_ptr, u_char st0_tag);
-typedef struct { u_char address_size, operand_size, segment; }
-        overrides;
+typedef void (*FUNC_ST0) (FPU_REG * st0_ptr, u_char st0_tag);
+typedef struct {
+       u_char address_size, operand_size, segment;
+} overrides;
 /* This structure is 32 bits: */
-typedef struct { overrides override;
-                u_char default_mode; } fpu_addr_modes;
+typedef struct {
+       overrides override;
+       u_char default_mode;
+} fpu_addr_modes;
 /* PROTECTED has a restricted meaning in the emulator; it is used
    to signal that the emulator needs to do special things to ensure
    that protection is respected in a segmented model. */
 #define PROTECTED 4
-#define SIXTEEN   1         /* We rely upon this being 1 (true) */
+#define SIXTEEN   1            /* We rely upon this being 1 (true) */
 #define VM86      SIXTEEN
 #define PM16      (SIXTEEN | PROTECTED)
 #define SEG32     PROTECTED
@@ -166,10 +166,10 @@ extern u_char const data_sizes_16[32];
 #define signpositive(a) ( (signbyte(a) & 0x80) == 0 )
 #define signnegative(a) (signbyte(a) & 0x80)
 
-static inline void reg_copy(FPU_REG const *x, FPU_REG *y)
+static inline void reg_copy(FPU_REG const *x, FPU_REG * y)
 {
-  *(short *)&(y->exp) = *(const short *)&(x->exp); 
-  *(long long *)&(y->sigl) = *(const long long *)&(x->sigl);
+       *(short *)&(y->exp) = *(const short *)&(x->exp);
+       *(long long *)&(y->sigl) = *(const long long *)&(x->sigl);
 }
 
 #define exponent(x)  (((*(short *)&((x)->exp)) & 0x7fff) - EXTENDED_Ebias)
@@ -184,29 +184,28 @@ static inline void reg_copy(FPU_REG const *x, FPU_REG *y)
 
 #define significand(x) ( ((unsigned long long *)&((x)->sigl))[0] )
 
-
 /*----- Prototypes for functions written in assembler -----*/
 /* extern void reg_move(FPU_REG *a, FPU_REG *b); */
 
-asmlinkage int FPU_normalize(FPU_REG *x);
-asmlinkage int FPU_normalize_nuo(FPU_REG *x);
+asmlinkage int FPU_normalize(FPU_REG * x);
+asmlinkage int FPU_normalize_nuo(FPU_REG * x);
 asmlinkage int FPU_u_sub(FPU_REG const *arg1, FPU_REG const *arg2,
-                        FPU_REG *answ, unsigned int control_w, u_char sign,
+                        FPU_REG * answ, unsigned int control_w, u_char sign,
                         int expa, int expb);
 asmlinkage int FPU_u_mul(FPU_REG const *arg1, FPU_REG const *arg2,
-                        FPU_REG *answ, unsigned int control_w, u_char sign,
+                        FPU_REG * answ, unsigned int control_w, u_char sign,
                         int expon);
 asmlinkage int FPU_u_div(FPU_REG const *arg1, FPU_REG const *arg2,
-                        FPU_REG *answ, unsigned int control_w, u_char sign);
+                        FPU_REG * answ, unsigned int control_w, u_char sign);
 asmlinkage int FPU_u_add(FPU_REG const *arg1, FPU_REG const *arg2,
-                        FPU_REG *answ, unsigned int control_w, u_char sign,
+                        FPU_REG * answ, unsigned int control_w, u_char sign,
                         int expa, int expb);
-asmlinkage int wm_sqrt(FPU_REG *n, int dummy1, int dummy2,
+asmlinkage int wm_sqrt(FPU_REG * n, int dummy1, int dummy2,
                       unsigned int control_w, u_char sign);
-asmlinkage unsigned    FPU_shrx(void *l, unsigned x);
-asmlinkage unsigned    FPU_shrxs(void *v, unsigned x);
+asmlinkage unsigned FPU_shrx(void *l, unsigned x);
+asmlinkage unsigned FPU_shrxs(void *v, unsigned x);
 asmlinkage unsigned long FPU_div_small(unsigned long long *x, unsigned long y);
-asmlinkage int FPU_round(FPU_REG *arg, unsigned int extent, int dummy,
+asmlinkage int FPU_round(FPU_REG * arg, unsigned int extent, int dummy,
                         unsigned int control_w, u_char sign);
 
 #ifndef MAKING_PROTO
index 1853524..cbb8717 100644 (file)
 #include "control_w.h"
 #include "status_w.h"
 
-#define __BAD__ FPU_illegal   /* Illegal on an 80486, causes SIGILL */
+#define __BAD__ FPU_illegal    /* Illegal on an 80486, causes SIGILL */
 
-#ifndef NO_UNDOC_CODE    /* Un-documented FPU op-codes supported by default. */
+#ifndef NO_UNDOC_CODE          /* Un-documented FPU op-codes supported by default. */
 
 /* WARNING: These codes are not documented by Intel in their 80486 manual
    and may not work on FPU clones or later Intel FPUs. */
 
 /* Changes to support the un-doc codes provided by Linus Torvalds. */
 
-#define _d9_d8_ fstp_i    /* unofficial code (19) */
-#define _dc_d0_ fcom_st   /* unofficial code (14) */
-#define _dc_d8_ fcompst   /* unofficial code (1c) */
-#define _dd_c8_ fxch_i    /* unofficial code (0d) */
-#define _de_d0_ fcompst   /* unofficial code (16) */
-#define _df_c0_ ffreep    /* unofficial code (07) ffree + pop */
-#define _df_c8_ fxch_i    /* unofficial code (0f) */
-#define _df_d0_ fstp_i    /* unofficial code (17) */
-#define _df_d8_ fstp_i    /* unofficial code (1f) */
+#define _d9_d8_ fstp_i         /* unofficial code (19) */
+#define _dc_d0_ fcom_st                /* unofficial code (14) */
+#define _dc_d8_ fcompst                /* unofficial code (1c) */
+#define _dd_c8_ fxch_i         /* unofficial code (0d) */
+#define _de_d0_ fcompst                /* unofficial code (16) */
+#define _df_c0_ ffreep         /* unofficial code (07) ffree + pop */
+#define _df_c8_ fxch_i         /* unofficial code (0f) */
+#define _df_d0_ fstp_i         /* unofficial code (17) */
+#define _df_d8_ fstp_i         /* unofficial code (1f) */
 
 static FUNC const st_instr_table[64] = {
-  fadd__,   fld_i_,     __BAD__, __BAD__, fadd_i,  ffree_,  faddp_,  _df_c0_,
-  fmul__,   fxch_i,     __BAD__, __BAD__, fmul_i,  _dd_c8_, fmulp_,  _df_c8_,
-  fcom_st,  fp_nop,     __BAD__, __BAD__, _dc_d0_, fst_i_,  _de_d0_, _df_d0_,
-  fcompst,  _d9_d8_,    __BAD__, __BAD__, _dc_d8_, fstp_i,  fcompp,  _df_d8_,
-  fsub__,   FPU_etc,    __BAD__, finit_,  fsubri,  fucom_,  fsubrp,  fstsw_,
-  fsubr_,   fconst,     fucompp, __BAD__, fsub_i,  fucomp,  fsubp_,  __BAD__,
-  fdiv__,   FPU_triga,  __BAD__, __BAD__, fdivri,  __BAD__, fdivrp,  __BAD__,
-  fdivr_,   FPU_trigb,  __BAD__, __BAD__, fdiv_i,  __BAD__, fdivp_,  __BAD__,
+       fadd__, fld_i_, __BAD__, __BAD__, fadd_i, ffree_, faddp_, _df_c0_,
+       fmul__, fxch_i, __BAD__, __BAD__, fmul_i, _dd_c8_, fmulp_, _df_c8_,
+       fcom_st, fp_nop, __BAD__, __BAD__, _dc_d0_, fst_i_, _de_d0_, _df_d0_,
+       fcompst, _d9_d8_, __BAD__, __BAD__, _dc_d8_, fstp_i, fcompp, _df_d8_,
+       fsub__, FPU_etc, __BAD__, finit_, fsubri, fucom_, fsubrp, fstsw_,
+       fsubr_, fconst, fucompp, __BAD__, fsub_i, fucomp, fsubp_, __BAD__,
+       fdiv__, FPU_triga, __BAD__, __BAD__, fdivri, __BAD__, fdivrp, __BAD__,
+       fdivr_, FPU_trigb, __BAD__, __BAD__, fdiv_i, __BAD__, fdivp_, __BAD__,
 };
 
-#else     /* Support only documented FPU op-codes */
+#else /* Support only documented FPU op-codes */
 
 static FUNC const st_instr_table[64] = {
-  fadd__,   fld_i_,     __BAD__, __BAD__, fadd_i,  ffree_,  faddp_,  __BAD__,
-  fmul__,   fxch_i,     __BAD__, __BAD__, fmul_i,  __BAD__, fmulp_,  __BAD__,
-  fcom_st,  fp_nop,     __BAD__, __BAD__, __BAD__, fst_i_,  __BAD__, __BAD__,
-  fcompst,  __BAD__,    __BAD__, __BAD__, __BAD__, fstp_i,  fcompp,  __BAD__,
-  fsub__,   FPU_etc,    __BAD__, finit_,  fsubri,  fucom_,  fsubrp,  fstsw_,
-  fsubr_,   fconst,     fucompp, __BAD__, fsub_i,  fucomp,  fsubp_,  __BAD__,
-  fdiv__,   FPU_triga,  __BAD__, __BAD__, fdivri,  __BAD__, fdivrp,  __BAD__,
-  fdivr_,   FPU_trigb,  __BAD__, __BAD__, fdiv_i,  __BAD__, fdivp_,  __BAD__,
+       fadd__, fld_i_, __BAD__, __BAD__, fadd_i, ffree_, faddp_, __BAD__,
+       fmul__, fxch_i, __BAD__, __BAD__, fmul_i, __BAD__, fmulp_, __BAD__,
+       fcom_st, fp_nop, __BAD__, __BAD__, __BAD__, fst_i_, __BAD__, __BAD__,
+       fcompst, __BAD__, __BAD__, __BAD__, __BAD__, fstp_i, fcompp, __BAD__,
+       fsub__, FPU_etc, __BAD__, finit_, fsubri, fucom_, fsubrp, fstsw_,
+       fsubr_, fconst, fucompp, __BAD__, fsub_i, fucomp, fsubp_, __BAD__,
+       fdiv__, FPU_triga, __BAD__, __BAD__, fdivri, __BAD__, fdivrp, __BAD__,
+       fdivr_, FPU_trigb, __BAD__, __BAD__, fdiv_i, __BAD__, fdivp_, __BAD__,
 };
 
 #endif /* NO_UNDOC_CODE */
 
-
-#define _NONE_ 0   /* Take no special action */
-#define _REG0_ 1   /* Need to check for not empty st(0) */
-#define _REGI_ 2   /* Need to check for not empty st(0) and st(rm) */
-#define _REGi_ 0   /* Uses st(rm) */
-#define _PUSH_ 3   /* Need to check for space to push onto stack */
-#define _null_ 4   /* Function illegal or not implemented */
-#define _REGIi 5   /* Uses st(0) and st(rm), result to st(rm) */
-#define _REGIp 6   /* Uses st(0) and st(rm), result to st(rm) then pop */
-#define _REGIc 0   /* Compare st(0) and st(rm) */
-#define _REGIn 0   /* Uses st(0) and st(rm), but handle checks later */
+#define _NONE_ 0               /* Take no special action */
+#define _REG0_ 1               /* Need to check for not empty st(0) */
+#define _REGI_ 2               /* Need to check for not empty st(0) and st(rm) */
+#define _REGi_ 0               /* Uses st(rm) */
+#define _PUSH_ 3               /* Need to check for space to push onto stack */
+#define _null_ 4               /* Function illegal or not implemented */
+#define _REGIi 5               /* Uses st(0) and st(rm), result to st(rm) */
+#define _REGIp 6               /* Uses st(0) and st(rm), result to st(rm) then pop */
+#define _REGIc 0               /* Compare st(0) and st(rm) */
+#define _REGIn 0               /* Uses st(0) and st(rm), but handle checks later */
 
 #ifndef NO_UNDOC_CODE
 
 /* Un-documented FPU op-codes supported by default. (see above) */
 
 static u_char const type_table[64] = {
-  _REGI_, _NONE_, _null_, _null_, _REGIi, _REGi_, _REGIp, _REGi_,
-  _REGI_, _REGIn, _null_, _null_, _REGIi, _REGI_, _REGIp, _REGI_,
-  _REGIc, _NONE_, _null_, _null_, _REGIc, _REG0_, _REGIc, _REG0_,
-  _REGIc, _REG0_, _null_, _null_, _REGIc, _REG0_, _REGIc, _REG0_,
-  _REGI_, _NONE_, _null_, _NONE_, _REGIi, _REGIc, _REGIp, _NONE_,
-  _REGI_, _NONE_, _REGIc, _null_, _REGIi, _REGIc, _REGIp, _null_,
-  _REGI_, _NONE_, _null_, _null_, _REGIi, _null_, _REGIp, _null_,
-  _REGI_, _NONE_, _null_, _null_, _REGIi, _null_, _REGIp, _null_
+       _REGI_, _NONE_, _null_, _null_, _REGIi, _REGi_, _REGIp, _REGi_,
+       _REGI_, _REGIn, _null_, _null_, _REGIi, _REGI_, _REGIp, _REGI_,
+       _REGIc, _NONE_, _null_, _null_, _REGIc, _REG0_, _REGIc, _REG0_,
+       _REGIc, _REG0_, _null_, _null_, _REGIc, _REG0_, _REGIc, _REG0_,
+       _REGI_, _NONE_, _null_, _NONE_, _REGIi, _REGIc, _REGIp, _NONE_,
+       _REGI_, _NONE_, _REGIc, _null_, _REGIi, _REGIc, _REGIp, _null_,
+       _REGI_, _NONE_, _null_, _null_, _REGIi, _null_, _REGIp, _null_,
+       _REGI_, _NONE_, _null_, _null_, _REGIi, _null_, _REGIp, _null_
 };
 
-#else     /* Support only documented FPU op-codes */
+#else /* Support only documented FPU op-codes */
 
 static u_char const type_table[64] = {
-  _REGI_, _NONE_, _null_, _null_, _REGIi, _REGi_, _REGIp, _null_,
-  _REGI_, _REGIn, _null_, _null_, _REGIi, _null_, _REGIp, _null_,
-  _REGIc, _NONE_, _null_, _null_, _null_, _REG0_, _null_, _null_,
-  _REGIc, _null_, _null_, _null_, _null_, _REG0_, _REGIc, _null_,
-  _REGI_, _NONE_, _null_, _NONE_, _REGIi, _REGIc, _REGIp, _NONE_,
-  _REGI_, _NONE_, _REGIc, _null_, _REGIi, _REGIc, _REGIp, _null_,
-  _REGI_, _NONE_, _null_, _null_, _REGIi, _null_, _REGIp, _null_,
-  _REGI_, _NONE_, _null_, _null_, _REGIi, _null_, _REGIp, _null_
+       _REGI_, _NONE_, _null_, _null_, _REGIi, _REGi_, _REGIp, _null_,
+       _REGI_, _REGIn, _null_, _null_, _REGIi, _null_, _REGIp, _null_,
+       _REGIc, _NONE_, _null_, _null_, _null_, _REG0_, _null_, _null_,
+       _REGIc, _null_, _null_, _null_, _null_, _REG0_, _REGIc, _null_,
+       _REGI_, _NONE_, _null_, _NONE_, _REGIi, _REGIc, _REGIp, _NONE_,
+       _REGI_, _NONE_, _REGIc, _null_, _REGIi, _REGIc, _REGIp, _null_,
+       _REGI_, _NONE_, _null_, _null_, _REGIi, _null_, _REGIp, _null_,
+       _REGI_, _NONE_, _null_, _null_, _REGIi, _null_, _REGIp, _null_
 };
 
 #endif /* NO_UNDOC_CODE */
 
-
 #ifdef RE_ENTRANT_CHECKING
-u_char emulating=0;
+u_char emulating = 0;
 #endif /* RE_ENTRANT_CHECKING */
 
-static int valid_prefix(u_char *Byte, u_char __user **fpu_eip,
-                       overrides *override);
+static int valid_prefix(u_char * Byte, u_char __user ** fpu_eip,
+                       overrides * override);
 
 asmlinkage void math_emulate(long arg)
 {
-  u_char  FPU_modrm, byte1;
-  unsigned short code;
-  fpu_addr_modes addr_modes;
-  int unmasked;
-  FPU_REG loaded_data;
-  FPU_REG *st0_ptr;
-  u_char         loaded_tag, st0_tag;
-  void __user *data_address;
-  struct address data_sel_off;
-  struct address entry_sel_off;
-  unsigned long code_base = 0;
-  unsigned long code_limit = 0;  /* Initialized to stop compiler warnings */
-  struct desc_struct code_descriptor;
+       u_char FPU_modrm, byte1;
+       unsigned short code;
+       fpu_addr_modes addr_modes;
+       int unmasked;
+       FPU_REG loaded_data;
+       FPU_REG *st0_ptr;
+       u_char loaded_tag, st0_tag;
+       void __user *data_address;
+       struct address data_sel_off;
+       struct address entry_sel_off;
+       unsigned long code_base = 0;
+       unsigned long code_limit = 0;   /* Initialized to stop compiler warnings */
+       struct desc_struct code_descriptor;
 
 #ifdef RE_ENTRANT_CHECKING
-  if ( emulating )
-    {
-      printk("ERROR: wm-FPU-emu is not RE-ENTRANT!\n");
-    }
-  RE_ENTRANT_CHECK_ON;
+       if (emulating) {
+               printk("ERROR: wm-FPU-emu is not RE-ENTRANT!\n");
+       }
+       RE_ENTRANT_CHECK_ON;
 #endif /* RE_ENTRANT_CHECKING */
 
-  if (!used_math())
-    {
-      finit();
-      set_used_math();
-    }
-
-  SETUP_DATA_AREA(arg);
-
-  FPU_ORIG_EIP = FPU_EIP;
-
-  if ( (FPU_EFLAGS & 0x00020000) != 0 )
-    {
-      /* Virtual 8086 mode */
-      addr_modes.default_mode = VM86;
-      FPU_EIP += code_base = FPU_CS << 4;
-      code_limit = code_base + 0xffff;  /* Assumes code_base <= 0xffff0000 */
-    }
-  else if ( FPU_CS == __USER_CS && FPU_DS == __USER_DS )
-    {
-      addr_modes.default_mode = 0;
-    }
-  else if ( FPU_CS == __KERNEL_CS )
-    {
-      printk("math_emulate: %04x:%08lx\n",FPU_CS,FPU_EIP);
-      panic("Math emulation needed in kernel");
-    }
-  else
-    {
-
-      if ( (FPU_CS & 4) != 4 )   /* Must be in the LDT */
-       {
-         /* Can only handle segmented addressing via the LDT
-            for now, and it must be 16 bit */
-         printk("FPU emulator: Unsupported addressing mode\n");
-         math_abort(FPU_info, SIGILL);
+       if (!used_math()) {
+               finit();
+               set_used_math();
        }
 
-      code_descriptor = LDT_DESCRIPTOR(FPU_CS);
-      if ( SEG_D_SIZE(code_descriptor) )
-       {
-         /* The above test may be wrong, the book is not clear */
-         /* Segmented 32 bit protected mode */
-         addr_modes.default_mode = SEG32;
+       SETUP_DATA_AREA(arg);
+
+       FPU_ORIG_EIP = FPU_EIP;
+
+       if ((FPU_EFLAGS & 0x00020000) != 0) {
+               /* Virtual 8086 mode */
+               addr_modes.default_mode = VM86;
+               FPU_EIP += code_base = FPU_CS << 4;
+               code_limit = code_base + 0xffff;        /* Assumes code_base <= 0xffff0000 */
+       } else if (FPU_CS == __USER_CS && FPU_DS == __USER_DS) {
+               addr_modes.default_mode = 0;
+       } else if (FPU_CS == __KERNEL_CS) {
+               printk("math_emulate: %04x:%08lx\n", FPU_CS, FPU_EIP);
+               panic("Math emulation needed in kernel");
+       } else {
+
+               if ((FPU_CS & 4) != 4) {        /* Must be in the LDT */
+                       /* Can only handle segmented addressing via the LDT
+                          for now, and it must be 16 bit */
+                       printk("FPU emulator: Unsupported addressing mode\n");
+                       math_abort(FPU_info, SIGILL);
+               }
+
+               code_descriptor = LDT_DESCRIPTOR(FPU_CS);
+               if (SEG_D_SIZE(code_descriptor)) {
+                       /* The above test may be wrong, the book is not clear */
+                       /* Segmented 32 bit protected mode */
+                       addr_modes.default_mode = SEG32;
+               } else {
+                       /* 16 bit protected mode */
+                       addr_modes.default_mode = PM16;
+               }
+               FPU_EIP += code_base = SEG_BASE_ADDR(code_descriptor);
+               code_limit = code_base
+                   + (SEG_LIMIT(code_descriptor) +
+                      1) * SEG_GRANULARITY(code_descriptor)
+                   - 1;
+               if (code_limit < code_base)
+                       code_limit = 0xffffffff;
        }
-      else
-       {
-         /* 16 bit protected mode */
-         addr_modes.default_mode = PM16;
+
+       FPU_lookahead = 1;
+       if (current->ptrace & PT_PTRACED)
+               FPU_lookahead = 0;
+
+       if (!valid_prefix(&byte1, (u_char __user **) & FPU_EIP,
+                         &addr_modes.override)) {
+               RE_ENTRANT_CHECK_OFF;
+               printk
+                   ("FPU emulator: Unknown prefix byte 0x%02x, probably due to\n"
+                    "FPU emulator: self-modifying code! (emulation impossible)\n",
+                    byte1);
+               RE_ENTRANT_CHECK_ON;
+               EXCEPTION(EX_INTERNAL | 0x126);
+               math_abort(FPU_info, SIGILL);
        }
-      FPU_EIP += code_base = SEG_BASE_ADDR(code_descriptor);
-      code_limit = code_base
-       + (SEG_LIMIT(code_descriptor)+1) * SEG_GRANULARITY(code_descriptor)
-         - 1;
-      if ( code_limit < code_base ) code_limit = 0xffffffff;
-    }
-
-  FPU_lookahead = 1;
-  if (current->ptrace & PT_PTRACED)
-    FPU_lookahead = 0;
-
-  if ( !valid_prefix(&byte1, (u_char __user **)&FPU_EIP,
-                    &addr_modes.override) )
-    {
-      RE_ENTRANT_CHECK_OFF;
-      printk("FPU emulator: Unknown prefix byte 0x%02x, probably due to\n"
-            "FPU emulator: self-modifying code! (emulation impossible)\n",
-            byte1);
-      RE_ENTRANT_CHECK_ON;
-      EXCEPTION(EX_INTERNAL|0x126);
-      math_abort(FPU_info,SIGILL);
-    }
-
-do_another_FPU_instruction:
-
-  no_ip_update = 0;
-
-  FPU_EIP++;  /* We have fetched the prefix and first code bytes. */
-
-  if ( addr_modes.default_mode )
-    {
-      /* This checks for the minimum instruction bytes.
-        We also need to check any extra (address mode) code access. */
-      if ( FPU_EIP > code_limit )
-       math_abort(FPU_info,SIGSEGV);
-    }
-
-  if ( (byte1 & 0xf8) != 0xd8 )
-    {
-      if ( byte1 == FWAIT_OPCODE )
-       {
-         if (partial_status & SW_Summary)
-           goto do_the_FPU_interrupt;
-         else
-           goto FPU_fwait_done;
+
+      do_another_FPU_instruction:
+
+       no_ip_update = 0;
+
+       FPU_EIP++;              /* We have fetched the prefix and first code bytes. */
+
+       if (addr_modes.default_mode) {
+               /* This checks for the minimum instruction bytes.
+                  We also need to check any extra (address mode) code access. */
+               if (FPU_EIP > code_limit)
+                       math_abort(FPU_info, SIGSEGV);
        }
+
+       if ((byte1 & 0xf8) != 0xd8) {
+               if (byte1 == FWAIT_OPCODE) {
+                       if (partial_status & SW_Summary)
+                               goto do_the_FPU_interrupt;
+                       else
+                               goto FPU_fwait_done;
+               }
 #ifdef PARANOID
-      EXCEPTION(EX_INTERNAL|0x128);
-      math_abort(FPU_info,SIGILL);
+               EXCEPTION(EX_INTERNAL | 0x128);
+               math_abort(FPU_info, SIGILL);
 #endif /* PARANOID */
-    }
-
-  RE_ENTRANT_CHECK_OFF;
-  FPU_code_access_ok(1);
-  FPU_get_user(FPU_modrm, (u_char __user *) FPU_EIP);
-  RE_ENTRANT_CHECK_ON;
-  FPU_EIP++;
-
-  if (partial_status & SW_Summary)
-    {
-      /* Ignore the error for now if the current instruction is a no-wait
-        control instruction */
-      /* The 80486 manual contradicts itself on this topic,
-        but a real 80486 uses the following instructions:
-        fninit, fnstenv, fnsave, fnstsw, fnstenv, fnclex.
-       */
-      code = (FPU_modrm << 8) | byte1;
-      if ( ! ( (((code & 0xf803) == 0xe003) ||    /* fnclex, fninit, fnstsw */
-               (((code & 0x3003) == 0x3001) &&   /* fnsave, fnstcw, fnstenv,
-                                                    fnstsw */
-                ((code & 0xc000) != 0xc000))) ) )
-       {
-         /*
-          *  We need to simulate the action of the kernel to FPU
-          *  interrupts here.
-          */
-       do_the_FPU_interrupt:
-
-         FPU_EIP = FPU_ORIG_EIP;       /* Point to current FPU instruction. */
-
-         RE_ENTRANT_CHECK_OFF;
-         current->thread.trap_no = 16;
-         current->thread.error_code = 0;
-         send_sig(SIGFPE, current, 1);
-         return;
-       }
-    }
-
-  entry_sel_off.offset = FPU_ORIG_EIP;
-  entry_sel_off.selector = FPU_CS;
-  entry_sel_off.opcode = (byte1 << 8) | FPU_modrm;
-
-  FPU_rm = FPU_modrm & 7;
-
-  if ( FPU_modrm < 0300 )
-    {
-      /* All of these instructions use the mod/rm byte to get a data address */
-
-      if ( (addr_modes.default_mode & SIXTEEN)
-         ^ (addr_modes.override.address_size == ADDR_SIZE_PREFIX) )
-       data_address = FPU_get_address_16(FPU_modrm, &FPU_EIP, &data_sel_off,
-                                         addr_modes);
-      else
-       data_address = FPU_get_address(FPU_modrm, &FPU_EIP, &data_sel_off,
-                                      addr_modes);
-
-      if ( addr_modes.default_mode )
-       {
-         if ( FPU_EIP-1 > code_limit )
-           math_abort(FPU_info,SIGSEGV);
        }
 
-      if ( !(byte1 & 1) )
-       {
-         unsigned short status1 = partial_status;
-
-         st0_ptr = &st(0);
-         st0_tag = FPU_gettag0();
-
-         /* Stack underflow has priority */
-         if ( NOT_EMPTY_ST0 )
-           {
-             if ( addr_modes.default_mode & PROTECTED )
-               {
-                 /* This table works for 16 and 32 bit protected mode */
-                 if ( access_limit < data_sizes_16[(byte1 >> 1) & 3] )
-                   math_abort(FPU_info,SIGSEGV);
+       RE_ENTRANT_CHECK_OFF;
+       FPU_code_access_ok(1);
+       FPU_get_user(FPU_modrm, (u_char __user *) FPU_EIP);
+       RE_ENTRANT_CHECK_ON;
+       FPU_EIP++;
+
+       if (partial_status & SW_Summary) {
+               /* Ignore the error for now if the current instruction is a no-wait
+                  control instruction */
+               /* The 80486 manual contradicts itself on this topic,
+                  but a real 80486 uses the following instructions:
+                  fninit, fnstenv, fnsave, fnstsw, fnstenv, fnclex.
+                */
+               code = (FPU_modrm << 8) | byte1;
+               if (!((((code & 0xf803) == 0xe003) ||   /* fnclex, fninit, fnstsw */
+                      (((code & 0x3003) == 0x3001) &&  /* fnsave, fnstcw, fnstenv,
+                                                          fnstsw */
+                       ((code & 0xc000) != 0xc000))))) {
+                       /*
+                        *  We need to simulate the action of the kernel to FPU
+                        *  interrupts here.
+                        */
+                     do_the_FPU_interrupt:
+
+                       FPU_EIP = FPU_ORIG_EIP; /* Point to current FPU instruction. */
+
+                       RE_ENTRANT_CHECK_OFF;
+                       current->thread.trap_no = 16;
+                       current->thread.error_code = 0;
+                       send_sig(SIGFPE, current, 1);
+                       return;
                }
+       }
 
-             unmasked = 0;  /* Do this here to stop compiler warnings. */
-             switch ( (byte1 >> 1) & 3 )
-               {
-               case 0:
-                 unmasked = FPU_load_single((float __user *)data_address,
-                                            &loaded_data);
-                 loaded_tag = unmasked & 0xff;
-                 unmasked &= ~0xff;
-                 break;
-               case 1:
-                 loaded_tag = FPU_load_int32((long __user *)data_address, &loaded_data);
-                 break;
-               case 2:
-                 unmasked = FPU_load_double((double __user *)data_address,
-                                            &loaded_data);
-                 loaded_tag = unmasked & 0xff;
-                 unmasked &= ~0xff;
-                 break;
-               case 3:
-               default:  /* Used here to suppress gcc warnings. */
-                 loaded_tag = FPU_load_int16((short __user *)data_address, &loaded_data);
-                 break;
-               }
+       entry_sel_off.offset = FPU_ORIG_EIP;
+       entry_sel_off.selector = FPU_CS;
+       entry_sel_off.opcode = (byte1 << 8) | FPU_modrm;
 
-             /* No more access to user memory, it is safe
-                to use static data now */
-
-             /* NaN operands have the next priority. */
-             /* We have to delay looking at st(0) until after
-                loading the data, because that data might contain an SNaN */
-             if ( ((st0_tag == TAG_Special) && isNaN(st0_ptr)) ||
-                 ((loaded_tag == TAG_Special) && isNaN(&loaded_data)) )
-               {
-                 /* Restore the status word; we might have loaded a
-                    denormal. */
-                 partial_status = status1;
-                 if ( (FPU_modrm & 0x30) == 0x10 )
-                   {
-                     /* fcom or fcomp */
-                     EXCEPTION(EX_Invalid);
-                     setcc(SW_C3 | SW_C2 | SW_C0);
-                     if ( (FPU_modrm & 0x08) && (control_word & CW_Invalid) )
-                       FPU_pop();             /* fcomp, masked, so we pop. */
-                   }
-                 else
-                   {
-                     if ( loaded_tag == TAG_Special )
-                       loaded_tag = FPU_Special(&loaded_data);
-#ifdef PECULIAR_486
-                     /* This is not really needed, but gives behaviour
-                        identical to an 80486 */
-                     if ( (FPU_modrm & 0x28) == 0x20 )
-                       /* fdiv or fsub */
-                       real_2op_NaN(&loaded_data, loaded_tag, 0, &loaded_data);
-                     else
-#endif /* PECULIAR_486 */ 
-                       /* fadd, fdivr, fmul, or fsubr */
-                       real_2op_NaN(&loaded_data, loaded_tag, 0, st0_ptr);
-                   }
-                 goto reg_mem_instr_done;
-               }
+       FPU_rm = FPU_modrm & 7;
 
-             if ( unmasked && !((FPU_modrm & 0x30) == 0x10) )
-               {
-                 /* Is not a comparison instruction. */
-                 if ( (FPU_modrm & 0x38) == 0x38 )
-                   {
-                     /* fdivr */
-                     if ( (st0_tag == TAG_Zero) &&
-                          ((loaded_tag == TAG_Valid)
-                           || (loaded_tag == TAG_Special
-                               && isdenormal(&loaded_data))) )
-                       {
-                         if ( FPU_divide_by_zero(0, getsign(&loaded_data))
-                              < 0 )
-                           {
-                             /* We use the fact here that the unmasked
-                                exception in the loaded data was for a
-                                denormal operand */
-                             /* Restore the state of the denormal op bit */
-                             partial_status &= ~SW_Denorm_Op;
-                             partial_status |= status1 & SW_Denorm_Op;
-                           }
-                         else
-                           setsign(st0_ptr, getsign(&loaded_data));
-                       }
-                   }
-                 goto reg_mem_instr_done;
-               }
+       if (FPU_modrm < 0300) {
+               /* All of these instructions use the mod/rm byte to get a data address */
 
-             switch ( (FPU_modrm >> 3) & 7 )
-               {
-               case 0:         /* fadd */
-                 clear_C1();
-                 FPU_add(&loaded_data, loaded_tag, 0, control_word);
-                 break;
-               case 1:         /* fmul */
-                 clear_C1();
-                 FPU_mul(&loaded_data, loaded_tag, 0, control_word);
-                 break;
-               case 2:         /* fcom */
-                 FPU_compare_st_data(&loaded_data, loaded_tag);
-                 break;
-               case 3:         /* fcomp */
-                 if ( !FPU_compare_st_data(&loaded_data, loaded_tag)
-                      && !unmasked )
-                   FPU_pop();
-                 break;
-               case 4:         /* fsub */
-                 clear_C1();
-                 FPU_sub(LOADED|loaded_tag, (int)&loaded_data, control_word);
-                 break;
-               case 5:         /* fsubr */
-                 clear_C1();
-                 FPU_sub(REV|LOADED|loaded_tag, (int)&loaded_data, control_word);
-                 break;
-               case 6:         /* fdiv */
-                 clear_C1();
-                 FPU_div(LOADED|loaded_tag, (int)&loaded_data, control_word);
-                 break;
-               case 7:         /* fdivr */
-                 clear_C1();
-                 if ( st0_tag == TAG_Zero )
-                   partial_status = status1;  /* Undo any denorm tag,
-                                                 zero-divide has priority. */
-                 FPU_div(REV|LOADED|loaded_tag, (int)&loaded_data, control_word);
-                 break;
+               if ((addr_modes.default_mode & SIXTEEN)
+                   ^ (addr_modes.override.address_size == ADDR_SIZE_PREFIX))
+                       data_address =
+                           FPU_get_address_16(FPU_modrm, &FPU_EIP,
+                                              &data_sel_off, addr_modes);
+               else
+                       data_address =
+                           FPU_get_address(FPU_modrm, &FPU_EIP, &data_sel_off,
+                                           addr_modes);
+
+               if (addr_modes.default_mode) {
+                       if (FPU_EIP - 1 > code_limit)
+                               math_abort(FPU_info, SIGSEGV);
                }
-           }
-         else
-           {
-             if ( (FPU_modrm & 0x30) == 0x10 )
-               {
-                 /* The instruction is fcom or fcomp */
-                 EXCEPTION(EX_StackUnder);
-                 setcc(SW_C3 | SW_C2 | SW_C0);
-                 if ( (FPU_modrm & 0x08) && (control_word & CW_Invalid) )
-                   FPU_pop();             /* fcomp */
+
+               if (!(byte1 & 1)) {
+                       unsigned short status1 = partial_status;
+
+                       st0_ptr = &st(0);
+                       st0_tag = FPU_gettag0();
+
+                       /* Stack underflow has priority */
+                       if (NOT_EMPTY_ST0) {
+                               if (addr_modes.default_mode & PROTECTED) {
+                                       /* This table works for 16 and 32 bit protected mode */
+                                       if (access_limit <
+                                           data_sizes_16[(byte1 >> 1) & 3])
+                                               math_abort(FPU_info, SIGSEGV);
+                               }
+
+                               unmasked = 0;   /* Do this here to stop compiler warnings. */
+                               switch ((byte1 >> 1) & 3) {
+                               case 0:
+                                       unmasked =
+                                           FPU_load_single((float __user *)
+                                                           data_address,
+                                                           &loaded_data);
+                                       loaded_tag = unmasked & 0xff;
+                                       unmasked &= ~0xff;
+                                       break;
+                               case 1:
+                                       loaded_tag =
+                                           FPU_load_int32((long __user *)
+                                                          data_address,
+                                                          &loaded_data);
+                                       break;
+                               case 2:
+                                       unmasked =
+                                           FPU_load_double((double __user *)
+                                                           data_address,
+                                                           &loaded_data);
+                                       loaded_tag = unmasked & 0xff;
+                                       unmasked &= ~0xff;
+                                       break;
+                               case 3:
+                               default:        /* Used here to suppress gcc warnings. */
+                                       loaded_tag =
+                                           FPU_load_int16((short __user *)
+                                                          data_address,
+                                                          &loaded_data);
+                                       break;
+                               }
+
+                               /* No more access to user memory, it is safe
+                                  to use static data now */
+
+                               /* NaN operands have the next priority. */
+                               /* We have to delay looking at st(0) until after
+                                  loading the data, because that data might contain an SNaN */
+                               if (((st0_tag == TAG_Special) && isNaN(st0_ptr))
+                                   || ((loaded_tag == TAG_Special)
+                                       && isNaN(&loaded_data))) {
+                                       /* Restore the status word; we might have loaded a
+                                          denormal. */
+                                       partial_status = status1;
+                                       if ((FPU_modrm & 0x30) == 0x10) {
+                                               /* fcom or fcomp */
+                                               EXCEPTION(EX_Invalid);
+                                               setcc(SW_C3 | SW_C2 | SW_C0);
+                                               if ((FPU_modrm & 0x08)
+                                                   && (control_word &
+                                                       CW_Invalid))
+                                                       FPU_pop();      /* fcomp, masked, so we pop. */
+                                       } else {
+                                               if (loaded_tag == TAG_Special)
+                                                       loaded_tag =
+                                                           FPU_Special
+                                                           (&loaded_data);
+#ifdef PECULIAR_486
+                                               /* This is not really needed, but gives behaviour
+                                                  identical to an 80486 */
+                                               if ((FPU_modrm & 0x28) == 0x20)
+                                                       /* fdiv or fsub */
+                                                       real_2op_NaN
+                                                           (&loaded_data,
+                                                            loaded_tag, 0,
+                                                            &loaded_data);
+                                               else
+#endif /* PECULIAR_486 */
+                                                       /* fadd, fdivr, fmul, or fsubr */
+                                                       real_2op_NaN
+                                                           (&loaded_data,
+                                                            loaded_tag, 0,
+                                                            st0_ptr);
+                                       }
+                                       goto reg_mem_instr_done;
+                               }
+
+                               if (unmasked && !((FPU_modrm & 0x30) == 0x10)) {
+                                       /* Is not a comparison instruction. */
+                                       if ((FPU_modrm & 0x38) == 0x38) {
+                                               /* fdivr */
+                                               if ((st0_tag == TAG_Zero) &&
+                                                   ((loaded_tag == TAG_Valid)
+                                                    || (loaded_tag ==
+                                                        TAG_Special
+                                                        &&
+                                                        isdenormal
+                                                        (&loaded_data)))) {
+                                                       if (FPU_divide_by_zero
+                                                           (0,
+                                                            getsign
+                                                            (&loaded_data))
+                                                           < 0) {
+                                                               /* We use the fact here that the unmasked
+                                                                  exception in the loaded data was for a
+                                                                  denormal operand */
+                                                               /* Restore the state of the denormal op bit */
+                                                               partial_status
+                                                                   &=
+                                                                   ~SW_Denorm_Op;
+                                                               partial_status
+                                                                   |=
+                                                                   status1 &
+                                                                   SW_Denorm_Op;
+                                                       } else
+                                                               setsign(st0_ptr,
+                                                                       getsign
+                                                                       (&loaded_data));
+                                               }
+                                       }
+                                       goto reg_mem_instr_done;
+                               }
+
+                               switch ((FPU_modrm >> 3) & 7) {
+                               case 0: /* fadd */
+                                       clear_C1();
+                                       FPU_add(&loaded_data, loaded_tag, 0,
+                                               control_word);
+                                       break;
+                               case 1: /* fmul */
+                                       clear_C1();
+                                       FPU_mul(&loaded_data, loaded_tag, 0,
+                                               control_word);
+                                       break;
+                               case 2: /* fcom */
+                                       FPU_compare_st_data(&loaded_data,
+                                                           loaded_tag);
+                                       break;
+                               case 3: /* fcomp */
+                                       if (!FPU_compare_st_data
+                                           (&loaded_data, loaded_tag)
+                                           && !unmasked)
+                                               FPU_pop();
+                                       break;
+                               case 4: /* fsub */
+                                       clear_C1();
+                                       FPU_sub(LOADED | loaded_tag,
+                                               (int)&loaded_data,
+                                               control_word);
+                                       break;
+                               case 5: /* fsubr */
+                                       clear_C1();
+                                       FPU_sub(REV | LOADED | loaded_tag,
+                                               (int)&loaded_data,
+                                               control_word);
+                                       break;
+                               case 6: /* fdiv */
+                                       clear_C1();
+                                       FPU_div(LOADED | loaded_tag,
+                                               (int)&loaded_data,
+                                               control_word);
+                                       break;
+                               case 7: /* fdivr */
+                                       clear_C1();
+                                       if (st0_tag == TAG_Zero)
+                                               partial_status = status1;       /* Undo any denorm tag,
+                                                                                  zero-divide has priority. */
+                                       FPU_div(REV | LOADED | loaded_tag,
+                                               (int)&loaded_data,
+                                               control_word);
+                                       break;
+                               }
+                       } else {
+                               if ((FPU_modrm & 0x30) == 0x10) {
+                                       /* The instruction is fcom or fcomp */
+                                       EXCEPTION(EX_StackUnder);
+                                       setcc(SW_C3 | SW_C2 | SW_C0);
+                                       if ((FPU_modrm & 0x08)
+                                           && (control_word & CW_Invalid))
+                                               FPU_pop();      /* fcomp */
+                               } else
+                                       FPU_stack_underflow();
+                       }
+                     reg_mem_instr_done:
+                       operand_address = data_sel_off;
+               } else {
+                       if (!(no_ip_update =
+                             FPU_load_store(((FPU_modrm & 0x38) | (byte1 & 6))
+                                            >> 1, addr_modes, data_address))) {
+                               operand_address = data_sel_off;
+                       }
                }
-             else
-               FPU_stack_underflow();
-           }
-       reg_mem_instr_done:
-         operand_address = data_sel_off;
-       }
-      else
-       {
-         if ( !(no_ip_update =
-                FPU_load_store(((FPU_modrm & 0x38) | (byte1 & 6)) >> 1,
-                               addr_modes, data_address)) )
-           {
-             operand_address = data_sel_off;
-           }
-       }
 
-    }
-  else
-    {
-      /* None of these instructions access user memory */
-      u_char instr_index = (FPU_modrm & 0x38) | (byte1 & 7);
+       } else {
+               /* None of these instructions access user memory */
+               u_char instr_index = (FPU_modrm & 0x38) | (byte1 & 7);
 
 #ifdef PECULIAR_486
-      /* This is supposed to be undefined, but a real 80486 seems
-        to do this: */
-      operand_address.offset = 0;
-      operand_address.selector = FPU_DS;
+               /* This is supposed to be undefined, but a real 80486 seems
+                  to do this: */
+               operand_address.offset = 0;
+               operand_address.selector = FPU_DS;
 #endif /* PECULIAR_486 */
 
-      st0_ptr = &st(0);
-      st0_tag = FPU_gettag0();
-      switch ( type_table[(int) instr_index] )
-       {
-       case _NONE_:   /* also _REGIc: _REGIn */
-         break;
-       case _REG0_:
-         if ( !NOT_EMPTY_ST0 )
-           {
-             FPU_stack_underflow();
-             goto FPU_instruction_done;
-           }
-         break;
-       case _REGIi:
-         if ( !NOT_EMPTY_ST0 || !NOT_EMPTY(FPU_rm) )
-           {
-             FPU_stack_underflow_i(FPU_rm);
-             goto FPU_instruction_done;
-           }
-         break;
-       case _REGIp:
-         if ( !NOT_EMPTY_ST0 || !NOT_EMPTY(FPU_rm) )
-           {
-             FPU_stack_underflow_pop(FPU_rm);
-             goto FPU_instruction_done;
-           }
-         break;
-       case _REGI_:
-         if ( !NOT_EMPTY_ST0 || !NOT_EMPTY(FPU_rm) )
-           {
-             FPU_stack_underflow();
-             goto FPU_instruction_done;
-           }
-         break;
-       case _PUSH_:     /* Only used by the fld st(i) instruction */
-         break;
-       case _null_:
-         FPU_illegal();
-         goto FPU_instruction_done;
-       default:
-         EXCEPTION(EX_INTERNAL|0x111);
-         goto FPU_instruction_done;
-       }
-      (*st_instr_table[(int) instr_index])();
+               st0_ptr = &st(0);
+               st0_tag = FPU_gettag0();
+               switch (type_table[(int)instr_index]) {
+               case _NONE_:    /* also _REGIc: _REGIn */
+                       break;
+               case _REG0_:
+                       if (!NOT_EMPTY_ST0) {
+                               FPU_stack_underflow();
+                               goto FPU_instruction_done;
+                       }
+                       break;
+               case _REGIi:
+                       if (!NOT_EMPTY_ST0 || !NOT_EMPTY(FPU_rm)) {
+                               FPU_stack_underflow_i(FPU_rm);
+                               goto FPU_instruction_done;
+                       }
+                       break;
+               case _REGIp:
+                       if (!NOT_EMPTY_ST0 || !NOT_EMPTY(FPU_rm)) {
+                               FPU_stack_underflow_pop(FPU_rm);
+                               goto FPU_instruction_done;
+                       }
+                       break;
+               case _REGI_:
+                       if (!NOT_EMPTY_ST0 || !NOT_EMPTY(FPU_rm)) {
+                               FPU_stack_underflow();
+                               goto FPU_instruction_done;
+                       }
+                       break;
+               case _PUSH_:    /* Only used by the fld st(i) instruction */
+                       break;
+               case _null_:
+                       FPU_illegal();
+                       goto FPU_instruction_done;
+               default:
+                       EXCEPTION(EX_INTERNAL | 0x111);
+                       goto FPU_instruction_done;
+               }
+               (*st_instr_table[(int)instr_index]) ();
 
-FPU_instruction_done:
-      ;
-    }
+             FPU_instruction_done:
+               ;
+       }
 
-  if ( ! no_ip_update )
-    instruction_address = entry_sel_off;
+       if (!no_ip_update)
+               instruction_address = entry_sel_off;
 
-FPU_fwait_done:
+      FPU_fwait_done:
 
 #ifdef DEBUG
-  RE_ENTRANT_CHECK_OFF;
-  FPU_printall();
-  RE_ENTRANT_CHECK_ON;
+       RE_ENTRANT_CHECK_OFF;
+       FPU_printall();
+       RE_ENTRANT_CHECK_ON;
 #endif /* DEBUG */
 
-  if (FPU_lookahead && !need_resched())
-    {
-      FPU_ORIG_EIP = FPU_EIP - code_base;
-      if ( valid_prefix(&byte1, (u_char __user **)&FPU_EIP,
-                       &addr_modes.override) )
-       goto do_another_FPU_instruction;
-    }
+       if (FPU_lookahead && !need_resched()) {
+               FPU_ORIG_EIP = FPU_EIP - code_base;
+               if (valid_prefix(&byte1, (u_char __user **) & FPU_EIP,
+                                &addr_modes.override))
+                       goto do_another_FPU_instruction;
+       }
 
-  if ( addr_modes.default_mode )
-    FPU_EIP -= code_base;
+       if (addr_modes.default_mode)
+               FPU_EIP -= code_base;
 
-  RE_ENTRANT_CHECK_OFF;
+       RE_ENTRANT_CHECK_OFF;
 }
 
-
 /* Support for prefix bytes is not yet complete. To properly handle
    all prefix bytes, further changes are needed in the emulator code
    which accesses user address space. Access to separate segments is
    important for msdos emulation. */
-static int valid_prefix(u_char *Byte, u_char __user **fpu_eip,
-                       overrides *override)
+static int valid_prefix(u_char * Byte, u_char __user ** fpu_eip,
+                       overrides * override)
 {
-  u_char byte;
-  u_char __user *ip = *fpu_eip;
-
-  *override = (overrides) { 0, 0, PREFIX_DEFAULT };       /* defaults */
-
-  RE_ENTRANT_CHECK_OFF;
-  FPU_code_access_ok(1);
-  FPU_get_user(byte, ip);
-  RE_ENTRANT_CHECK_ON;
-
-  while ( 1 )
-    {
-      switch ( byte )
-       {
-       case ADDR_SIZE_PREFIX:
-         override->address_size = ADDR_SIZE_PREFIX;
-         goto do_next_byte;
-
-       case OP_SIZE_PREFIX:
-         override->operand_size = OP_SIZE_PREFIX;
-         goto do_next_byte;
-
-       case PREFIX_CS:
-         override->segment = PREFIX_CS_;
-         goto do_next_byte;
-       case PREFIX_ES:
-         override->segment = PREFIX_ES_;
-         goto do_next_byte;
-       case PREFIX_SS:
-         override->segment = PREFIX_SS_;
-         goto do_next_byte;
-       case PREFIX_FS:
-         override->segment = PREFIX_FS_;
-         goto do_next_byte;
-       case PREFIX_GS:
-         override->segment = PREFIX_GS_;
-         goto do_next_byte;
-       case PREFIX_DS:
-         override->segment = PREFIX_DS_;
-         goto do_next_byte;
+       u_char byte;
+       u_char __user *ip = *fpu_eip;
+
+       *override = (overrides) {
+       0, 0, PREFIX_DEFAULT};  /* defaults */
+
+       RE_ENTRANT_CHECK_OFF;
+       FPU_code_access_ok(1);
+       FPU_get_user(byte, ip);
+       RE_ENTRANT_CHECK_ON;
+
+       while (1) {
+               switch (byte) {
+               case ADDR_SIZE_PREFIX:
+                       override->address_size = ADDR_SIZE_PREFIX;
+                       goto do_next_byte;
+
+               case OP_SIZE_PREFIX:
+                       override->operand_size = OP_SIZE_PREFIX;
+                       goto do_next_byte;
+
+               case PREFIX_CS:
+                       override->segment = PREFIX_CS_;
+                       goto do_next_byte;
+               case PREFIX_ES:
+                       override->segment = PREFIX_ES_;
+                       goto do_next_byte;
+               case PREFIX_SS:
+                       override->segment = PREFIX_SS_;
+                       goto do_next_byte;
+               case PREFIX_FS:
+                       override->segment = PREFIX_FS_;
+                       goto do_next_byte;
+               case PREFIX_GS:
+                       override->segment = PREFIX_GS_;
+                       goto do_next_byte;
+               case PREFIX_DS:
+                       override->segment = PREFIX_DS_;
+                       goto do_next_byte;
 
 /* lock is not a valid prefix for FPU instructions,
    let the cpu handle it to generate a SIGILL. */
 /*     case PREFIX_LOCK: */
 
-         /* rep.. prefixes have no meaning for FPU instructions */
-       case PREFIX_REPE:
-       case PREFIX_REPNE:
-
-       do_next_byte:
-         ip++;
-         RE_ENTRANT_CHECK_OFF;
-         FPU_code_access_ok(1);
-         FPU_get_user(byte, ip);
-         RE_ENTRANT_CHECK_ON;
-         break;
-       case FWAIT_OPCODE:
-         *Byte = byte;
-         return 1;
-       default:
-         if ( (byte & 0xf8) == 0xd8 )
-           {
-             *Byte = byte;
-             *fpu_eip = ip;
-             return 1;
-           }
-         else
-           {
-             /* Not a valid sequence of prefix bytes followed by
-                an FPU instruction. */
-             *Byte = byte;  /* Needed for error message. */
-             return 0;
-           }
+                       /* rep.. prefixes have no meaning for FPU instructions */
+               case PREFIX_REPE:
+               case PREFIX_REPNE:
+
+                     do_next_byte:
+                       ip++;
+                       RE_ENTRANT_CHECK_OFF;
+                       FPU_code_access_ok(1);
+                       FPU_get_user(byte, ip);
+                       RE_ENTRANT_CHECK_ON;
+                       break;
+               case FWAIT_OPCODE:
+                       *Byte = byte;
+                       return 1;
+               default:
+                       if ((byte & 0xf8) == 0xd8) {
+                               *Byte = byte;
+                               *fpu_eip = ip;
+                               return 1;
+                       } else {
+                               /* Not a valid sequence of prefix bytes followed by
+                                  an FPU instruction. */
+                               *Byte = byte;   /* Needed for error message. */
+                               return 0;
+                       }
+               }
        }
-    }
 }
 
-
-void math_abort(struct info * info, unsigned int signal)
+void math_abort(struct info *info, unsigned int signal)
 {
        FPU_EIP = FPU_ORIG_EIP;
        current->thread.trap_no = 16;
        current->thread.error_code = 0;
-       send_sig(signal,current,1);
+       send_sig(signal, current, 1);
        RE_ENTRANT_CHECK_OFF;
-       __asm__("movl %0,%%esp ; ret": :"g" (((long) info)-4));
+      __asm__("movl %0,%%esp ; ret": :"g"(((long)info) - 4));
 #ifdef PARANOID
-      printk("ERROR: wm-FPU-emu math_abort failed!\n");
+       printk("ERROR: wm-FPU-emu math_abort failed!\n");
 #endif /* PARANOID */
 }
 
-
-
 #define S387 ((struct i387_soft_struct *)s387)
 #define sstatus_word() \
   ((S387->swd & ~SW_Top & 0xffff) | ((S387->ftop << SW_Top_Shift) & SW_Top))
 
-int restore_i387_soft(void *s387, struct _fpstate __user *buf)
+int restore_i387_soft(void *s387, struct _fpstate __user * buf)
 {
-  u_char __user *d = (u_char __user *)buf;
-  int offset, other, i, tags, regnr, tag, newtop;
-
-  RE_ENTRANT_CHECK_OFF;
-  FPU_access_ok(VERIFY_READ, d, 7*4 + 8*10);
-  if (__copy_from_user(&S387->cwd, d, 7*4))
-    return -1;
-  RE_ENTRANT_CHECK_ON;
-
-  d += 7*4;
-
-  S387->ftop = (S387->swd >> SW_Top_Shift) & 7;
-  offset = (S387->ftop & 7) * 10;
-  other = 80 - offset;
-
-  RE_ENTRANT_CHECK_OFF;
-  /* Copy all registers in stack order. */
-  if (__copy_from_user(((u_char *)&S387->st_space)+offset, d, other))
-    return -1;
-  if ( offset )
-    if (__copy_from_user((u_char *)&S387->st_space, d+other, offset))
-      return -1;
-  RE_ENTRANT_CHECK_ON;
-
-  /* The tags may need to be corrected now. */
-  tags = S387->twd;
-  newtop = S387->ftop;
-  for ( i = 0; i < 8; i++ )
-    {
-      regnr = (i+newtop) & 7;
-      if ( ((tags >> ((regnr & 7)*2)) & 3) != TAG_Empty )
-       {
-         /* The loaded data over-rides all other cases. */
-         tag = FPU_tagof((FPU_REG *)((u_char *)S387->st_space + 10*regnr));
-         tags &= ~(3 << (regnr*2));
-         tags |= (tag & 3) << (regnr*2);
+       u_char __user *d = (u_char __user *) buf;
+       int offset, other, i, tags, regnr, tag, newtop;
+
+       RE_ENTRANT_CHECK_OFF;
+       FPU_access_ok(VERIFY_READ, d, 7 * 4 + 8 * 10);
+       if (__copy_from_user(&S387->cwd, d, 7 * 4))
+               return -1;
+       RE_ENTRANT_CHECK_ON;
+
+       d += 7 * 4;
+
+       S387->ftop = (S387->swd >> SW_Top_Shift) & 7;
+       offset = (S387->ftop & 7) * 10;
+       other = 80 - offset;
+
+       RE_ENTRANT_CHECK_OFF;
+       /* Copy all registers in stack order. */
+       if (__copy_from_user(((u_char *) & S387->st_space) + offset, d, other))
+               return -1;
+       if (offset)
+               if (__copy_from_user
+                   ((u_char *) & S387->st_space, d + other, offset))
+                       return -1;
+       RE_ENTRANT_CHECK_ON;
+
+       /* The tags may need to be corrected now. */
+       tags = S387->twd;
+       newtop = S387->ftop;
+       for (i = 0; i < 8; i++) {
+               regnr = (i + newtop) & 7;
+               if (((tags >> ((regnr & 7) * 2)) & 3) != TAG_Empty) {
+                       /* The loaded data over-rides all other cases. */
+                       tag =
+                           FPU_tagof((FPU_REG *) ((u_char *) S387->st_space +
+                                                  10 * regnr));
+                       tags &= ~(3 << (regnr * 2));
+                       tags |= (tag & 3) << (regnr * 2);
+               }
        }
-    }
-  S387->twd = tags;
+       S387->twd = tags;
 
-  return 0;
+       return 0;
 }
 
-
 int save_i387_soft(void *s387, struct _fpstate __user * buf)
 {
-  u_char __user *d = (u_char __user *)buf;
-  int offset = (S387->ftop & 7) * 10, other = 80 - offset;
+       u_char __user *d = (u_char __user *) buf;
+       int offset = (S387->ftop & 7) * 10, other = 80 - offset;
 
-  RE_ENTRANT_CHECK_OFF;
-  FPU_access_ok(VERIFY_WRITE, d, 7*4 + 8*10);
+       RE_ENTRANT_CHECK_OFF;
+       FPU_access_ok(VERIFY_WRITE, d, 7 * 4 + 8 * 10);
 #ifdef PECULIAR_486
-  S387->cwd &= ~0xe080;
-  /* An 80486 sets nearly all of the reserved bits to 1. */
-  S387->cwd |= 0xffff0040;
-  S387->swd = sstatus_word() | 0xffff0000;
-  S387->twd |= 0xffff0000;
-  S387->fcs &= ~0xf8000000;
-  S387->fos |= 0xffff0000;
+       S387->cwd &= ~0xe080;
+       /* An 80486 sets nearly all of the reserved bits to 1. */
+       S387->cwd |= 0xffff0040;
+       S387->swd = sstatus_word() | 0xffff0000;
+       S387->twd |= 0xffff0000;
+       S387->fcs &= ~0xf8000000;
+       S387->fos |= 0xffff0000;
 #endif /* PECULIAR_486 */
-  if (__copy_to_user(d, &S387->cwd, 7*4))
-    return -1;
-  RE_ENTRANT_CHECK_ON;
-
-  d += 7*4;
-
-  RE_ENTRANT_CHECK_OFF;
-  /* Copy all registers in stack order. */
-  if (__copy_to_user(d, ((u_char *)&S387->st_space)+offset, other))
-    return -1;
-  if ( offset )
-    if (__copy_to_user(d+other, (u_char *)&S387->st_space, offset))
-      return -1;
-  RE_ENTRANT_CHECK_ON;
-
-  return 1;
+       if (__copy_to_user(d, &S387->cwd, 7 * 4))
+               return -1;
+       RE_ENTRANT_CHECK_ON;
+
+       d += 7 * 4;
+
+       RE_ENTRANT_CHECK_OFF;
+       /* Copy all registers in stack order. */
+       if (__copy_to_user(d, ((u_char *) & S387->st_space) + offset, other))
+               return -1;
+       if (offset)
+               if (__copy_to_user
+                   (d + other, (u_char *) & S387->st_space, offset))
+                       return -1;
+       RE_ENTRANT_CHECK_ON;
+
+       return 1;
 }
index e3b5d46..e73631e 100644 (file)
 #include "status_w.h"
 #include "reg_constant.h"
 
-
-static void fchs(FPU_REG *st0_ptr, u_char st0tag)
+static void fchs(FPU_REG * st0_ptr, u_char st0tag)
 {
-  if ( st0tag ^ TAG_Empty )
-    {
-      signbyte(st0_ptr) ^= SIGN_NEG;
-      clear_C1();
-    }
-  else
-    FPU_stack_underflow();
+       if (st0tag ^ TAG_Empty) {
+               signbyte(st0_ptr) ^= SIGN_NEG;
+               clear_C1();
+       } else
+               FPU_stack_underflow();
 }
 
-
-static void fabs(FPU_REG *st0_ptr, u_char st0tag)
+static void fabs(FPU_REG * st0_ptr, u_char st0tag)
 {
-  if ( st0tag ^ TAG_Empty )
-    {
-      setpositive(st0_ptr);
-      clear_C1();
-    }
-  else
-    FPU_stack_underflow();
+       if (st0tag ^ TAG_Empty) {
+               setpositive(st0_ptr);
+               clear_C1();
+       } else
+               FPU_stack_underflow();
 }
 
-
-static void ftst_(FPU_REG *st0_ptr, u_char st0tag)
+static void ftst_(FPU_REG * st0_ptr, u_char st0tag)
 {
-  switch (st0tag)
-    {
-    case TAG_Zero:
-      setcc(SW_C3);
-      break;
-    case TAG_Valid:
-      if (getsign(st0_ptr) == SIGN_POS)
-        setcc(0);
-      else
-        setcc(SW_C0);
-      break;
-    case TAG_Special:
-      switch ( FPU_Special(st0_ptr) )
-       {
-       case TW_Denormal:
-         if (getsign(st0_ptr) == SIGN_POS)
-           setcc(0);
-         else
-           setcc(SW_C0);
-         if ( denormal_operand() < 0 )
-           {
-#ifdef PECULIAR_486
-             /* This is weird! */
-             if (getsign(st0_ptr) == SIGN_POS)
+       switch (st0tag) {
+       case TAG_Zero:
                setcc(SW_C3);
+               break;
+       case TAG_Valid:
+               if (getsign(st0_ptr) == SIGN_POS)
+                       setcc(0);
+               else
+                       setcc(SW_C0);
+               break;
+       case TAG_Special:
+               switch (FPU_Special(st0_ptr)) {
+               case TW_Denormal:
+                       if (getsign(st0_ptr) == SIGN_POS)
+                               setcc(0);
+                       else
+                               setcc(SW_C0);
+                       if (denormal_operand() < 0) {
+#ifdef PECULIAR_486
+                               /* This is weird! */
+                               if (getsign(st0_ptr) == SIGN_POS)
+                                       setcc(SW_C3);
 #endif /* PECULIAR_486 */
-             return;
-           }
-         break;
-       case TW_NaN:
-         setcc(SW_C0|SW_C2|SW_C3);   /* Operand is not comparable */ 
-         EXCEPTION(EX_Invalid);
-         break;
-       case TW_Infinity:
-         if (getsign(st0_ptr) == SIGN_POS)
-           setcc(0);
-         else
-           setcc(SW_C0);
-         break;
-       default:
-         setcc(SW_C0|SW_C2|SW_C3);   /* Operand is not comparable */ 
-         EXCEPTION(EX_INTERNAL|0x14);
-         break;
+                               return;
+                       }
+                       break;
+               case TW_NaN:
+                       setcc(SW_C0 | SW_C2 | SW_C3);   /* Operand is not comparable */
+                       EXCEPTION(EX_Invalid);
+                       break;
+               case TW_Infinity:
+                       if (getsign(st0_ptr) == SIGN_POS)
+                               setcc(0);
+                       else
+                               setcc(SW_C0);
+                       break;
+               default:
+                       setcc(SW_C0 | SW_C2 | SW_C3);   /* Operand is not comparable */
+                       EXCEPTION(EX_INTERNAL | 0x14);
+                       break;
+               }
+               break;
+       case TAG_Empty:
+               setcc(SW_C0 | SW_C2 | SW_C3);
+               EXCEPTION(EX_StackUnder);
+               break;
        }
-      break;
-    case TAG_Empty:
-      setcc(SW_C0|SW_C2|SW_C3);
-      EXCEPTION(EX_StackUnder);
-      break;
-    }
 }
 
-
-static void fxam(FPU_REG *st0_ptr, u_char st0tag)
+static void fxam(FPU_REG * st0_ptr, u_char st0tag)
 {
-  int c = 0;
-  switch (st0tag)
-    {
-    case TAG_Empty:
-      c = SW_C3|SW_C0;
-      break;
-    case TAG_Zero:
-      c = SW_C3;
-      break;
-    case TAG_Valid:
-      c = SW_C2;
-      break;
-    case TAG_Special:
-      switch ( FPU_Special(st0_ptr) )
-       {
-       case TW_Denormal:
-         c = SW_C2|SW_C3;  /* Denormal */
-         break;
-       case TW_NaN:
-         /* We also use NaN for unsupported types. */
-         if ( (st0_ptr->sigh & 0x80000000) && (exponent(st0_ptr) == EXP_OVER) )
-           c = SW_C0;
-         break;
-       case TW_Infinity:
-         c = SW_C2|SW_C0;
-         break;
+       int c = 0;
+       switch (st0tag) {
+       case TAG_Empty:
+               c = SW_C3 | SW_C0;
+               break;
+       case TAG_Zero:
+               c = SW_C3;
+               break;
+       case TAG_Valid:
+               c = SW_C2;
+               break;
+       case TAG_Special:
+               switch (FPU_Special(st0_ptr)) {
+               case TW_Denormal:
+                       c = SW_C2 | SW_C3;      /* Denormal */
+                       break;
+               case TW_NaN:
+                       /* We also use NaN for unsupported types. */
+                       if ((st0_ptr->sigh & 0x80000000)
+                           && (exponent(st0_ptr) == EXP_OVER))
+                               c = SW_C0;
+                       break;
+               case TW_Infinity:
+                       c = SW_C2 | SW_C0;
+                       break;
+               }
        }
-    }
-  if ( getsign(st0_ptr) == SIGN_NEG )
-    c |= SW_C1;
-  setcc(c);
+       if (getsign(st0_ptr) == SIGN_NEG)
+               c |= SW_C1;
+       setcc(c);
 }
 
-
 static FUNC_ST0 const fp_etc_table[] = {
-  fchs, fabs, (FUNC_ST0)FPU_illegal, (FUNC_ST0)FPU_illegal,
-  ftst_, fxam, (FUNC_ST0)FPU_illegal, (FUNC_ST0)FPU_illegal
+       fchs, fabs, (FUNC_ST0) FPU_illegal, (FUNC_ST0) FPU_illegal,
+       ftst_, fxam, (FUNC_ST0) FPU_illegal, (FUNC_ST0) FPU_illegal
 };
 
 void FPU_etc(void)
 {
-  (fp_etc_table[FPU_rm])(&st(0), FPU_gettag0());
+       (fp_etc_table[FPU_rm]) (&st(0), FPU_gettag0());
 }
index 37a8a7f..0f63841 100644 (file)
@@ -5,7 +5,7 @@
 extern void FPU_illegal(void);
 extern void FPU_printall(void);
 asmlinkage void FPU_exception(int n);
-extern int real_1op_NaN(FPU_REG *a);
+extern int real_1op_NaN(FPU_REG * a);
 extern int real_2op_NaN(FPU_REG const *b, u_char tagb, int deststnr,
                        FPU_REG const *defaultNaN);
 asmlinkage int arith_invalid(int deststnr);
@@ -14,8 +14,8 @@ extern int set_precision_flag(int flags);
 asmlinkage void set_precision_flag_up(void);
 asmlinkage void set_precision_flag_down(void);
 asmlinkage int denormal_operand(void);
-asmlinkage int arith_overflow(FPU_REG *dest);
-asmlinkage int arith_underflow(FPU_REG *dest);
+asmlinkage int arith_overflow(FPU_REG * dest);
+asmlinkage int arith_underflow(FPU_REG * dest);
 extern void FPU_stack_overflow(void);
 extern void FPU_stack_underflow(void);
 extern void FPU_stack_underflow_i(int i);
@@ -66,7 +66,7 @@ extern int FPU_Special(FPU_REG const *ptr);
 extern int isNaN(FPU_REG const *ptr);
 extern void FPU_pop(void);
 extern int FPU_empty_i(int stnr);
-extern int FPU_stackoverflow(FPU_REG **st_new_ptr);
+extern int FPU_stackoverflow(FPU_REG ** st_new_ptr);
 extern void FPU_copy_to_regi(FPU_REG const *r, u_char tag, int stnr);
 extern void FPU_copy_to_reg1(FPU_REG const *r, u_char tag);
 extern void FPU_copy_to_reg0(FPU_REG const *r, u_char tag);
@@ -75,26 +75,28 @@ extern void FPU_triga(void);
 extern void FPU_trigb(void);
 /* get_address.c */
 extern void __user *FPU_get_address(u_char FPU_modrm, unsigned long *fpu_eip,
-                        struct address *addr, fpu_addr_modes addr_modes);
+                                   struct address *addr,
+                                   fpu_addr_modes addr_modes);
 extern void __user *FPU_get_address_16(u_char FPU_modrm, unsigned long *fpu_eip,
-                           struct address *addr, fpu_addr_modes addr_modes);
+                                      struct address *addr,
+                                      fpu_addr_modes addr_modes);
 /* load_store.c */
 extern int FPU_load_store(u_char type, fpu_addr_modes addr_modes,
-                           void __user *data_address);
+                         void __user * data_address);
 /* poly_2xm1.c */
-extern int poly_2xm1(u_char sign, FPU_REG *arg, FPU_REG *result);
+extern int poly_2xm1(u_char sign, FPU_REG * arg, FPU_REG * result);
 /* poly_atan.c */
-extern void poly_atan(FPU_REG *st0_ptr, u_char st0_tag, FPU_REG *st1_ptr,
+extern void poly_atan(FPU_REG * st0_ptr, u_char st0_tag, FPU_REG * st1_ptr,
                      u_char st1_tag);
 /* poly_l2.c */
-extern void poly_l2(FPU_REG *st0_ptr, FPU_REG *st1_ptr, u_char st1_sign);
-extern int poly_l2p1(u_char s0, u_char s1, FPU_REG *r0, FPU_REG *r1,
-                    FPU_REG *d);
+extern void poly_l2(FPU_REG * st0_ptr, FPU_REG * st1_ptr, u_char st1_sign);
+extern int poly_l2p1(u_char s0, u_char s1, FPU_REG * r0, FPU_REG * r1,
+                    FPU_REG * d);
 /* poly_sin.c */
-extern void poly_sine(FPU_REG *st0_ptr);
-extern void poly_cos(FPU_REG *st0_ptr);
+extern void poly_sine(FPU_REG * st0_ptr);
+extern void poly_cos(FPU_REG * st0_ptr);
 /* poly_tan.c */
-extern void poly_tan(FPU_REG *st0_ptr);
+extern void poly_tan(FPU_REG * st0_ptr);
 /* reg_add_sub.c */
 extern int FPU_add(FPU_REG const *b, u_char tagb, int destrnr, int control_w);
 extern int FPU_sub(int flags, int rm, int control_w);
@@ -109,32 +111,34 @@ extern void fucompp(void);
 /* reg_constant.c */
 extern void fconst(void);
 /* reg_ld_str.c */
-extern int FPU_load_extended(long double __user *s, int stnr);
-extern int FPU_load_double(double __user *dfloat, FPU_REG *loaded_data);
-extern int FPU_load_single(float __user *single, FPU_REG *loaded_data);
-extern int FPU_load_int64(long long __user *_s);
-extern int FPU_load_int32(long __user *_s, FPU_REG *loaded_data);
-extern int FPU_load_int16(short __user *_s, FPU_REG *loaded_data);
-extern int FPU_load_bcd(u_char __user *s);
-extern int FPU_store_extended(FPU_REG *st0_ptr, u_char st0_tag,
-                             long double __user *d);
-extern int FPU_store_double(FPU_REG *st0_ptr, u_char st0_tag, double __user *dfloat);
-extern int FPU_store_single(FPU_REG *st0_ptr, u_char st0_tag, float __user *single);
-extern int FPU_store_int64(FPU_REG *st0_ptr, u_char st0_tag, long long __user *d);
-extern int FPU_store_int32(FPU_REG *st0_ptr, u_char st0_tag, long __user *d);
-extern int FPU_store_int16(FPU_REG *st0_ptr, u_char st0_tag, short __user *d);
-extern int FPU_store_bcd(FPU_REG *st0_ptr, u_char st0_tag, u_char __user *d);
-extern int FPU_round_to_int(FPU_REG *r, u_char tag);
-extern u_char __user *fldenv(fpu_addr_modes addr_modes, u_char __user *s);
-extern void frstor(fpu_addr_modes addr_modes, u_char __user *data_address);
-extern u_char __user *fstenv(fpu_addr_modes addr_modes, u_char __user *d);
-extern void fsave(fpu_addr_modes addr_modes, u_char __user *data_address);
-extern int FPU_tagof(FPU_REG *ptr);
+extern int FPU_load_extended(long double __user * s, int stnr);
+extern int FPU_load_double(double __user * dfloat, FPU_REG * loaded_data);
+extern int FPU_load_single(float __user * single, FPU_REG * loaded_data);
+extern int FPU_load_int64(long long __user * _s);
+extern int FPU_load_int32(long __user * _s, FPU_REG * loaded_data);
+extern int FPU_load_int16(short __user * _s, FPU_REG * loaded_data);
+extern int FPU_load_bcd(u_char __user * s);
+extern int FPU_store_extended(FPU_REG * st0_ptr, u_char st0_tag,
+                             long double __user * d);
+extern int FPU_store_double(FPU_REG * st0_ptr, u_char st0_tag,
+                           double __user * dfloat);
+extern int FPU_store_single(FPU_REG * st0_ptr, u_char st0_tag,
+                           float __user * single);
+extern int FPU_store_int64(FPU_REG * st0_ptr, u_char st0_tag,
+                          long long __user * d);
+extern int FPU_store_int32(FPU_REG * st0_ptr, u_char st0_tag, long __user * d);
+extern int FPU_store_int16(FPU_REG * st0_ptr, u_char st0_tag, short __user * d);
+extern int FPU_store_bcd(FPU_REG * st0_ptr, u_char st0_tag, u_char __user * d);
+extern int FPU_round_to_int(FPU_REG * r, u_char tag);
+extern u_char __user *fldenv(fpu_addr_modes addr_modes, u_char __user * s);
+extern void frstor(fpu_addr_modes addr_modes, u_char __user * data_address);
+extern u_char __user *fstenv(fpu_addr_modes addr_modes, u_char __user * d);
+extern void fsave(fpu_addr_modes addr_modes, u_char __user * data_address);
+extern int FPU_tagof(FPU_REG * ptr);
 /* reg_mul.c */
 extern int FPU_mul(FPU_REG const *b, u_char tagb, int deststnr, int control_w);
 
 extern int FPU_div(int flags, int regrm, int control_w);
 /* reg_convert.c */
-extern int FPU_to_exp16(FPU_REG const *a, FPU_REG *x);
+extern int FPU_to_exp16(FPU_REG const *a, FPU_REG * x);
 #endif /* _FPU_PROTO_H */
-
index cb436fe..d9c657c 100644 (file)
 #include "fpu_system.h"
 #include "exception.h"
 
-
 void FPU_pop(void)
 {
-  fpu_tag_word |= 3 << ((top & 7)*2);
-  top++;
+       fpu_tag_word |= 3 << ((top & 7) * 2);
+       top++;
 }
 
-
 int FPU_gettag0(void)
 {
-  return (fpu_tag_word >> ((top & 7)*2)) & 3;
+       return (fpu_tag_word >> ((top & 7) * 2)) & 3;
 }
 
-
 int FPU_gettagi(int stnr)
 {
-  return (fpu_tag_word >> (((top+stnr) & 7)*2)) & 3;
+       return (fpu_tag_word >> (((top + stnr) & 7) * 2)) & 3;
 }
 
-
 int FPU_gettag(int regnr)
 {
-  return (fpu_tag_word >> ((regnr & 7)*2)) & 3;
+       return (fpu_tag_word >> ((regnr & 7) * 2)) & 3;
 }
 
-
 void FPU_settag0(int tag)
 {
-  int regnr = top;
-  regnr &= 7;
-  fpu_tag_word &= ~(3 << (regnr*2));
-  fpu_tag_word |= (tag & 3) << (regnr*2);
+       int regnr = top;
+       regnr &= 7;
+       fpu_tag_word &= ~(3 << (regnr * 2));
+       fpu_tag_word |= (tag & 3) << (regnr * 2);
 }
 
-
 void FPU_settagi(int stnr, int tag)
 {
-  int regnr = stnr+top;
-  regnr &= 7;
-  fpu_tag_word &= ~(3 << (regnr*2));
-  fpu_tag_word |= (tag & 3) << (regnr*2);
+       int regnr = stnr + top;
+       regnr &= 7;
+       fpu_tag_word &= ~(3 << (regnr * 2));
+       fpu_tag_word |= (tag & 3) << (regnr * 2);
 }
 
-
 void FPU_settag(int regnr, int tag)
 {
-  regnr &= 7;
-  fpu_tag_word &= ~(3 << (regnr*2));
-  fpu_tag_word |= (tag & 3) << (regnr*2);
+       regnr &= 7;
+       fpu_tag_word &= ~(3 << (regnr * 2));
+       fpu_tag_word |= (tag & 3) << (regnr * 2);
 }
 
-
 int FPU_Special(FPU_REG const *ptr)
 {
-  int exp = exponent(ptr);
-
-  if ( exp == EXP_BIAS+EXP_UNDER )
-    return TW_Denormal;
-  else if ( exp != EXP_BIAS+EXP_OVER )
-    return TW_NaN;
-  else if ( (ptr->sigh == 0x80000000) && (ptr->sigl == 0) )
-    return TW_Infinity;
-  return TW_NaN;
+       int exp = exponent(ptr);
+
+       if (exp == EXP_BIAS + EXP_UNDER)
+               return TW_Denormal;
+       else if (exp != EXP_BIAS + EXP_OVER)
+               return TW_NaN;
+       else if ((ptr->sigh == 0x80000000) && (ptr->sigl == 0))
+               return TW_Infinity;
+       return TW_NaN;
 }
 
-
 int isNaN(FPU_REG const *ptr)
 {
-  return ( (exponent(ptr) == EXP_BIAS+EXP_OVER)
-          && !((ptr->sigh == 0x80000000) && (ptr->sigl == 0)) );
+       return ((exponent(ptr) == EXP_BIAS + EXP_OVER)
+               && !((ptr->sigh == 0x80000000) && (ptr->sigl == 0)));
 }
 
-
 int FPU_empty_i(int stnr)
 {
-  int regnr = (top+stnr) & 7;
+       int regnr = (top + stnr) & 7;
 
-  return ((fpu_tag_word >> (regnr*2)) & 3) == TAG_Empty;
+       return ((fpu_tag_word >> (regnr * 2)) & 3) == TAG_Empty;
 }
 
-
-int FPU_stackoverflow(FPU_REG **st_new_ptr)
+int FPU_stackoverflow(FPU_REG ** st_new_ptr)
 {
-  *st_new_ptr = &st(-1);
+       *st_new_ptr = &st(-1);
 
-  return ((fpu_tag_word >> (((top - 1) & 7)*2)) & 3) != TAG_Empty;
+       return ((fpu_tag_word >> (((top - 1) & 7) * 2)) & 3) != TAG_Empty;
 }
 
-
 void FPU_copy_to_regi(FPU_REG const *r, u_char tag, int stnr)
 {
-  reg_copy(r, &st(stnr));
-  FPU_settagi(stnr, tag);
+       reg_copy(r, &st(stnr));
+       FPU_settagi(stnr, tag);
 }
 
 void FPU_copy_to_reg1(FPU_REG const *r, u_char tag)
 {
-  reg_copy(r, &st(1));
-  FPU_settagi(1, tag);
+       reg_copy(r, &st(1));
+       FPU_settagi(1, tag);
 }
 
 void FPU_copy_to_reg0(FPU_REG const *r, u_char tag)
 {
-  int regnr = top;
-  regnr &= 7;
+       int regnr = top;
+       regnr &= 7;
 
-  reg_copy(r, &st(0));
+       reg_copy(r, &st(0));
 
-  fpu_tag_word &= ~(3 << (regnr*2));
-  fpu_tag_word |= (tag & 3) << (regnr*2);
+       fpu_tag_word &= ~(3 << (regnr * 2));
+       fpu_tag_word |= (tag & 3) << (regnr * 2);
 }
index 403cbde..e5316a2 100644 (file)
 #include "fpu_emu.h"
 #include "status_w.h"
 #include "control_w.h"
-#include "reg_constant.h"      
+#include "reg_constant.h"
 
 static void rem_kernel(unsigned long long st0, unsigned long long *y,
-                      unsigned long long st1,
-                      unsigned long long q, int n);
+                      unsigned long long st1, unsigned long long q, int n);
 
 #define BETTER_THAN_486
 
@@ -31,790 +30,708 @@ static void rem_kernel(unsigned long long st0, unsigned long long *y,
 /* Limited measurements show no results worse than 64 bit precision
    except for the results for arguments close to 2^63, where the
    precision of the result sometimes degrades to about 63.9 bits */
-static int trig_arg(FPU_REG *st0_ptr, int even)
+static int trig_arg(FPU_REG * st0_ptr, int even)
 {
-  FPU_REG tmp;
-  u_char tmptag;
-  unsigned long long q;
-  int old_cw = control_word, saved_status = partial_status;
-  int tag, st0_tag = TAG_Valid;
-
-  if ( exponent(st0_ptr) >= 63 )
-    {
-      partial_status |= SW_C2;     /* Reduction incomplete. */
-      return -1;
-    }
-
-  control_word &= ~CW_RC;
-  control_word |= RC_CHOP;
-
-  setpositive(st0_ptr);
-  tag = FPU_u_div(st0_ptr, &CONST_PI2, &tmp, PR_64_BITS | RC_CHOP | 0x3f,
-                 SIGN_POS);
-
-  FPU_round_to_int(&tmp, tag);  /* Fortunately, this can't overflow
-                                  to 2^64 */
-  q = significand(&tmp);
-  if ( q )
-    {
-      rem_kernel(significand(st0_ptr),
-                &significand(&tmp),
-                significand(&CONST_PI2),
-                q, exponent(st0_ptr) - exponent(&CONST_PI2));
-      setexponent16(&tmp, exponent(&CONST_PI2));
-      st0_tag = FPU_normalize(&tmp);
-      FPU_copy_to_reg0(&tmp, st0_tag);
-    }
-
-  if ( (even && !(q & 1)) || (!even && (q & 1)) )
-    {
-      st0_tag = FPU_sub(REV|LOADED|TAG_Valid, (int)&CONST_PI2, FULL_PRECISION);
+       FPU_REG tmp;
+       u_char tmptag;
+       unsigned long long q;
+       int old_cw = control_word, saved_status = partial_status;
+       int tag, st0_tag = TAG_Valid;
+
+       if (exponent(st0_ptr) >= 63) {
+               partial_status |= SW_C2;        /* Reduction incomplete. */
+               return -1;
+       }
 
-#ifdef BETTER_THAN_486
-      /* So far, the results are exact but based upon a 64 bit
-        precision approximation to pi/2. The technique used
-        now is equivalent to using an approximation to pi/2 which
-        is accurate to about 128 bits. */
-      if ( (exponent(st0_ptr) <= exponent(&CONST_PI2extra) + 64) || (q > 1) )
-       {
-         /* This code gives the effect of having pi/2 to better than
-            128 bits precision. */
-
-         significand(&tmp) = q + 1;
-         setexponent16(&tmp, 63);
-         FPU_normalize(&tmp);
-         tmptag =
-           FPU_u_mul(&CONST_PI2extra, &tmp, &tmp, FULL_PRECISION, SIGN_POS,
-                     exponent(&CONST_PI2extra) + exponent(&tmp));
-         setsign(&tmp, getsign(&CONST_PI2extra));
-         st0_tag = FPU_add(&tmp, tmptag, 0, FULL_PRECISION);
-         if ( signnegative(st0_ptr) )
-           {
-             /* CONST_PI2extra is negative, so the result of the addition
-                can be negative. This means that the argument is actually
-                in a different quadrant. The correction is always < pi/2,
-                so it can't overflow into yet another quadrant. */
-             setpositive(st0_ptr);
-             q++;
-           }
+       control_word &= ~CW_RC;
+       control_word |= RC_CHOP;
+
+       setpositive(st0_ptr);
+       tag = FPU_u_div(st0_ptr, &CONST_PI2, &tmp, PR_64_BITS | RC_CHOP | 0x3f,
+                       SIGN_POS);
+
+       FPU_round_to_int(&tmp, tag);    /* Fortunately, this can't overflow
+                                          to 2^64 */
+       q = significand(&tmp);
+       if (q) {
+               rem_kernel(significand(st0_ptr),
+                          &significand(&tmp),
+                          significand(&CONST_PI2),
+                          q, exponent(st0_ptr) - exponent(&CONST_PI2));
+               setexponent16(&tmp, exponent(&CONST_PI2));
+               st0_tag = FPU_normalize(&tmp);
+               FPU_copy_to_reg0(&tmp, st0_tag);
        }
+
+       if ((even && !(q & 1)) || (!even && (q & 1))) {
+               st0_tag =
+                   FPU_sub(REV | LOADED | TAG_Valid, (int)&CONST_PI2,
+                           FULL_PRECISION);
+
+#ifdef BETTER_THAN_486
+               /* So far, the results are exact but based upon a 64 bit
+                  precision approximation to pi/2. The technique used
+                  now is equivalent to using an approximation to pi/2 which
+                  is accurate to about 128 bits. */
+               if ((exponent(st0_ptr) <= exponent(&CONST_PI2extra) + 64)
+                   || (q > 1)) {
+                       /* This code gives the effect of having pi/2 to better than
+                          128 bits precision. */
+
+                       significand(&tmp) = q + 1;
+                       setexponent16(&tmp, 63);
+                       FPU_normalize(&tmp);
+                       tmptag =
+                           FPU_u_mul(&CONST_PI2extra, &tmp, &tmp,
+                                     FULL_PRECISION, SIGN_POS,
+                                     exponent(&CONST_PI2extra) +
+                                     exponent(&tmp));
+                       setsign(&tmp, getsign(&CONST_PI2extra));
+                       st0_tag = FPU_add(&tmp, tmptag, 0, FULL_PRECISION);
+                       if (signnegative(st0_ptr)) {
+                               /* CONST_PI2extra is negative, so the result of the addition
+                                  can be negative. This means that the argument is actually
+                                  in a different quadrant. The correction is always < pi/2,
+                                  so it can't overflow into yet another quadrant. */
+                               setpositive(st0_ptr);
+                               q++;
+                       }
+               }
 #endif /* BETTER_THAN_486 */
-    }
+       }
 #ifdef BETTER_THAN_486
-  else
-    {
-      /* So far, the results are exact but based upon a 64 bit
-        precision approximation to pi/2. The technique used
-        now is equivalent to using an approximation to pi/2 which
-        is accurate to about 128 bits. */
-      if ( ((q > 0) && (exponent(st0_ptr) <= exponent(&CONST_PI2extra) + 64))
-          || (q > 1) )
-       {
-         /* This code gives the effect of having p/2 to better than
-            128 bits precision. */
-
-         significand(&tmp) = q;
-         setexponent16(&tmp, 63);
-         FPU_normalize(&tmp);         /* This must return TAG_Valid */
-         tmptag = FPU_u_mul(&CONST_PI2extra, &tmp, &tmp, FULL_PRECISION,
-                            SIGN_POS,
-                            exponent(&CONST_PI2extra) + exponent(&tmp));
-         setsign(&tmp, getsign(&CONST_PI2extra));
-         st0_tag = FPU_sub(LOADED|(tmptag & 0x0f), (int)&tmp,
-                           FULL_PRECISION);
-         if ( (exponent(st0_ptr) == exponent(&CONST_PI2)) &&
-             ((st0_ptr->sigh > CONST_PI2.sigh)
-              || ((st0_ptr->sigh == CONST_PI2.sigh)
-                  && (st0_ptr->sigl > CONST_PI2.sigl))) )
-           {
-             /* CONST_PI2extra is negative, so the result of the
-                subtraction can be larger than pi/2. This means
-                that the argument is actually in a different quadrant.
-                The correction is always < pi/2, so it can't overflow
-                into yet another quadrant. */
-             st0_tag = FPU_sub(REV|LOADED|TAG_Valid, (int)&CONST_PI2,
-                               FULL_PRECISION);
-             q++;
-           }
+       else {
+               /* So far, the results are exact but based upon a 64 bit
+                  precision approximation to pi/2. The technique used
+                  now is equivalent to using an approximation to pi/2 which
+                  is accurate to about 128 bits. */
+               if (((q > 0)
+                    && (exponent(st0_ptr) <= exponent(&CONST_PI2extra) + 64))
+                   || (q > 1)) {
+                       /* This code gives the effect of having p/2 to better than
+                          128 bits precision. */
+
+                       significand(&tmp) = q;
+                       setexponent16(&tmp, 63);
+                       FPU_normalize(&tmp);    /* This must return TAG_Valid */
+                       tmptag =
+                           FPU_u_mul(&CONST_PI2extra, &tmp, &tmp,
+                                     FULL_PRECISION, SIGN_POS,
+                                     exponent(&CONST_PI2extra) +
+                                     exponent(&tmp));
+                       setsign(&tmp, getsign(&CONST_PI2extra));
+                       st0_tag = FPU_sub(LOADED | (tmptag & 0x0f), (int)&tmp,
+                                         FULL_PRECISION);
+                       if ((exponent(st0_ptr) == exponent(&CONST_PI2)) &&
+                           ((st0_ptr->sigh > CONST_PI2.sigh)
+                            || ((st0_ptr->sigh == CONST_PI2.sigh)
+                                && (st0_ptr->sigl > CONST_PI2.sigl)))) {
+                               /* CONST_PI2extra is negative, so the result of the
+                                  subtraction can be larger than pi/2. This means
+                                  that the argument is actually in a different quadrant.
+                                  The correction is always < pi/2, so it can't overflow
+                                  into yet another quadrant. */
+                               st0_tag =
+                                   FPU_sub(REV | LOADED | TAG_Valid,
+                                           (int)&CONST_PI2, FULL_PRECISION);
+                               q++;
+                       }
+               }
        }
-    }
 #endif /* BETTER_THAN_486 */
 
-  FPU_settag0(st0_tag);
-  control_word = old_cw;
-  partial_status = saved_status & ~SW_C2;     /* Reduction complete. */
+       FPU_settag0(st0_tag);
+       control_word = old_cw;
+       partial_status = saved_status & ~SW_C2; /* Reduction complete. */
 
-  return (q & 3) | even;
+       return (q & 3) | even;
 }
 
-
 /* Convert a long to register */
 static void convert_l2reg(long const *arg, int deststnr)
 {
-  int tag;
-  long num = *arg;
-  u_char sign;
-  FPU_REG *dest = &st(deststnr);
-
-  if (num == 0)
-    {
-      FPU_copy_to_regi(&CONST_Z, TAG_Zero, deststnr);
-      return;
-    }
-
-  if (num > 0)
-    { sign = SIGN_POS; }
-  else
-    { num = -num; sign = SIGN_NEG; }
-
-  dest->sigh = num;
-  dest->sigl = 0;
-  setexponent16(dest, 31);
-  tag = FPU_normalize(dest);
-  FPU_settagi(deststnr, tag);
-  setsign(dest, sign);
-  return;
-}
+       int tag;
+       long num = *arg;
+       u_char sign;
+       FPU_REG *dest = &st(deststnr);
 
+       if (num == 0) {
+               FPU_copy_to_regi(&CONST_Z, TAG_Zero, deststnr);
+               return;
+       }
+
+       if (num > 0) {
+               sign = SIGN_POS;
+       } else {
+               num = -num;
+               sign = SIGN_NEG;
+       }
 
-static void single_arg_error(FPU_REG *st0_ptr, u_char st0_tag)
+       dest->sigh = num;
+       dest->sigl = 0;
+       setexponent16(dest, 31);
+       tag = FPU_normalize(dest);
+       FPU_settagi(deststnr, tag);
+       setsign(dest, sign);
+       return;
+}
+
+static void single_arg_error(FPU_REG * st0_ptr, u_char st0_tag)
 {
-  if ( st0_tag == TAG_Empty )
-    FPU_stack_underflow();  /* Puts a QNaN in st(0) */
-  else if ( st0_tag == TW_NaN )
-    real_1op_NaN(st0_ptr);       /* return with a NaN in st(0) */
+       if (st0_tag == TAG_Empty)
+               FPU_stack_underflow();  /* Puts a QNaN in st(0) */
+       else if (st0_tag == TW_NaN)
+               real_1op_NaN(st0_ptr);  /* return with a NaN in st(0) */
 #ifdef PARANOID
-  else
-    EXCEPTION(EX_INTERNAL|0x0112);
+       else
+               EXCEPTION(EX_INTERNAL | 0x0112);
 #endif /* PARANOID */
 }
 
-
-static void single_arg_2_error(FPU_REG *st0_ptr, u_char st0_tag)
+static void single_arg_2_error(FPU_REG * st0_ptr, u_char st0_tag)
 {
-  int isNaN;
-
-  switch ( st0_tag )
-    {
-    case TW_NaN:
-      isNaN = (exponent(st0_ptr) == EXP_OVER) && (st0_ptr->sigh & 0x80000000);
-      if ( isNaN && !(st0_ptr->sigh & 0x40000000) )   /* Signaling ? */
-       {
-         EXCEPTION(EX_Invalid);
-         if ( control_word & CW_Invalid )
-           {
-             /* The masked response */
-             /* Convert to a QNaN */
-             st0_ptr->sigh |= 0x40000000;
-             push();
-             FPU_copy_to_reg0(st0_ptr, TAG_Special);
-           }
-       }
-      else if ( isNaN )
-       {
-         /* A QNaN */
-         push();
-         FPU_copy_to_reg0(st0_ptr, TAG_Special);
-       }
-      else
-       {
-         /* pseudoNaN or other unsupported */
-         EXCEPTION(EX_Invalid);
-         if ( control_word & CW_Invalid )
-           {
-             /* The masked response */
-             FPU_copy_to_reg0(&CONST_QNaN, TAG_Special);
-             push();
-             FPU_copy_to_reg0(&CONST_QNaN, TAG_Special);
-           }
-       }
-      break;              /* return with a NaN in st(0) */
+       int isNaN;
+
+       switch (st0_tag) {
+       case TW_NaN:
+               isNaN = (exponent(st0_ptr) == EXP_OVER)
+                   && (st0_ptr->sigh & 0x80000000);
+               if (isNaN && !(st0_ptr->sigh & 0x40000000)) {   /* Signaling ? */
+                       EXCEPTION(EX_Invalid);
+                       if (control_word & CW_Invalid) {
+                               /* The masked response */
+                               /* Convert to a QNaN */
+                               st0_ptr->sigh |= 0x40000000;
+                               push();
+                               FPU_copy_to_reg0(st0_ptr, TAG_Special);
+                       }
+               } else if (isNaN) {
+                       /* A QNaN */
+                       push();
+                       FPU_copy_to_reg0(st0_ptr, TAG_Special);
+               } else {
+                       /* pseudoNaN or other unsupported */
+                       EXCEPTION(EX_Invalid);
+                       if (control_word & CW_Invalid) {
+                               /* The masked response */
+                               FPU_copy_to_reg0(&CONST_QNaN, TAG_Special);
+                               push();
+                               FPU_copy_to_reg0(&CONST_QNaN, TAG_Special);
+                       }
+               }
+               break;          /* return with a NaN in st(0) */
 #ifdef PARANOID
-    default:
-      EXCEPTION(EX_INTERNAL|0x0112);
+       default:
+               EXCEPTION(EX_INTERNAL | 0x0112);
 #endif /* PARANOID */
-    }
+       }
 }
 
-
 /*---------------------------------------------------------------------------*/
 
-static void f2xm1(FPU_REG *st0_ptr, u_char tag)
+static void f2xm1(FPU_REG * st0_ptr, u_char tag)
 {
-  FPU_REG a;
+       FPU_REG a;
 
-  clear_C1();
+       clear_C1();
 
-  if ( tag == TAG_Valid )
-    {
-      /* For an 80486 FPU, the result is undefined if the arg is >= 1.0 */
-      if ( exponent(st0_ptr) < 0 )
-       {
-       denormal_arg:
+       if (tag == TAG_Valid) {
+               /* For an 80486 FPU, the result is undefined if the arg is >= 1.0 */
+               if (exponent(st0_ptr) < 0) {
+                     denormal_arg:
 
-         FPU_to_exp16(st0_ptr, &a);
+                       FPU_to_exp16(st0_ptr, &a);
 
-         /* poly_2xm1(x) requires 0 < st(0) < 1. */
-         poly_2xm1(getsign(st0_ptr), &a, st0_ptr);
+                       /* poly_2xm1(x) requires 0 < st(0) < 1. */
+                       poly_2xm1(getsign(st0_ptr), &a, st0_ptr);
+               }
+               set_precision_flag_up();        /* 80486 appears to always do this */
+               return;
        }
-      set_precision_flag_up();   /* 80486 appears to always do this */
-      return;
-    }
 
-  if ( tag == TAG_Zero )
-    return;
+       if (tag == TAG_Zero)
+               return;
 
-  if ( tag == TAG_Special )
-    tag = FPU_Special(st0_ptr);
+       if (tag == TAG_Special)
+               tag = FPU_Special(st0_ptr);
 
-  switch ( tag )
-    {
-    case TW_Denormal:
-      if ( denormal_operand() < 0 )
-       return;
-      goto denormal_arg;
-    case TW_Infinity:
-      if ( signnegative(st0_ptr) )
-       {
-         /* -infinity gives -1 (p16-10) */
-         FPU_copy_to_reg0(&CONST_1, TAG_Valid);
-         setnegative(st0_ptr);
+       switch (tag) {
+       case TW_Denormal:
+               if (denormal_operand() < 0)
+                       return;
+               goto denormal_arg;
+       case TW_Infinity:
+               if (signnegative(st0_ptr)) {
+                       /* -infinity gives -1 (p16-10) */
+                       FPU_copy_to_reg0(&CONST_1, TAG_Valid);
+                       setnegative(st0_ptr);
+               }
+               return;
+       default:
+               single_arg_error(st0_ptr, tag);
        }
-      return;
-    default:
-      single_arg_error(st0_ptr, tag);
-    }
 }
 
-
-static void fptan(FPU_REG *st0_ptr, u_char st0_tag)
+static void fptan(FPU_REG * st0_ptr, u_char st0_tag)
 {
-  FPU_REG *st_new_ptr;
-  int q;
-  u_char arg_sign = getsign(st0_ptr);
-
-  /* Stack underflow has higher priority */
-  if ( st0_tag == TAG_Empty )
-    {
-      FPU_stack_underflow();  /* Puts a QNaN in st(0) */
-      if ( control_word & CW_Invalid )
-       {
-         st_new_ptr = &st(-1);
-         push();
-         FPU_stack_underflow();  /* Puts a QNaN in the new st(0) */
+       FPU_REG *st_new_ptr;
+       int q;
+       u_char arg_sign = getsign(st0_ptr);
+
+       /* Stack underflow has higher priority */
+       if (st0_tag == TAG_Empty) {
+               FPU_stack_underflow();  /* Puts a QNaN in st(0) */
+               if (control_word & CW_Invalid) {
+                       st_new_ptr = &st(-1);
+                       push();
+                       FPU_stack_underflow();  /* Puts a QNaN in the new st(0) */
+               }
+               return;
        }
-      return;
-    }
-
-  if ( STACK_OVERFLOW )
-    { FPU_stack_overflow(); return; }
-
-  if ( st0_tag == TAG_Valid )
-    {
-      if ( exponent(st0_ptr) > -40 )
-       {
-         if ( (q = trig_arg(st0_ptr, 0)) == -1 )
-           {
-             /* Operand is out of range */
-             return;
-           }
-
-         poly_tan(st0_ptr);
-         setsign(st0_ptr, (q & 1) ^ (arg_sign != 0));
-         set_precision_flag_up();  /* We do not really know if up or down */
+
+       if (STACK_OVERFLOW) {
+               FPU_stack_overflow();
+               return;
        }
-      else
-       {
-         /* For a small arg, the result == the argument */
-         /* Underflow may happen */
 
-       denormal_arg:
+       if (st0_tag == TAG_Valid) {
+               if (exponent(st0_ptr) > -40) {
+                       if ((q = trig_arg(st0_ptr, 0)) == -1) {
+                               /* Operand is out of range */
+                               return;
+                       }
+
+                       poly_tan(st0_ptr);
+                       setsign(st0_ptr, (q & 1) ^ (arg_sign != 0));
+                       set_precision_flag_up();        /* We do not really know if up or down */
+               } else {
+                       /* For a small arg, the result == the argument */
+                       /* Underflow may happen */
+
+                     denormal_arg:
+
+                       FPU_to_exp16(st0_ptr, st0_ptr);
 
-         FPU_to_exp16(st0_ptr, st0_ptr);
-      
-         st0_tag = FPU_round(st0_ptr, 1, 0, FULL_PRECISION, arg_sign);
-         FPU_settag0(st0_tag);
+                       st0_tag =
+                           FPU_round(st0_ptr, 1, 0, FULL_PRECISION, arg_sign);
+                       FPU_settag0(st0_tag);
+               }
+               push();
+               FPU_copy_to_reg0(&CONST_1, TAG_Valid);
+               return;
        }
-      push();
-      FPU_copy_to_reg0(&CONST_1, TAG_Valid);
-      return;
-    }
-
-  if ( st0_tag == TAG_Zero )
-    {
-      push();
-      FPU_copy_to_reg0(&CONST_1, TAG_Valid);
-      setcc(0);
-      return;
-    }
-
-  if ( st0_tag == TAG_Special )
-    st0_tag = FPU_Special(st0_ptr);
-
-  if ( st0_tag == TW_Denormal )
-    {
-      if ( denormal_operand() < 0 )
-       return;
 
-      goto denormal_arg;
-    }
-
-  if ( st0_tag == TW_Infinity )
-    {
-      /* The 80486 treats infinity as an invalid operand */
-      if ( arith_invalid(0) >= 0 )
-       {
-         st_new_ptr = &st(-1);
-         push();
-         arith_invalid(0);
+       if (st0_tag == TAG_Zero) {
+               push();
+               FPU_copy_to_reg0(&CONST_1, TAG_Valid);
+               setcc(0);
+               return;
+       }
+
+       if (st0_tag == TAG_Special)
+               st0_tag = FPU_Special(st0_ptr);
+
+       if (st0_tag == TW_Denormal) {
+               if (denormal_operand() < 0)
+                       return;
+
+               goto denormal_arg;
        }
-      return;
-    }
 
-  single_arg_2_error(st0_ptr, st0_tag);
-}
+       if (st0_tag == TW_Infinity) {
+               /* The 80486 treats infinity as an invalid operand */
+               if (arith_invalid(0) >= 0) {
+                       st_new_ptr = &st(-1);
+                       push();
+                       arith_invalid(0);
+               }
+               return;
+       }
 
+       single_arg_2_error(st0_ptr, st0_tag);
+}
 
-static void fxtract(FPU_REG *st0_ptr, u_char st0_tag)
+static void fxtract(FPU_REG * st0_ptr, u_char st0_tag)
 {
-  FPU_REG *st_new_ptr;
-  u_char sign;
-  register FPU_REG *st1_ptr = st0_ptr;  /* anticipate */
-
-  if ( STACK_OVERFLOW )
-    {  FPU_stack_overflow(); return; }
-
-  clear_C1();
-
-  if ( st0_tag == TAG_Valid )
-    {
-      long e;
-
-      push();
-      sign = getsign(st1_ptr);
-      reg_copy(st1_ptr, st_new_ptr);
-      setexponent16(st_new_ptr, exponent(st_new_ptr));
-
-    denormal_arg:
-
-      e = exponent16(st_new_ptr);
-      convert_l2reg(&e, 1);
-      setexponentpos(st_new_ptr, 0);
-      setsign(st_new_ptr, sign);
-      FPU_settag0(TAG_Valid);       /* Needed if arg was a denormal */
-      return;
-    }
-  else if ( st0_tag == TAG_Zero )
-    {
-      sign = getsign(st0_ptr);
-
-      if ( FPU_divide_by_zero(0, SIGN_NEG) < 0 )
-       return;
+       FPU_REG *st_new_ptr;
+       u_char sign;
+       register FPU_REG *st1_ptr = st0_ptr;    /* anticipate */
 
-      push();
-      FPU_copy_to_reg0(&CONST_Z, TAG_Zero);
-      setsign(st_new_ptr, sign);
-      return;
-    }
+       if (STACK_OVERFLOW) {
+               FPU_stack_overflow();
+               return;
+       }
 
-  if ( st0_tag == TAG_Special )
-    st0_tag = FPU_Special(st0_ptr);
+       clear_C1();
 
-  if ( st0_tag == TW_Denormal )
-    {
-      if (denormal_operand() < 0 )
-       return;
+       if (st0_tag == TAG_Valid) {
+               long e;
 
-      push();
-      sign = getsign(st1_ptr);
-      FPU_to_exp16(st1_ptr, st_new_ptr);
-      goto denormal_arg;
-    }
-  else if ( st0_tag == TW_Infinity )
-    {
-      sign = getsign(st0_ptr);
-      setpositive(st0_ptr);
-      push();
-      FPU_copy_to_reg0(&CONST_INF, TAG_Special);
-      setsign(st_new_ptr, sign);
-      return;
-    }
-  else if ( st0_tag == TW_NaN )
-    {
-      if ( real_1op_NaN(st0_ptr) < 0 )
-       return;
+               push();
+               sign = getsign(st1_ptr);
+               reg_copy(st1_ptr, st_new_ptr);
+               setexponent16(st_new_ptr, exponent(st_new_ptr));
+
+             denormal_arg:
+
+               e = exponent16(st_new_ptr);
+               convert_l2reg(&e, 1);
+               setexponentpos(st_new_ptr, 0);
+               setsign(st_new_ptr, sign);
+               FPU_settag0(TAG_Valid); /* Needed if arg was a denormal */
+               return;
+       } else if (st0_tag == TAG_Zero) {
+               sign = getsign(st0_ptr);
+
+               if (FPU_divide_by_zero(0, SIGN_NEG) < 0)
+                       return;
 
-      push();
-      FPU_copy_to_reg0(st0_ptr, TAG_Special);
-      return;
-    }
-  else if ( st0_tag == TAG_Empty )
-    {
-      /* Is this the correct behaviour? */
-      if ( control_word & EX_Invalid )
-       {
-         FPU_stack_underflow();
-         push();
-         FPU_stack_underflow();
+               push();
+               FPU_copy_to_reg0(&CONST_Z, TAG_Zero);
+               setsign(st_new_ptr, sign);
+               return;
+       }
+
+       if (st0_tag == TAG_Special)
+               st0_tag = FPU_Special(st0_ptr);
+
+       if (st0_tag == TW_Denormal) {
+               if (denormal_operand() < 0)
+                       return;
+
+               push();
+               sign = getsign(st1_ptr);
+               FPU_to_exp16(st1_ptr, st_new_ptr);
+               goto denormal_arg;
+       } else if (st0_tag == TW_Infinity) {
+               sign = getsign(st0_ptr);
+               setpositive(st0_ptr);
+               push();
+               FPU_copy_to_reg0(&CONST_INF, TAG_Special);
+               setsign(st_new_ptr, sign);
+               return;
+       } else if (st0_tag == TW_NaN) {
+               if (real_1op_NaN(st0_ptr) < 0)
+                       return;
+
+               push();
+               FPU_copy_to_reg0(st0_ptr, TAG_Special);
+               return;
+       } else if (st0_tag == TAG_Empty) {
+               /* Is this the correct behaviour? */
+               if (control_word & EX_Invalid) {
+                       FPU_stack_underflow();
+                       push();
+                       FPU_stack_underflow();
+               } else
+                       EXCEPTION(EX_StackUnder);
        }
-      else
-       EXCEPTION(EX_StackUnder);
-    }
 #ifdef PARANOID
-  else
-    EXCEPTION(EX_INTERNAL | 0x119);
+       else
+               EXCEPTION(EX_INTERNAL | 0x119);
 #endif /* PARANOID */
 }
 
-
 static void fdecstp(void)
 {
-  clear_C1();
-  top--;
+       clear_C1();
+       top--;
 }
 
 static void fincstp(void)
 {
-  clear_C1();
-  top++;
+       clear_C1();
+       top++;
 }
 
-
-static void fsqrt_(FPU_REG *st0_ptr, u_char st0_tag)
+static void fsqrt_(FPU_REG * st0_ptr, u_char st0_tag)
 {
-  int expon;
-
-  clear_C1();
-
-  if ( st0_tag == TAG_Valid )
-    {
-      u_char tag;
-      
-      if (signnegative(st0_ptr))
-       {
-         arith_invalid(0);  /* sqrt(negative) is invalid */
-         return;
-       }
+       int expon;
+
+       clear_C1();
 
-      /* make st(0) in  [1.0 .. 4.0) */
-      expon = exponent(st0_ptr);
-
-    denormal_arg:
-
-      setexponent16(st0_ptr, (expon & 1));
-
-      /* Do the computation, the sign of the result will be positive. */
-      tag = wm_sqrt(st0_ptr, 0, 0, control_word, SIGN_POS);
-      addexponent(st0_ptr, expon >> 1);
-      FPU_settag0(tag);
-      return;
-    }
-
-  if ( st0_tag == TAG_Zero )
-    return;
-
-  if ( st0_tag == TAG_Special )
-    st0_tag = FPU_Special(st0_ptr);
-
-  if ( st0_tag == TW_Infinity )
-    {
-      if ( signnegative(st0_ptr) )
-       arith_invalid(0);  /* sqrt(-Infinity) is invalid */
-      return;
-    }
-  else if ( st0_tag == TW_Denormal )
-    {
-      if (signnegative(st0_ptr))
-       {
-         arith_invalid(0);  /* sqrt(negative) is invalid */
-         return;
+       if (st0_tag == TAG_Valid) {
+               u_char tag;
+
+               if (signnegative(st0_ptr)) {
+                       arith_invalid(0);       /* sqrt(negative) is invalid */
+                       return;
+               }
+
+               /* make st(0) in  [1.0 .. 4.0) */
+               expon = exponent(st0_ptr);
+
+             denormal_arg:
+
+               setexponent16(st0_ptr, (expon & 1));
+
+               /* Do the computation, the sign of the result will be positive. */
+               tag = wm_sqrt(st0_ptr, 0, 0, control_word, SIGN_POS);
+               addexponent(st0_ptr, expon >> 1);
+               FPU_settag0(tag);
+               return;
        }
 
-      if ( denormal_operand() < 0 )
-       return;
+       if (st0_tag == TAG_Zero)
+               return;
 
-      FPU_to_exp16(st0_ptr, st0_ptr);
+       if (st0_tag == TAG_Special)
+               st0_tag = FPU_Special(st0_ptr);
 
-      expon = exponent16(st0_ptr);
+       if (st0_tag == TW_Infinity) {
+               if (signnegative(st0_ptr))
+                       arith_invalid(0);       /* sqrt(-Infinity) is invalid */
+               return;
+       } else if (st0_tag == TW_Denormal) {
+               if (signnegative(st0_ptr)) {
+                       arith_invalid(0);       /* sqrt(negative) is invalid */
+                       return;
+               }
 
-      goto denormal_arg;
-    }
+               if (denormal_operand() < 0)
+                       return;
 
-  single_arg_error(st0_ptr, st0_tag);
+               FPU_to_exp16(st0_ptr, st0_ptr);
 
-}
+               expon = exponent16(st0_ptr);
+
+               goto denormal_arg;
+       }
 
+       single_arg_error(st0_ptr, st0_tag);
 
-static void frndint_(FPU_REG *st0_ptr, u_char st0_tag)
+}
+
+static void frndint_(FPU_REG * st0_ptr, u_char st0_tag)
 {
-  int flags, tag;
+       int flags, tag;
 
-  if ( st0_tag == TAG_Valid )
-    {
-      u_char sign;
+       if (st0_tag == TAG_Valid) {
+               u_char sign;
 
-    denormal_arg:
+             denormal_arg:
 
-      sign = getsign(st0_ptr);
+               sign = getsign(st0_ptr);
 
-      if (exponent(st0_ptr) > 63)
-       return;
+               if (exponent(st0_ptr) > 63)
+                       return;
+
+               if (st0_tag == TW_Denormal) {
+                       if (denormal_operand() < 0)
+                               return;
+               }
+
+               /* Fortunately, this can't overflow to 2^64 */
+               if ((flags = FPU_round_to_int(st0_ptr, st0_tag)))
+                       set_precision_flag(flags);
 
-      if ( st0_tag == TW_Denormal )
-       {
-         if (denormal_operand() < 0 )
-           return;
+               setexponent16(st0_ptr, 63);
+               tag = FPU_normalize(st0_ptr);
+               setsign(st0_ptr, sign);
+               FPU_settag0(tag);
+               return;
        }
 
-      /* Fortunately, this can't overflow to 2^64 */
-      if ( (flags = FPU_round_to_int(st0_ptr, st0_tag)) )
-       set_precision_flag(flags);
-
-      setexponent16(st0_ptr, 63);
-      tag = FPU_normalize(st0_ptr);
-      setsign(st0_ptr, sign);
-      FPU_settag0(tag);
-      return;
-    }
-
-  if ( st0_tag == TAG_Zero )
-    return;
-
-  if ( st0_tag == TAG_Special )
-    st0_tag = FPU_Special(st0_ptr);
-
-  if ( st0_tag == TW_Denormal )
-    goto denormal_arg;
-  else if ( st0_tag == TW_Infinity )
-    return;
-  else
-    single_arg_error(st0_ptr, st0_tag);
-}
+       if (st0_tag == TAG_Zero)
+               return;
 
+       if (st0_tag == TAG_Special)
+               st0_tag = FPU_Special(st0_ptr);
 
-static int fsin(FPU_REG *st0_ptr, u_char tag)
+       if (st0_tag == TW_Denormal)
+               goto denormal_arg;
+       else if (st0_tag == TW_Infinity)
+               return;
+       else
+               single_arg_error(st0_ptr, st0_tag);
+}
+
+static int fsin(FPU_REG * st0_ptr, u_char tag)
 {
-  u_char arg_sign = getsign(st0_ptr);
-
-  if ( tag == TAG_Valid )
-    {
-      int q;
-
-      if ( exponent(st0_ptr) > -40 )
-       {
-         if ( (q = trig_arg(st0_ptr, 0)) == -1 )
-           {
-             /* Operand is out of range */
-             return 1;
-           }
-
-         poly_sine(st0_ptr);
-         
-         if (q & 2)
-           changesign(st0_ptr);
-
-         setsign(st0_ptr, getsign(st0_ptr) ^ arg_sign);
-
-         /* We do not really know if up or down */
-         set_precision_flag_up();
-         return 0;
+       u_char arg_sign = getsign(st0_ptr);
+
+       if (tag == TAG_Valid) {
+               int q;
+
+               if (exponent(st0_ptr) > -40) {
+                       if ((q = trig_arg(st0_ptr, 0)) == -1) {
+                               /* Operand is out of range */
+                               return 1;
+                       }
+
+                       poly_sine(st0_ptr);
+
+                       if (q & 2)
+                               changesign(st0_ptr);
+
+                       setsign(st0_ptr, getsign(st0_ptr) ^ arg_sign);
+
+                       /* We do not really know if up or down */
+                       set_precision_flag_up();
+                       return 0;
+               } else {
+                       /* For a small arg, the result == the argument */
+                       set_precision_flag_up();        /* Must be up. */
+                       return 0;
+               }
        }
-      else
-       {
-         /* For a small arg, the result == the argument */
-         set_precision_flag_up();  /* Must be up. */
-         return 0;
+
+       if (tag == TAG_Zero) {
+               setcc(0);
+               return 0;
        }
-    }
-
-  if ( tag == TAG_Zero )
-    {
-      setcc(0);
-      return 0;
-    }
-
-  if ( tag == TAG_Special )
-    tag = FPU_Special(st0_ptr);
-
-  if ( tag == TW_Denormal )
-    {
-      if ( denormal_operand() < 0 )
-       return 1;
-
-      /* For a small arg, the result == the argument */
-      /* Underflow may happen */
-      FPU_to_exp16(st0_ptr, st0_ptr);
-      
-      tag = FPU_round(st0_ptr, 1, 0, FULL_PRECISION, arg_sign);
-
-      FPU_settag0(tag);
-
-      return 0;
-    }
-  else if ( tag == TW_Infinity )
-    {
-      /* The 80486 treats infinity as an invalid operand */
-      arith_invalid(0);
-      return 1;
-    }
-  else
-    {
-      single_arg_error(st0_ptr, tag);
-      return 1;
-    }
-}
 
+       if (tag == TAG_Special)
+               tag = FPU_Special(st0_ptr);
 
-static int f_cos(FPU_REG *st0_ptr, u_char tag)
-{
-  u_char st0_sign;
-
-  st0_sign = getsign(st0_ptr);
-
-  if ( tag == TAG_Valid )
-    {
-      int q;
-
-      if ( exponent(st0_ptr) > -40 )
-       {
-         if ( (exponent(st0_ptr) < 0)
-             || ((exponent(st0_ptr) == 0)
-                 && (significand(st0_ptr) <= 0xc90fdaa22168c234LL)) )
-           {
-             poly_cos(st0_ptr);
-
-             /* We do not really know if up or down */
-             set_precision_flag_down();
-         
-             return 0;
-           }
-         else if ( (q = trig_arg(st0_ptr, FCOS)) != -1 )
-           {
-             poly_sine(st0_ptr);
-
-             if ((q+1) & 2)
-               changesign(st0_ptr);
-
-             /* We do not really know if up or down */
-             set_precision_flag_down();
-         
-             return 0;
-           }
-         else
-           {
-             /* Operand is out of range */
-             return 1;
-           }
+       if (tag == TW_Denormal) {
+               if (denormal_operand() < 0)
+                       return 1;
+
+               /* For a small arg, the result == the argument */
+               /* Underflow may happen */
+               FPU_to_exp16(st0_ptr, st0_ptr);
+
+               tag = FPU_round(st0_ptr, 1, 0, FULL_PRECISION, arg_sign);
+
+               FPU_settag0(tag);
+
+               return 0;
+       } else if (tag == TW_Infinity) {
+               /* The 80486 treats infinity as an invalid operand */
+               arith_invalid(0);
+               return 1;
+       } else {
+               single_arg_error(st0_ptr, tag);
+               return 1;
        }
-      else
-       {
-       denormal_arg:
+}
+
+static int f_cos(FPU_REG * st0_ptr, u_char tag)
+{
+       u_char st0_sign;
+
+       st0_sign = getsign(st0_ptr);
 
-         setcc(0);
-         FPU_copy_to_reg0(&CONST_1, TAG_Valid);
+       if (tag == TAG_Valid) {
+               int q;
+
+               if (exponent(st0_ptr) > -40) {
+                       if ((exponent(st0_ptr) < 0)
+                           || ((exponent(st0_ptr) == 0)
+                               && (significand(st0_ptr) <=
+                                   0xc90fdaa22168c234LL))) {
+                               poly_cos(st0_ptr);
+
+                               /* We do not really know if up or down */
+                               set_precision_flag_down();
+
+                               return 0;
+                       } else if ((q = trig_arg(st0_ptr, FCOS)) != -1) {
+                               poly_sine(st0_ptr);
+
+                               if ((q + 1) & 2)
+                                       changesign(st0_ptr);
+
+                               /* We do not really know if up or down */
+                               set_precision_flag_down();
+
+                               return 0;
+                       } else {
+                               /* Operand is out of range */
+                               return 1;
+                       }
+               } else {
+                     denormal_arg:
+
+                       setcc(0);
+                       FPU_copy_to_reg0(&CONST_1, TAG_Valid);
 #ifdef PECULIAR_486
-         set_precision_flag_down();  /* 80486 appears to do this. */
+                       set_precision_flag_down();      /* 80486 appears to do this. */
 #else
-         set_precision_flag_up();  /* Must be up. */
+                       set_precision_flag_up();        /* Must be up. */
 #endif /* PECULIAR_486 */
-         return 0;
+                       return 0;
+               }
+       } else if (tag == TAG_Zero) {
+               FPU_copy_to_reg0(&CONST_1, TAG_Valid);
+               setcc(0);
+               return 0;
        }
-    }
-  else if ( tag == TAG_Zero )
-    {
-      FPU_copy_to_reg0(&CONST_1, TAG_Valid);
-      setcc(0);
-      return 0;
-    }
-
-  if ( tag == TAG_Special )
-    tag = FPU_Special(st0_ptr);
-
-  if ( tag == TW_Denormal )
-    {
-      if ( denormal_operand() < 0 )
-       return 1;
-
-      goto denormal_arg;
-    }
-  else if ( tag == TW_Infinity )
-    {
-      /* The 80486 treats infinity as an invalid operand */
-      arith_invalid(0);
-      return 1;
-    }
-  else
-    {
-      single_arg_error(st0_ptr, tag);  /* requires st0_ptr == &st(0) */
-      return 1;
-    }
-}
 
+       if (tag == TAG_Special)
+               tag = FPU_Special(st0_ptr);
+
+       if (tag == TW_Denormal) {
+               if (denormal_operand() < 0)
+                       return 1;
+
+               goto denormal_arg;
+       } else if (tag == TW_Infinity) {
+               /* The 80486 treats infinity as an invalid operand */
+               arith_invalid(0);
+               return 1;
+       } else {
+               single_arg_error(st0_ptr, tag); /* requires st0_ptr == &st(0) */
+               return 1;
+       }
+}
 
-static void fcos(FPU_REG *st0_ptr, u_char st0_tag)
+static void fcos(FPU_REG * st0_ptr, u_char st0_tag)
 {
-  f_cos(st0_ptr, st0_tag);
+       f_cos(st0_ptr, st0_tag);
 }
 
-
-static void fsincos(FPU_REG *st0_ptr, u_char st0_tag)
+static void fsincos(FPU_REG * st0_ptr, u_char st0_tag)
 {
-  FPU_REG *st_new_ptr;
-  FPU_REG arg;
-  u_char tag;
-
-  /* Stack underflow has higher priority */
-  if ( st0_tag == TAG_Empty )
-    {
-      FPU_stack_underflow();  /* Puts a QNaN in st(0) */
-      if ( control_word & CW_Invalid )
-       {
-         st_new_ptr = &st(-1);
-         push();
-         FPU_stack_underflow();  /* Puts a QNaN in the new st(0) */
+       FPU_REG *st_new_ptr;
+       FPU_REG arg;
+       u_char tag;
+
+       /* Stack underflow has higher priority */
+       if (st0_tag == TAG_Empty) {
+               FPU_stack_underflow();  /* Puts a QNaN in st(0) */
+               if (control_word & CW_Invalid) {
+                       st_new_ptr = &st(-1);
+                       push();
+                       FPU_stack_underflow();  /* Puts a QNaN in the new st(0) */
+               }
+               return;
        }
-      return;
-    }
-
-  if ( STACK_OVERFLOW )
-    { FPU_stack_overflow(); return; }
-
-  if ( st0_tag == TAG_Special )
-    tag = FPU_Special(st0_ptr);
-  else
-    tag = st0_tag;
-
-  if ( tag == TW_NaN )
-    {
-      single_arg_2_error(st0_ptr, TW_NaN);
-      return;
-    }
-  else if ( tag == TW_Infinity )
-    {
-      /* The 80486 treats infinity as an invalid operand */
-      if ( arith_invalid(0) >= 0 )
-       {
-         /* Masked response */
-         push();
-         arith_invalid(0);
+
+       if (STACK_OVERFLOW) {
+               FPU_stack_overflow();
+               return;
        }
-      return;
-    }
-
-  reg_copy(st0_ptr, &arg);
-  if ( !fsin(st0_ptr, st0_tag) )
-    {
-      push();
-      FPU_copy_to_reg0(&arg, st0_tag);
-      f_cos(&st(0), st0_tag);
-    }
-  else
-    {
-      /* An error, so restore st(0) */
-      FPU_copy_to_reg0(&arg, st0_tag);
-    }
-}
 
+       if (st0_tag == TAG_Special)
+               tag = FPU_Special(st0_ptr);
+       else
+               tag = st0_tag;
+
+       if (tag == TW_NaN) {
+               single_arg_2_error(st0_ptr, TW_NaN);
+               return;
+       } else if (tag == TW_Infinity) {
+               /* The 80486 treats infinity as an invalid operand */
+               if (arith_invalid(0) >= 0) {
+                       /* Masked response */
+                       push();
+                       arith_invalid(0);
+               }
+               return;
+       }
+
+       reg_copy(st0_ptr, &arg);
+       if (!fsin(st0_ptr, st0_tag)) {
+               push();
+               FPU_copy_to_reg0(&arg, st0_tag);
+               f_cos(&st(0), st0_tag);
+       } else {
+               /* An error, so restore st(0) */
+               FPU_copy_to_reg0(&arg, st0_tag);
+       }
+}
 
 /*---------------------------------------------------------------------------*/
 /* The following all require two arguments: st(0) and st(1) */
@@ -826,1020 +743,901 @@ static void fsincos(FPU_REG *st0_ptr, u_char st0_tag)
    result must be zero.
  */
 static void rem_kernel(unsigned long long st0, unsigned long long *y,
-                      unsigned long long st1,
-                      unsigned long long q, int n)
+                      unsigned long long st1, unsigned long long q, int n)
 {
-  int dummy;
-  unsigned long long x;
-
-  x = st0 << n;
-
-  /* Do the required multiplication and subtraction in the one operation */
-
-  /* lsw x -= lsw st1 * lsw q */
-  asm volatile ("mull %4; subl %%eax,%0; sbbl %%edx,%1"
-               :"=m" (((unsigned *)&x)[0]), "=m" (((unsigned *)&x)[1]),
-               "=a" (dummy)
-               :"2" (((unsigned *)&st1)[0]), "m" (((unsigned *)&q)[0])
-               :"%dx");
-  /* msw x -= msw st1 * lsw q */
-  asm volatile ("mull %3; subl %%eax,%0"
-               :"=m" (((unsigned *)&x)[1]), "=a" (dummy)
-               :"1" (((unsigned *)&st1)[1]), "m" (((unsigned *)&q)[0])
-               :"%dx");
-  /* msw x -= lsw st1 * msw q */
-  asm volatile ("mull %3; subl %%eax,%0"
-               :"=m" (((unsigned *)&x)[1]), "=a" (dummy)
-               :"1" (((unsigned *)&st1)[0]), "m" (((unsigned *)&q)[1])
-               :"%dx");
-
-  *y = x;
+       int dummy;
+       unsigned long long x;
+
+       x = st0 << n;
+
+       /* Do the required multiplication and subtraction in the one operation */
+
+       /* lsw x -= lsw st1 * lsw q */
+       asm volatile ("mull %4; subl %%eax,%0; sbbl %%edx,%1":"=m"
+                     (((unsigned *)&x)[0]), "=m"(((unsigned *)&x)[1]),
+                     "=a"(dummy)
+                     :"2"(((unsigned *)&st1)[0]), "m"(((unsigned *)&q)[0])
+                     :"%dx");
+       /* msw x -= msw st1 * lsw q */
+       asm volatile ("mull %3; subl %%eax,%0":"=m" (((unsigned *)&x)[1]),
+                     "=a"(dummy)
+                     :"1"(((unsigned *)&st1)[1]), "m"(((unsigned *)&q)[0])
+                     :"%dx");
+       /* msw x -= lsw st1 * msw q */
+       asm volatile ("mull %3; subl %%eax,%0":"=m" (((unsigned *)&x)[1]),
+                     "=a"(dummy)
+                     :"1"(((unsigned *)&st1)[0]), "m"(((unsigned *)&q)[1])
+                     :"%dx");
+
+       *y = x;
 }
 
-
 /* Remainder of st(0) / st(1) */
 /* This routine produces exact results, i.e. there is never any
    rounding or truncation, etc of the result. */
-static void do_fprem(FPU_REG *st0_ptr, u_char st0_tag, int round)
+static void do_fprem(FPU_REG * st0_ptr, u_char st0_tag, int round)
 {
-  FPU_REG *st1_ptr = &st(1);
-  u_char st1_tag = FPU_gettagi(1);
-
-  if ( !((st0_tag ^ TAG_Valid) | (st1_tag ^ TAG_Valid)) )
-    {
-      FPU_REG tmp, st0, st1;
-      u_char st0_sign, st1_sign;
-      u_char tmptag;
-      int tag;
-      int old_cw;
-      int expdif;
-      long long q;
-      unsigned short saved_status;
-      int cc;
-
-    fprem_valid:
-      /* Convert registers for internal use. */
-      st0_sign = FPU_to_exp16(st0_ptr, &st0);
-      st1_sign = FPU_to_exp16(st1_ptr, &st1);
-      expdif = exponent16(&st0) - exponent16(&st1);
-
-      old_cw = control_word;
-      cc = 0;
-
-      /* We want the status following the denorm tests, but don't want
-        the status changed by the arithmetic operations. */
-      saved_status = partial_status;
-      control_word &= ~CW_RC;
-      control_word |= RC_CHOP;
-
-      if ( expdif < 64 )
-       {
-         /* This should be the most common case */
-
-         if ( expdif > -2 )
-           {
-             u_char sign = st0_sign ^ st1_sign;
-             tag = FPU_u_div(&st0, &st1, &tmp,
-                             PR_64_BITS | RC_CHOP | 0x3f,
-                             sign);
-             setsign(&tmp, sign);
-
-             if ( exponent(&tmp) >= 0 )
-               {
-                 FPU_round_to_int(&tmp, tag);  /* Fortunately, this can't
-                                                  overflow to 2^64 */
-                 q = significand(&tmp);
-
-                 rem_kernel(significand(&st0),
-                            &significand(&tmp),
-                            significand(&st1),
-                            q, expdif);
-
-                 setexponent16(&tmp, exponent16(&st1));
-               }
-             else
-               {
-                 reg_copy(&st0, &tmp);
-                 q = 0;
-               }
-
-             if ( (round == RC_RND) && (tmp.sigh & 0xc0000000) )
-               {
-                 /* We may need to subtract st(1) once more,
-                    to get a result <= 1/2 of st(1). */
-                 unsigned long long x;
-                 expdif = exponent16(&st1) - exponent16(&tmp);
-                 if ( expdif <= 1 )
-                   {
-                     if ( expdif == 0 )
-                       x = significand(&st1) - significand(&tmp);
-                     else /* expdif is 1 */
-                       x = (significand(&st1) << 1) - significand(&tmp);
-                     if ( (x < significand(&tmp)) ||
-                         /* or equi-distant (from 0 & st(1)) and q is odd */
-                         ((x == significand(&tmp)) && (q & 1) ) )
-                       {
-                         st0_sign = ! st0_sign;
-                         significand(&tmp) = x;
-                         q++;
+       FPU_REG *st1_ptr = &st(1);
+       u_char st1_tag = FPU_gettagi(1);
+
+       if (!((st0_tag ^ TAG_Valid) | (st1_tag ^ TAG_Valid))) {
+               FPU_REG tmp, st0, st1;
+               u_char st0_sign, st1_sign;
+               u_char tmptag;
+               int tag;
+               int old_cw;
+               int expdif;
+               long long q;
+               unsigned short saved_status;
+               int cc;
+
+             fprem_valid:
+               /* Convert registers for internal use. */
+               st0_sign = FPU_to_exp16(st0_ptr, &st0);
+               st1_sign = FPU_to_exp16(st1_ptr, &st1);
+               expdif = exponent16(&st0) - exponent16(&st1);
+
+               old_cw = control_word;
+               cc = 0;
+
+               /* We want the status following the denorm tests, but don't want
+                  the status changed by the arithmetic operations. */
+               saved_status = partial_status;
+               control_word &= ~CW_RC;
+               control_word |= RC_CHOP;
+
+               if (expdif < 64) {
+                       /* This should be the most common case */
+
+                       if (expdif > -2) {
+                               u_char sign = st0_sign ^ st1_sign;
+                               tag = FPU_u_div(&st0, &st1, &tmp,
+                                               PR_64_BITS | RC_CHOP | 0x3f,
+                                               sign);
+                               setsign(&tmp, sign);
+
+                               if (exponent(&tmp) >= 0) {
+                                       FPU_round_to_int(&tmp, tag);    /* Fortunately, this can't
+                                                                          overflow to 2^64 */
+                                       q = significand(&tmp);
+
+                                       rem_kernel(significand(&st0),
+                                                  &significand(&tmp),
+                                                  significand(&st1),
+                                                  q, expdif);
+
+                                       setexponent16(&tmp, exponent16(&st1));
+                               } else {
+                                       reg_copy(&st0, &tmp);
+                                       q = 0;
+                               }
+
+                               if ((round == RC_RND)
+                                   && (tmp.sigh & 0xc0000000)) {
+                                       /* We may need to subtract st(1) once more,
+                                          to get a result <= 1/2 of st(1). */
+                                       unsigned long long x;
+                                       expdif =
+                                           exponent16(&st1) - exponent16(&tmp);
+                                       if (expdif <= 1) {
+                                               if (expdif == 0)
+                                                       x = significand(&st1) -
+                                                           significand(&tmp);
+                                               else    /* expdif is 1 */
+                                                       x = (significand(&st1)
+                                                            << 1) -
+                                                           significand(&tmp);
+                                               if ((x < significand(&tmp)) ||
+                                                   /* or equi-distant (from 0 & st(1)) and q is odd */
+                                                   ((x == significand(&tmp))
+                                                    && (q & 1))) {
+                                                       st0_sign = !st0_sign;
+                                                       significand(&tmp) = x;
+                                                       q++;
+                                               }
+                                       }
+                               }
+
+                               if (q & 4)
+                                       cc |= SW_C0;
+                               if (q & 2)
+                                       cc |= SW_C3;
+                               if (q & 1)
+                                       cc |= SW_C1;
+                       } else {
+                               control_word = old_cw;
+                               setcc(0);
+                               return;
                        }
-                   }
-               }
-
-             if (q & 4) cc |= SW_C0;
-             if (q & 2) cc |= SW_C3;
-             if (q & 1) cc |= SW_C1;
-           }
-         else
-           {
-             control_word = old_cw;
-             setcc(0);
-             return;
-           }
-       }
-      else
-       {
-         /* There is a large exponent difference ( >= 64 ) */
-         /* To make much sense, the code in this section should
-            be done at high precision. */
-         int exp_1, N;
-         u_char sign;
-
-         /* prevent overflow here */
-         /* N is 'a number between 32 and 63' (p26-113) */
-         reg_copy(&st0, &tmp);
-         tmptag = st0_tag;
-         N = (expdif & 0x0000001f) + 32;  /* This choice gives results
-                                             identical to an AMD 486 */
-         setexponent16(&tmp, N);
-         exp_1 = exponent16(&st1);
-         setexponent16(&st1, 0);
-         expdif -= N;
-
-         sign = getsign(&tmp) ^ st1_sign;
-         tag = FPU_u_div(&tmp, &st1, &tmp, PR_64_BITS | RC_CHOP | 0x3f,
-                         sign);
-         setsign(&tmp, sign);
-
-         FPU_round_to_int(&tmp, tag);  /* Fortunately, this can't
-                                          overflow to 2^64 */
-
-         rem_kernel(significand(&st0),
-                    &significand(&tmp),
-                    significand(&st1),
-                    significand(&tmp),
-                    exponent(&tmp)
-                    ); 
-         setexponent16(&tmp, exp_1 + expdif);
-
-         /* It is possible for the operation to be complete here.
-            What does the IEEE standard say? The Intel 80486 manual
-            implies that the operation will never be completed at this
-            point, and the behaviour of a real 80486 confirms this.
-          */
-         if ( !(tmp.sigh | tmp.sigl) )
-           {
-             /* The result is zero */
-             control_word = old_cw;
-             partial_status = saved_status;
-             FPU_copy_to_reg0(&CONST_Z, TAG_Zero);
-             setsign(&st0, st0_sign);
+               } else {
+                       /* There is a large exponent difference ( >= 64 ) */
+                       /* To make much sense, the code in this section should
+                          be done at high precision. */
+                       int exp_1, N;
+                       u_char sign;
+
+                       /* prevent overflow here */
+                       /* N is 'a number between 32 and 63' (p26-113) */
+                       reg_copy(&st0, &tmp);
+                       tmptag = st0_tag;
+                       N = (expdif & 0x0000001f) + 32; /* This choice gives results
+                                                          identical to an AMD 486 */
+                       setexponent16(&tmp, N);
+                       exp_1 = exponent16(&st1);
+                       setexponent16(&st1, 0);
+                       expdif -= N;
+
+                       sign = getsign(&tmp) ^ st1_sign;
+                       tag =
+                           FPU_u_div(&tmp, &st1, &tmp,
+                                     PR_64_BITS | RC_CHOP | 0x3f, sign);
+                       setsign(&tmp, sign);
+
+                       FPU_round_to_int(&tmp, tag);    /* Fortunately, this can't
+                                                          overflow to 2^64 */
+
+                       rem_kernel(significand(&st0),
+                                  &significand(&tmp),
+                                  significand(&st1),
+                                  significand(&tmp), exponent(&tmp)
+                           );
+                       setexponent16(&tmp, exp_1 + expdif);
+
+                       /* It is possible for the operation to be complete here.
+                          What does the IEEE standard say? The Intel 80486 manual
+                          implies that the operation will never be completed at this
+                          point, and the behaviour of a real 80486 confirms this.
+                        */
+                       if (!(tmp.sigh | tmp.sigl)) {
+                               /* The result is zero */
+                               control_word = old_cw;
+                               partial_status = saved_status;
+                               FPU_copy_to_reg0(&CONST_Z, TAG_Zero);
+                               setsign(&st0, st0_sign);
 #ifdef PECULIAR_486
-             setcc(SW_C2);
+                               setcc(SW_C2);
 #else
-             setcc(0);
+                               setcc(0);
 #endif /* PECULIAR_486 */
-             return;
-           }
-         cc = SW_C2;
-       }
+                               return;
+                       }
+                       cc = SW_C2;
+               }
 
-      control_word = old_cw;
-      partial_status = saved_status;
-      tag = FPU_normalize_nuo(&tmp);
-      reg_copy(&tmp, st0_ptr);
-
-      /* The only condition to be looked for is underflow,
-        and it can occur here only if underflow is unmasked. */
-      if ( (exponent16(&tmp) <= EXP_UNDER) && (tag != TAG_Zero)
-         && !(control_word & CW_Underflow) )
-       {
-         setcc(cc);
-         tag = arith_underflow(st0_ptr);
-         setsign(st0_ptr, st0_sign);
-         FPU_settag0(tag);
-         return;
-       }
-      else if ( (exponent16(&tmp) > EXP_UNDER) || (tag == TAG_Zero) )
-       {
-         stdexp(st0_ptr);
-         setsign(st0_ptr, st0_sign);
-       }
-      else
-       {
-         tag = FPU_round(st0_ptr, 0, 0, FULL_PRECISION, st0_sign);
-       }
-      FPU_settag0(tag);
-      setcc(cc);
+               control_word = old_cw;
+               partial_status = saved_status;
+               tag = FPU_normalize_nuo(&tmp);
+               reg_copy(&tmp, st0_ptr);
+
+               /* The only condition to be looked for is underflow,
+                  and it can occur here only if underflow is unmasked. */
+               if ((exponent16(&tmp) <= EXP_UNDER) && (tag != TAG_Zero)
+                   && !(control_word & CW_Underflow)) {
+                       setcc(cc);
+                       tag = arith_underflow(st0_ptr);
+                       setsign(st0_ptr, st0_sign);
+                       FPU_settag0(tag);
+                       return;
+               } else if ((exponent16(&tmp) > EXP_UNDER) || (tag == TAG_Zero)) {
+                       stdexp(st0_ptr);
+                       setsign(st0_ptr, st0_sign);
+               } else {
+                       tag =
+                           FPU_round(st0_ptr, 0, 0, FULL_PRECISION, st0_sign);
+               }
+               FPU_settag0(tag);
+               setcc(cc);
 
-      return;
-    }
+               return;
+       }
 
-  if ( st0_tag == TAG_Special )
-    st0_tag = FPU_Special(st0_ptr);
-  if ( st1_tag == TAG_Special )
-    st1_tag = FPU_Special(st1_ptr);
+       if (st0_tag == TAG_Special)
+               st0_tag = FPU_Special(st0_ptr);
+       if (st1_tag == TAG_Special)
+               st1_tag = FPU_Special(st1_ptr);
 
-  if ( ((st0_tag == TAG_Valid) && (st1_tag == TW_Denormal))
+       if (((st0_tag == TAG_Valid) && (st1_tag == TW_Denormal))
            || ((st0_tag == TW_Denormal) && (st1_tag == TAG_Valid))
-           || ((st0_tag == TW_Denormal) && (st1_tag == TW_Denormal)) )
-    {
-      if ( denormal_operand() < 0 )
-       return;
-      goto fprem_valid;
-    }
-  else if ( (st0_tag == TAG_Empty) || (st1_tag == TAG_Empty) )
-    {
-      FPU_stack_underflow();
-      return;
-    }
-  else if ( st0_tag == TAG_Zero )
-    {
-      if ( st1_tag == TAG_Valid )
-       {
-         setcc(0); return;
-       }
-      else if ( st1_tag == TW_Denormal )
-       {
-         if ( denormal_operand() < 0 )
-           return;
-         setcc(0); return;
-       }
-      else if ( st1_tag == TAG_Zero )
-       { arith_invalid(0); return; } /* fprem(?,0) always invalid */
-      else if ( st1_tag == TW_Infinity )
-       { setcc(0); return; }
-    }
-  else if ( (st0_tag == TAG_Valid) || (st0_tag == TW_Denormal) )
-    {
-      if ( st1_tag == TAG_Zero )
-       {
-         arith_invalid(0); /* fprem(Valid,Zero) is invalid */
-         return;
-       }
-      else if ( st1_tag != TW_NaN )
-       {
-         if ( ((st0_tag == TW_Denormal) || (st1_tag == TW_Denormal))
-              && (denormal_operand() < 0) )
-           return;
-
-         if ( st1_tag == TW_Infinity )
-           {
-             /* fprem(Valid,Infinity) is o.k. */
-             setcc(0); return;
-           }
-       }
-    }
-  else if ( st0_tag == TW_Infinity )
-    {
-      if ( st1_tag != TW_NaN )
-       {
-         arith_invalid(0); /* fprem(Infinity,?) is invalid */
-         return;
+           || ((st0_tag == TW_Denormal) && (st1_tag == TW_Denormal))) {
+               if (denormal_operand() < 0)
+                       return;
+               goto fprem_valid;
+       } else if ((st0_tag == TAG_Empty) || (st1_tag == TAG_Empty)) {
+               FPU_stack_underflow();
+               return;
+       } else if (st0_tag == TAG_Zero) {
+               if (st1_tag == TAG_Valid) {
+                       setcc(0);
+                       return;
+               } else if (st1_tag == TW_Denormal) {
+                       if (denormal_operand() < 0)
+                               return;
+                       setcc(0);
+                       return;
+               } else if (st1_tag == TAG_Zero) {
+                       arith_invalid(0);
+                       return;
+               } /* fprem(?,0) always invalid */
+               else if (st1_tag == TW_Infinity) {
+                       setcc(0);
+                       return;
+               }
+       } else if ((st0_tag == TAG_Valid) || (st0_tag == TW_Denormal)) {
+               if (st1_tag == TAG_Zero) {
+                       arith_invalid(0);       /* fprem(Valid,Zero) is invalid */
+                       return;
+               } else if (st1_tag != TW_NaN) {
+                       if (((st0_tag == TW_Denormal)
+                            || (st1_tag == TW_Denormal))
+                           && (denormal_operand() < 0))
+                               return;
+
+                       if (st1_tag == TW_Infinity) {
+                               /* fprem(Valid,Infinity) is o.k. */
+                               setcc(0);
+                               return;
+                       }
+               }
+       } else if (st0_tag == TW_Infinity) {
+               if (st1_tag != TW_NaN) {
+                       arith_invalid(0);       /* fprem(Infinity,?) is invalid */
+                       return;
+               }
        }
-    }
 
-  /* One of the registers must contain a NaN if we got here. */
+       /* One of the registers must contain a NaN if we got here. */
 
 #ifdef PARANOID
-  if ( (st0_tag != TW_NaN) && (st1_tag != TW_NaN) )
-      EXCEPTION(EX_INTERNAL | 0x118);
+       if ((st0_tag != TW_NaN) && (st1_tag != TW_NaN))
+               EXCEPTION(EX_INTERNAL | 0x118);
 #endif /* PARANOID */
 
-  real_2op_NaN(st1_ptr, st1_tag, 0, st1_ptr);
+       real_2op_NaN(st1_ptr, st1_tag, 0, st1_ptr);
 
 }
 
-
 /* ST(1) <- ST(1) * log ST;  pop ST */
-static void fyl2x(FPU_REG *st0_ptr, u_char st0_tag)
+static void fyl2x(FPU_REG * st0_ptr, u_char st0_tag)
 {
-  FPU_REG *st1_ptr = &st(1), exponent;
-  u_char st1_tag = FPU_gettagi(1);
-  u_char sign;
-  int e, tag;
-
-  clear_C1();
-
-  if ( (st0_tag == TAG_Valid) && (st1_tag == TAG_Valid) )
-    {
-    both_valid:
-      /* Both regs are Valid or Denormal */
-      if ( signpositive(st0_ptr) )
-       {
-         if ( st0_tag == TW_Denormal )
-           FPU_to_exp16(st0_ptr, st0_ptr);
-         else
-           /* Convert st(0) for internal use. */
-           setexponent16(st0_ptr, exponent(st0_ptr));
-
-         if ( (st0_ptr->sigh == 0x80000000) && (st0_ptr->sigl == 0) )
-           {
-             /* Special case. The result can be precise. */
-             u_char esign;
-             e = exponent16(st0_ptr);
-             if ( e >= 0 )
-               {
-                 exponent.sigh = e;
-                 esign = SIGN_POS;
-               }
-             else
-               {
-                 exponent.sigh = -e;
-                 esign = SIGN_NEG;
+       FPU_REG *st1_ptr = &st(1), exponent;
+       u_char st1_tag = FPU_gettagi(1);
+       u_char sign;
+       int e, tag;
+
+       clear_C1();
+
+       if ((st0_tag == TAG_Valid) && (st1_tag == TAG_Valid)) {
+             both_valid:
+               /* Both regs are Valid or Denormal */
+               if (signpositive(st0_ptr)) {
+                       if (st0_tag == TW_Denormal)
+                               FPU_to_exp16(st0_ptr, st0_ptr);
+                       else
+                               /* Convert st(0) for internal use. */
+                               setexponent16(st0_ptr, exponent(st0_ptr));
+
+                       if ((st0_ptr->sigh == 0x80000000)
+                           && (st0_ptr->sigl == 0)) {
+                               /* Special case. The result can be precise. */
+                               u_char esign;
+                               e = exponent16(st0_ptr);
+                               if (e >= 0) {
+                                       exponent.sigh = e;
+                                       esign = SIGN_POS;
+                               } else {
+                                       exponent.sigh = -e;
+                                       esign = SIGN_NEG;
+                               }
+                               exponent.sigl = 0;
+                               setexponent16(&exponent, 31);
+                               tag = FPU_normalize_nuo(&exponent);
+                               stdexp(&exponent);
+                               setsign(&exponent, esign);
+                               tag =
+                                   FPU_mul(&exponent, tag, 1, FULL_PRECISION);
+                               if (tag >= 0)
+                                       FPU_settagi(1, tag);
+                       } else {
+                               /* The usual case */
+                               sign = getsign(st1_ptr);
+                               if (st1_tag == TW_Denormal)
+                                       FPU_to_exp16(st1_ptr, st1_ptr);
+                               else
+                                       /* Convert st(1) for internal use. */
+                                       setexponent16(st1_ptr,
+                                                     exponent(st1_ptr));
+                               poly_l2(st0_ptr, st1_ptr, sign);
+                       }
+               } else {
+                       /* negative */
+                       if (arith_invalid(1) < 0)
+                               return;
                }
-             exponent.sigl = 0;
-             setexponent16(&exponent, 31);
-             tag = FPU_normalize_nuo(&exponent);
-             stdexp(&exponent);
-             setsign(&exponent, esign);
-             tag = FPU_mul(&exponent, tag, 1, FULL_PRECISION);
-             if ( tag >= 0 )
-               FPU_settagi(1, tag);
-           }
-         else
-           {
-             /* The usual case */
-             sign = getsign(st1_ptr);
-             if ( st1_tag == TW_Denormal )
-               FPU_to_exp16(st1_ptr, st1_ptr);
-             else
-               /* Convert st(1) for internal use. */
-               setexponent16(st1_ptr, exponent(st1_ptr));
-             poly_l2(st0_ptr, st1_ptr, sign);
-           }
-       }
-      else
-       {
-         /* negative */
-         if ( arith_invalid(1) < 0 )
-           return;
-       }
 
-      FPU_pop();
-
-      return;
-    }
-
-  if ( st0_tag == TAG_Special )
-    st0_tag = FPU_Special(st0_ptr);
-  if ( st1_tag == TAG_Special )
-    st1_tag = FPU_Special(st1_ptr);
-
-  if ( (st0_tag == TAG_Empty) || (st1_tag == TAG_Empty) )
-    {
-      FPU_stack_underflow_pop(1);
-      return;
-    }
-  else if ( (st0_tag <= TW_Denormal) && (st1_tag <= TW_Denormal) )
-    {
-      if ( st0_tag == TAG_Zero )
-       {
-         if ( st1_tag == TAG_Zero )
-           {
-             /* Both args zero is invalid */
-             if ( arith_invalid(1) < 0 )
-               return;
-           }
-         else
-           {
-             u_char sign;
-             sign = getsign(st1_ptr)^SIGN_NEG;
-             if ( FPU_divide_by_zero(1, sign) < 0 )
-               return;
+               FPU_pop();
 
-             setsign(st1_ptr, sign);
-           }
-       }
-      else if ( st1_tag == TAG_Zero )
-       {
-         /* st(1) contains zero, st(0) valid <> 0 */
-         /* Zero is the valid answer */
-         sign = getsign(st1_ptr);
-         
-         if ( signnegative(st0_ptr) )
-           {
-             /* log(negative) */
-             if ( arith_invalid(1) < 0 )
                return;
-           }
-         else if ( (st0_tag == TW_Denormal) && (denormal_operand() < 0) )
-           return;
-         else
-           {
-             if ( exponent(st0_ptr) < 0 )
-               sign ^= SIGN_NEG;
-
-             FPU_copy_to_reg1(&CONST_Z, TAG_Zero);
-             setsign(st1_ptr, sign);
-           }
        }
-      else
-       {
-         /* One or both operands are denormals. */
-         if ( denormal_operand() < 0 )
-           return;
-         goto both_valid;
-       }
-    }
-  else if ( (st0_tag == TW_NaN) || (st1_tag == TW_NaN) )
-    {
-      if ( real_2op_NaN(st0_ptr, st0_tag, 1, st0_ptr) < 0 )
-       return;
-    }
-  /* One or both arg must be an infinity */
-  else if ( st0_tag == TW_Infinity )
-    {
-      if ( (signnegative(st0_ptr)) || (st1_tag == TAG_Zero) )
-       {
-         /* log(-infinity) or 0*log(infinity) */
-         if ( arith_invalid(1) < 0 )
-           return;
-       }
-      else
-       {
-         u_char sign = getsign(st1_ptr);
 
-         if ( (st1_tag == TW_Denormal) && (denormal_operand() < 0) )
-           return;
+       if (st0_tag == TAG_Special)
+               st0_tag = FPU_Special(st0_ptr);
+       if (st1_tag == TAG_Special)
+               st1_tag = FPU_Special(st1_ptr);
 
-         FPU_copy_to_reg1(&CONST_INF, TAG_Special);
-         setsign(st1_ptr, sign);
-       }
-    }
-  /* st(1) must be infinity here */
-  else if ( ((st0_tag == TAG_Valid) || (st0_tag == TW_Denormal))
-           && ( signpositive(st0_ptr) ) )
-    {
-      if ( exponent(st0_ptr) >= 0 )
-       {
-         if ( (exponent(st0_ptr) == 0) &&
-             (st0_ptr->sigh == 0x80000000) &&
-             (st0_ptr->sigl == 0) )
-           {
-             /* st(0) holds 1.0 */
-             /* infinity*log(1) */
-             if ( arith_invalid(1) < 0 )
+       if ((st0_tag == TAG_Empty) || (st1_tag == TAG_Empty)) {
+               FPU_stack_underflow_pop(1);
                return;
-           }
-         /* else st(0) is positive and > 1.0 */
+       } else if ((st0_tag <= TW_Denormal) && (st1_tag <= TW_Denormal)) {
+               if (st0_tag == TAG_Zero) {
+                       if (st1_tag == TAG_Zero) {
+                               /* Both args zero is invalid */
+                               if (arith_invalid(1) < 0)
+                                       return;
+                       } else {
+                               u_char sign;
+                               sign = getsign(st1_ptr) ^ SIGN_NEG;
+                               if (FPU_divide_by_zero(1, sign) < 0)
+                                       return;
+
+                               setsign(st1_ptr, sign);
+                       }
+               } else if (st1_tag == TAG_Zero) {
+                       /* st(1) contains zero, st(0) valid <> 0 */
+                       /* Zero is the valid answer */
+                       sign = getsign(st1_ptr);
+
+                       if (signnegative(st0_ptr)) {
+                               /* log(negative) */
+                               if (arith_invalid(1) < 0)
+                                       return;
+                       } else if ((st0_tag == TW_Denormal)
+                                  && (denormal_operand() < 0))
+                               return;
+                       else {
+                               if (exponent(st0_ptr) < 0)
+                                       sign ^= SIGN_NEG;
+
+                               FPU_copy_to_reg1(&CONST_Z, TAG_Zero);
+                               setsign(st1_ptr, sign);
+                       }
+               } else {
+                       /* One or both operands are denormals. */
+                       if (denormal_operand() < 0)
+                               return;
+                       goto both_valid;
+               }
+       } else if ((st0_tag == TW_NaN) || (st1_tag == TW_NaN)) {
+               if (real_2op_NaN(st0_ptr, st0_tag, 1, st0_ptr) < 0)
+                       return;
+       }
+       /* One or both arg must be an infinity */
+       else if (st0_tag == TW_Infinity) {
+               if ((signnegative(st0_ptr)) || (st1_tag == TAG_Zero)) {
+                       /* log(-infinity) or 0*log(infinity) */
+                       if (arith_invalid(1) < 0)
+                               return;
+               } else {
+                       u_char sign = getsign(st1_ptr);
+
+                       if ((st1_tag == TW_Denormal)
+                           && (denormal_operand() < 0))
+                               return;
+
+                       FPU_copy_to_reg1(&CONST_INF, TAG_Special);
+                       setsign(st1_ptr, sign);
+               }
        }
-      else
-       {
-         /* st(0) is positive and < 1.0 */
+       /* st(1) must be infinity here */
+       else if (((st0_tag == TAG_Valid) || (st0_tag == TW_Denormal))
+                && (signpositive(st0_ptr))) {
+               if (exponent(st0_ptr) >= 0) {
+                       if ((exponent(st0_ptr) == 0) &&
+                           (st0_ptr->sigh == 0x80000000) &&
+                           (st0_ptr->sigl == 0)) {
+                               /* st(0) holds 1.0 */
+                               /* infinity*log(1) */
+                               if (arith_invalid(1) < 0)
+                                       return;
+                       }
+                       /* else st(0) is positive and > 1.0 */
+               } else {
+                       /* st(0) is positive and < 1.0 */
 
-         if ( (st0_tag == TW_Denormal) && (denormal_operand() < 0) )
-           return;
+                       if ((st0_tag == TW_Denormal)
+                           && (denormal_operand() < 0))
+                               return;
 
-         changesign(st1_ptr);
-       }
-    }
-  else
-    {
-      /* st(0) must be zero or negative */
-      if ( st0_tag == TAG_Zero )
-       {
-         /* This should be invalid, but a real 80486 is happy with it. */
+                       changesign(st1_ptr);
+               }
+       } else {
+               /* st(0) must be zero or negative */
+               if (st0_tag == TAG_Zero) {
+                       /* This should be invalid, but a real 80486 is happy with it. */
 
 #ifndef PECULIAR_486
-         sign = getsign(st1_ptr);
-         if ( FPU_divide_by_zero(1, sign) < 0 )
-           return;
+                       sign = getsign(st1_ptr);
+                       if (FPU_divide_by_zero(1, sign) < 0)
+                               return;
 #endif /* PECULIAR_486 */
 
-         changesign(st1_ptr);
+                       changesign(st1_ptr);
+               } else if (arith_invalid(1) < 0)        /* log(negative) */
+                       return;
        }
-      else if ( arith_invalid(1) < 0 )   /* log(negative) */
-       return;
-    }
 
-  FPU_pop();
+       FPU_pop();
 }
 
-
-static void fpatan(FPU_REG *st0_ptr, u_char st0_tag)
+static void fpatan(FPU_REG * st0_ptr, u_char st0_tag)
 {
-  FPU_REG *st1_ptr = &st(1);
-  u_char st1_tag = FPU_gettagi(1);
-  int tag;
+       FPU_REG *st1_ptr = &st(1);
+       u_char st1_tag = FPU_gettagi(1);
+       int tag;
 
-  clear_C1();
-  if ( !((st0_tag ^ TAG_Valid) | (st1_tag ^ TAG_Valid)) )
-    {
-    valid_atan:
+       clear_C1();
+       if (!((st0_tag ^ TAG_Valid) | (st1_tag ^ TAG_Valid))) {
+             valid_atan:
 
-      poly_atan(st0_ptr, st0_tag, st1_ptr, st1_tag);
+               poly_atan(st0_ptr, st0_tag, st1_ptr, st1_tag);
 
-      FPU_pop();
+               FPU_pop();
 
-      return;
-    }
+               return;
+       }
 
-  if ( st0_tag == TAG_Special )
-    st0_tag = FPU_Special(st0_ptr);
-  if ( st1_tag == TAG_Special )
-    st1_tag = FPU_Special(st1_ptr);
+       if (st0_tag == TAG_Special)
+               st0_tag = FPU_Special(st0_ptr);
+       if (st1_tag == TAG_Special)
+               st1_tag = FPU_Special(st1_ptr);
 
-  if ( ((st0_tag == TAG_Valid) && (st1_tag == TW_Denormal))
+       if (((st0_tag == TAG_Valid) && (st1_tag == TW_Denormal))
            || ((st0_tag == TW_Denormal) && (st1_tag == TAG_Valid))
-           || ((st0_tag == TW_Denormal) && (st1_tag == TW_Denormal)) )
-    {
-      if ( denormal_operand() < 0 )
-       return;
+           || ((st0_tag == TW_Denormal) && (st1_tag == TW_Denormal))) {
+               if (denormal_operand() < 0)
+                       return;
 
-      goto valid_atan;
-    }
-  else if ( (st0_tag == TAG_Empty) || (st1_tag == TAG_Empty) )
-    {
-      FPU_stack_underflow_pop(1);
-      return;
-    }
-  else if ( (st0_tag == TW_NaN) || (st1_tag == TW_NaN) )
-    {
-      if ( real_2op_NaN(st0_ptr, st0_tag, 1, st0_ptr) >= 0 )
-         FPU_pop();
-      return;
-    }
-  else if ( (st0_tag == TW_Infinity) || (st1_tag == TW_Infinity) )
-    {
-      u_char sign = getsign(st1_ptr);
-      if ( st0_tag == TW_Infinity )
-       {
-         if ( st1_tag == TW_Infinity )
-           {
-             if ( signpositive(st0_ptr) )
-               {
-                 FPU_copy_to_reg1(&CONST_PI4, TAG_Valid);
-               }
-             else
-               {
-                 setpositive(st1_ptr);
-                 tag = FPU_u_add(&CONST_PI4, &CONST_PI2, st1_ptr,
-                                 FULL_PRECISION, SIGN_POS,
-                                 exponent(&CONST_PI4), exponent(&CONST_PI2));
-                 if ( tag >= 0 )
-                   FPU_settagi(1, tag);
-               }
-           }
-         else
-           {
-             if ( (st1_tag == TW_Denormal) && (denormal_operand() < 0) )
+               goto valid_atan;
+       } else if ((st0_tag == TAG_Empty) || (st1_tag == TAG_Empty)) {
+               FPU_stack_underflow_pop(1);
+               return;
+       } else if ((st0_tag == TW_NaN) || (st1_tag == TW_NaN)) {
+               if (real_2op_NaN(st0_ptr, st0_tag, 1, st0_ptr) >= 0)
+                       FPU_pop();
                return;
+       } else if ((st0_tag == TW_Infinity) || (st1_tag == TW_Infinity)) {
+               u_char sign = getsign(st1_ptr);
+               if (st0_tag == TW_Infinity) {
+                       if (st1_tag == TW_Infinity) {
+                               if (signpositive(st0_ptr)) {
+                                       FPU_copy_to_reg1(&CONST_PI4, TAG_Valid);
+                               } else {
+                                       setpositive(st1_ptr);
+                                       tag =
+                                           FPU_u_add(&CONST_PI4, &CONST_PI2,
+                                                     st1_ptr, FULL_PRECISION,
+                                                     SIGN_POS,
+                                                     exponent(&CONST_PI4),
+                                                     exponent(&CONST_PI2));
+                                       if (tag >= 0)
+                                               FPU_settagi(1, tag);
+                               }
+                       } else {
+                               if ((st1_tag == TW_Denormal)
+                                   && (denormal_operand() < 0))
+                                       return;
+
+                               if (signpositive(st0_ptr)) {
+                                       FPU_copy_to_reg1(&CONST_Z, TAG_Zero);
+                                       setsign(st1_ptr, sign); /* An 80486 preserves the sign */
+                                       FPU_pop();
+                                       return;
+                               } else {
+                                       FPU_copy_to_reg1(&CONST_PI, TAG_Valid);
+                               }
+                       }
+               } else {
+                       /* st(1) is infinity, st(0) not infinity */
+                       if ((st0_tag == TW_Denormal)
+                           && (denormal_operand() < 0))
+                               return;
 
-             if ( signpositive(st0_ptr) )
-               {
-                 FPU_copy_to_reg1(&CONST_Z, TAG_Zero);
-                 setsign(st1_ptr, sign);   /* An 80486 preserves the sign */
-                 FPU_pop();
-                 return;
+                       FPU_copy_to_reg1(&CONST_PI2, TAG_Valid);
                }
-             else
-               {
-                 FPU_copy_to_reg1(&CONST_PI, TAG_Valid);
+               setsign(st1_ptr, sign);
+       } else if (st1_tag == TAG_Zero) {
+               /* st(0) must be valid or zero */
+               u_char sign = getsign(st1_ptr);
+
+               if ((st0_tag == TW_Denormal) && (denormal_operand() < 0))
+                       return;
+
+               if (signpositive(st0_ptr)) {
+                       /* An 80486 preserves the sign */
+                       FPU_pop();
+                       return;
                }
-           }
-       }
-      else
-       {
-         /* st(1) is infinity, st(0) not infinity */
-         if ( (st0_tag == TW_Denormal) && (denormal_operand() < 0) )
-           return;
 
-         FPU_copy_to_reg1(&CONST_PI2, TAG_Valid);
-       }
-      setsign(st1_ptr, sign);
-    }
-  else if ( st1_tag == TAG_Zero )
-    {
-      /* st(0) must be valid or zero */
-      u_char sign = getsign(st1_ptr);
-
-      if ( (st0_tag == TW_Denormal) && (denormal_operand() < 0) )
-       return;
+               FPU_copy_to_reg1(&CONST_PI, TAG_Valid);
+               setsign(st1_ptr, sign);
+       } else if (st0_tag == TAG_Zero) {
+               /* st(1) must be TAG_Valid here */
+               u_char sign = getsign(st1_ptr);
 
-      if ( signpositive(st0_ptr) )
-       {
-         /* An 80486 preserves the sign */
-         FPU_pop();
-         return;
-       }
+               if ((st1_tag == TW_Denormal) && (denormal_operand() < 0))
+                       return;
 
-      FPU_copy_to_reg1(&CONST_PI, TAG_Valid);
-      setsign(st1_ptr, sign);
-    }
-  else if ( st0_tag == TAG_Zero )
-    {
-      /* st(1) must be TAG_Valid here */
-      u_char sign = getsign(st1_ptr);
-
-      if ( (st1_tag == TW_Denormal) && (denormal_operand() < 0) )
-       return;
-
-      FPU_copy_to_reg1(&CONST_PI2, TAG_Valid);
-      setsign(st1_ptr, sign);
-    }
+               FPU_copy_to_reg1(&CONST_PI2, TAG_Valid);
+               setsign(st1_ptr, sign);
+       }
 #ifdef PARANOID
-  else
-    EXCEPTION(EX_INTERNAL | 0x125);
+       else
+               EXCEPTION(EX_INTERNAL | 0x125);
 #endif /* PARANOID */
 
-  FPU_pop();
-  set_precision_flag_up();  /* We do not really know if up or down */
+       FPU_pop();
+       set_precision_flag_up();        /* We do not really know if up or down */
 }
 
-
-static void fprem(FPU_REG *st0_ptr, u_char st0_tag)
+static void fprem(FPU_REG * st0_ptr, u_char st0_tag)
 {
-  do_fprem(st0_ptr, st0_tag, RC_CHOP);
+       do_fprem(st0_ptr, st0_tag, RC_CHOP);
 }
 
-
-static void fprem1(FPU_REG *st0_ptr, u_char st0_tag)
+static void fprem1(FPU_REG * st0_ptr, u_char st0_tag)
 {
-  do_fprem(st0_ptr, st0_tag, RC_RND);
+       do_fprem(st0_ptr, st0_tag, RC_RND);
 }
 
-
-static void fyl2xp1(FPU_REG *st0_ptr, u_char st0_tag)
+static void fyl2xp1(FPU_REG * st0_ptr, u_char st0_tag)
 {
-  u_char sign, sign1;
-  FPU_REG *st1_ptr = &st(1), a, b;
-  u_char st1_tag = FPU_gettagi(1);
+       u_char sign, sign1;
+       FPU_REG *st1_ptr = &st(1), a, b;
+       u_char st1_tag = FPU_gettagi(1);
 
-  clear_C1();
-  if ( !((st0_tag ^ TAG_Valid) | (st1_tag ^ TAG_Valid)) )
-    {
-    valid_yl2xp1:
+       clear_C1();
+       if (!((st0_tag ^ TAG_Valid) | (st1_tag ^ TAG_Valid))) {
+             valid_yl2xp1:
 
-      sign = getsign(st0_ptr);
-      sign1 = getsign(st1_ptr);
+               sign = getsign(st0_ptr);
+               sign1 = getsign(st1_ptr);
 
-      FPU_to_exp16(st0_ptr, &a);
-      FPU_to_exp16(st1_ptr, &b);
+               FPU_to_exp16(st0_ptr, &a);
+               FPU_to_exp16(st1_ptr, &b);
 
-      if ( poly_l2p1(sign, sign1, &a, &b, st1_ptr) )
-       return;
+               if (poly_l2p1(sign, sign1, &a, &b, st1_ptr))
+                       return;
 
-      FPU_pop();
-      return;
-    }
+               FPU_pop();
+               return;
+       }
 
-  if ( st0_tag == TAG_Special )
-    st0_tag = FPU_Special(st0_ptr);
-  if ( st1_tag == TAG_Special )
-    st1_tag = FPU_Special(st1_ptr);
+       if (st0_tag == TAG_Special)
+               st0_tag = FPU_Special(st0_ptr);
+       if (st1_tag == TAG_Special)
+               st1_tag = FPU_Special(st1_ptr);
 
-  if ( ((st0_tag == TAG_Valid) && (st1_tag == TW_Denormal))
+       if (((st0_tag == TAG_Valid) && (st1_tag == TW_Denormal))
            || ((st0_tag == TW_Denormal) && (st1_tag == TAG_Valid))
-           || ((st0_tag == TW_Denormal) && (st1_tag == TW_Denormal)) )
-    {
-      if ( denormal_operand() < 0 )
-       return;
-
-      goto valid_yl2xp1;
-    }
-  else if ( (st0_tag == TAG_Empty) | (st1_tag == TAG_Empty) )
-    {
-      FPU_stack_underflow_pop(1);
-      return;
-    }
-  else if ( st0_tag == TAG_Zero )
-    {
-      switch ( st1_tag )
-       {
-       case TW_Denormal:
-         if ( denormal_operand() < 0 )
-           return;
-
-       case TAG_Zero:
-       case TAG_Valid:
-         setsign(st0_ptr, getsign(st0_ptr) ^ getsign(st1_ptr));
-         FPU_copy_to_reg1(st0_ptr, st0_tag);
-         break;
-
-       case TW_Infinity:
-         /* Infinity*log(1) */
-         if ( arith_invalid(1) < 0 )
-           return;
-         break;
+           || ((st0_tag == TW_Denormal) && (st1_tag == TW_Denormal))) {
+               if (denormal_operand() < 0)
+                       return;
 
-       case TW_NaN:
-         if ( real_2op_NaN(st0_ptr, st0_tag, 1, st0_ptr) < 0 )
-           return;
-         break;
-
-       default:
+               goto valid_yl2xp1;
+       } else if ((st0_tag == TAG_Empty) | (st1_tag == TAG_Empty)) {
+               FPU_stack_underflow_pop(1);
+               return;
+       } else if (st0_tag == TAG_Zero) {
+               switch (st1_tag) {
+               case TW_Denormal:
+                       if (denormal_operand() < 0)
+                               return;
+
+               case TAG_Zero:
+               case TAG_Valid:
+                       setsign(st0_ptr, getsign(st0_ptr) ^ getsign(st1_ptr));
+                       FPU_copy_to_reg1(st0_ptr, st0_tag);
+                       break;
+
+               case TW_Infinity:
+                       /* Infinity*log(1) */
+                       if (arith_invalid(1) < 0)
+                               return;
+                       break;
+
+               case TW_NaN:
+                       if (real_2op_NaN(st0_ptr, st0_tag, 1, st0_ptr) < 0)
+                               return;
+                       break;
+
+               default:
 #ifdef PARANOID
-         EXCEPTION(EX_INTERNAL | 0x116);
-         return;
+                       EXCEPTION(EX_INTERNAL | 0x116);
+                       return;
 #endif /* PARANOID */
-         break;
-       }
-    }
-  else if ( (st0_tag == TAG_Valid) || (st0_tag == TW_Denormal) )
-    {
-      switch ( st1_tag )
-       {
-       case TAG_Zero:
-         if ( signnegative(st0_ptr) )
-           {
-             if ( exponent(st0_ptr) >= 0 )
-               {
-                 /* st(0) holds <= -1.0 */
-#ifdef PECULIAR_486   /* Stupid 80486 doesn't worry about log(negative). */
-                 changesign(st1_ptr);
+                       break;
+               }
+       } else if ((st0_tag == TAG_Valid) || (st0_tag == TW_Denormal)) {
+               switch (st1_tag) {
+               case TAG_Zero:
+                       if (signnegative(st0_ptr)) {
+                               if (exponent(st0_ptr) >= 0) {
+                                       /* st(0) holds <= -1.0 */
+#ifdef PECULIAR_486            /* Stupid 80486 doesn't worry about log(negative). */
+                                       changesign(st1_ptr);
 #else
-                 if ( arith_invalid(1) < 0 )
-                   return;
+                                       if (arith_invalid(1) < 0)
+                                               return;
 #endif /* PECULIAR_486 */
-               }
-             else if ( (st0_tag == TW_Denormal) && (denormal_operand() < 0) )
-               return;
-             else
-               changesign(st1_ptr);
-           }
-         else if ( (st0_tag == TW_Denormal) && (denormal_operand() < 0) )
-           return;
-         break;
-
-       case TW_Infinity:
-         if ( signnegative(st0_ptr) )
-           {
-             if ( (exponent(st0_ptr) >= 0) &&
-                 !((st0_ptr->sigh == 0x80000000) &&
-                   (st0_ptr->sigl == 0)) )
-               {
-                 /* st(0) holds < -1.0 */
-#ifdef PECULIAR_486   /* Stupid 80486 doesn't worry about log(negative). */
-                 changesign(st1_ptr);
+                               } else if ((st0_tag == TW_Denormal)
+                                          && (denormal_operand() < 0))
+                                       return;
+                               else
+                                       changesign(st1_ptr);
+                       } else if ((st0_tag == TW_Denormal)
+                                  && (denormal_operand() < 0))
+                               return;
+                       break;
+
+               case TW_Infinity:
+                       if (signnegative(st0_ptr)) {
+                               if ((exponent(st0_ptr) >= 0) &&
+                                   !((st0_ptr->sigh == 0x80000000) &&
+                                     (st0_ptr->sigl == 0))) {
+                                       /* st(0) holds < -1.0 */
+#ifdef PECULIAR_486            /* Stupid 80486 doesn't worry about log(negative). */
+                                       changesign(st1_ptr);
 #else
-                 if ( arith_invalid(1) < 0 ) return;
+                                       if (arith_invalid(1) < 0)
+                                               return;
 #endif /* PECULIAR_486 */
+                               } else if ((st0_tag == TW_Denormal)
+                                          && (denormal_operand() < 0))
+                                       return;
+                               else
+                                       changesign(st1_ptr);
+                       } else if ((st0_tag == TW_Denormal)
+                                  && (denormal_operand() < 0))
+                               return;
+                       break;
+
+               case TW_NaN:
+                       if (real_2op_NaN(st0_ptr, st0_tag, 1, st0_ptr) < 0)
+                               return;
                }
-             else if ( (st0_tag == TW_Denormal) && (denormal_operand() < 0) )
-               return;
-             else
-               changesign(st1_ptr);
-           }
-         else if ( (st0_tag == TW_Denormal) && (denormal_operand() < 0) )
-           return;
-         break;
-
-       case TW_NaN:
-         if ( real_2op_NaN(st0_ptr, st0_tag, 1, st0_ptr) < 0 )
-           return;
-       }
 
-    }
-  else if ( st0_tag == TW_NaN )
-    {
-      if ( real_2op_NaN(st0_ptr, st0_tag, 1, st0_ptr) < 0 )
-       return;
-    }
-  else if ( st0_tag == TW_Infinity )
-    {
-      if ( st1_tag == TW_NaN )
-       {
-         if ( real_2op_NaN(st0_ptr, st0_tag, 1, st0_ptr) < 0 )
-           return;
-       }
-      else if ( signnegative(st0_ptr) )
-       {
+       } else if (st0_tag == TW_NaN) {
+               if (real_2op_NaN(st0_ptr, st0_tag, 1, st0_ptr) < 0)
+                       return;
+       } else if (st0_tag == TW_Infinity) {
+               if (st1_tag == TW_NaN) {
+                       if (real_2op_NaN(st0_ptr, st0_tag, 1, st0_ptr) < 0)
+                               return;
+               } else if (signnegative(st0_ptr)) {
 #ifndef PECULIAR_486
-         /* This should have higher priority than denormals, but... */
-         if ( arith_invalid(1) < 0 )  /* log(-infinity) */
-           return;
+                       /* This should have higher priority than denormals, but... */
+                       if (arith_invalid(1) < 0)       /* log(-infinity) */
+                               return;
 #endif /* PECULIAR_486 */
-         if ( (st1_tag == TW_Denormal) && (denormal_operand() < 0) )
-           return;
+                       if ((st1_tag == TW_Denormal)
+                           && (denormal_operand() < 0))
+                               return;
 #ifdef PECULIAR_486
-         /* Denormal operands actually get higher priority */
-         if ( arith_invalid(1) < 0 )  /* log(-infinity) */
-           return;
+                       /* Denormal operands actually get higher priority */
+                       if (arith_invalid(1) < 0)       /* log(-infinity) */
+                               return;
 #endif /* PECULIAR_486 */
-       }
-      else if ( st1_tag == TAG_Zero )
-       {
-         /* log(infinity) */
-         if ( arith_invalid(1) < 0 )
-           return;
-       }
-       
-      /* st(1) must be valid here. */
+               } else if (st1_tag == TAG_Zero) {
+                       /* log(infinity) */
+                       if (arith_invalid(1) < 0)
+                               return;
+               }
 
-      else if ( (st1_tag == TW_Denormal) && (denormal_operand() < 0) )
-       return;
+               /* st(1) must be valid here. */
+
+               else if ((st1_tag == TW_Denormal) && (denormal_operand() < 0))
+                       return;
 
-      /* The Manual says that log(Infinity) is invalid, but a real
-        80486 sensibly says that it is o.k. */
-      else
-       {
-         u_char sign = getsign(st1_ptr);
-         FPU_copy_to_reg1(&CONST_INF, TAG_Special);
-         setsign(st1_ptr, sign);
+               /* The Manual says that log(Infinity) is invalid, but a real
+                  80486 sensibly says that it is o.k. */
+               else {
+                       u_char sign = getsign(st1_ptr);
+                       FPU_copy_to_reg1(&CONST_INF, TAG_Special);
+                       setsign(st1_ptr, sign);
+               }
        }
-    }
 #ifdef PARANOID
-  else
-    {
-      EXCEPTION(EX_INTERNAL | 0x117);
-      return;
-    }
+       else {
+               EXCEPTION(EX_INTERNAL | 0x117);
+               return;
+       }
 #endif /* PARANOID */
 
-  FPU_pop();
-  return;
+       FPU_pop();
+       return;
 
 }
 
-
-static void fscale(FPU_REG *st0_ptr, u_char st0_tag)
+static void fscale(FPU_REG * st0_ptr, u_char st0_tag)
 {
-  FPU_REG *st1_ptr = &st(1);
-  u_char st1_tag = FPU_gettagi(1);
-  int old_cw = control_word;
-  u_char sign = getsign(st0_ptr);
-
-  clear_C1();
-  if ( !((st0_tag ^ TAG_Valid) | (st1_tag ^ TAG_Valid)) )
-    {
-      long scale;
-      FPU_REG tmp;
-
-      /* Convert register for internal use. */
-      setexponent16(st0_ptr, exponent(st0_ptr));
-
-    valid_scale:
-
-      if ( exponent(st1_ptr) > 30 )
-       {
-         /* 2^31 is far too large, would require 2^(2^30) or 2^(-2^30) */
-
-         if ( signpositive(st1_ptr) )
-           {
-             EXCEPTION(EX_Overflow);
-             FPU_copy_to_reg0(&CONST_INF, TAG_Special);
-           }
-         else
-           {
-             EXCEPTION(EX_Underflow);
-             FPU_copy_to_reg0(&CONST_Z, TAG_Zero);
-           }
-         setsign(st0_ptr, sign);
-         return;
-       }
-
-      control_word &= ~CW_RC;
-      control_word |= RC_CHOP;
-      reg_copy(st1_ptr, &tmp);
-      FPU_round_to_int(&tmp, st1_tag);      /* This can never overflow here */
-      control_word = old_cw;
-      scale = signnegative(st1_ptr) ? -tmp.sigl : tmp.sigl;
-      scale += exponent16(st0_ptr);
-
-      setexponent16(st0_ptr, scale);
-
-      /* Use FPU_round() to properly detect under/overflow etc */
-      FPU_round(st0_ptr, 0, 0, control_word, sign);
-
-      return;
-    }
-
-  if ( st0_tag == TAG_Special )
-    st0_tag = FPU_Special(st0_ptr);
-  if ( st1_tag == TAG_Special )
-    st1_tag = FPU_Special(st1_ptr);
-
-  if ( (st0_tag == TAG_Valid) || (st0_tag == TW_Denormal) )
-    {
-      switch ( st1_tag )
-       {
-       case TAG_Valid:
-         /* st(0) must be a denormal */
-         if ( (st0_tag == TW_Denormal) && (denormal_operand() < 0) )
-           return;
-
-         FPU_to_exp16(st0_ptr, st0_ptr);  /* Will not be left on stack */
-         goto valid_scale;
-
-       case TAG_Zero:
-         if ( st0_tag == TW_Denormal )
-           denormal_operand();
-         return;
-
-       case TW_Denormal:
-         denormal_operand();
-         return;
-
-       case TW_Infinity:
-         if ( (st0_tag == TW_Denormal) && (denormal_operand() < 0) )
-           return;
-
-         if ( signpositive(st1_ptr) )
-           FPU_copy_to_reg0(&CONST_INF, TAG_Special);
-         else
-           FPU_copy_to_reg0(&CONST_Z, TAG_Zero);
-         setsign(st0_ptr, sign);
-         return;
+       FPU_REG *st1_ptr = &st(1);
+       u_char st1_tag = FPU_gettagi(1);
+       int old_cw = control_word;
+       u_char sign = getsign(st0_ptr);
+
+       clear_C1();
+       if (!((st0_tag ^ TAG_Valid) | (st1_tag ^ TAG_Valid))) {
+               long scale;
+               FPU_REG tmp;
+
+               /* Convert register for internal use. */
+               setexponent16(st0_ptr, exponent(st0_ptr));
+
+             valid_scale:
+
+               if (exponent(st1_ptr) > 30) {
+                       /* 2^31 is far too large, would require 2^(2^30) or 2^(-2^30) */
+
+                       if (signpositive(st1_ptr)) {
+                               EXCEPTION(EX_Overflow);
+                               FPU_copy_to_reg0(&CONST_INF, TAG_Special);
+                       } else {
+                               EXCEPTION(EX_Underflow);
+                               FPU_copy_to_reg0(&CONST_Z, TAG_Zero);
+                       }
+                       setsign(st0_ptr, sign);
+                       return;
+               }
 
-       case TW_NaN:
-         real_2op_NaN(st1_ptr, st1_tag, 0, st0_ptr);
-         return;
-       }
-    }
-  else if ( st0_tag == TAG_Zero )
-    {
-      switch ( st1_tag )
-       {
-       case TAG_Valid:
-       case TAG_Zero:
-         return;
+               control_word &= ~CW_RC;
+               control_word |= RC_CHOP;
+               reg_copy(st1_ptr, &tmp);
+               FPU_round_to_int(&tmp, st1_tag);        /* This can never overflow here */
+               control_word = old_cw;
+               scale = signnegative(st1_ptr) ? -tmp.sigl : tmp.sigl;
+               scale += exponent16(st0_ptr);
 
-       case TW_Denormal:
-         denormal_operand();
-         return;
+               setexponent16(st0_ptr, scale);
 
-       case TW_Infinity:
-         if ( signpositive(st1_ptr) )
-           arith_invalid(0); /* Zero scaled by +Infinity */
-         return;
+               /* Use FPU_round() to properly detect under/overflow etc */
+               FPU_round(st0_ptr, 0, 0, control_word, sign);
 
-       case TW_NaN:
-         real_2op_NaN(st1_ptr, st1_tag, 0, st0_ptr);
-         return;
+               return;
        }
-    }
-  else if ( st0_tag == TW_Infinity )
-    {
-      switch ( st1_tag )
-       {
-       case TAG_Valid:
-       case TAG_Zero:
-         return;
-
-       case TW_Denormal:
-         denormal_operand();
-         return;
 
-       case TW_Infinity:
-         if ( signnegative(st1_ptr) )
-           arith_invalid(0); /* Infinity scaled by -Infinity */
-         return;
-
-       case TW_NaN:
-         real_2op_NaN(st1_ptr, st1_tag, 0, st0_ptr);
-         return;
+       if (st0_tag == TAG_Special)
+               st0_tag = FPU_Special(st0_ptr);
+       if (st1_tag == TAG_Special)
+               st1_tag = FPU_Special(st1_ptr);
+
+       if ((st0_tag == TAG_Valid) || (st0_tag == TW_Denormal)) {
+               switch (st1_tag) {
+               case TAG_Valid:
+                       /* st(0) must be a denormal */
+                       if ((st0_tag == TW_Denormal)
+                           && (denormal_operand() < 0))
+                               return;
+
+                       FPU_to_exp16(st0_ptr, st0_ptr); /* Will not be left on stack */
+                       goto valid_scale;
+
+               case TAG_Zero:
+                       if (st0_tag == TW_Denormal)
+                               denormal_operand();
+                       return;
+
+               case TW_Denormal:
+                       denormal_operand();
+                       return;
+
+               case TW_Infinity:
+                       if ((st0_tag == TW_Denormal)
+                           && (denormal_operand() < 0))
+                               return;
+
+                       if (signpositive(st1_ptr))
+                               FPU_copy_to_reg0(&CONST_INF, TAG_Special);
+                       else
+                               FPU_copy_to_reg0(&CONST_Z, TAG_Zero);
+                       setsign(st0_ptr, sign);
+                       return;
+
+               case TW_NaN:
+                       real_2op_NaN(st1_ptr, st1_tag, 0, st0_ptr);
+                       return;
+               }
+       } else if (st0_tag == TAG_Zero) {
+               switch (st1_tag) {
+               case TAG_Valid:
+               case TAG_Zero:
+                       return;
+
+               case TW_Denormal:
+                       denormal_operand();
+                       return;
+
+               case TW_Infinity:
+                       if (signpositive(st1_ptr))
+                               arith_invalid(0);       /* Zero scaled by +Infinity */
+                       return;
+
+               case TW_NaN:
+                       real_2op_NaN(st1_ptr, st1_tag, 0, st0_ptr);
+                       return;
+               }
+       } else if (st0_tag == TW_Infinity) {
+               switch (st1_tag) {
+               case TAG_Valid:
+               case TAG_Zero:
+                       return;
+
+               case TW_Denormal:
+                       denormal_operand();
+                       return;
+
+               case TW_Infinity:
+                       if (signnegative(st1_ptr))
+                               arith_invalid(0);       /* Infinity scaled by -Infinity */
+                       return;
+
+               case TW_NaN:
+                       real_2op_NaN(st1_ptr, st1_tag, 0, st0_ptr);
+                       return;
+               }
+       } else if (st0_tag == TW_NaN) {
+               if (st1_tag != TAG_Empty) {
+                       real_2op_NaN(st1_ptr, st1_tag, 0, st0_ptr);
+                       return;
+               }
        }
-    }
-  else if ( st0_tag == TW_NaN )
-    {
-      if ( st1_tag != TAG_Empty )
-       { real_2op_NaN(st1_ptr, st1_tag, 0, st0_ptr); return; }
-    }
-
 #ifdef PARANOID
-  if ( !((st0_tag == TAG_Empty) || (st1_tag == TAG_Empty)) )
-    {
-      EXCEPTION(EX_INTERNAL | 0x115);
-      return;
-    }
+       if (!((st0_tag == TAG_Empty) || (st1_tag == TAG_Empty))) {
+               EXCEPTION(EX_INTERNAL | 0x115);
+               return;
+       }
 #endif
 
-  /* At least one of st(0), st(1) must be empty */
-  FPU_stack_underflow();
+       /* At least one of st(0), st(1) must be empty */
+       FPU_stack_underflow();
 
 }
 
-
 /*---------------------------------------------------------------------------*/
 
 static FUNC_ST0 const trig_table_a[] = {
-  f2xm1, fyl2x, fptan, fpatan,
-  fxtract, fprem1, (FUNC_ST0)fdecstp, (FUNC_ST0)fincstp
+       f2xm1, fyl2x, fptan, fpatan,
+       fxtract, fprem1, (FUNC_ST0) fdecstp, (FUNC_ST0) fincstp
 };
 
 void FPU_triga(void)
 {
-  (trig_table_a[FPU_rm])(&st(0), FPU_gettag0());
+       (trig_table_a[FPU_rm]) (&st(0), FPU_gettag0());
 }
 
-
-static FUNC_ST0 const trig_table_b[] =
-  {
-    fprem, fyl2xp1, fsqrt_, fsincos, frndint_, fscale, (FUNC_ST0)fsin, fcos
-  };
+static FUNC_ST0 const trig_table_b[] = {
+       fprem, fyl2xp1, fsqrt_, fsincos, frndint_, fscale, (FUNC_ST0) fsin, fcos
+};
 
 void FPU_trigb(void)
 {
-  (trig_table_b[FPU_rm])(&st(0), FPU_gettag0());
+       (trig_table_b[FPU_rm]) (&st(0), FPU_gettag0());
 }
index 2e2c51a..d701e2b 100644 (file)
@@ -17,7 +17,6 @@
  |    other processes using the emulator while swapping is in progress.      |
  +---------------------------------------------------------------------------*/
 
-
 #include <linux/stddef.h>
 
 #include <asm/uaccess.h>
 #include "exception.h"
 #include "fpu_emu.h"
 
-
 #define FPU_WRITE_BIT 0x10
 
 static int reg_offset[] = {
-       offsetof(struct info,___eax),
-       offsetof(struct info,___ecx),
-       offsetof(struct info,___edx),
-       offsetof(struct info,___ebx),
-       offsetof(struct info,___esp),
-       offsetof(struct info,___ebp),
-       offsetof(struct info,___esi),
-       offsetof(struct info,___edi)
+       offsetof(struct info, ___eax),
+       offsetof(struct info, ___ecx),
+       offsetof(struct info, ___edx),
+       offsetof(struct info, ___ebx),
+       offsetof(struct info, ___esp),
+       offsetof(struct info, ___ebp),
+       offsetof(struct info, ___esi),
+       offsetof(struct info, ___edi)
 };
 
 #define REG_(x) (*(long *)(reg_offset[(x)]+(u_char *) FPU_info))
 
 static int reg_offset_vm86[] = {
-       offsetof(struct info,___cs),
-       offsetof(struct info,___vm86_ds),
-       offsetof(struct info,___vm86_es),
-       offsetof(struct info,___vm86_fs),
-       offsetof(struct info,___vm86_gs),
-       offsetof(struct info,___ss),
-       offsetof(struct info,___vm86_ds)
-      };
+       offsetof(struct info, ___cs),
+       offsetof(struct info, ___vm86_ds),
+       offsetof(struct info, ___vm86_es),
+       offsetof(struct info, ___vm86_fs),
+       offsetof(struct info, ___vm86_gs),
+       offsetof(struct info, ___ss),
+       offsetof(struct info, ___vm86_ds)
+};
 
 #define VM86_REG_(x) (*(unsigned short *) \
                      (reg_offset_vm86[((unsigned)x)]+(u_char *) FPU_info))
@@ -60,158 +58,141 @@ static int reg_offset_vm86[] = {
 #define ___GS ___ds
 
 static int reg_offset_pm[] = {
-       offsetof(struct info,___cs),
-       offsetof(struct info,___ds),
-       offsetof(struct info,___es),
-       offsetof(struct info,___fs),
-       offsetof(struct info,___GS),
-       offsetof(struct info,___ss),
-       offsetof(struct info,___ds)
-      };
+       offsetof(struct info, ___cs),
+       offsetof(struct info, ___ds),
+       offsetof(struct info, ___es),
+       offsetof(struct info, ___fs),
+       offsetof(struct info, ___GS),
+       offsetof(struct info, ___ss),
+       offsetof(struct info, ___ds)
+};
 
 #define PM_REG_(x) (*(unsigned short *) \
                      (reg_offset_pm[((unsigned)x)]+(u_char *) FPU_info))
 
-
 /* Decode the SIB byte. This function assumes mod != 0 */
 static int sib(int mod, unsigned long *fpu_eip)
 {
-  u_char ss,index,base;
-  long offset;
-
-  RE_ENTRANT_CHECK_OFF;
-  FPU_code_access_ok(1);
-  FPU_get_user(base, (u_char __user *) (*fpu_eip));   /* The SIB byte */
-  RE_ENTRANT_CHECK_ON;
-  (*fpu_eip)++;
-  ss = base >> 6;
-  index = (base >> 3) & 7;
-  base &= 7;
-
-  if ((mod == 0) && (base == 5))
-    offset = 0;              /* No base register */
-  else
-    offset = REG_(base);
-
-  if (index == 4)
-    {
-      /* No index register */
-      /* A non-zero ss is illegal */
-      if ( ss )
-       EXCEPTION(EX_Invalid);
-    }
-  else
-    {
-      offset += (REG_(index)) << ss;
-    }
-
-  if (mod == 1)
-    {
-      /* 8 bit signed displacement */
-      long displacement;
-      RE_ENTRANT_CHECK_OFF;
-      FPU_code_access_ok(1);
-      FPU_get_user(displacement, (signed char __user *) (*fpu_eip));
-      offset += displacement;
-      RE_ENTRANT_CHECK_ON;
-      (*fpu_eip)++;
-    }
-  else if (mod == 2 || base == 5) /* The second condition also has mod==0 */
-    {
-      /* 32 bit displacement */
-      long displacement;
-      RE_ENTRANT_CHECK_OFF;
-      FPU_code_access_ok(4);
-      FPU_get_user(displacement, (long __user *) (*fpu_eip));
-      offset += displacement;
-      RE_ENTRANT_CHECK_ON;
-      (*fpu_eip) += 4;
-    }
-
-  return offset;
-}
+       u_char ss, index, base;
+       long offset;
+
+       RE_ENTRANT_CHECK_OFF;
+       FPU_code_access_ok(1);
+       FPU_get_user(base, (u_char __user *) (*fpu_eip));       /* The SIB byte */
+       RE_ENTRANT_CHECK_ON;
+       (*fpu_eip)++;
+       ss = base >> 6;
+       index = (base >> 3) & 7;
+       base &= 7;
+
+       if ((mod == 0) && (base == 5))
+               offset = 0;     /* No base register */
+       else
+               offset = REG_(base);
+
+       if (index == 4) {
+               /* No index register */
+               /* A non-zero ss is illegal */
+               if (ss)
+                       EXCEPTION(EX_Invalid);
+       } else {
+               offset += (REG_(index)) << ss;
+       }
+
+       if (mod == 1) {
+               /* 8 bit signed displacement */
+               long displacement;
+               RE_ENTRANT_CHECK_OFF;
+               FPU_code_access_ok(1);
+               FPU_get_user(displacement, (signed char __user *)(*fpu_eip));
+               offset += displacement;
+               RE_ENTRANT_CHECK_ON;
+               (*fpu_eip)++;
+       } else if (mod == 2 || base == 5) {     /* The second condition also has mod==0 */
+               /* 32 bit displacement */
+               long displacement;
+               RE_ENTRANT_CHECK_OFF;
+               FPU_code_access_ok(4);
+               FPU_get_user(displacement, (long __user *)(*fpu_eip));
+               offset += displacement;
+               RE_ENTRANT_CHECK_ON;
+               (*fpu_eip) += 4;
+       }
 
+       return offset;
+}
 
-static unsigned long vm86_segment(u_char segment,
-                                 struct address *addr)
+static unsigned long vm86_segment(u_char segment, struct address *addr)
 {
-  segment--;
+       segment--;
 #ifdef PARANOID
-  if ( segment > PREFIX_SS_ )
-    {
-      EXCEPTION(EX_INTERNAL|0x130);
-      math_abort(FPU_info,SIGSEGV);
-    }
+       if (segment > PREFIX_SS_) {
+               EXCEPTION(EX_INTERNAL | 0x130);
+               math_abort(FPU_info, SIGSEGV);
+       }
 #endif /* PARANOID */
-  addr->selector = VM86_REG_(segment);
-  return (unsigned long)VM86_REG_(segment) << 4;
+       addr->selector = VM86_REG_(segment);
+       return (unsigned long)VM86_REG_(segment) << 4;
 }
 
-
 /* This should work for 16 and 32 bit protected mode. */
 static long pm_address(u_char FPU_modrm, u_char segment,
                       struct address *addr, long offset)
-{ 
-  struct desc_struct descriptor;
-  unsigned long base_address, limit, address, seg_top;
+{
+       struct desc_struct descriptor;
+       unsigned long base_address, limit, address, seg_top;
 
-  segment--;
+       segment--;
 
 #ifdef PARANOID
-  /* segment is unsigned, so this also detects if segment was 0: */
-  if ( segment > PREFIX_SS_ )
-    {
-      EXCEPTION(EX_INTERNAL|0x132);
-      math_abort(FPU_info,SIGSEGV);
-    }
+       /* segment is unsigned, so this also detects if segment was 0: */
+       if (segment > PREFIX_SS_) {
+               EXCEPTION(EX_INTERNAL | 0x132);
+               math_abort(FPU_info, SIGSEGV);
+       }
 #endif /* PARANOID */
 
-  switch ( segment )
-    {
-      /* gs isn't used by the kernel, so it still has its
-        user-space value. */
-    case PREFIX_GS_-1:
-      /* N.B. - movl %seg, mem is a 2 byte write regardless of prefix */
-      savesegment(gs, addr->selector);
-      break;
-    default:
-      addr->selector = PM_REG_(segment);
-    }
-
-  descriptor = LDT_DESCRIPTOR(PM_REG_(segment));
-  base_address = SEG_BASE_ADDR(descriptor);
-  address = base_address + offset;
-  limit = base_address
-       + (SEG_LIMIT(descriptor)+1) * SEG_GRANULARITY(descriptor) - 1;
-  if ( limit < base_address ) limit = 0xffffffff;
-
-  if ( SEG_EXPAND_DOWN(descriptor) )
-    {
-      if ( SEG_G_BIT(descriptor) )
-       seg_top = 0xffffffff;
-      else
-       {
-         seg_top = base_address + (1 << 20);
-         if ( seg_top < base_address ) seg_top = 0xffffffff;
+       switch (segment) {
+               /* gs isn't used by the kernel, so it still has its
+                  user-space value. */
+       case PREFIX_GS_ - 1:
+               /* N.B. - movl %seg, mem is a 2 byte write regardless of prefix */
+               savesegment(gs, addr->selector);
+               break;
+       default:
+               addr->selector = PM_REG_(segment);
        }
-      access_limit =
-       (address <= limit) || (address >= seg_top) ? 0 :
-         ((seg_top-address) >= 255 ? 255 : seg_top-address);
-    }
-  else
-    {
-      access_limit =
-       (address > limit) || (address < base_address) ? 0 :
-         ((limit-address) >= 254 ? 255 : limit-address+1);
-    }
-  if ( SEG_EXECUTE_ONLY(descriptor) ||
-      (!SEG_WRITE_PERM(descriptor) && (FPU_modrm & FPU_WRITE_BIT)) )
-    {
-      access_limit = 0;
-    }
-  return address;
-}
 
+       descriptor = LDT_DESCRIPTOR(PM_REG_(segment));
+       base_address = SEG_BASE_ADDR(descriptor);
+       address = base_address + offset;
+       limit = base_address
+           + (SEG_LIMIT(descriptor) + 1) * SEG_GRANULARITY(descriptor) - 1;
+       if (limit < base_address)
+               limit = 0xffffffff;
+
+       if (SEG_EXPAND_DOWN(descriptor)) {
+               if (SEG_G_BIT(descriptor))
+                       seg_top = 0xffffffff;
+               else {
+                       seg_top = base_address + (1 << 20);
+                       if (seg_top < base_address)
+                               seg_top = 0xffffffff;
+               }
+               access_limit =
+                   (address <= limit) || (address >= seg_top) ? 0 :
+                   ((seg_top - address) >= 255 ? 255 : seg_top - address);
+       } else {
+               access_limit =
+                   (address > limit) || (address < base_address) ? 0 :
+                   ((limit - address) >= 254 ? 255 : limit - address + 1);
+       }
+       if (SEG_EXECUTE_ONLY(descriptor) ||
+           (!SEG_WRITE_PERM(descriptor) && (FPU_modrm & FPU_WRITE_BIT))) {
+               access_limit = 0;
+       }
+       return address;
+}
 
 /*
        MOD R/M byte:  MOD == 3 has a special use for the FPU
@@ -221,7 +202,6 @@ static long pm_address(u_char FPU_modrm, u_char segment,
        .....   .........   .........
         MOD    OPCODE(2)     R/M
 
-
        SIB byte
 
        7   6   5   4   3   2   1   0
@@ -231,208 +211,194 @@ static long pm_address(u_char FPU_modrm, u_char segment,
 */
 
 void __user *FPU_get_address(u_char FPU_modrm, unsigned long *fpu_eip,
-                 struct address *addr,
-                 fpu_addr_modes addr_modes)
+                            struct address *addr, fpu_addr_modes addr_modes)
+{
+       u_char mod;
+       unsigned rm = FPU_modrm & 7;
+       long *cpu_reg_ptr;
+       int address = 0;        /* Initialized just to stop compiler warnings. */
+
+       /* Memory accessed via the cs selector is write protected
+          in `non-segmented' 32 bit protected mode. */
+       if (!addr_modes.default_mode && (FPU_modrm & FPU_WRITE_BIT)
+           && (addr_modes.override.segment == PREFIX_CS_)) {
+               math_abort(FPU_info, SIGSEGV);
+       }
+
+       addr->selector = FPU_DS;        /* Default, for 32 bit non-segmented mode. */
+
+       mod = (FPU_modrm >> 6) & 3;
+
+       if (rm == 4 && mod != 3) {
+               address = sib(mod, fpu_eip);
+       } else {
+               cpu_reg_ptr = &REG_(rm);
+               switch (mod) {
+               case 0:
+                       if (rm == 5) {
+                               /* Special case: disp32 */
+                               RE_ENTRANT_CHECK_OFF;
+                               FPU_code_access_ok(4);
+                               FPU_get_user(address,
+                                            (unsigned long __user
+                                             *)(*fpu_eip));
+                               (*fpu_eip) += 4;
+                               RE_ENTRANT_CHECK_ON;
+                               addr->offset = address;
+                               return (void __user *)address;
+                       } else {
+                               address = *cpu_reg_ptr; /* Just return the contents
+                                                          of the cpu register */
+                               addr->offset = address;
+                               return (void __user *)address;
+                       }
+               case 1:
+                       /* 8 bit signed displacement */
+                       RE_ENTRANT_CHECK_OFF;
+                       FPU_code_access_ok(1);
+                       FPU_get_user(address, (signed char __user *)(*fpu_eip));
+                       RE_ENTRANT_CHECK_ON;
+                       (*fpu_eip)++;
+                       break;
+               case 2:
+                       /* 32 bit displacement */
+                       RE_ENTRANT_CHECK_OFF;
+                       FPU_code_access_ok(4);
+                       FPU_get_user(address, (long __user *)(*fpu_eip));
+                       (*fpu_eip) += 4;
+                       RE_ENTRANT_CHECK_ON;
+                       break;
+               case 3:
+                       /* Not legal for the FPU */
+                       EXCEPTION(EX_Invalid);
+               }
+               address += *cpu_reg_ptr;
+       }
+
+       addr->offset = address;
+
+       switch (addr_modes.default_mode) {
+       case 0:
+               break;
+       case VM86:
+               address += vm86_segment(addr_modes.override.segment, addr);
+               break;
+       case PM16:
+       case SEG32:
+               address = pm_address(FPU_modrm, addr_modes.override.segment,
+                                    addr, address);
+               break;
+       default:
+               EXCEPTION(EX_INTERNAL | 0x133);
+       }
+
+       return (void __user *)address;
+}
+
+void __user *FPU_get_address_16(u_char FPU_modrm, unsigned long *fpu_eip,
+                               struct address *addr, fpu_addr_modes addr_modes)
 {
-  u_char mod;
-  unsigned rm = FPU_modrm & 7;
-  long *cpu_reg_ptr;
-  int address = 0;     /* Initialized just to stop compiler warnings. */
-
-  /* Memory accessed via the cs selector is write protected
-     in `non-segmented' 32 bit protected mode. */
-  if ( !addr_modes.default_mode && (FPU_modrm & FPU_WRITE_BIT)
-      && (addr_modes.override.segment == PREFIX_CS_) )
-    {
-      math_abort(FPU_info,SIGSEGV);
-    }
-
-  addr->selector = FPU_DS;   /* Default, for 32 bit non-segmented mode. */
-
-  mod = (FPU_modrm >> 6) & 3;
-
-  if (rm == 4 && mod != 3)
-    {
-      address = sib(mod, fpu_eip);
-    }
-  else
-    {
-      cpu_reg_ptr = & REG_(rm);
-      switch (mod)
-       {
+       u_char mod;
+       unsigned rm = FPU_modrm & 7;
+       int address = 0;        /* Default used for mod == 0 */
+
+       /* Memory accessed via the cs selector is write protected
+          in `non-segmented' 32 bit protected mode. */
+       if (!addr_modes.default_mode && (FPU_modrm & FPU_WRITE_BIT)
+           && (addr_modes.override.segment == PREFIX_CS_)) {
+               math_abort(FPU_info, SIGSEGV);
+       }
+
+       addr->selector = FPU_DS;        /* Default, for 32 bit non-segmented mode. */
+
+       mod = (FPU_modrm >> 6) & 3;
+
+       switch (mod) {
        case 0:
-         if (rm == 5)
-           {
-             /* Special case: disp32 */
-             RE_ENTRANT_CHECK_OFF;
-             FPU_code_access_ok(4);
-             FPU_get_user(address, (unsigned long __user *) (*fpu_eip));
-             (*fpu_eip) += 4;
-             RE_ENTRANT_CHECK_ON;
-             addr->offset = address;
-             return (void __user *) address;
-           }
-         else
-           {
-             address = *cpu_reg_ptr;  /* Just return the contents
-                                         of the cpu register */
-             addr->offset = address;
-             return (void __user *) address;
-           }
+               if (rm == 6) {
+                       /* Special case: disp16 */
+                       RE_ENTRANT_CHECK_OFF;
+                       FPU_code_access_ok(2);
+                       FPU_get_user(address,
+                                    (unsigned short __user *)(*fpu_eip));
+                       (*fpu_eip) += 2;
+                       RE_ENTRANT_CHECK_ON;
+                       goto add_segment;
+               }
+               break;
        case 1:
-         /* 8 bit signed displacement */
-         RE_ENTRANT_CHECK_OFF;
-         FPU_code_access_ok(1);
-         FPU_get_user(address, (signed char __user *) (*fpu_eip));
-         RE_ENTRANT_CHECK_ON;
-         (*fpu_eip)++;
-         break;
+               /* 8 bit signed displacement */
+               RE_ENTRANT_CHECK_OFF;
+               FPU_code_access_ok(1);
+               FPU_get_user(address, (signed char __user *)(*fpu_eip));
+               RE_ENTRANT_CHECK_ON;
+               (*fpu_eip)++;
+               break;
        case 2:
-         /* 32 bit displacement */
-         RE_ENTRANT_CHECK_OFF;
-         FPU_code_access_ok(4);
-         FPU_get_user(address, (long __user *) (*fpu_eip));
-         (*fpu_eip) += 4;
-         RE_ENTRANT_CHECK_ON;
-         break;
+               /* 16 bit displacement */
+               RE_ENTRANT_CHECK_OFF;
+               FPU_code_access_ok(2);
+               FPU_get_user(address, (unsigned short __user *)(*fpu_eip));
+               (*fpu_eip) += 2;
+               RE_ENTRANT_CHECK_ON;
+               break;
        case 3:
-         /* Not legal for the FPU */
-         EXCEPTION(EX_Invalid);
+               /* Not legal for the FPU */
+               EXCEPTION(EX_Invalid);
+               break;
+       }
+       switch (rm) {
+       case 0:
+               address += FPU_info->___ebx + FPU_info->___esi;
+               break;
+       case 1:
+               address += FPU_info->___ebx + FPU_info->___edi;
+               break;
+       case 2:
+               address += FPU_info->___ebp + FPU_info->___esi;
+               if (addr_modes.override.segment == PREFIX_DEFAULT)
+                       addr_modes.override.segment = PREFIX_SS_;
+               break;
+       case 3:
+               address += FPU_info->___ebp + FPU_info->___edi;
+               if (addr_modes.override.segment == PREFIX_DEFAULT)
+                       addr_modes.override.segment = PREFIX_SS_;
+               break;
+       case 4:
+               address += FPU_info->___esi;
+               break;
+       case 5:
+               address += FPU_info->___edi;
+               break;
+       case 6:
+               address += FPU_info->___ebp;
+               if (addr_modes.override.segment == PREFIX_DEFAULT)
+                       addr_modes.override.segment = PREFIX_SS_;
+               break;
+       case 7:
+               address += FPU_info->___ebx;
+               break;
        }
-      address += *cpu_reg_ptr;
-    }
-
-  addr->offset = address;
-
-  switch ( addr_modes.default_mode )
-    {
-    case 0:
-      break;
-    case VM86:
-      address += vm86_segment(addr_modes.override.segment, addr);
-      break;
-    case PM16:
-    case SEG32:
-      address = pm_address(FPU_modrm, addr_modes.override.segment,
-                          addr, address);
-      break;
-    default:
-      EXCEPTION(EX_INTERNAL|0x133);
-    }
-
-  return (void __user *)address;
-}
 
+      add_segment:
+       address &= 0xffff;
 
-void __user *FPU_get_address_16(u_char FPU_modrm, unsigned long *fpu_eip,
-                    struct address *addr,
-                    fpu_addr_modes addr_modes)
-{
-  u_char mod;
-  unsigned rm = FPU_modrm & 7;
-  int address = 0;     /* Default used for mod == 0 */
-
-  /* Memory accessed via the cs selector is write protected
-     in `non-segmented' 32 bit protected mode. */
-  if ( !addr_modes.default_mode && (FPU_modrm & FPU_WRITE_BIT)
-      && (addr_modes.override.segment == PREFIX_CS_) )
-    {
-      math_abort(FPU_info,SIGSEGV);
-    }
-
-  addr->selector = FPU_DS;   /* Default, for 32 bit non-segmented mode. */
-
-  mod = (FPU_modrm >> 6) & 3;
-
-  switch (mod)
-    {
-    case 0:
-      if (rm == 6)
-       {
-         /* Special case: disp16 */
-         RE_ENTRANT_CHECK_OFF;
-         FPU_code_access_ok(2);
-         FPU_get_user(address, (unsigned short __user *) (*fpu_eip));
-         (*fpu_eip) += 2;
-         RE_ENTRANT_CHECK_ON;
-         goto add_segment;
+       addr->offset = address;
+
+       switch (addr_modes.default_mode) {
+       case 0:
+               break;
+       case VM86:
+               address += vm86_segment(addr_modes.override.segment, addr);
+               break;
+       case PM16:
+       case SEG32:
+               address = pm_address(FPU_modrm, addr_modes.override.segment,
+                                    addr, address);
+               break;
+       default:
+               EXCEPTION(EX_INTERNAL | 0x131);
        }
-      break;
-    case 1:
-      /* 8 bit signed displacement */
-      RE_ENTRANT_CHECK_OFF;
-      FPU_code_access_ok(1);
-      FPU_get_user(address, (signed char __user *) (*fpu_eip));
-      RE_ENTRANT_CHECK_ON;
-      (*fpu_eip)++;
-      break;
-    case 2:
-      /* 16 bit displacement */
-      RE_ENTRANT_CHECK_OFF;
-      FPU_code_access_ok(2);
-      FPU_get_user(address, (unsigned short __user *) (*fpu_eip));
-      (*fpu_eip) += 2;
-      RE_ENTRANT_CHECK_ON;
-      break;
-    case 3:
-      /* Not legal for the FPU */
-      EXCEPTION(EX_Invalid);
-      break;
-    }
-  switch ( rm )
-    {
-    case 0:
-      address += FPU_info->___ebx + FPU_info->___esi;
-      break;
-    case 1:
-      address += FPU_info->___ebx + FPU_info->___edi;
-      break;
-    case 2:
-      address += FPU_info->___ebp + FPU_info->___esi;
-      if ( addr_modes.override.segment == PREFIX_DEFAULT )
-       addr_modes.override.segment = PREFIX_SS_;
-      break;
-    case 3:
-      address += FPU_info->___ebp + FPU_info->___edi;
-      if ( addr_modes.override.segment == PREFIX_DEFAULT )
-       addr_modes.override.segment = PREFIX_SS_;
-      break;
-    case 4:
-      address += FPU_info->___esi;
-      break;
-    case 5:
-      address += FPU_info->___edi;
-      break;
-    case 6:
-      address += FPU_info->___ebp;
-      if ( addr_modes.override.segment == PREFIX_DEFAULT )
-       addr_modes.override.segment = PREFIX_SS_;
-      break;
-    case 7:
-      address += FPU_info->___ebx;
-      break;
-    }
-
- add_segment:
-  address &= 0xffff;
-
-  addr->offset = address;
-
-  switch ( addr_modes.default_mode )
-    {
-    case 0:
-      break;
-    case VM86:
-      address += vm86_segment(addr_modes.override.segment, addr);
-      break;
-    case PM16:
-    case SEG32:
-      address = pm_address(FPU_modrm, addr_modes.override.segment,
-                          addr, address);
-      break;
-    default:
-      EXCEPTION(EX_INTERNAL|0x131);
-    }
-
-  return (void __user *)address ;
+
+       return (void __user *)address;
 }
index eebd6fb..2931ff3 100644 (file)
 #include "status_w.h"
 #include "control_w.h"
 
-
-#define _NONE_ 0   /* st0_ptr etc not needed */
-#define _REG0_ 1   /* Will be storing st(0) */
-#define _PUSH_ 3   /* Need to check for space to push onto stack */
-#define _null_ 4   /* Function illegal or not implemented */
+#define _NONE_ 0               /* st0_ptr etc not needed */
+#define _REG0_ 1               /* Will be storing st(0) */
+#define _PUSH_ 3               /* Need to check for space to push onto stack */
+#define _null_ 4               /* Function illegal or not implemented */
 
 #define pop_0()        { FPU_settag0(TAG_Empty); top++; }
 
-
 static u_char const type_table[32] = {
-  _PUSH_, _PUSH_, _PUSH_, _PUSH_,
-  _null_, _null_, _null_, _null_,
-  _REG0_, _REG0_, _REG0_, _REG0_,
-  _REG0_, _REG0_, _REG0_, _REG0_,
-  _NONE_, _null_, _NONE_, _PUSH_,
-  _NONE_, _PUSH_, _null_, _PUSH_,
-  _NONE_, _null_, _NONE_, _REG0_,
-  _NONE_, _REG0_, _NONE_, _REG0_
-  };
+       _PUSH_, _PUSH_, _PUSH_, _PUSH_,
+       _null_, _null_, _null_, _null_,
+       _REG0_, _REG0_, _REG0_, _REG0_,
+       _REG0_, _REG0_, _REG0_, _REG0_,
+       _NONE_, _null_, _NONE_, _PUSH_,
+       _NONE_, _PUSH_, _null_, _PUSH_,
+       _NONE_, _null_, _NONE_, _REG0_,
+       _NONE_, _REG0_, _NONE_, _REG0_
+};
 
 u_char const data_sizes_16[32] = {
-  4,  4,  8,  2,  0,  0,  0,  0,
-  4,  4,  8,  2,  4,  4,  8,  2,
-  14, 0, 94, 10,  2, 10,  0,  8,  
-  14, 0, 94, 10,  2, 10,  2,  8
+       4, 4, 8, 2, 0, 0, 0, 0,
+       4, 4, 8, 2, 4, 4, 8, 2,
+       14, 0, 94, 10, 2, 10, 0, 8,
+       14, 0, 94, 10, 2, 10, 2, 8
 };
 
 static u_char const data_sizes_32[32] = {
-  4,  4,  8,  2,  0,  0,  0,  0,
-  4,  4,  8,  2,  4,  4,  8,  2,
-  28, 0,108, 10,  2, 10,  0,  8,  
-  28, 0,108, 10,  2, 10,  2,  8
+       4, 4, 8, 2, 0, 0, 0, 0,
+       4, 4, 8, 2, 4, 4, 8, 2,
+       28, 0, 108, 10, 2, 10, 0, 8,
+       28, 0, 108, 10, 2, 10, 2, 8
 };
 
 int FPU_load_store(u_char type, fpu_addr_modes addr_modes,
-                    void __user *data_address)
+                  void __user * data_address)
 {
-  FPU_REG loaded_data;
-  FPU_REG *st0_ptr;
-  u_char st0_tag = TAG_Empty;  /* This is just to stop a gcc warning. */
-  u_char loaded_tag;
+       FPU_REG loaded_data;
+       FPU_REG *st0_ptr;
+       u_char st0_tag = TAG_Empty;     /* This is just to stop a gcc warning. */
+       u_char loaded_tag;
 
-  st0_ptr = NULL;    /* Initialized just to stop compiler warnings. */
+       st0_ptr = NULL;         /* Initialized just to stop compiler warnings. */
 
-  if ( addr_modes.default_mode & PROTECTED )
-    {
-      if ( addr_modes.default_mode == SEG32 )
-       {
-         if ( access_limit < data_sizes_32[type] )
-           math_abort(FPU_info,SIGSEGV);
-       }
-      else if ( addr_modes.default_mode == PM16 )
-       {
-         if ( access_limit < data_sizes_16[type] )
-           math_abort(FPU_info,SIGSEGV);
-       }
+       if (addr_modes.default_mode & PROTECTED) {
+               if (addr_modes.default_mode == SEG32) {
+                       if (access_limit < data_sizes_32[type])
+                               math_abort(FPU_info, SIGSEGV);
+               } else if (addr_modes.default_mode == PM16) {
+                       if (access_limit < data_sizes_16[type])
+                               math_abort(FPU_info, SIGSEGV);
+               }
 #ifdef PARANOID
-      else
-       EXCEPTION(EX_INTERNAL|0x140);
+               else
+                       EXCEPTION(EX_INTERNAL | 0x140);
 #endif /* PARANOID */
-    }
+       }
 
-  switch ( type_table[type] )
-    {
-    case _NONE_:
-      break;
-    case _REG0_:
-      st0_ptr = &st(0);       /* Some of these instructions pop after
-                                storing */
-      st0_tag = FPU_gettag0();
-      break;
-    case _PUSH_:
-      {
-       if ( FPU_gettagi(-1) != TAG_Empty )
-         { FPU_stack_overflow(); return 0; }
-       top--;
-       st0_ptr = &st(0);
-      }
-      break;
-    case _null_:
-      FPU_illegal();
-      return 0;
+       switch (type_table[type]) {
+       case _NONE_:
+               break;
+       case _REG0_:
+               st0_ptr = &st(0);       /* Some of these instructions pop after
+                                          storing */
+               st0_tag = FPU_gettag0();
+               break;
+       case _PUSH_:
+               {
+                       if (FPU_gettagi(-1) != TAG_Empty) {
+                               FPU_stack_overflow();
+                               return 0;
+                       }
+                       top--;
+                       st0_ptr = &st(0);
+               }
+               break;
+       case _null_:
+               FPU_illegal();
+               return 0;
 #ifdef PARANOID
-    default:
-      EXCEPTION(EX_INTERNAL|0x141);
-      return 0;
+       default:
+               EXCEPTION(EX_INTERNAL | 0x141);
+               return 0;
 #endif /* PARANOID */
-    }
-
-  switch ( type )
-    {
-    case 000:       /* fld m32real */
-      clear_C1();
-      loaded_tag = FPU_load_single((float __user *)data_address, &loaded_data);
-      if ( (loaded_tag == TAG_Special)
-          && isNaN(&loaded_data)
-          && (real_1op_NaN(&loaded_data) < 0) )
-       {
-         top++;
-         break;
-       }
-      FPU_copy_to_reg0(&loaded_data, loaded_tag);
-      break;
-    case 001:      /* fild m32int */
-      clear_C1();
-      loaded_tag = FPU_load_int32((long __user *)data_address, &loaded_data);
-      FPU_copy_to_reg0(&loaded_data, loaded_tag);
-      break;
-    case 002:      /* fld m64real */
-      clear_C1();
-      loaded_tag = FPU_load_double((double __user *)data_address, &loaded_data);
-      if ( (loaded_tag == TAG_Special)
-          && isNaN(&loaded_data)
-          && (real_1op_NaN(&loaded_data) < 0) )
-       {
-         top++;
-         break;
        }
-      FPU_copy_to_reg0(&loaded_data, loaded_tag);
-      break;
-    case 003:      /* fild m16int */
-      clear_C1();
-      loaded_tag = FPU_load_int16((short __user *)data_address, &loaded_data);
-      FPU_copy_to_reg0(&loaded_data, loaded_tag);
-      break;
-    case 010:      /* fst m32real */
-      clear_C1();
-      FPU_store_single(st0_ptr, st0_tag, (float __user *)data_address);
-      break;
-    case 011:      /* fist m32int */
-      clear_C1();
-      FPU_store_int32(st0_ptr, st0_tag, (long __user *)data_address);
-      break;
-    case 012:     /* fst m64real */
-      clear_C1();
-      FPU_store_double(st0_ptr, st0_tag, (double __user *)data_address);
-      break;
-    case 013:     /* fist m16int */
-      clear_C1();
-      FPU_store_int16(st0_ptr, st0_tag, (short __user *)data_address);
-      break;
-    case 014:     /* fstp m32real */
-      clear_C1();
-      if ( FPU_store_single(st0_ptr, st0_tag, (float __user *)data_address) )
-       pop_0();  /* pop only if the number was actually stored
-                    (see the 80486 manual p16-28) */
-      break;
-    case 015:     /* fistp m32int */
-      clear_C1();
-      if ( FPU_store_int32(st0_ptr, st0_tag, (long __user *)data_address) )
-       pop_0();  /* pop only if the number was actually stored
-                    (see the 80486 manual p16-28) */
-      break;
-    case 016:     /* fstp m64real */
-      clear_C1();
-      if ( FPU_store_double(st0_ptr, st0_tag, (double __user *)data_address) )
-       pop_0();  /* pop only if the number was actually stored
-                    (see the 80486 manual p16-28) */
-      break;
-    case 017:     /* fistp m16int */
-      clear_C1();
-      if ( FPU_store_int16(st0_ptr, st0_tag, (short __user *)data_address) )
-       pop_0();  /* pop only if the number was actually stored
-                    (see the 80486 manual p16-28) */
-      break;
-    case 020:     /* fldenv  m14/28byte */
-      fldenv(addr_modes, (u_char __user *)data_address);
-      /* Ensure that the values just loaded are not changed by
-        fix-up operations. */
-      return 1;
-    case 022:     /* frstor m94/108byte */
-      frstor(addr_modes, (u_char __user *)data_address);
-      /* Ensure that the values just loaded are not changed by
-        fix-up operations. */
-      return 1;
-    case 023:     /* fbld m80dec */
-      clear_C1();
-      loaded_tag = FPU_load_bcd((u_char __user *)data_address);
-      FPU_settag0(loaded_tag);
-      break;
-    case 024:     /* fldcw */
-      RE_ENTRANT_CHECK_OFF;
-      FPU_access_ok(VERIFY_READ, data_address, 2);
-      FPU_get_user(control_word, (unsigned short __user *) data_address);
-      RE_ENTRANT_CHECK_ON;
-      if ( partial_status & ~control_word & CW_Exceptions )
-       partial_status |= (SW_Summary | SW_Backward);
-      else
-       partial_status &= ~(SW_Summary | SW_Backward);
+
+       switch (type) {
+       case 000:               /* fld m32real */
+               clear_C1();
+               loaded_tag =
+                   FPU_load_single((float __user *)data_address, &loaded_data);
+               if ((loaded_tag == TAG_Special)
+                   && isNaN(&loaded_data)
+                   && (real_1op_NaN(&loaded_data) < 0)) {
+                       top++;
+                       break;
+               }
+               FPU_copy_to_reg0(&loaded_data, loaded_tag);
+               break;
+       case 001:               /* fild m32int */
+               clear_C1();
+               loaded_tag =
+                   FPU_load_int32((long __user *)data_address, &loaded_data);
+               FPU_copy_to_reg0(&loaded_data, loaded_tag);
+               break;
+       case 002:               /* fld m64real */
+               clear_C1();
+               loaded_tag =
+                   FPU_load_double((double __user *)data_address,
+                                   &loaded_data);
+               if ((loaded_tag == TAG_Special)
+                   && isNaN(&loaded_data)
+                   && (real_1op_NaN(&loaded_data) < 0)) {
+                       top++;
+                       break;
+               }
+               FPU_copy_to_reg0(&loaded_data, loaded_tag);
+               break;
+       case 003:               /* fild m16int */
+               clear_C1();
+               loaded_tag =
+                   FPU_load_int16((short __user *)data_address, &loaded_data);
+               FPU_copy_to_reg0(&loaded_data, loaded_tag);
+               break;
+       case 010:               /* fst m32real */
+               clear_C1();
+               FPU_store_single(st0_ptr, st0_tag,
+                                (float __user *)data_address);
+               break;
+       case 011:               /* fist m32int */
+               clear_C1();
+               FPU_store_int32(st0_ptr, st0_tag, (long __user *)data_address);
+               break;
+       case 012:               /* fst m64real */
+               clear_C1();
+               FPU_store_double(st0_ptr, st0_tag,
+                                (double __user *)data_address);
+               break;
+       case 013:               /* fist m16int */
+               clear_C1();
+               FPU_store_int16(st0_ptr, st0_tag, (short __user *)data_address);
+               break;
+       case 014:               /* fstp m32real */
+               clear_C1();
+               if (FPU_store_single
+                   (st0_ptr, st0_tag, (float __user *)data_address))
+                       pop_0();        /* pop only if the number was actually stored
+                                          (see the 80486 manual p16-28) */
+               break;
+       case 015:               /* fistp m32int */
+               clear_C1();
+               if (FPU_store_int32
+                   (st0_ptr, st0_tag, (long __user *)data_address))
+                       pop_0();        /* pop only if the number was actually stored
+                                          (see the 80486 manual p16-28) */
+               break;
+       case 016:               /* fstp m64real */
+               clear_C1();
+               if (FPU_store_double
+                   (st0_ptr, st0_tag, (double __user *)data_address))
+                       pop_0();        /* pop only if the number was actually stored
+                                          (see the 80486 manual p16-28) */
+               break;
+       case 017:               /* fistp m16int */
+               clear_C1();
+               if (FPU_store_int16
+                   (st0_ptr, st0_tag, (short __user *)data_address))
+                       pop_0();        /* pop only if the number was actually stored
+                                          (see the 80486 manual p16-28) */
+               break;
+       case 020:               /* fldenv  m14/28byte */
+               fldenv(addr_modes, (u_char __user *) data_address);
+               /* Ensure that the values just loaded are not changed by
+                  fix-up operations. */
+               return 1;
+       case 022:               /* frstor m94/108byte */
+               frstor(addr_modes, (u_char __user *) data_address);
+               /* Ensure that the values just loaded are not changed by
+                  fix-up operations. */
+               return 1;
+       case 023:               /* fbld m80dec */
+               clear_C1();
+               loaded_tag = FPU_load_bcd((u_char __user *) data_address);
+               FPU_settag0(loaded_tag);
+               break;
+       case 024:               /* fldcw */
+               RE_ENTRANT_CHECK_OFF;
+               FPU_access_ok(VERIFY_READ, data_address, 2);
+               FPU_get_user(control_word,
+                            (unsigned short __user *)data_address);
+               RE_ENTRANT_CHECK_ON;
+               if (partial_status & ~control_word & CW_Exceptions)
+                       partial_status |= (SW_Summary | SW_Backward);
+               else
+                       partial_status &= ~(SW_Summary | SW_Backward);
 #ifdef PECULIAR_486
-      control_word |= 0x40;  /* An 80486 appears to always set this bit */
+               control_word |= 0x40;   /* An 80486 appears to always set this bit */
 #endif /* PECULIAR_486 */
-      return 1;
-    case 025:      /* fld m80real */
-      clear_C1();
-      loaded_tag = FPU_load_extended((long double __user *)data_address, 0);
-      FPU_settag0(loaded_tag);
-      break;
-    case 027:      /* fild m64int */
-      clear_C1();
-      loaded_tag = FPU_load_int64((long long __user *)data_address);
-      if (loaded_tag == TAG_Error)
+               return 1;
+       case 025:               /* fld m80real */
+               clear_C1();
+               loaded_tag =
+                   FPU_load_extended((long double __user *)data_address, 0);
+               FPU_settag0(loaded_tag);
+               break;
+       case 027:               /* fild m64int */
+               clear_C1();
+               loaded_tag = FPU_load_int64((long long __user *)data_address);
+               if (loaded_tag == TAG_Error)
+                       return 0;
+               FPU_settag0(loaded_tag);
+               break;
+       case 030:               /* fstenv  m14/28byte */
+               fstenv(addr_modes, (u_char __user *) data_address);
+               return 1;
+       case 032:               /* fsave */
+               fsave(addr_modes, (u_char __user *) data_address);
+               return 1;
+       case 033:               /* fbstp m80dec */
+               clear_C1();
+               if (FPU_store_bcd
+                   (st0_ptr, st0_tag, (u_char __user *) data_address))
+                       pop_0();        /* pop only if the number was actually stored
+                                          (see the 80486 manual p16-28) */
+               break;
+       case 034:               /* fstcw m16int */
+