[tor-commits] [tor-browser/tor-browser-24.2.0esr-1] Backport mingw-w64 fixes from Mozilla

mikeperry at torproject.org mikeperry at torproject.org
Tue Dec 10 06:02:25 UTC 2013


commit 6d167dd8dbe69b3540ca140f5a5344b351493f6c
Author: Mike Perry <mikeperry-git at torproject.org>
Date:   Mon Dec 9 22:00:55 2013 -0800

    Backport mingw-w64 fixes from Mozilla
    
    Includes:
    https://hg.mozilla.org/mozilla-central/rev/7b86302ab2b3
    https://hg.mozilla.org/mozilla-central/rev/1651ea86cb00
    https://hg.mozilla.org/mozilla-central/rev/fda0046aa376
    https://hg.mozilla.org/mozilla-central/rev/02d4ae55e1c3
---
 gfx/2d/DrawTargetD2D.h              |    4 +-
 gfx/2d/RadialGradientEffectD2D1.cpp |   13 ++--
 gfx/2d/RadialGradientEffectD2D1.h   |    5 +-
 gfx/skia/src/ports/SkThread_win.cpp |    2 +-
 mfbt/Assertions.h                   |  115 +++++++++++++++++++++++++----------
 5 files changed, 95 insertions(+), 44 deletions(-)

diff --git a/gfx/2d/DrawTargetD2D.h b/gfx/2d/DrawTargetD2D.h
index 0df4862..eb2bd6e 100644
--- a/gfx/2d/DrawTargetD2D.h
+++ b/gfx/2d/DrawTargetD2D.h
@@ -147,8 +147,8 @@ public:
 
 private:
   TemporaryRef<ID2D1Bitmap>
-  DrawTargetD2D::GetBitmapForSurface(SourceSurface *aSurface,
-                                     Rect &aSource);
+  GetBitmapForSurface(SourceSurface *aSurface,
+                      Rect &aSource);
   friend class AutoSaveRestoreClippedOut;
   friend class SourceSurfaceD2DTarget;
 
