pspp-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: netbsd build update


From: John Darrington
Subject: Re: netbsd build update
Date: Fri, 19 May 2006 16:09:13 +0800
User-agent: Mutt/1.5.9i

On Thu, May 18, 2006 at 08:27:24PM -0700, Ben Pfaff wrote:
     John Darrington <address@hidden> writes:
     
     > On Thu, May 18, 2006 at 05:25:04PM -0700, Ben Pfaff wrote:
     >      
     >      Yes.  I want to call fpsetmask(0) in fp_init().  (The numerous
     >      manpages that Google returns for fpsetmask() seem to indicate
     >      that this is the syntax to turn off all exceptions, and they all
     >      indicate that <ieeefp.h> is the right header to include.)
     >
     > I'm not sure that it might not be a better idea to catch SIGFPE and
     > issue a warning message, and then continue.
     
     Why?

Not all floating point errors will result in NaN.  Particularly
underflow/ overflow errors.  Typically they just result in an
unchanged variable.  The user will have no idea that his results might
have bad values.
     
     Furthermore, I doubt it's possible portably.  I suspect that some
     CPUs will in fact retry the instruction and fault again in a loop.

They all will.  A signal handler returns to the address that caused it.
Provided that sigaction (part of the POSIX standard) is supported we
can reliably overcome this problem thus:

We have two signal handlers:  fpe_handler_ignore, which does nothing,
and fpe_handler_warn which a) logs a warning message, b) resets the
handler to fpe_handler_ignore, and c) returns.

At the start of every procedure, the active handler is reset to 
fpe_handler_warn.   Thus, when a FPE occurs, the user gets a warning,
the handler is set to ignore further FPEs and the procedure completes
normally.  The user gets his results, but has been warned that they
might not be correct.

J'


-- 
PGP Public key ID: 1024D/2DE827B3 
fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See http://pgp.mit.edu or any PGP keyserver for public key.


Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]