Bug 712129 - Move MOZ*INLINE macros from Util.h into Attributes.h, where they make more sense. r=luke
authorJeff Walden <jwalden@mit.edu>
Mon, 19 Dec 2011 14:45:52 -0500
changeset 83237 cffea4a903accb901b02517270378f6d76403382
parent 83236 0df00b3b8846361c28b8147a2ce781d69e467cf2
child 83238 0d7567cf0a67a44906ab85ba9f2acc6ead70ba63
push id4319
push userjwalden@mit.edu
push dateThu, 22 Dec 2011 02:57:27 +0000
treeherdermozilla-inbound@8d4a9617fcd1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs712129
milestone12.0a1
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 712129 - Move MOZ*INLINE macros from Util.h into Attributes.h, where they make more sense. r=luke
mfbt/Attributes.h
mfbt/RefPtr.h
mfbt/Util.h
--- a/mfbt/Attributes.h
+++ b/mfbt/Attributes.h
@@ -44,16 +44,49 @@
 #define mozilla_Attributes_h_
 
 /*
  * This header does not include any other headers so that it can be included by
  * code that is (only currently) mfbt-incompatible.
  */
 
 /*
+ * MOZ_INLINE is a macro which expands to tell the compiler that the method
+ * decorated with it should be inlined.  This macro is usable from C and C++
+ * code, even though C89 does not support the |inline| keyword.  The compiler
+ * may ignore this directive if it chooses.
+ */
+#if defined(__cplusplus)
+#  define MOZ_INLINE            inline
+#elif defined(_MSC_VER)
+#  define MOZ_INLINE            __inline
+#elif defined(__GNUC__)
+#  define MOZ_INLINE            __inline__
+#else
+#  define MOZ_INLINE            inline
+#endif
+
+/*
+ * MOZ_ALWAYS_INLINE is a macro which expands to tell the compiler that the
+ * method decorated with it must be inlined, even if the compiler thinks
+ * otherwise.  This is only a (much) stronger version of the MOZ_INLINE hint:
+ * compilers are not guaranteed to respect it (although they're much more likely
+ * to do so).
+ */
+#if defined(DEBUG)
+#  define MOZ_ALWAYS_INLINE     MOZ_INLINE
+#elif defined(_MSC_VER)
+#  define MOZ_ALWAYS_INLINE     __forceinline
+#elif defined(__GNUC__)
+#  define MOZ_ALWAYS_INLINE     __attribute__((always_inline)) MOZ_INLINE
+#else
+#  define MOZ_ALWAYS_INLINE     MOZ_INLINE
+#endif
+
+/*
  * g++ requires -std=c++0x or -std=gnu++0x to support C++11 functionality
  * without warnings (functionality used by the macros below).  These modes are
  * detectable by checking whether __GXX_EXPERIMENTAL_CXX0X__ is defined or, more
  * standardly, by checking whether __cplusplus has a C++11 or greater value.
  * Current versions of g++ do not correctly set __cplusplus, so we check both
  * for forward compatibility.
  */
 #if defined(__clang__)
@@ -67,16 +100,19 @@
 #  endif
 #  if __has_extension(cxx_deleted_functions)
 #    define MOZ_HAVE_CXX11_DELETE
 #  endif
 #  if __has_extension(cxx_override_control)
 #    define MOZ_HAVE_CXX11_OVERRIDE
 #    define MOZ_HAVE_CXX11_FINAL         final
 #  endif
+#  if __has_attribute(noinline)
+#    define MOZ_HAVE_NEVER_INLINE        __attribute__((noinline))
+#  endif
 #  if __has_attribute(noreturn)
 #    define MOZ_HAVE_NORETURN            __attribute__((noreturn))
 #  endif
 #elif defined(__GNUC__)
 #  if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
 #    if __GNUC__ > 4
 #      define MOZ_HAVE_CXX11_DELETE
 #      define MOZ_HAVE_CXX11_OVERRIDE
@@ -95,27 +131,41 @@
 #    if __GNUC__ > 4
 #      define MOZ_HAVE_CXX11_FINAL       __final
 #    elif __GNUC__ == 4
 #      if __GNUC_MINOR__ >= 7
 #        define MOZ_HAVE_CXX11_FINAL     __final
 #      endif
 #    endif
 #  endif
