Skip to content

Commit

Permalink
Summary: support gcc atomic ops on clang too
Browse files Browse the repository at this point in the history
Clang actually does support __atomic_XXX atomic ops builtins but does
not advertise itselt as gcc 4.7 or later. So we now detect clang
separetely.

We're enabling gcc atomic ops on clang >= 3.4 since this is the oldest
version that I can test.

This should fix issue #797.
  • Loading branch information
alk committed Jul 4, 2016
1 parent 7f86eab commit eb474c9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/base/atomicops.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,14 @@
+ __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__)

#define CLANG_VERSION (__clang_major__ * 10000 \
+ __clang_minor__ * 100 \
+ __clang_patchlevel__)

#if defined(TCMALLOC_PREFER_GCC_ATOMICS) && defined(__GNUC__) && GCC_VERSION >= 40700
#include "base/atomicops-internals-gcc.h"
#elif defined(TCMALLOC_PREFER_GCC_ATOMICS) && defined(__clang__) && CLANG_VERSION >= 30400
#include "base/atomicops-internals-gcc.h"
#elif defined(__MACH__) && defined(__APPLE__)
#include "base/atomicops-internals-macosx.h"
#elif defined(__GNUC__) && defined(ARMV6)
Expand All @@ -120,6 +126,8 @@
#include "base/atomicops-internals-mips.h"
#elif defined(__GNUC__) && GCC_VERSION >= 40700
#include "base/atomicops-internals-gcc.h"
#elif defined(__clang__) && CLANG_VERSION >= 30400
#include "base/atomicops-internals-gcc.h"
#else
#error You need to implement atomic operations for this architecture
#endif
Expand Down

0 comments on commit eb474c9

Please sign in to comment.