From d77877808fc9f00c3570353717d9659f8994ffc2 Mon Sep 17 00:00:00 2001 From: Feng Xiao Date: Thu, 4 Dec 2014 17:30:58 -0800 Subject: Fix thread local annotatoin and add back type traits is_convertable for MSVC --- src/google/protobuf/arena.h | 2 +- src/google/protobuf/stubs/common.h | 6 ++++++ src/google/protobuf/stubs/type_traits.h | 4 ++-- src/google/protobuf/stubs/type_traits_unittest.cc | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h index 519e3569..b5822bdb 100644 --- a/src/google/protobuf/arena.h +++ b/src/google/protobuf/arena.h @@ -312,7 +312,7 @@ class LIBPROTOBUF_EXPORT Arena { static const size_t kHeaderSize = sizeof(Block); static google::protobuf::internal::SequenceNumber lifecycle_id_generator_; - static __thread ThreadCache thread_cache_; + static GOOGLE_THREAD_LOCAL ThreadCache thread_cache_; // SFINAE for skipping addition to delete list for a Type. This is mainly to // skip proto2/proto1 message objects with cc_enable_arenas=true from being diff --git a/src/google/protobuf/stubs/common.h b/src/google/protobuf/stubs/common.h index 17dd6671..c3f735a2 100644 --- a/src/google/protobuf/stubs/common.h +++ b/src/google/protobuf/stubs/common.h @@ -314,6 +314,12 @@ inline void GOOGLE_UNALIGNED_STORE64(void *p, uint64 v) { } #endif +#if defined(_MSC_VER) +#define GOOGLE_THREAD_LOCAL __declspec(thread) +#else +#define GOOGLE_THREAD_LOCAL __thread +#endif + // =================================================================== // from google3/base/basictypes.h diff --git a/src/google/protobuf/stubs/type_traits.h b/src/google/protobuf/stubs/type_traits.h index f5365c38..0c294677 100644 --- a/src/google/protobuf/stubs/type_traits.h +++ b/src/google/protobuf/stubs/type_traits.h @@ -103,7 +103,7 @@ template struct remove_reference; template struct add_reference; template struct remove_pointer; template struct is_same; -#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3) +#if !(defined(__GNUC__) && __GNUC__ <= 3) template struct is_convertible; #endif @@ -322,7 +322,7 @@ template struct is_same : public false_type { }; template struct is_same : public true_type { }; // Specified by TR1 [4.6] Relationships between types -#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3) +#if !(defined(__GNUC__) && __GNUC__ <= 3) namespace type_traits_internal { // This class is an implementation detail for is_convertible, and you diff --git a/src/google/protobuf/stubs/type_traits_unittest.cc b/src/google/protobuf/stubs/type_traits_unittest.cc index b42b9e83..49c10ace 100644 --- a/src/google/protobuf/stubs/type_traits_unittest.cc +++ b/src/google/protobuf/stubs/type_traits_unittest.cc @@ -610,7 +610,7 @@ TEST(TypeTraitsTest, TestIsSame) { } TEST(TypeTraitsTest, TestConvertible) { -#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3) +#if !(defined(__GNUC__) && __GNUC__ <= 3) EXPECT_TRUE((is_convertible::value)); EXPECT_TRUE((is_convertible::value)); EXPECT_TRUE((is_convertible::value)); -- cgit v1.2.3