+#  define MOZ_HAVE_NEVER_INLINE          __attribute__((noinline))
 #  define MOZ_HAVE_NORETURN              __attribute__((noreturn))
 #elif defined(_MSC_VER)
 #  if _MSC_VER >= 1400
 #    define MOZ_HAVE_CXX11_OVERRIDE
      /* MSVC currently spells "final" as "sealed". */
 #    define MOZ_HAVE_CXX11_FINAL         sealed
 #  endif
+#  define MOZ_HAVE_NEVER_INLINE          __declspec(noinline)
 #  define MOZ_HAVE_NORETURN              __declspec(noreturn)
 #endif
 
 /*
+ * MOZ_NEVER_INLINE is a macro which expands to tell the compiler that the
+ * method decorated with it must never be inlined, even if the compiler would
+ * otherwise choose to inline the method.  Compilers aren't absolutely
+ * guaranteed to support this, but most do.
+ */
+#if defined(MOZ_HAVE_NEVER_INLINE)
+#  define MOZ_NEVER_INLINE      MOZ_HAVE_NEVER_INLINE
+#else
+#  define MOZ_NEVER_INLINE      /* no support */
+#endif
+
+/*
  * MOZ_NORETURN, specified at the start of a function declaration, indicates
  * that the given function does not return.  (The function definition does not
  * need to be annotated.)
  *
  *   MOZ_NORETURN void abort(const char* msg);
  *
  * This modifier permits the compiler to optimize code assuming a call to such a
  * function will never return.  It also enables the compiler to avoid spurious
--- a/mfbt/RefPtr.h
+++ b/mfbt/RefPtr.h
@@ -38,17 +38,16 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef mozilla_RefPtr_h_
 #define mozilla_RefPtr_h_
 
 #include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
-#include "mozilla/Util.h"
 
 /**
  * Helpers for defining and using refcounted objects.
  */
 
 namespace mozilla {
 
 template<typename T> class RefCounted;
--- a/mfbt/Util.h
+++ b/mfbt/Util.h
@@ -39,69 +39,16 @@
 
 #ifndef mozilla_Util_h_
 #define mozilla_Util_h_
 
 #include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/Types.h"
 
-/*
- * MOZ_INLINE is a macro which expands to tell the compiler that the method
- * decorated with it should be inlined.  This macro is usable from C and C++
- * code, even though C89 does not support the |inline| keyword.  The compiler
- * may ignore this directive if it chooses.
- */
-#ifndef MOZ_INLINE
-#  if defined __cplusplus
-#    define MOZ_INLINE          inline
-#  elif defined _MSC_VER
-#    define MOZ_INLINE          __inline
-#  elif defined __GNUC__
-#    define MOZ_INLINE          __inline__
-#  else
-#    define MOZ_INLINE          inline
-#  endif
-#endif
-
-/*
- * MOZ_ALWAYS_INLINE is a macro which expands to tell the compiler that the
- * method decorated with it must be inlined, even if the compiler thinks
- * otherwise.  This is only a (much) stronger version of the MOZ_INLINE hint:
- * compilers are not guaranteed to respect it (although they're much more likely
- * to do so).
- */
-#ifndef MOZ_ALWAYS_INLINE
-#  if defined DEBUG
-#    define MOZ_ALWAYS_INLINE   MOZ_INLINE
-#  elif defined _MSC_VER
-#    define MOZ_ALWAYS_INLINE   __forceinline
-#  elif defined __GNUC__
-#    define MOZ_ALWAYS_INLINE   __attribute__((always_inline)) MOZ_INLINE
-#  else
-#    define MOZ_ALWAYS_INLINE   MOZ_INLINE
-#  endif
-#endif
-
-/*
- * MOZ_NEVER_INLINE is a macro which expands to tell the compiler that the
- * method decorated with it must never be inlined, even if the compiler would
- * otherwise choose to inline the method.  Compilers aren't absolutely
- * guaranteed to support this, but most do.
- */
-#ifndef MOZ_NEVER_INLINE
-#  if defined _MSC_VER
-#    define MOZ_NEVER_INLINE __declspec(noinline)
-#  elif defined __GNUC__
-#    define MOZ_NEVER_INLINE __attribute__((noinline))
-#  else
-#    define MOZ_NEVER_INLINE
-#  endif
-#endif
-
 #ifdef __cplusplus
 
 namespace mozilla {
 
 /**
  * DebugOnly contains a value of type T, but only in debug builds.  In
  * release builds, it does not contain a value.  This helper is
  * intended to be used along with ASSERT()-style macros, allowing one