[yunqa.de] Re: Why Disable FPU exceptions?

  • From: Edwin Yip <edwin.yip@xxxxxxxxxxxxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Wed, 25 Nov 2009 10:41:47 +0800

Hi Ralf,

Thank you for the always detailed and informative explanation (I usually
learn from your replies) and it helps :)

Are you just back from a vacation or the like? I almost forget my question
;)

On Wed, Nov 25, 2009 at 1:19 AM, Delphi Inspiration <delphi@xxxxxxxx> wrote:

> At 05:23 03.11.2009, Edwin Yip wrote:
>
> >In the DEMO programs, I found many occurrences of the following two lines:
> >  { Disable FPU exceptions. No need to restore, setting is process
> specific. }
> >  Set8087CW($133F);
> >
> >What problem does that function call solves?
>
> As the comment explains, the above call disables FPU expections for your
> process. FPU exceptions do not normally occur, but if they do (for example
> by a divide by zero instruction) they are not handled by the DISQLite3
> internals. As a result, the call stack unwinds immediately and some code
> might not be executed. This can result in memory leaks or other undefined
> application behaviour.
>
> >Should I add this line to my program?
>
> According to my testing, I advise to add the line (or a similar
> instruction) to avoid potential memory leaks or other undefined application
> behaviour. If you want to leave FPU exceptions enabled, be sure to test your
> application properly to ensure it works as expected.
>
> Unfortunately, it is difficult to tell if and when FPU exceptions occur and
> will cause problems to DISQLite3. This is, by the way, true for most C
> libraries used by Delphi (including DLLs written in C). Therefore it is
> usually best to switch off FPU exceptions if they use the FPU calculations.
> Existing Delphi code should not be effected.
>
> Ralf
>
> _______________________________________________
> Delphi Inspiration mailing list
> yunqa@xxxxxxxxxxxxx
> //www.freelists.org/list/yunqa
>
>
>
>


-- 
Best Regards,
Edwin Yip

Mind Mapping is as Effortless as Typing
http://www.InnovationGear.com

Other related posts: