From 4024ee8f8dc2265fd6483a7115e772e48cde0dc3 Mon Sep 17 00:00:00 2001 From: Myk Melez Date: Fri, 21 Apr 2017 17:15:23 -0700 Subject: [PATCH] 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 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mfbt/ThreadLocal.h b/mfbt/ThreadLocal.h index 391e748ada22..a1c0ae4721d7 100644 --- a/mfbt/ThreadLocal.h +++ b/mfbt/ThreadLocal.h @@ -31,7 +31,8 @@ typedef sig_atomic_t sig_safe_t; namespace detail { -#if defined(HAVE_THREAD_TLS_KEYWORD) || defined(XP_WIN) || defined(XP_MACOSX) +#if defined(HAVE_THREAD_TLS_KEYWORD) || defined(XP_WIN) || \ + (defined(XP_MACOSX) && defined(__has_feature) && __has_feature(cxx_thread_local)) #define MOZ_HAS_THREAD_LOCAL #endif @@ -181,7 +182,7 @@ ThreadLocal::set(const T aValue) } #ifdef MOZ_HAS_THREAD_LOCAL -#if defined(XP_WIN) || defined(XP_MACOSX) +#if defined(XP_WIN) || (defined(XP_MACOSX) && defined(__has_feature) && __has_feature(cxx_thread_local)) #define MOZ_THREAD_LOCAL(TYPE) thread_local mozilla::detail::ThreadLocal #else #define MOZ_THREAD_LOCAL(TYPE) __thread mozilla::detail::ThreadLocal