Bug 1460720 Fiddle MinGW to avoid mapping _aligned_malloc to mm_alloc and cause a redefinition r?glandium
authorTom Ritter <tom@mozilla.com>
Thu, 10 May 2018 14:55:22 -0500
changeset 1512116 e5a64b93c20f3202866bf3dcfd158df8bd54aec5
parent 1512115 cef227307935e564ab2caa86084d3b414a345625
child 1512117 28424f3f76eae7fffad373c4bbe9191e933832ae
push id271714
push usertritter@mozilla.com
push dateTue, 15 May 2018 15:37:34 +0000
treeherdertry@28424f3f76ea [default view] [failures only]
reviewersglandium
bugs1460720
milestone60.0
Bug 1460720 Fiddle MinGW to avoid mapping _aligned_malloc to mm_alloc and cause a redefinition r?glandium MozReview-Commit-ID: 3EwAd81Iz7r
memory/build/moz.build
memory/build/mozmemory_wrap.cpp
--- a/memory/build/moz.build
+++ b/memory/build/moz.build
@@ -16,17 +16,17 @@ DEFINES['MOZ_MEMORY_IMPL'] = True
 
 if CONFIG['MOZ_REPLACE_MALLOC']:
     EXPORTS += [
         'replace_malloc.h',
         'replace_malloc_bridge.h',
     ]
 
 if CONFIG['MOZ_MEMORY']:
-    UNIFIED_SOURCES += [
+    SOURCES += [
         'mozjemalloc.cpp',
         'mozmemory_wrap.cpp',
     ]
 else:
     UNIFIED_SOURCES += [
         'fallback.cpp',
     ]
 
--- a/memory/build/mozmemory_wrap.cpp
+++ b/memory/build/mozmemory_wrap.cpp
@@ -1,14 +1,21 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+// 64 Bit MinGW Builds define _aligned_malloc to gcc's mm_alloc
+// which causes a redefinition error. We can trick MinGW into not
+// doing that.
+#if defined(__MINGW32__) && defined(HAVE_64BIT_BUILD)
+#define _MM_MALLOC_H_INCLUDED
+#endif
+
 #include <string.h>
 #include "mozmemory_wrap.h"
 #include "mozilla/Types.h"
 
 // Declare malloc implementation functions with the right return and
 // argument types.
 #define MALLOC_DECL(name, return_type, ...)                                    \
   MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__);