From owner-freebsd-current Sun Aug 30 20:23:42 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id UAA14304 for freebsd-current-outgoing; Sun, 30 Aug 1998 20:23:42 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.15.68.22]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id UAA14298 for ; Sun, 30 Aug 1998 20:23:36 -0700 (PDT) (envelope-from bde@godzilla.zeta.org.au) Received: (from bde@localhost) by godzilla.zeta.org.au (8.8.7/8.8.7) id NAA24605; Mon, 31 Aug 1998 13:22:29 +1000 Date: Mon, 31 Aug 1998 13:22:29 +1000 From: Bruce Evans Message-Id: <199808310322.NAA24605@godzilla.zeta.org.au> To: bde@zeta.org.au, cracauer@cons.org, current@FreeBSD.ORG, luoqi@watermarkgroup.com, shocking@prth.pgs.com Subject: Re: Floating Point Exceptions, signal handlers & subsequent ops Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG >> >If sig == SIGFPE, then expect the trap code to be one of FPE_*_TRAP >> >values from machine/trap.h, *not* one of the T_* values. >> >> Except this is not implemented. > >Does the appended diff count as an implementation? Test program >included. Er, no. The exception status word is a bitmap. Code to map it to a machine_dependent exception code should look something like: code = translation_table[ffs(status_word & control_word & 0x3F)]; Perhaps it should do more if the final bitmap doesn't have precisely 1 bit set in it. It's normal for the status word to have multiple bits set. Anding with the control word and 0x3F probably reduces the number to 1 in most cases, but it is possible for applications to create strange bitmaps using control instructions. >Index: i386/i386/machdep.c >=================================================================== >RCS file: /home/CVS-FreeBSD/src/sys/i386/i386/machdep.c,v >retrieving revision 1.304 >diff -c -r1.304 machdep.c >*** machdep.c 1998/08/18 07:46:58 1.304 >--- machdep.c 1998/08/30 00:22:59 >*************** >*** 136,141 **** >--- 136,143 ---- > #include > #include > >+ #include >+ This header is application-only. > extern void init386 __P((int first)); > extern void dblfault_handler __P((void)); > >*************** >*** 502,508 **** >--- 504,515 ---- > struct sigframe sf; > struct sigacts *psp = p->p_sigacts; > int oonstack; >+ u_long fpuctrl; > >+ if (sig == SIGFPE && code == 0) { >+ __fnstcw(&fpuctrl); The FPU can't be used here if there was a context switch between the FPU trap and here. >+ code = 0x3F & ~fpuctrl & curpcb->pcb_savefpu.sv_ex_sw; >+ } This is missing the translation from the machine-dependent bitmap to the "machine-independent" single-exception code. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message