Skip to content

Commit 6dc267f

Browse files
committed
Fix #2: RecursiveBenaphore won't build on Linux using Clang.
1 parent 4ccc595 commit 6dc267f

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

common/benaphore.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,20 @@ class RecursiveBenaphore
6868
: m_contentionCount(0)
6969
// Apple LLVM 6.0 (in Xcode 6.1) refuses to initialize m_owner from a std::thread::id.
7070
// "error: no viable conversion from 'std::__1::__thread_id' to '_Atomic(std::__1::__thread_id)'"
71-
// Using atomic_init (below) in that case.
72-
#if !defined(__llvm__)
71+
// (Note: On Linux, as of April 11, 2015, Clang 3.7 & libc++ don't have this problem.)
72+
// Prefer atomic_init (below) when Apple LLVM is detected.
73+
#if !(defined(__llvm__) && defined(__APPLE__))
7374
, m_owner(std::thread::id())
74-
#endif
75+
#endif
7576
, m_recursion(0)
7677
{
7778
// GCC 4.7.2's libstdc++-v3 doesn't implement atomic_init.
7879
// "warning: inline function 'void std::atomic_init(std::atomic<_ITp>*, _ITp) [with _ITp = std::thread::id]' used but never defined [enabled by default]"
7980
// Using the constructor (above) in that case.
80-
#if defined(__llvm__)
81+
#if (defined(__llvm__) && defined(__APPLE__))
8182
std::atomic_init(&m_owner, std::thread::id());
82-
#endif
83-
83+
#endif
84+
8485
// If this assert fails on your system, you'll have to replace std::thread::id with a
8586
// more compact, platform-specific thread ID, or just comment the assert and live with
8687
// the extra overhead.

0 commit comments

Comments
 (0)