Move libcds 1.6.0 from SVN
[libcds.git] / cds / compiler / clang / cxx11_atomic_prepatches.h
1 //$$CDS-header$$
2
3 #ifndef __CDS_COMPILER_CLANG_CXX11_ATOMIC_PREPATCHES_H
4 #define __CDS_COMPILER_CLANG_CXX11_ATOMIC_PREPATCHES_H
5
6 #if CDS_CXX11_ATOMIC_SUPPORT == 1
7 #   if CDS_COMPILER_VERSION == 30100
8         // Clang 3.1 workaround
9         // Clang 3.1 does not support __atomic_is_lock_free intrinsic function from GCC
10         template <typename T>
11         static inline bool __atomic_is_lock_free( size_t, T* ) CDS_NOEXCEPT
12         {
13             return sizeof(T) <= 8;
14         }
15
16         // clang does not implement GCC 4.7 low-level __atomic_xxx intrinsics
17         // See http://comments.gmane.org/gmane.comp.compilers.clang.devel/20093
18
19         // In Clang 3.1 the following workaround results in
20         //      Assertion `Proto && "Functions without a prototype cannot be overloaded"' failed
21         // and clang crashed
22         // So, we cannot use Clang with GCC 4.7 atomics
23 /*
24         template <typename T>
25         static inline void __atomic_load(T *ptr, T *ret, int memmodel)
26         {
27             *ret = __atomic_load( ptr, memmodel );
28         }
29
30         template <typename T>
31         static inline  void __atomic_store(T *ptr, T *val, int memmodel)
32         {
33             __atomic_store( ptr, *val, memmodel );
34         }
35
36         template <typename T>
37         static inline  void __atomic_exchange(T *ptr, T *val, T *ret, int memmodel)
38         {
39             *ret =  __atomic_exchange( ptr, *val, memmodel );
40         }
41
42         template <typename T>
43         static inline  bool __atomic_compare_exchange(T *ptr, T *expected, T *desired, bool weak, int success_memmodel, int failure_memmodel)
44         {
45             if ( weak )
46                 return __atomic_compare_exchange_weak( ptr, expected, *desired, success_memmodel, failure_memmodel );
47             else
48                 return __atomic_compare_exchange_strong( ptr, expected, *desired, success_memmodel, failure_memmodel );
49         }
50 */
51 #   endif
52 #endif
53
54 #endif // #ifndef __CDS_COMPILER_CLANG_CXX11_ATOMIC_PREPATCHES_H