diff --git a/gfx/2d/RadialGradientEffectD2D1.cpp b/gfx/2d/RadialGradientEffectD2D1.cpp
index 42bdf70..ec9224b 100644
--- a/gfx/2d/RadialGradientEffectD2D1.cpp
+++ b/gfx/2d/RadialGradientEffectD2D1.cpp
@@ -264,12 +264,13 @@ HRESULT
 RadialGradientEffectD2D1::Register(ID2D1Factory1 *aFactory)
 {
   D2D1_PROPERTY_BINDING bindings[] = {
-    D2D1_VALUE_TYPE_BINDING(L"StopCollection", &SetStopCollection, &GetStopCollection),
-    D2D1_VALUE_TYPE_BINDING(L"Center1", &SetCenter1, &GetCenter1),
-    D2D1_VALUE_TYPE_BINDING(L"Center2", &SetCenter2, &GetCenter2),
-    D2D1_VALUE_TYPE_BINDING(L"Radius1", &SetRadius1, &GetRadius1),
-    D2D1_VALUE_TYPE_BINDING(L"Radius2", &SetRadius2, &GetRadius2),
-    D2D1_VALUE_TYPE_BINDING(L"Transform", &SetTransform, &GetTransform)
+    D2D1_VALUE_TYPE_BINDING(L"StopCollection", &RadialGradientEffectD2D1::SetStopCollection,
+                            &RadialGradientEffectD2D1::GetStopCollection),
+    D2D1_VALUE_TYPE_BINDING(L"Center1", &RadialGradientEffectD2D1::SetCenter1, &RadialGradientEffectD2D1::GetCenter1),
+    D2D1_VALUE_TYPE_BINDING(L"Center2", &RadialGradientEffectD2D1::SetCenter2, &RadialGradientEffectD2D1::GetCenter2),
+    D2D1_VALUE_TYPE_BINDING(L"Radius1", &RadialGradientEffectD2D1::SetRadius1, &RadialGradientEffectD2D1::GetRadius1),
+    D2D1_VALUE_TYPE_BINDING(L"Radius2", &RadialGradientEffectD2D1::SetRadius2, &RadialGradientEffectD2D1::GetRadius2),
+    D2D1_VALUE_TYPE_BINDING(L"Transform", &RadialGradientEffectD2D1::SetTransform, &RadialGradientEffectD2D1::GetTransform)
   };
   HRESULT hr = aFactory->RegisterEffectFromString(CLSID_RadialGradientEffect, kXmlDescription, bindings, ARRAYSIZE(bindings), CreateEffect);
 
diff --git a/gfx/2d/RadialGradientEffectD2D1.h b/gfx/2d/RadialGradientEffectD2D1.h
index 6218f73..5a8ca3c 100644
--- a/gfx/2d/RadialGradientEffectD2D1.h
+++ b/gfx/2d/RadialGradientEffectD2D1.h
@@ -11,6 +11,7 @@
 #include <d2d1effecthelpers.h>
 
 #include "2D.h"
+#include "mozilla/Attributes.h"
 
 // {97143DC6-CBC4-4DD4-A8BA-13342B0BA46D}
 DEFINE_GUID(CLSID_RadialGradientEffect, 
@@ -37,8 +38,8 @@ enum {
   RADIAL_PROP_TRANSFORM
 };
 
-class RadialGradientEffectD2D1 : public ID2D1EffectImpl
-                               , public ID2D1DrawTransform
+class RadialGradientEffectD2D1 MOZ_FINAL : public ID2D1EffectImpl
+                                         , public ID2D1DrawTransform
 {
 public:
   // ID2D1EffectImpl
diff --git a/gfx/skia/src/ports/SkThread_win.cpp b/gfx/skia/src/ports/SkThread_win.cpp
index 91a5ceb..fab15f3 100644
--- a/gfx/skia/src/ports/SkThread_win.cpp
+++ b/gfx/skia/src/ports/SkThread_win.cpp
@@ -36,7 +36,7 @@ void sk_membar_aquire__after_atomic_dec() { }
 
 int32_t sk_atomic_conditional_inc(int32_t* addr) {
     while (true) {
-        LONG value = static_cast<LONG const volatile&>(*addr);
+        LONG value = static_cast<int32_t const volatile&>(*addr);
         if (value == 0) {
             return 0;
         }
diff --git a/mfbt/Assertions.h b/mfbt/Assertions.h
index 5ead7f4..9885a62 100644
--- a/mfbt/Assertions.h
+++ b/mfbt/Assertions.h
@@ -133,55 +133,93 @@ extern "C" {
 #endif
 
 /*
- * MOZ_CRASH crashes the program, plain and simple, in a Breakpad-compatible
- * way, in both debug and release builds.
+ * Prints |s| as an assertion failure (using file and ln as the location of the
+ * assertion) to the standard debug-output channel.
  *
- * MOZ_CRASH is a good solution for "handling" failure cases when you're
- * unwilling or unable to handle them more cleanly -- for OOM, for likely memory
- * corruption, and so on.  It's also a good solution if you need safe behavior
- * in release builds as well as debug builds.  But if the failure is one that
- * should be debugged and fixed, MOZ_ASSERT is generally preferable.
+ * Usually you should use MOZ_ASSERT or MOZ_CRASH instead of this method.  This
+ * method is primarily for internal use in this header, and only secondarily
+ * for use in implementing release-build assertions.
+ */
+static MOZ_ALWAYS_INLINE void
+MOZ_ReportAssertionFailure(const char* s, const char* file, int ln)
+{
+#ifdef ANDROID
+  __android_log_print(ANDROID_LOG_FATAL, "MOZ_Assert",
+                      "Assertion failure: %s, at %s:%d\n", s, file, ln);
+#else
+  fprintf(stderr, "Assertion failure: %s, at %s:%d\n", s, file, ln);
+  fflush(stderr);
+#endif
+}
+
+static MOZ_ALWAYS_INLINE void
+MOZ_ReportCrash(const char* s, const char* file, int ln)
+{
+#ifdef ANDROID
+    __android_log_print(ANDROID_LOG_FATAL, "MOZ_CRASH",
+                        "Hit MOZ_CRASH(%s) at %s:%d\n", s, file, ln);
+#else
+  fprintf(stderr, "Hit MOZ_CRASH(%s) at %s:%d\n", s, file, ln);
+  fflush(stderr);
+#endif
+}
+
+/**
+ * MOZ_REALLY_CRASH is used in the implementation of MOZ_CRASH().  You should
+ * call MOZ_CRASH instead.
  */
 #if defined(_MSC_VER)
    /*
     * On MSVC use the __debugbreak compiler intrinsic, which produces an inline
     * (not nested in a system function) breakpoint.  This distinctively invokes
     * Breakpad without requiring system library symbols on all stack-processing
-    * machines, as a nested breakpoint would require.  We use TerminateProcess
-    * with the exit code aborting would generate because we don't want to invoke
-    * atexit handlers, destructors, library unload handlers, and so on when our
-    * process might be in a compromised state.  We don't use abort() because
-    * it'd cause Windows to annoyingly pop up the process error dialog multiple
-    * times.  See bug 345118 and bug 426163.
+    * machines, as a nested breakpoint would require.
+    *
+    * We use TerminateProcess with the exit code aborting would generate
+    * because we don't want to invoke atexit handlers, destructors, library
+    * unload handlers, and so on when our process might be in a compromised
+    * state.
+    *
+    * We don't use abort() because it'd cause Windows to annoyingly pop up the
+    * process error dialog multiple times.  See bug 345118 and bug 426163.
+    *
+    * We follow TerminateProcess() with a call to MOZ_NoReturn() so that the
+    * compiler doesn't hassle us to provide a return statement after a
+    * MOZ_REALLY_CRASH() call.
     *
     * (Technically these are Windows requirements, not MSVC requirements.  But
     * practically you need MSVC for debugging, and we only ship builds created
     * by MSVC, so doing it this way reduces complexity.)
     */
+
+__declspec(noreturn) __inline void MOZ_NoReturn() {}
+
 #  ifdef __cplusplus
-#    define MOZ_CRASH() \
+#    define MOZ_REALLY_CRASH() \
        do { \
          __debugbreak(); \
          *((volatile int*) NULL) = 123; \
          ::TerminateProcess(::GetCurrentProcess(), 3); \
+         ::MOZ_NoReturn(); \
        } while (0)
 #  else
-#    define MOZ_CRASH() \
+#    define MOZ_REALLY_CRASH() \
        do { \
          __debugbreak(); \
          *((volatile int*) NULL) = 123; \
          TerminateProcess(GetCurrentProcess(), 3); \
+         MOZ_NoReturn(); \
        } while (0)
 #  endif
 #else
 #  ifdef __cplusplus
-#    define MOZ_CRASH() \
+#    define MOZ_REALLY_CRASH() \
        do { \
          *((volatile int*) NULL) = 123; \
          ::abort(); \
        } while (0)
 #  else
-#    define MOZ_CRASH() \
+#    define MOZ_REALLY_CRASH() \
        do { \
          *((volatile int*) NULL) = 123; \
          abort(); \
@@ -190,24 +228,35 @@ extern "C" {
 #endif
 
 /*
- * Prints |s| as an assertion failure (using file and ln as the location of the
- * assertion) to the standard debug-output channel.
+ * MOZ_CRASH([explanation-string]) crashes the program, plain and simple, in a
+ * Breakpad-compatible way, in both debug and release builds.
+ *
+ * MOZ_CRASH is a good solution for "handling" failure cases when you're
+ * unwilling or unable to handle them more cleanly -- for OOM, for likely memory
+ * corruption, and so on.  It's also a good solution if you need safe behavior
+ * in release builds as well as debug builds.  But if the failure is one that
+ * should be debugged and fixed, MOZ_ASSERT is generally preferable.
+ *
+ * The optional explanation-string, if provided, must be a string literal
+ * explaining why we're crashing.  This argument is intended for use with
+ * MOZ_CRASH() calls whose rationale is non-obvious; don't use it if it's
+ * obvious why we're crashing.
  *
- * Usually you should use MOZ_ASSERT instead of this method.  This method is
- * primarily for internal use in this header, and only secondarily for use in
- * implementing release-build assertions.
+ * If we're a DEBUG build and we crash at a MOZ_CRASH which provides an
+ * explanation-string, we print the string to stderr.  Otherwise, we don't
+ * print anything; this is because we want MOZ_CRASH to be 100% safe in release
+ * builds, and it's hard to print to stderr safely when memory might have been
+ * corrupted.
  */
-static MOZ_ALWAYS_INLINE void
-MOZ_ReportAssertionFailure(const char* s, const char* file, int ln)
-{
-#ifdef ANDROID
-  __android_log_print(ANDROID_LOG_FATAL, "MOZ_Assert",
-                      "Assertion failure: %s, at %s:%d\n", s, file, ln);
+#ifndef DEBUG
+#  define MOZ_CRASH(...) MOZ_REALLY_CRASH()
 #else
-  fprintf(stderr, "Assertion failure: %s, at %s:%d\n", s, file, ln);
-  fflush(stderr);
+#  define MOZ_CRASH(...) \
+     do { \
+       MOZ_ReportCrash("" __VA_ARGS__, __FILE__, __LINE__); \
+       MOZ_REALLY_CRASH(); \
+     } while(0)
 #endif
-}
 
 #ifdef __cplusplus
 } /* extern "C" */
@@ -251,7 +300,7 @@ MOZ_ReportAssertionFailure(const char* s, const char* file, int ln)
      do { \
        if (MOZ_UNLIKELY(!(expr))) { \
          MOZ_ReportAssertionFailure(#expr, __FILE__, __LINE__); \
-         MOZ_CRASH(); \
+         MOZ_REALLY_CRASH(); \
        } \
      } while (0)
    /* Now the two-argument form. */
@@ -259,7 +308,7 @@ MOZ_ReportAssertionFailure(const char* s, const char* file, int ln)
      do { \
        if (MOZ_UNLIKELY(!(expr))) { \
          MOZ_ReportAssertionFailure(#expr " (" explain ")", __FILE__, __LINE__); \
-         MOZ_CRASH(); \
+         MOZ_REALLY_CRASH(); \
        } \
      } while (0)
    /* And now, helper macrology up the wazoo. */



More information about the tor-commits mailing list