>From 6bb7e156a99b6674f93f0ed11cc63de9efca5772 Mon Sep 17 00:00:00 2001
From: KO Myung-Hun <komh78@gmail.com>
Date: Wed, 10 Sep 2014 17:00:49 +0900
Subject: [PATCH] skins2: os2: save and restore FPU cw

WinCreateMsgQueue() changes FPU cw but does not restore it. This causes
SIGFPE later.

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
(cherry picked from commit c35f6c1be0c06204a7b9787695cfa1150c5e5f90)

Signed-off-by: KO Myung-Hun <komh@chollian.net>
---
 modules/gui/skins2/os2/os2_factory.cpp |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/modules/gui/skins2/os2/os2_factory.cpp b/modules/gui/skins2/os2/os2_factory.cpp
index 61170eb..2cbfb85 100644
--- a/modules/gui/skins2/os2/os2_factory.cpp
+++ b/modules/gui/skins2/os2/os2_factory.cpp
@@ -31,6 +31,7 @@
 #include <io.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <cfloat>
 
 #include "os2_factory.hpp"
 #include "os2_graphics.hpp"
@@ -169,8 +170,16 @@ bool OS2Factory::init()
     MorphToPM();
 
     m_hab = WinInitialize( 0 );
+
+    // save FPU CW
+    unsigned saved_cw = _control87( 0, 0 );
+
+    // WinCreateMsgQueue() changes FPU CW but does not restore it
     m_hmq = WinCreateMsgQueue( m_hab, 0 );
 
+    // restore FPU CW
+    _control87( saved_cw, MCW_EM | MCW_IC | MCW_RC | MCW_PC );
+
     if( !WinRegisterClass( m_hab, vlc_class, OS2Factory::OS2Proc,
                            CS_SIZEREDRAW, sizeof( PVOID )))
     {
-- 
1.7.3.2

