|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r62756 - in trunk: boost boost/integer libs/integer/test
From: steven_at_[hidden]
Date: 2010-06-10 15:49:35
Author: steven_watanabe
Date: 2010-06-10 15:49:34 EDT (Thu, 10 Jun 2010)
New Revision: 62756
URL: http://svn.boost.org/trac/boost/changeset/62756
Log:
Add a 64 bit specialization of low_bits_mask_t. Fixes #4332
Text files modified:
trunk/boost/integer/integer_mask.hpp | 24 ++++++++++
trunk/boost/integer_fwd.hpp | 16 ------
trunk/libs/integer/test/integer_mask_test.cpp | 92 +++++++++++++++++++++++++++++++++++++--
3 files changed, 110 insertions(+), 22 deletions(-)
Modified: trunk/boost/integer/integer_mask.hpp
==============================================================================
--- trunk/boost/integer/integer_mask.hpp (original)
+++ trunk/boost/integer/integer_mask.hpp 2010-06-10 15:49:34 EDT (Thu, 10 Jun 2010)
@@ -20,6 +20,17 @@
#include <boost/limits.hpp> // for std::numeric_limits
+//
+// We simply cannot include this header on gcc without getting copious warnings of the kind:
+//
+// boost/integer/integer_mask.hpp:93:35: warning: use of C99 long long integer constant
+//
+// And yet there is no other reasonable implementation, so we declare this a system header
+// to suppress these warnings.
+//
+#if defined(__GNUC__) && (__GNUC__ >= 4)
+#pragma GCC system_header
+#endif
namespace boost
{
@@ -89,6 +100,19 @@
BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned long );
#endif
+#if defined(BOOST_HAS_LONG_LONG)
+ #if ((defined(ULLONG_MAX) && (ULLONG_MAX > ULONG_MAX)) ||\
+ (defined(ULONG_LONG_MAX) && (ULONG_LONG_MAX > ULONG_MAX)) ||\
+ (defined(ULONGLONG_MAX) && (ULONGLONG_MAX > ULONG_MAX)) ||\
+ (defined(_ULLONG_MAX) && (_ULLONG_MAX > ULONG_MAX)))
+ BOOST_LOW_BITS_MASK_SPECIALIZE( boost::ulong_long_type );
+ #endif
+#elif defined(BOOST_HAS_MS_INT64)
+ #if 18446744073709551615ui64 > ULONG_MAX
+ BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned __int64 );
+ #endif
+#endif
+
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
Modified: trunk/boost/integer_fwd.hpp
==============================================================================
--- trunk/boost/integer_fwd.hpp (original)
+++ trunk/boost/integer_fwd.hpp 2010-06-10 15:49:34 EDT (Thu, 10 Jun 2010)
@@ -136,22 +136,6 @@
template < >
struct low_bits_mask_t< ::std::numeric_limits<unsigned char>::digits >;
-#if USHRT_MAX > UCHAR_MAX
-template < >
- struct low_bits_mask_t< ::std::numeric_limits<unsigned short>::digits >;
-#endif
-
-#if UINT_MAX > USHRT_MAX
-template < >
- struct low_bits_mask_t< ::std::numeric_limits<unsigned int>::digits >;
-#endif
-
-#if ULONG_MAX > UINT_MAX
-template < >
- struct low_bits_mask_t< ::std::numeric_limits<unsigned long>::digits >;
-#endif
-
-
// From <boost/integer/static_log2.hpp> ------------------------------------//
template <static_log2_argument_type Value >
Modified: trunk/libs/integer/test/integer_mask_test.cpp
==============================================================================
--- trunk/libs/integer/test/integer_mask_test.cpp (original)
+++ trunk/libs/integer/test/integer_mask_test.cpp 2010-06-10 15:49:34 EDT (Thu, 10 Jun 2010)
@@ -21,25 +21,35 @@
#pragma warning(disable:4127) // conditional expression is constant
#endif
+#if defined(BOOST_HAS_LONG_LONG)
+#define MASK_TYPE ::boost::ulong_long_type
+#elif defined(BOOST_HAS_MS_INT64)
+#define MASK_TYPE unsigned __int64
+#else
+#define MASK_TYPE unsigned long
+#endif
+
+#define ONE (static_cast<MASK_TYPE>(1))
+
#define PRIVATE_HIGH_BIT_SLOW_TEST(v) BOOST_TEST( ::boost::high_bit_mask_t< \
- (v) >::high_bit == (1ul << (v)) );
+ (v) >::high_bit == (ONE << (v)) );
#define PRIVATE_HIGH_BIT_FAST_TEST(v) BOOST_TEST( ::boost::high_bit_mask_t< \
- (v) >::high_bit_fast == (1ul << (v)) );
+ (v) >::high_bit_fast == (ONE << (v)) );
#define PRIVATE_HIGH_BIT_TEST(v) do { PRIVATE_HIGH_BIT_SLOW_TEST(v); \
PRIVATE_HIGH_BIT_FAST_TEST(v); } while (false)
#define PRIVATE_LOW_BITS_SLOW_TEST(v) \
do{ \
- unsigned long mask = 0;\
+ MASK_TYPE mask = 0;\
if(v > 0)\
- { mask = ((1ul << (v-1)) - 1); mask <<= 1; mask |= 1; }\
+ { mask = ((ONE << (v-1)) - 1); mask <<= 1; mask |= 1; }\
BOOST_TEST( ::boost::low_bits_mask_t< (v) >::sig_bits == mask); \
}while(false);
#define PRIVATE_LOW_BITS_FAST_TEST(v) \
do{ \
- unsigned long mask = 0;\
+ MASK_TYPE mask = 0;\
if(v > 0)\
- { mask = ((1ul << (v-1)) - 1); mask <<= 1; mask |= 1; }\
+ { mask = ((ONE << (v-1)) - 1); mask <<= 1; mask |= 1; }\
BOOST_TEST( ::boost::low_bits_mask_t< (v) >::sig_bits_fast == mask);\
}while(false);
#define PRIVATE_LOW_BITS_TEST(v) do { PRIVATE_LOW_BITS_SLOW_TEST(v); \
@@ -52,6 +62,41 @@
using std::endl;
cout << "Doing high_bit_mask_t tests." << endl;
+
+#if defined(BOOST_HAS_LONG_LONG) || defined(BOOST_HAS_MS_INT64)
+ PRIVATE_HIGH_BIT_TEST( 63 );
+ PRIVATE_HIGH_BIT_TEST( 62 );
+ PRIVATE_HIGH_BIT_TEST( 61 );
+ PRIVATE_HIGH_BIT_TEST( 60 );
+ PRIVATE_HIGH_BIT_TEST( 59 );
+ PRIVATE_HIGH_BIT_TEST( 58 );
+ PRIVATE_HIGH_BIT_TEST( 57 );
+ PRIVATE_HIGH_BIT_TEST( 56 );
+ PRIVATE_HIGH_BIT_TEST( 55 );
+ PRIVATE_HIGH_BIT_TEST( 54 );
+ PRIVATE_HIGH_BIT_TEST( 53 );
+ PRIVATE_HIGH_BIT_TEST( 52 );
+ PRIVATE_HIGH_BIT_TEST( 51 );
+ PRIVATE_HIGH_BIT_TEST( 50 );
+ PRIVATE_HIGH_BIT_TEST( 49 );
+ PRIVATE_HIGH_BIT_TEST( 48 );
+ PRIVATE_HIGH_BIT_TEST( 47 );
+ PRIVATE_HIGH_BIT_TEST( 46 );
+ PRIVATE_HIGH_BIT_TEST( 45 );
+ PRIVATE_HIGH_BIT_TEST( 44 );
+ PRIVATE_HIGH_BIT_TEST( 43 );
+ PRIVATE_HIGH_BIT_TEST( 42 );
+ PRIVATE_HIGH_BIT_TEST( 41 );
+ PRIVATE_HIGH_BIT_TEST( 40 );
+ PRIVATE_HIGH_BIT_TEST( 39 );
+ PRIVATE_HIGH_BIT_TEST( 38 );
+ PRIVATE_HIGH_BIT_TEST( 37 );
+ PRIVATE_HIGH_BIT_TEST( 36 );
+ PRIVATE_HIGH_BIT_TEST( 35 );
+ PRIVATE_HIGH_BIT_TEST( 34 );
+ PRIVATE_HIGH_BIT_TEST( 33 );
+ PRIVATE_HIGH_BIT_TEST( 32 );
+#endif
PRIVATE_HIGH_BIT_TEST( 31 );
PRIVATE_HIGH_BIT_TEST( 30 );
PRIVATE_HIGH_BIT_TEST( 29 );
@@ -86,6 +131,41 @@
PRIVATE_HIGH_BIT_TEST( 0 );
cout << "Doing low_bits_mask_t tests." << endl;
+
+#if defined(BOOST_HAS_LONG_LONG) || defined(BOOST_HAS_MS_INT64)
+ PRIVATE_LOW_BITS_TEST( 64 );
+ PRIVATE_LOW_BITS_TEST( 63 );
+ PRIVATE_LOW_BITS_TEST( 62 );
+ PRIVATE_LOW_BITS_TEST( 61 );
+ PRIVATE_LOW_BITS_TEST( 60 );
+ PRIVATE_LOW_BITS_TEST( 59 );
+ PRIVATE_LOW_BITS_TEST( 58 );
+ PRIVATE_LOW_BITS_TEST( 57 );
+ PRIVATE_LOW_BITS_TEST( 56 );
+ PRIVATE_LOW_BITS_TEST( 55 );
+ PRIVATE_LOW_BITS_TEST( 54 );
+ PRIVATE_LOW_BITS_TEST( 53 );
+ PRIVATE_LOW_BITS_TEST( 52 );
+ PRIVATE_LOW_BITS_TEST( 51 );
+ PRIVATE_LOW_BITS_TEST( 50 );
+ PRIVATE_LOW_BITS_TEST( 49 );
+ PRIVATE_LOW_BITS_TEST( 48 );
+ PRIVATE_LOW_BITS_TEST( 47 );
+ PRIVATE_LOW_BITS_TEST( 46 );
+ PRIVATE_LOW_BITS_TEST( 45 );
+ PRIVATE_LOW_BITS_TEST( 44 );
+ PRIVATE_LOW_BITS_TEST( 43 );
+ PRIVATE_LOW_BITS_TEST( 42 );
+ PRIVATE_LOW_BITS_TEST( 41 );
+ PRIVATE_LOW_BITS_TEST( 40 );
+ PRIVATE_LOW_BITS_TEST( 39 );
+ PRIVATE_LOW_BITS_TEST( 38 );
+ PRIVATE_LOW_BITS_TEST( 37 );
+ PRIVATE_LOW_BITS_TEST( 36 );
+ PRIVATE_LOW_BITS_TEST( 35 );
+ PRIVATE_LOW_BITS_TEST( 34 );
+ PRIVATE_LOW_BITS_TEST( 33 );
+#endif
PRIVATE_LOW_BITS_TEST( 32 );
PRIVATE_LOW_BITS_TEST( 31 );
PRIVATE_LOW_BITS_TEST( 30 );
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk