Bug 614631 - Macros for SEH exception depending on compiler configuration r+a=benjamin
authorJacek Caban <jacek@codeweavers.com>
Tue, 11 Jan 2011 10:16:59 +0000
changeset 60281 808d5140670c5f12b9f13b1ddffb1c4255dc9d72
parent 60280 f518eb4285bfa7c93f3feb0904e32acd510fd481
child 60282 6106b8079342b90d54d3f29064a19cf60187bb32
push id17909
push userjacek@codeweavers.com
push dateTue, 11 Jan 2011 09:16:43 +0000
treeherdermozilla-central@6106b8079342 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs614631
milestone2.0b10pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 614631 - Macros for SEH exception depending on compiler configuration r+a=benjamin
configure.in
modules/plugin/base/src/nsPluginSafety.h
widget/src/windows/nsFilePicker.cpp
xpcom/base/nscore.h
--- a/configure.in
+++ b/configure.in
@@ -678,16 +678,17 @@ case "$target" in
         else
             AC_MSG_ERROR([This version ($CC_VERSION) of the MSVC compiler is unsupported. See https://developer.mozilla.org/en/Windows_Build_Prerequisites.])
         fi
 
         _MOZ_RTTI_FLAGS_ON='-GR'
         _MOZ_RTTI_FLAGS_OFF='-GR-'
         _MOZ_EXCEPTIONS_FLAGS_ON='-EHsc'
         _MOZ_EXCEPTIONS_FLAGS_OFF=''
+        AC_DEFINE(HAVE_SEH_EXCEPTIONS)
 
         if test -n "$WIN32_REDIST_DIR"; then
             WIN32_REDIST_DIR=`cd "$WIN32_REDIST_DIR" && pwd`
         fi
 
         dnl Ensure that mt.exe is 'Microsoft (R) Manifest Tool',
         dnl not something else like "magnetic tape manipulation utility".
         MSMT_TOOL=`mt 2>&1|grep 'Microsoft (R) Manifest Tool'`
--- a/modules/plugin/base/src/nsPluginSafety.h
+++ b/modules/plugin/base/src/nsPluginSafety.h
@@ -64,21 +64,21 @@ PR_END_MACRO
 
 #define NS_TRY_SAFE_CALL_RETURN(ret, fun, pluginInst) \
 PR_BEGIN_MACRO                                     \
   PRIntervalTime startTime = PR_IntervalNow();     \
   if(gSkipPluginSafeCalls)                         \
     ret = fun;                                     \
   else                                             \
   {                                                \
-    try                                            \
+    MOZ_SEH_TRY                                    \
     {                                              \
       ret = fun;                                   \
     }                                              \
-    catch(...)                                     \
+    MOZ_SEH_EXCEPT(PR_TRUE)                        \
     {                                              \
       nsresult res;                                \
       nsCOMPtr<nsIPluginHost> host(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID, &res));\
       if(NS_SUCCEEDED(res) && (host != nsnull))    \
         host->HandleBadPlugin(nsnull, pluginInst); \
       ret = (NPError)NS_ERROR_FAILURE;             \
     }                                              \
   }                                                \
@@ -87,21 +87,21 @@ PR_END_MACRO
 
 #define NS_TRY_SAFE_CALL_VOID(fun, pluginInst) \
 PR_BEGIN_MACRO                              \
   PRIntervalTime startTime = PR_IntervalNow();     \
   if(gSkipPluginSafeCalls)                  \
     fun;                                    \
   else                                      \
   {                                         \
-    try                                     \
+    MOZ_SEH_TRY                             \
     {                                       \
       fun;                                  \
     }                                       \
-    catch(...)                              \
+    MOZ_SEH_EXCEPT(PR_TRUE)                 \
     {                                       \
       nsresult res;                         \
       nsCOMPtr<nsIPluginHost> host(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID, &res));\
       if(NS_SUCCEEDED(res) && (host != nsnull))\
         host->HandleBadPlugin(nsnull, pluginInst);\
     }                                       \
   }                                         \
   NS_NotifyPluginCall(startTime);		   \
--- a/widget/src/windows/nsFilePicker.cpp
+++ b/widget/src/windows/nsFilePicker.cpp
@@ -231,17 +231,17 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt1
           //    often appends ".html" even if you have an extension
           //    It obeys your extension if you put quotes around name
           ofn.lpstrDefExt = htmExt.get();
         }
       }
     }
 
 #ifndef WINCE
-    try {
+    MOZ_SEH_TRY {
 #endif
       if (mMode == modeOpen) {
         // FILE MUST EXIST!
         ofn.Flags |= OFN_FILEMUSTEXIST;
         result = ::GetOpenFileNameW(&ofn);
       }
       else if (mMode == modeOpenMultiple) {
         ofn.Flags |= OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_EXPLORER;
@@ -281,25 +281,25 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt1
         result = ::GetOpenFileNameW(&ofn);
       }
 #endif
       else {
         NS_ERROR("unsupported mode"); 
       }
 #ifndef WINCE
     }
-    catch(...) {
+    MOZ_SEH_EXCEPT(PR_TRUE) {
       MessageBoxW(ofn.hwndOwner,
                   0,
                   L"The filepicker was unexpectedly closed by Windows.",
                   MB_ICONERROR);
       result = PR_FALSE;
     }
 #endif
-  
+
     if (result) {
       // Remember what filter type the user selected
       mSelectedType = (PRInt16)ofn.nFilterIndex;
 
       // Set user-selected location of file or directory
       if (mMode == modeOpenMultiple) {
         
         // from msdn.microsoft.com, "Open and Save As Dialog Boxes" section:
--- a/xpcom/base/nscore.h
+++ b/xpcom/base/nscore.h
@@ -550,9 +550,20 @@ typedef PRUint32 nsrefcnt;
 #else
 # define NS_SCRIPTABLE
 # define NS_INPARAM
 # define NS_OUTPARAM
 # define NS_INOUTPARAM
 # define NS_OVERRIDE
 #endif
 
+/*
+ * SEH exception macros.
+ */
+#ifdef HAVE_SEH_EXCEPTIONS
+#define MOZ_SEH_TRY           __try
+#define MOZ_SEH_EXCEPT(expr)  __except(expr)
+#else
+#define MOZ_SEH_TRY           if(PR_TRUE)
+#define MOZ_SEH_EXCEPT(expr)  else
+#endif
+
 #endif /* nscore_h___ */