From: khizmax Date: Tue, 30 May 2017 20:34:39 +0000 (+0300) Subject: Fixed ambiguity in casting size_t to one of unsigned type (found in AIX 32bit target) X-Git-Tag: v2.3.0~11 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=libcds.git;a=commitdiff_plain;h=fb39f01da6fceb1d350bc0cae8ff2ed22b3c128b Fixed ambiguity in casting size_t to one of unsigned type (found in AIX 32bit target) --- diff --git a/cds/details/size_t_cast.h b/cds/details/size_t_cast.h new file mode 100644 index 00000000..f79dbd9d --- /dev/null +++ b/cds/details/size_t_cast.h @@ -0,0 +1,63 @@ +/* +This file is a part of libcds - Concurrent Data Structures library + +(C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017 + +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: + +* Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +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. +*/ + +#ifndef CDSLIB_DETAILS_SIZE_T_CAST_H +#define CDSLIB_DETAILS_SIZE_T_CAST_H + +#include + +//@cond +namespace cds { namespace details { + + template + struct size_t_unsigned; + + template <> + struct size_t_unsigned<4> + { + typedef uint32_t type; + }; + + template <> + struct size_t_unsigned<8> + { + typedef uint64_t type; + }; + + static inline size_t_unsigned::type size_t_cast( size_t n ) + { + return static_cast< size_t_unsigned::type>( n ); + } + +}} // namespace cds::details +//@endcond + +#endif // #ifndef CDSLIB_DETAILS_SIZE_T_CAST_H + diff --git a/cds/intrusive/details/split_list_base.h b/cds/intrusive/details/split_list_base.h index e4ef11ad..ce7c299e 100644 --- a/cds/intrusive/details/split_list_base.h +++ b/cds/intrusive/details/split_list_base.h @@ -39,6 +39,7 @@ #include #include #include +#include namespace cds { namespace intrusive { @@ -1302,13 +1303,13 @@ namespace cds { namespace intrusive { template static inline size_t regular_hash( size_t nHash ) { - return BitReversalAlgo()( nHash ) | size_t(1); + return static_cast( BitReversalAlgo()( cds::details::size_t_cast( nHash ))) | size_t(1); } template static inline size_t dummy_hash( size_t nHash ) { - return BitReversalAlgo()( nHash ) & ~size_t(1); + return static_cast( BitReversalAlgo()( cds::details::size_t_cast( nHash ))) & ~size_t(1); } //@endcond diff --git a/projects/Win/vc14/cds.vcxproj b/projects/Win/vc14/cds.vcxproj index 91071fe4..12aeea18 100644 --- a/projects/Win/vc14/cds.vcxproj +++ b/projects/Win/vc14/cds.vcxproj @@ -511,6 +511,7 @@ + diff --git a/projects/Win/vc14/cds.vcxproj.filters b/projects/Win/vc14/cds.vcxproj.filters index f362b391..5987d4bf 100644 --- a/projects/Win/vc14/cds.vcxproj.filters +++ b/projects/Win/vc14/cds.vcxproj.filters @@ -1258,5 +1258,8 @@ Header Files\cds\container + + Header Files\cds\details + \ No newline at end of file diff --git a/projects/Win/vc141/cds.vcxproj b/projects/Win/vc141/cds.vcxproj index a74adfc6..ace327b5 100644 --- a/projects/Win/vc141/cds.vcxproj +++ b/projects/Win/vc141/cds.vcxproj @@ -511,6 +511,7 @@ + diff --git a/projects/Win/vc141/cds.vcxproj.filters b/projects/Win/vc141/cds.vcxproj.filters index 137444c8..04f33e00 100644 --- a/projects/Win/vc141/cds.vcxproj.filters +++ b/projects/Win/vc141/cds.vcxproj.filters @@ -1258,5 +1258,8 @@ Header Files\cds\container + + Header Files\cds\details + \ No newline at end of file