Fixed Clang 3.7 + libc++ issues
authorkhizmax <libcds.dev@gmail.com>
Thu, 29 Sep 2016 20:35:53 +0000 (23:35 +0300)
committerkhizmax <libcds.dev@gmail.com>
Thu, 29 Sep 2016 20:35:53 +0000 (23:35 +0300)
cds/algo/atomic.h
cds/compiler/clang/defs.h
cds/compiler/cxx11_atomic.h
cds/container/striped_map/std_map.h
cds/intrusive/mspriority_queue.h
projects/Win/vc14/stress-pqueue.vcxproj.filters
test/stress/map/map_type.h
test/stress/pqueue/item.h
test/stress/pqueue/pqueue_type.h
test/unit/misc/cxx11_atomic_class.cpp
test/unit/misc/cxx11_atomic_func.cpp

index a30737aa1a3758fddc5b944ae78d9d638d36fd66..f0e50f9c60602e5a1d97c90a726999c98a2ab78e 100644 (file)
@@ -5,7 +5,7 @@
 
     Source code repo: http://github.com/khizmax/libcds/
     Download: http://sourceforge.net/projects/libcds/files/
-    
+
     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions are met:
 
@@ -25,7 +25,7 @@
     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     
+    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
 #ifndef CDSLIB_CXX11_ATOMIC_H
index 8d7010510535f394fb0ee5dc0944cec94ad03086..6d95122883bf7ace2ea46dd81d14393d8a397f21 100644 (file)
@@ -5,7 +5,7 @@
 
     Source code repo: http://github.com/khizmax/libcds/
     Download: http://sourceforge.net/projects/libcds/files/
-    
+
     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions are met:
 
@@ -48,7 +48,7 @@
 #   error "Compiler version error. Clang version 3.3.0 and above is supported"
 #endif
 
-#if defined(_LIBCPP_VERSION) && !defined(CDS_USE_BOOST_ATOMIC)
+#if defined(_LIBCPP_VERSION) && !defined(CDS_USE_BOOST_ATOMIC) && CDS_COMPILER_VERSION < 30700
     // Note: Clang libc++ atomic leads to program crash.
     // So, we use libcds atomic implementation
 #   define CDS_USE_LIBCDS_ATOMIC
