BSD 4_3_Net_2 release
[unix-history] / usr / src / sys / tahoe / math / fpe.c
index c08b4d4..6232027 100644 (file)
@@ -1,19 +1,54 @@
-/*     fpe.c   1.1     86/01/03        */
+/*-
+ * Copyright (c) 1985 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Computer Consoles Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)fpe.c       7.1 (Berkeley) 12/6/90
+ */
 
 
-#include "../tahoe/psl.h"
-#include "../tahoe/reg.h"
-#include "../tahoe/pte.h"
-#include "../tahoe/mtpr.h"
-#include "../tahoemath/Kfp.h"
+#include "../include/psl.h"
+#include "../include/reg.h"
+#include "../include/pte.h"
+#include "../include/mtpr.h"
+#include "../math/Kfp.h"
 
 
-#include "param.h"
-#include "systm.h"
-#include "dir.h"
-#include "user.h"
-#include "proc.h"
-#include "seg.h"
-#include "acct.h"
-#include "kernel.h"
+#include "sys/param.h"
+#include "sys/systm.h"
+#include "sys/user.h"
+#include "sys/proc.h"
+#include "sys/seg.h"
+#include "sys/acct.h"
+#include "sys/kernel.h"
 
 /*
  * Floating point emulation support.
 
 /*
  * Floating point emulation support.
@@ -63,6 +98,7 @@ fpemulate(hfsreg, acc_most, acc_least, dbl, op_most, op_least, opcode, pc, psl)
        int type;                       /* opcode type, FLOAT or DOUBLE */
        union { float ff; int fi; } f_res;
        union { double dd; int di[2]; } d_res;
        int type;                       /* opcode type, FLOAT or DOUBLE */
        union { float ff; int fi; } f_res;
        union { double dd; int di[2]; } d_res;
+       int error = 0;
 
 #ifdef lint
        r0 = 0; r0 = r0; r1 = 0; r1 = r1;
 
 #ifdef lint
        r0 = 0; r0 = r0; r1 = 0; r1 = r1;
@@ -79,7 +115,7 @@ fpemulate(hfsreg, acc_most, acc_least, dbl, op_most, op_least, opcode, pc, psl)
        }
        if (fp >= &fpetab[NFPETAB]) {
                opcode = DIV0_EXC;      /* generate SIGILL - XXX */
        }
        if (fp >= &fpetab[NFPETAB]) {
                opcode = DIV0_EXC;      /* generate SIGILL - XXX */
-               return;
+               return (0);
        }
        switch (type) {
 
        }
        switch (type) {
 
@@ -107,24 +143,22 @@ fpemulate(hfsreg, acc_most, acc_least, dbl, op_most, op_least, opcode, pc, psl)
                if (locr0[PS] & PSL_IV)   {  /* overflow enabled? */
 #endif
                        opcode = OVF_EXC;
                if (locr0[PS] & PSL_IV)   {  /* overflow enabled? */
 #endif
                        opcode = OVF_EXC;
-                       u.u_error = (hfs & HFS_DOM) ? EDOM : ERANGE;
-                       return;
+                       return ((hfs & HFS_DOM) ? EDOM : ERANGE);
 #ifdef notdef
                }
 #endif
        } else if (hfs & HFS_UNDF) {
                if (locr0[PS] &  PSL_FU) {  /* underflow enabled? */
                        opcode = UNDF_EXC;
 #ifdef notdef
                }
 #endif
        } else if (hfs & HFS_UNDF) {
                if (locr0[PS] &  PSL_FU) {  /* underflow enabled? */
                        opcode = UNDF_EXC;
-                       u.u_error = (hfs & HFS_DOM) ? EDOM : ERANGE;
-                       return;
+                       return ((hfs & HFS_DOM) ? EDOM : ERANGE);
                } 
        } else if (hfs & HFS_DIVZ) {
                opcode = DIV0_EXC;
                } 
        } else if (hfs & HFS_DIVZ) {
                opcode = DIV0_EXC;
-               return;
+               return (0);
        } else if (hfs & HFS_DOM)
        } else if (hfs & HFS_DOM)
-               u.u_error = EDOM;
+               error = EDOM;
        else if (hfs & HFS_RANGE)
        else if (hfs & HFS_RANGE)
-               u.u_error = ERANGE;
+               error = ERANGE;
        switch (type) {
 
        case DOUBLE:
        switch (type) {
 
        case DOUBLE:
@@ -144,4 +178,5 @@ fpemulate(hfsreg, acc_most, acc_least, dbl, op_most, op_least, opcode, pc, psl)
                break;
        }
        opcode = 0;
                break;
        }
        opcode = 0;
+       return (error);
 }
 }