Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65721 - in branches/release: boost boost/integer libs/integer libs/integer/test
From: john_at_[hidden]
Date: 2010-10-02 08:14:10


Author: johnmaddock
Date: 2010-10-02 08:14:04 EDT (Sat, 02 Oct 2010)
New Revision: 65721
URL: http://svn.boost.org/trac/boost/changeset/65721

Log:
Fix logic in cstdint to prefer smaller integers when possible.
Improve PP-logic in integer-traits.
Suppress some compiler warnings.
Properties modified:
   branches/release/boost/integer/ (props changed)
   branches/release/libs/integer/ (props changed)
Text files modified:
   branches/release/boost/cstdint.hpp | 25 ++++++---
   branches/release/boost/integer/integer_mask.hpp | 24 ++++++++++
   branches/release/boost/integer_fwd.hpp | 16 ------
   branches/release/libs/integer/test/integer_mask_test.cpp | 92 +++++++++++++++++++++++++++++++++++++--
   4 files changed, 126 insertions(+), 31 deletions(-)

Modified: branches/release/boost/cstdint.hpp
==============================================================================
--- branches/release/boost/cstdint.hpp (original)
+++ branches/release/boost/cstdint.hpp 2010-10-02 08:14:04 EDT (Sat, 02 Oct 2010)
@@ -137,7 +137,7 @@
 
 } // namespace boost
 
-#elif defined(__FreeBSD__) && (__FreeBSD__ <= 4) || defined(__osf__)
+#elif defined(__FreeBSD__) && (__FreeBSD__ <= 4) || defined(__osf__) || defined(__VMS)
 // FreeBSD and Tru64 have an <inttypes.h> that contains much of what we need.
 # include <inttypes.h>
 
@@ -256,20 +256,27 @@
 
 // 32-bit types -----------------------------------------------------------//
 
-# if ULONG_MAX == 0xffffffff
- typedef long int32_t;
- typedef long int_least32_t;
- typedef long int_fast32_t;
- typedef unsigned long uint32_t;
- typedef unsigned long uint_least32_t;
- typedef unsigned long uint_fast32_t;
-# elif UINT_MAX == 0xffffffff
+# if UINT_MAX == 0xffffffff
      typedef int int32_t;
      typedef int int_least32_t;
      typedef int int_fast32_t;
      typedef unsigned int uint32_t;
      typedef unsigned int uint_least32_t;
      typedef unsigned int uint_fast32_t;
+# elif (USHRT_MAX == 0xffffffff)
+ typedef short int32_t;
+ typedef short int_least32_t;
+ typedef short int_fast32_t;
+ typedef unsigned short uint32_t;
+ typedef unsigned short uint_least32_t;
+ typedef unsigned short uint_fast32_t;
+# elif ULONG_MAX == 0xffffffff
+ typedef long int32_t;
+ typedef long int_least32_t;
+ typedef long int_fast32_t;
+ typedef unsigned long uint32_t;
+ typedef unsigned long uint_least32_t;
+ typedef unsigned long uint_fast32_t;
 # elif (UINT_MAX == 0xffffffffffffffff) && defined(__MTA__)
       // Integers are 64 bits on the MTA / XMT
       typedef __int32 int32_t;

Modified: branches/release/boost/integer/integer_mask.hpp
==============================================================================
--- branches/release/boost/integer/integer_mask.hpp (original)
+++ branches/release/boost/integer/integer_mask.hpp 2010-10-02 08:14:04 EDT (Sat, 02 Oct 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: branches/release/boost/integer_fwd.hpp
==============================================================================
--- branches/release/boost/integer_fwd.hpp (original)
+++ branches/release/boost/integer_fwd.hpp 2010-10-02 08:14:04 EDT (Sat, 02 Oct 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: branches/release/libs/integer/test/integer_mask_test.cpp
==============================================================================
--- branches/release/libs/integer/test/integer_mask_test.cpp (original)
+++ branches/release/libs/integer/test/integer_mask_test.cpp 2010-10-02 08:14:04 EDT (Sat, 02 Oct 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