Bug 1357897 - ensure __has_feature(thread_local) before using it on Mac; r=froydnj
authorMyk Melez <myk@mykzilla.org>
Fri, 21 Apr 2017 17:15:23 -0700
changeset 405432 de88e4dc9d99ea7cef2d571bf5bebf2bdc5d99f6
parent 405431 d2f7c7cea2182f251872c137acd772c510b7ea64
child 405433 78480dd41c9dca7dd127a8d3ab59a1c16e982924
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1357897, 1348419
milestone55.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 1357897 - ensure __has_feature(thread_local) before using it on Mac; r=froydnj Bug 1348419 enabled thread-local storage for Mac, but only Xcode 8+ supports that feature, which busted building with Xcode 7-. This change fixes that bustage by ensuring a Mac compiler supports the feature before using it.
mfbt/ThreadLocal.h
--- a/mfbt/ThreadLocal.h
+++ b/mfbt/ThreadLocal.h
@@ -26,17 +26,25 @@ namespace mozilla {
 #if defined(XP_WIN)
 typedef unsigned long sig_safe_t;
 #else
 typedef sig_atomic_t sig_safe_t;
 #endif
 
 namespace detail {
 
-#if defined(HAVE_THREAD_TLS_KEYWORD) || defined(XP_WIN) || defined(XP_MACOSX)
+#ifdef XP_MACOSX
+#  if defined(__has_feature)
+#    if __has_feature(cxx_thread_local)
+#      define MACOSX_HAS_THREAD_LOCAL
+#    endif
+#  endif
+#endif
+
+#if defined(HAVE_THREAD_TLS_KEYWORD) || defined(XP_WIN) || defined(MACOSX_HAS_THREAD_LOCAL)
 #define MOZ_HAS_THREAD_LOCAL
 #endif
 
 /*
  * Thread Local Storage helpers.
  *
  * Usage:
  *
@@ -176,17 +184,17 @@ ThreadLocal<T>::set(const T aValue)
   bool succeeded = !pthread_setspecific(mKey, h);
   if (!succeeded) {
     MOZ_CRASH();
   }
 #endif
 }
 
 #ifdef MOZ_HAS_THREAD_LOCAL
-#if defined(XP_WIN) || defined(XP_MACOSX)
+#if defined(XP_WIN) || defined(MACOSX_HAS_THREAD_LOCAL)
 #define MOZ_THREAD_LOCAL(TYPE) thread_local mozilla::detail::ThreadLocal<TYPE>
 #else
 #define MOZ_THREAD_LOCAL(TYPE) __thread mozilla::detail::ThreadLocal<TYPE>
 #endif
 #else
 #define MOZ_THREAD_LOCAL(TYPE) mozilla::detail::ThreadLocal<TYPE>
 #endif