Module Name: src Committed By: tsutsui Date: Sat May 14 16:17:55 UTC 2011
Modified Files: src/sys/arch/m68k/fpe: fpu_emulate.c Log Message: Fix botch in rev 1.28 that causes wrong results of fcmp and ftst in FPE. fpu_upd_fpsr() should be called even in discard_result case if an emulated instruction gets proper result without signal. Fixes weird behavior of awk(1) seen on /etc/rc.d/postfix on XM6i and TME emulating sun3 without 68881. Should be pulled up to all netbsd-4 and netbsd-5 branches. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/arch/m68k/fpe/fpu_emulate.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/m68k/fpe/fpu_emulate.c diff -u src/sys/arch/m68k/fpe/fpu_emulate.c:1.30 src/sys/arch/m68k/fpe/fpu_emulate.c:1.31 --- src/sys/arch/m68k/fpe/fpu_emulate.c:1.30 Sat Mar 14 15:36:09 2009 +++ src/sys/arch/m68k/fpe/fpu_emulate.c Sat May 14 16:17:55 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu_emulate.c,v 1.30 2009/03/14 15:36:09 dsl Exp $ */ +/* $NetBSD: fpu_emulate.c,v 1.31 2011/05/14 16:17:55 tsutsui Exp $ */ /* * Copyright (c) 1995 Gordon W. Ross @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fpu_emulate.c,v 1.30 2009/03/14 15:36:09 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fpu_emulate.c,v 1.31 2011/05/14 16:17:55 tsutsui Exp $"); #include <sys/param.h> #include <sys/types.h> @@ -909,27 +909,34 @@ if (res == NULL) sig = SIGILL; - if (!discard_result && sig == 0) { - fpu_implode(fe, res, FTYPE_EXT, &fpregs[regnum * 3]); + if (sig == 0) { + if (!discard_result) + fpu_implode(fe, res, FTYPE_EXT, &fpregs[regnum * 3]); /* update fpsr according to the result of operation */ fpu_upd_fpsr(fe, res); #if DEBUG_FPE - printf("fpu_emul_arith: %08x,%08x,%08x stored in FP%d\n", - fpregs[regnum*3], fpregs[regnum*3+1], - fpregs[regnum*3+2], regnum); - } else if (sig == 0) { - static const char *class_name[] = - { "SNAN", "QNAN", "ZERO", "NUM", "INF" }; - printf("fpu_emul_arith: result(%s,%c,%d,%08x,%08x,%08x) discarded\n", - class_name[res->fp_class + 2], - res->fp_sign ? '-' : '+', res->fp_exp, - res->fp_mant[0], res->fp_mant[1], - res->fp_mant[2]); - } else { - printf("fpu_emul_arith: received signal %d\n", sig); + if (!discard_result) { + printf("fpu_emul_arith: %08x,%08x,%08x stored in FP%d\n", + fpregs[regnum*3], fpregs[regnum*3+1], + fpregs[regnum*3+2], regnum); + } else { + static const char *class_name[] = + { "SNAN", "QNAN", "ZERO", "NUM", "INF" }; + printf("fpu_emul_arith: result(%s,%c,%d,%08x,%08x,%08x)" + " discarded\n", + class_name[res->fp_class + 2], + res->fp_sign ? '-' : '+', res->fp_exp, + res->fp_mant[0], res->fp_mant[1], + res->fp_mant[2]); + } #endif } +#if DEBUG_FPE + else { + printf("fpu_emul_arith: received signal %d\n", sig); + } +#endif #if DEBUG_FPE printf("fpu_emul_arith: FPSR = %08x, FPCR = %08x\n",