gcc-4.8 does not supported std::atomic for 128-bit types
[libcds.git] / cds / compiler / gcc / defs.h
index e3c91e762626ef1d816a924d613f2bd36367bce7..99d8589c17d33f9c54e24f43196527ccf5e54efa 100644 (file)
 #   define CDS_DEPRECATED( reason ) __attribute__((deprecated( reason )))
 #endif
 
+// likely/unlikely
+
+#define cds_likely( expr )   __builtin_expect( !!( expr ), 1 )
+#define cds_unlikely( expr ) __builtin_expect( !!( expr ), 0 )
+
+// double-width CAS support
+#if CDS_BUILD_BITS == 64
+    // gcc-4.8 does not support 16-word (128bit) atomics
+#   if defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16 ) && CDS_COMPILER_VERSION >= 40900
+#       define CDS_DCAS_SUPPORT
+#   endif
+#else
+#   ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
+#       define CDS_DCAS_SUPPORT
+#   endif
+#endif
+
 #include <cds/compiler/gcc/compiler_barriers.h>
 
 #endif // #ifndef CDSLIB_COMPILER_GCC_DEFS_H