pspp-dev
[Top][All Lists]
Advanced

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

Re: netbsd build update


From: Ben Pfaff
Subject: Re: netbsd build update
Date: Fri, 19 May 2006 07:17:48 -0700
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux)

John Darrington <address@hidden> writes:

>      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.

You know, I take back my earlier comments.  This is pretty
reasonable, but only as long as the signal handler only sets a
flag that indicates an error has occurred, and masks further
exceptions.  Then leave the real handling up to the caller.  If
the caller notices, it can comment on it (and reset it);
otherwise, the main loop can issue a warning after the procedure
completes.

(Doing I/O in a signal handler is really a bad idea.)

We still need to be able to mask exceptions, though.  Otherwise,
fpe_handler_ignore will just get called in an infinite loop,
which is not an improvement.  Thus, I believe that we really want
"fpe_handler_record".
-- 
"There's only one thing that will make them stop hating you.
 And that's being so good at what you do that they can't ignore you.
 I told them you were the best.  Now you damn well better be."
--Orson Scott Card, _Ender's Game_




reply via email to

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