Date: Mon, 31 Aug 1998 13:22:29 +1000 From: Bruce Evans <bde@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 Message-ID: <199808310322.NAA24605@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
>> >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 <machine/random.h>
> #include <sys/ptrace.h>
>
>+ #include <machine/floatingpoint.h>
>+
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199808310322.NAA24605>
