Bug 1523949 - part 1 - make MOZ_THREAD_LOCAL name lookups work anywhere; r=erahm

MOZ_THREAD_LOCAL currently assumes its invocations live in the global
namespace, which may not always be true, e.g. when declaring a static
class member whose enclosing class lives in `namespace mozilla` or
similar.  We should qualify the name lookups required to always start
from the global namespace to avoid such problems.
This commit is contained in:
Nathan Froyd 2019-01-30 17:26:27 -05:00
parent 65862fa8e5
commit 0d56a7008a

View File

@ -213,15 +213,15 @@ inline void ThreadLocal<T, Storage>::set(const T aValue) {
#if (defined(XP_WIN) || defined(MACOSX_HAS_THREAD_LOCAL)) && \
!defined(__MINGW32__)
# define MOZ_THREAD_LOCAL(TYPE) \
thread_local mozilla::detail::ThreadLocal< \
TYPE, mozilla::detail::ThreadLocalNativeStorage>
thread_local ::mozilla::detail::ThreadLocal< \
TYPE, ::mozilla::detail::ThreadLocalNativeStorage>
#elif defined(HAVE_THREAD_TLS_KEYWORD)
# define MOZ_THREAD_LOCAL(TYPE) \
__thread mozilla::detail::ThreadLocal< \
TYPE, mozilla::detail::ThreadLocalNativeStorage>
__thread ::mozilla::detail::ThreadLocal< \
TYPE, ::mozilla::detail::ThreadLocalNativeStorage>
#else
# define MOZ_THREAD_LOCAL(TYPE) \
mozilla::detail::ThreadLocal<TYPE, mozilla::detail::ThreadLocalKeyStorage>
::mozilla::detail::ThreadLocal<TYPE, ::mozilla::detail::ThreadLocalKeyStorage>
#endif
} // namespace detail