index e0fcba6aee07fa238a232556e46a390f5fedf9d0..bdaf5260c8874381230a002efc8ab8b8b0d2c8c1 100644 (file)
@@ -114,6 +114,13 @@ namespace cds { namespace cxx11_atomic {
         {
             typedef std::uint64_t type;
         };
+#if CDS_BUILD_BITS == 64 && CDS_DCAS_SUPPORT
+        template <>
+        struct primary_type<16>
+        {
+            typedef unsigned __int128_t type;
+        };
+#endif
 
         template <typename T, typename Primary>
         struct make_atomic_primary
index 76da98bb7a619fed93123465ed058ee328c09f0e..b1693c8805dfa27befac3b2ea9b930a6e12fcb86 100644 (file)
@@ -5,7 +5,7 @@
 
     Source code repo: http://github.com/khizmax/libcds/
     Download: http://sourceforge.net/projects/libcds/files/
-    
+
     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions are met:
 
@@ -25,7 +25,7 @@
     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     
+    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
 #ifndef CDSLIB_CONTAINER_STRIPED_MAP_STD_MAP_ADAPTER_H
index 7b8476e4a202f54676ce8ff510bbc4ddc0f31f5e..5b43b465dd033ce5b754d73188c4fd337f12fec3 100644 (file)
@@ -5,7 +5,7 @@
 
     Source code repo: http://github.com/khizmax/libcds/
     Download: http://sourceforge.net/projects/libcds/files/
-    
+
     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions are met:
 
index aa96454be34856446cafc5416cf562c5e74a5549..8ad0b704397cad6a2b36900ac783cc776d57af99 100644 (file)
@@ -9,10 +9,6 @@
       <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r
       <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>\r
     </Filter>\r
-    <Filter Include="Resource Files">\r
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>\r
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>\r
-    </Filter>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <ClInclude Include="..\..\..\test\stress\pqueue\pqueue_type.h">\r
index f5c996f58a26a3df1b086482df65f71785b442a5..d0d03bf1523b40d152c56ec847e58930c0068eca 100644 (file)
@@ -5,7 +5,7 @@
 
     Source code repo: http://github.com/khizmax/libcds/
     Download: http://sourceforge.net/projects/libcds/files/
-    
+
     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions are met:
 
@@ -25,7 +25,7 @@
     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     
+    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
 #ifndef CDSUNIT_MAP_TYPE_H
@@ -73,7 +73,7 @@ namespace map {
     template <typename Key>
     struct hash;
 
-#define CDSUNIT_INT_COMPARE(t)  template <> struct cmp<t> { int operator()( t k1, t k2 ){ return (int)(k1 - k2); } }
+#define CDSUNIT_INT_COMPARE(t)  template <> struct cmp<t> { int operator()( t k1, t k2 ) const { return (int)(k1 - k2); } }
     CDSUNIT_INT_COMPARE(char);
     CDSUNIT_INT_COMPARE(unsigned char);
     CDSUNIT_INT_COMPARE(int);
@@ -84,7 +84,7 @@ namespace map {
     CDSUNIT_INT_COMPARE(unsigned long long);
 #undef CDSUNIT_INT_COMPARE
 
-#define CDSUNIT_INT_LESS(t)  template <> struct less<t> { bool operator()( t k1, t k2 ){ return k1 < k2; } }
+#define CDSUNIT_INT_LESS(t)  template <> struct less<t> { bool operator()( t k1, t k2 ) const { return k1 < k2; } }
     CDSUNIT_INT_LESS( char );
     CDSUNIT_INT_LESS( unsigned char );
     CDSUNIT_INT_LESS( int );
index 1a14fba18e586d6470384a56eb225c1404d56221..0d0627689015ad47d2c074cf143b9ad81ec28fc2 100644 (file)
@@ -5,7 +5,7 @@
 
     Source code repo: http://github.com/khizmax/libcds/
     Download: http://sourceforge.net/projects/libcds/files/
-    
+
     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions are met:
 
@@ -25,7 +25,7 @@
     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     
+    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
 #ifndef CDSSTRESS_PQUEUE_ITEM_H
@@ -52,61 +52,33 @@ namespace pqueue {
         simple_value( key_type n )
             : key(n) 
         {}
-    };
-} // namespace pqueue
 
-namespace std {
-    template <class T> struct less;
-    template <class T> struct greater;
-
-    template <>
-    struct less<pqueue::simple_value>
-    {
-        bool operator()( pqueue::simple_value const& k1, pqueue::simple_value const& k2 ) const
+        friend bool operator <( simple_value const& lhs, simple_value const& rhs )
         {
-            return k1.key < k2.key;
+            return lhs.key < rhs.key;
         }
-
-        bool operator()( pqueue::simple_value const& k1, size_t k2 ) const
+        friend bool operator <( simple_value const& lhs, size_t rhs )
         {
-            return k1.key < k2;
+            return lhs.key < rhs;
         }
-
-        bool operator()( size_t k1, pqueue::simple_value const& k2 ) const
+        friend bool operator <( size_t lhs, simple_value const& rhs )
         {
-            return k1 < k2.key;
+            return lhs < rhs.key;
         }
 
-        bool operator()( size_t k1, size_t k2 ) const
+        friend bool operator >( simple_value const& lhs, simple_value const& rhs )
         {
-            return k1 < k2;
+            return lhs.key > rhs.key;
         }
-    };
-
-    template <>
-    struct greater<pqueue::simple_value>
-    {
-        bool operator()( pqueue::simple_value const& k1, pqueue::simple_value const& k2 ) const
+        friend bool operator >( simple_value const& lhs, size_t rhs )
         {
-            return k1.key > k2.key;
+            return lhs.key > rhs;
         }
-
-        bool operator()( pqueue::simple_value const& k1, size_t k2 ) const
+        friend bool operator >( size_t lhs, simple_value const& rhs )
         {
-            return k1.key > k2;
-        }
-
-        bool operator()( size_t k1, pqueue::simple_value const& k2 ) const
-        {
-            return k1 > k2.key;
-        }
-
-        bool operator()( size_t k1, size_t k2 ) const
-        {
-            return k1 > k2;
+            return lhs > rhs.key;
         }
     };
-
-} // namespace std
+} // namespace pqueue
 
 #endif // #ifndef CDSSTRESS_PQUEUE_ITEM_H
index 2728fa28e33fad46d59955fad48a995514f72bd4..ce304665b351bab426579b8f0b1eea1594c6003b 100644 (file)
@@ -5,7 +5,7 @@
 
     Source code repo: http://github.com/khizmax/libcds/
     Download: http://sourceforge.net/projects/libcds/files/
-    
+
     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions are met:
 
index 7003e7045785d60a3bd9faee4c5a610f99356647..cc5c871e0137c92affd9307156a3c304cdcd9e8c 100644 (file)
@@ -788,7 +788,8 @@ namespace {
         test_atomic_integral_volatile<unsigned long long>();
     }
 
-#if CDS_COMPILER != CDS_COMPILER_CLANG || defined(_LIBCPP_VERSION)
+#if !( CDS_COMPILER == CDS_COMPILER_CLANG && defined(_LIBCPP_VERSION) && CDS_COMPILER_VERSION < 30800 )
+    //clang error (libc++) with atomic<void> fetch_add/fetch_sub
     TEST_F( cxx11_atomic_class, atomic_pointer_void )
     {
         do_test_atomic_pointer_void<false>();
index 8426ff9bd1e7ee4b173ec0a49f9fc625040d5b4a..98f2ef85f53b6050209ff2260602a78f33591420 100644 (file)
@@ -706,7 +706,8 @@ namespace misc {
         test_atomic_integral_volatile<unsigned long long>();
     }
 
-#if CDS_COMPILER != CDS_COMPILER_CLANG || defined(_LIBCPP_VERSION)
+#if !( CDS_COMPILER == CDS_COMPILER_CLANG && defined(_LIBCPP_VERSION) && CDS_COMPILER_VERSION < 30800 )
+    //clang error (libc++) with atomic<void> fetch_add/fetch_sub
     TEST_F( cxx11_atomic_func, atomic_pointer_void )
     {
         do_test_atomic_pointer_void<false>();