Mail Archives: djgpp/1999/10/26/05:56:17
On Mon, 25 Oct 1999, Waldemar Schultz wrote:
> 0
> NaN
> NaN
> CtrlBreak 295
>
> But I'd have epected something like:
>
> 0
> errno xxx
> NaN
> errno xxx
> NaN
> CtrlBreak 295
>
> Any explanation please ??
It's all in the docs: see the docs of the library function `_control87'.
There you will see that DJGPP startup code by default masks all
numeric exceptions, so all the invalid FP operations your code
attempts to do don't raise SIGFPE at all, and your handler isn't
called. Use `_control87' to unmask some of the exceptions, and the
program will work as you expect.
Your program is also based on another assumption: that math functions
in libc.a set errno when you attempt an invalid operation. This is
not true in v2.02; link with -lm if you want errno to be set (see
"info libc alpha libm" and "info libc alpha matherr" for more info
about this).
Note that, if you unmask numeric exceptions, SIGFPE is raised *before*
the called math function gets to look at the result (a NaN or an Inf)
produced by the invalid operation. This means that you cannot have
both SIGFPE and errno. I suggest to leave the numeric exceptions
masked, link with -lm, and write your own matherr function to serve
instead of the SIGFPE handler.
- Raw text -