Browse Source

Merge pull request #21 from edmonds/branches/clang_generic_atomics

Expose generic atomicops on Clang
xfxyjwf 11 years ago
parent
commit
5c8ab2cbb3

+ 2 - 1
src/google/protobuf/stubs/atomicops.h

@@ -192,7 +192,8 @@ GOOGLE_PROTOBUF_ATOMICOPS_ERROR
 #include <google/protobuf/stubs/atomicops_internals_mips_gcc.h>
 #elif defined(__native_client__)
 #include <google/protobuf/stubs/atomicops_internals_pnacl.h>
-#elif (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4))
+#elif (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4)) || \
+ (defined(__clang__) && __has_extension(c_atomic))
 #include <google/protobuf/stubs/atomicops_internals_generic_gcc.h>
 #else
 GOOGLE_PROTOBUF_ATOMICOPS_ERROR

+ 2 - 1
src/google/protobuf/stubs/platform_macros.h

@@ -63,7 +63,8 @@
 #elif defined(__pnacl__)
 #define GOOGLE_PROTOBUF_ARCH_32_BIT 1
 #elif defined(__GNUC__) && \
- (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4))
+ ((((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4)) || \
+  (defined(__clang__) && __has_extension(c_atomic)))
 // We fallback to the generic GCC >= 4.7 implementation in atomicops.h
 # if __LP64__
 #  define GOOGLE_PROTOBUF_ARCH_64_BIT 1