Skip to content

Commit

Permalink
Fixed the way floating point exceptions are masked.
Browse files Browse the repository at this point in the history
This is quick and incomplete solution for the CORE-4043 (FBCLIENT.DLL forces Delphi to ignore EZeroDivide exceptions). 
Complete solution should be MT-safe and sooner of all requires FP-exception handling code in the engine.
  • Loading branch information
hvlad committed Mar 7, 2013
1 parent 29d8931 commit 0ade3f4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/common/classes/FpeControl.h
Expand Up @@ -82,7 +82,9 @@ class FpeControl
static void maskAll() throw()
{
_clearfp(); // always call _clearfp() before setting control word
_controlfp(_CW_DEFAULT, _MCW_EM);

Mask cw;
__control87_2(_CW_DEFAULT, _MCW_EM, &cw, NULL);
}

private:
Expand All @@ -96,13 +98,15 @@ class FpeControl

static void getCurrentMask(Mask& m) throw()
{
m = _controlfp(0, 0);
__control87_2(0, 0, &m, NULL);
}

void restoreMask() throw()
{
_clearfp(); // always call _clearfp() before setting control word
_controlfp(savedMask, _MCW_EM); // restore saved

Mask cw;
__control87_2(savedMask, _MCW_EM, &cw, NULL); // restore saved
}

#elif defined(HAVE_FEGETENV)
Expand Down

0 comments on commit 0ade3f4

Please sign in to comment.