diff --git a/Engine/source/platformMac/macCarbMath.cpp b/Engine/source/platformMac/macCarbMath.cpp index e5c8aab89..f7e23e2f6 100644 --- a/Engine/source/platformMac/macCarbMath.cpp +++ b/Engine/source/platformMac/macCarbMath.cpp @@ -34,17 +34,21 @@ static MRandomLCG sgPlatRandom; U32 Platform::getMathControlState() { - return 0; -} - -void Platform::setMathControlStateKnown() -{ - + U16 cw; + asm("fstcw %0" : "=m" (cw) :); + return cw; } void Platform::setMathControlState(U32 state) { - + U16 cw = state; + asm("fldcw %0" : : "m" (cw)); +} + +void Platform::setMathControlStateKnown() +{ + U16 cw = 0x27F; + asm("fldcw %0" : : "m" (cw)); } //-------------------------------------- diff --git a/Engine/source/platformX86UNIX/x86UNIXMath.cpp b/Engine/source/platformX86UNIX/x86UNIXMath.cpp index 2a9abf547..1d1ddd6d2 100644 --- a/Engine/source/platformX86UNIX/x86UNIXMath.cpp +++ b/Engine/source/platformX86UNIX/x86UNIXMath.cpp @@ -130,17 +130,42 @@ F32 Platform::getRandom() return sgPlatRandom.randF(); } + +#if defined(i386) || defined(__x86_64__) + +U32 Platform::getMathControlState() +{ + U16 cw; + asm("fstcw %0" : "=m" (cw) :); + return cw; +} + +void Platform::setMathControlState(U32 state) +{ + U16 cw = state; + asm("fldcw %0" : : "m" (cw)); +} + +void Platform::setMathControlStateKnown() +{ + U16 cw = 0x27F; + asm("fldcw %0" : : "m" (cw)); +} + +#else + U32 Platform::getMathControlState() { return 0; } -void Platform::setMathControlStateKnown() -{ - -} - void Platform::setMathControlState(U32 state) { - } + +void Platform::setMathControlStateKnown() +{ +} + +#endif +