I have a DLL that changes the FPCW like this:
cw = _control87(MCW_EM,MCW_EM);
rc = IOProc_Entry2(pmmioStr, usMsg, lParam1, lParam2);
Questions:
1.) I guess the call to _control87 above just enables all floating point
exceptions, right ? Would that not be the default behaviour of any
thread anyway ?
2.) Do I need to reset the FPCW ?
cw = _control87(MCW_EM,MCW_EM);
rc = IOProc_Entry2(pmmioStr, usMsg, lParam1, lParam2);
cw = _control87(cw,MCW_EM);
Lars
Hi,
>Questions:
>1.) I guess the call to _control87 above just enables all floating point
>exceptions, right ?
That's how I read the call.
Would that not be the default behaviour of any
>thread anyway ?
No necessarily. This is highly runtime dependent. You might want to
google this group for the "fpcw trashing" and the "i hate fp math"
threads.
>2.) Do I need to reset the FPCW ?
> cw = _control87(MCW_EM,MCW_EM);
> rc = IOProc_Entry2(pmmioStr, usMsg, lParam1, lParam2);
> cw = _control87(cw,MCW_EM);
Only if the caller expects you to. Fun, huh?
What you can do in some (or maybe all) runtimes is capture the existing
control word with
old_cw = _control87(0,0);
and restore on exit with
_control87(old_cw,MCW_EM);
Steven
--
--------------------------------------------------------------------------------------------
Steven Levine <ste...@earthlink.bogus.net> MR2/ICE 3.00.11.18 BETA #10183
eCS/Warp/DIY/14.103a_W4 www.scoug.com irc.ca.webbnet.info #scoug (Wed 7pm PST)
--------------------------------------------------------------------------------------------
This is an area where a glaring lack of a standard has caused no end of
problems. I do the save and restore, and so far haven't had any
problems, with a rather limited range of experience.
--
prf
Let me remind what (is my understanding about what) Scott said about
USING fp exceptions under OS/2:
starting from about v2.11, the support for "handling" FP exception
is removed from the kernel.
Which basically means that there is little reason to do anything with
the exception, but ignore it. Thus the value of save/restore over
"just reset" is minimal...
E.g., EMX CRT sets FP exception flags to "ignore". However, since
there is a lot of buggy DLLs around (mostly by IBM), they may change
the flags during THEIR loading - ruining all application using FP
math...
Therefore the need to reset FP exception flags to "ignore" afer any
call which has a chance to load IBM-written DLLs. MMPROCs are such...
Yours,
Ilya
Maybe this is true for the stuff you do, but for PL/I I need all the FP
exceptions except Inexact Result.
--
prf
That's very interesting! Can you share your exception handlers?
Thanks,
Ilya