Переглянути джерело

Add math control state functions for intel

James Urquhart 10 роки тому
батько
коміт
a3f8227541

+ 9 - 5
Engine/source/platformMac/macCarbMath.cpp

@@ -34,17 +34,21 @@ static MRandomLCG sgPlatRandom;
 
 U32 Platform::getMathControlState()
 {
-   return 0;
+   U16 cw;
+   asm("fstcw %0" : "=m" (cw) :);
+   return cw;
 }
 
-void Platform::setMathControlStateKnown()
+void Platform::setMathControlState(U32 state)
 {
-   
+   U16 cw = state;
+   asm("fldcw %0" : : "m" (cw));
 }
 
-void Platform::setMathControlState(U32 state)
+void Platform::setMathControlStateKnown()
 {
-   
+   U16 cw = 0x27F;
+   asm("fldcw %0" : : "m" (cw));
 }
 
 //--------------------------------------

+ 28 - 3
Engine/source/platformX86UNIX/x86UNIXMath.cpp

@@ -130,17 +130,42 @@ F32 Platform::getRandom()
    return sgPlatRandom.randF();
 }
 
+
+#if defined(i386) || defined(__x86_64__)
+
 U32 Platform::getMathControlState()
 {
-   return 0;
+   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::setMathControlState(U32 state)
 {
-   
 }
+
+void Platform::setMathControlStateKnown()
+{
+}
+
+#endif
+