Bug 1423512 - Remove infallible allocator exception for xpcom glue code. r?erahm draft
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 06 Dec 2017 09:56:02 +0900
changeset 708691 8747ec5ef3090a546c1f2c9c319fee03b6138596
parent 708690 38eb8e86d4dcfcac313b49328dac765760f8d125
child 743211 8cea58d21d24bd6a210de99161ebdea600253e44
push id92405
push userbmo:mh+mozilla@glandium.org
push dateWed, 06 Dec 2017 22:32:57 +0000
reviewerserahm
bugs1423512, 868814
milestone59.0a1
Bug 1423512 - Remove infallible allocator exception for xpcom glue code. r?erahm Back when mozalloc was a separate library, the xpcom glue code could not use the infallible allocator API. But since bug 868814, that's not the case anymore, so we can safely include mozalloc.h when XPCOM_GLUE is set.
config/gcc-stl-wrapper.template.h
config/msvc-stl-wrapper.template.h
xpcom/base/nscore.h
--- a/config/gcc-stl-wrapper.template.h
+++ b/config/gcc-stl-wrapper.template.h
@@ -40,20 +40,18 @@
 #  define MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
 #endif
 
 #pragma GCC visibility push(default)
 #include_next <${HEADER}>
 #pragma GCC visibility pop
 
 #ifdef MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
-// See if we're in code that can use mozalloc.  NB: this duplicates
-// code in nscore.h because nscore.h pulls in prtypes.h, and chromium
-// can't build with that being included before base/basictypes.h.
-#  if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
+// See if we're in code that can use mozalloc.
+#  if !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
 #    include "mozilla/mozalloc.h"
 #  else
 #    error "STL code can only be used with infallible ::operator new()"
 #  endif
 #endif
 
 // gcc calls a __throw_*() function from bits/functexcept.h when it
 // wants to "throw an exception".  functexcept exists nominally to
--- a/config/msvc-stl-wrapper.template.h
+++ b/config/msvc-stl-wrapper.template.h
@@ -57,19 +57,17 @@
 #include_next <${HEADER}>
 #else
 #include <${HEADER_PATH}>
 #endif
 
 #pragma warning( pop )
 
 #ifdef MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
-// See if we're in code that can use mozalloc.  NB: this duplicates
-// code in nscore.h because nscore.h pulls in prtypes.h, and chromium
-// can't build with that being included before base/basictypes.h.
-#  if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
+// See if we're in code that can use mozalloc.
+#  if !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
 #    include "mozilla/mozalloc.h"
 #  else
 #    error "STL code can only be used with infallible ::operator new()"
 #  endif
 #endif
 
 #endif  // if mozilla_${HEADER}_h
--- a/xpcom/base/nscore.h
+++ b/xpcom/base/nscore.h
@@ -11,17 +11,17 @@
  * Make sure that we have the proper platform specific
  * c++ definitions needed by nscore.h
  */
 #ifndef _XPCOM_CONFIG_H_
 #include "xpcom-config.h"
 #endif
 
 /* Definitions of functions and operators that allocate memory. */
-#if !defined(XPCOM_GLUE) && !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
+#if !defined(NS_NO_XPCOM) && !defined(MOZ_NO_MOZALLOC)
 #  include "mozilla/mozalloc.h"
 #endif
 
 /**
  * Incorporate the integer data types which XPCOM uses.
  */
 #include <stddef.h>
 #include <stdint.h>