Subject: Re: FPE exeption
To: None <berg@student.tu-freiberg.de>
From: Mark Brinicombe <amb@physig4.ph.kcl.ac.uk>
List: port-arm32
Date: 09/09/1996 16:35:50
>cd src1; make -f Makefile CC="gcc -ansi -Wall -O -L/usr/X11R6/lib
>-I/usr/X11R6/include -fno-builtin"

-fno-builtin should not be needed

>Sep  5 22:01:24 line2 /netbsd: PC=0007fe78
>Sep  5 22:01:31 line2 /netbsd: fpe exception: 2 - Floating point overflow
>
>and that was it. Not able to run !
>
>Any suggestions what could be done ?
>
>The same c-code compiled on a linux/68k box as fine as here, but there it also
>was able to run !

Ok I there are two possible problems  here

1. A bug is some part of RiscBSD that results in an overflow when it should not

2. The overflow is valid but is masked under Linux.

The default behaviour of RiscBSD is to enable Invalid operation, divide by zero
and overflow traps (This actually comes from the default behaviour of the FPE
core).
I am guessing that Linux has these exceptions masked so the calculation
just returns a Nan or Inf.
I have a new version of libc that I am testing that has several functions
for enabling/disabling these traps.  When it is released a call like

fpsetmask(0);

would disable all FPE exception traps so no signals will get delivered for
them.

At the moment to do it you need a bit of assembly to modify the FPSR

rfs	r0
bic	r0, r0, #0x001f0000
orr	r0, r0, #<new trap mask>
wfs	r0

should probably do it. In practice it is probably a good idea to leave
invalid operations traps enabled.

Ok some could argue that a call to fpsetmask should not be needed. I don't
know where this behaviour is defined or whether the FP exception traps are
machine dependant.

May be RiscBSD should use a different default FP exception mask ?

Comments ?

Cheers,
				Mark


-- 
Mark Brinicombe				amb@physig.ph.kcl.ac.uk
Research Associate			http://www.ph.kcl.ac.uk/~amb/
Department of Physics			tel: 0171 873 2894
King's College London			fax: 0171 873 2716