mirror of
https://github.com/boostorg/integer.git
synced 2025-07-02 23:36:55 +02:00
Compare commits
23 Commits
sandbox-br
...
boost-1.44
Author | SHA1 | Date | |
---|---|---|---|
581224a4f7 | |||
245c28d187 | |||
f390a64825 | |||
e3da9260e1 | |||
730be18188 | |||
60db1676fc | |||
be17e798df | |||
a1bf7131b3 | |||
dcdfca5f38 | |||
12e2311aa4 | |||
e6bbb33660 | |||
1b9549693a | |||
382eabdff5 | |||
3531eb1ac5 | |||
85e4d3e23d | |||
550fe9d89f | |||
19ed0e48e0 | |||
559b44c259 | |||
b162db6b72 | |||
4935afbcd4 | |||
167961aba1 | |||
7ce7ba6bfd | |||
c8cb2b24a1 |
@ -137,7 +137,7 @@ namespace boost
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#elif defined(__FreeBSD__) && (__FreeBSD__ <= 4) || defined(__osf__) || defined(__VMS)
|
||||
#elif defined(__FreeBSD__) && (__FreeBSD__ <= 4) || defined(__osf__)
|
||||
// FreeBSD and Tru64 have an <inttypes.h> that contains much of what we need.
|
||||
# include <inttypes.h>
|
||||
|
||||
@ -256,27 +256,20 @@ namespace boost
|
||||
|
||||
// 32-bit types -----------------------------------------------------------//
|
||||
|
||||
# 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
|
||||
# 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
|
||||
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 (UINT_MAX == 0xffffffffffffffff) && defined(__MTA__)
|
||||
// Integers are 64 bits on the MTA / XMT
|
||||
typedef __int32 int32_t;
|
||||
|
@ -20,17 +20,6 @@
|
||||
|
||||
#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
|
||||
{
|
||||
@ -100,19 +89,6 @@ BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned int );
|
||||
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
|
||||
|
@ -136,6 +136,22 @@ template < std::size_t Bits >
|
||||
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 >
|
||||
|
@ -227,7 +227,7 @@ class integer_traits< ::boost::ulong_long_type>
|
||||
template<>
|
||||
class integer_traits< ::boost::long_long_type>
|
||||
: public std::numeric_limits< ::boost::long_long_type>,
|
||||
public detail::integer_traits_base< ::boost::long_long_type, (1LL << (sizeof(::boost::long_long_type) * CHAR_BIT - 1)), ~(1LL << (sizeof(::boost::long_long_type) * CHAR_BIT - 1))>
|
||||
public detail::integer_traits_base< ::boost::long_long_type, (1LL << (sizeof(::boost::long_long_type) - 1)), ~(1LL << (sizeof(::boost::long_long_type) - 1))>
|
||||
{ };
|
||||
|
||||
template<>
|
||||
|
@ -21,35 +21,25 @@
|
||||
#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 == (ONE << (v)) );
|
||||
(v) >::high_bit == (1ul << (v)) );
|
||||
#define PRIVATE_HIGH_BIT_FAST_TEST(v) BOOST_TEST( ::boost::high_bit_mask_t< \
|
||||
(v) >::high_bit_fast == (ONE << (v)) );
|
||||
(v) >::high_bit_fast == (1ul << (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{ \
|
||||
MASK_TYPE mask = 0;\
|
||||
unsigned long mask = 0;\
|
||||
if(v > 0)\
|
||||
{ mask = ((ONE << (v-1)) - 1); mask <<= 1; mask |= 1; }\
|
||||
{ mask = ((1ul << (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{ \
|
||||
MASK_TYPE mask = 0;\
|
||||
unsigned long mask = 0;\
|
||||
if(v > 0)\
|
||||
{ mask = ((ONE << (v-1)) - 1); mask <<= 1; mask |= 1; }\
|
||||
{ mask = ((1ul << (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); \
|
||||
@ -62,41 +52,6 @@ int main( int, char*[] )
|
||||
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 );
|
||||
@ -131,41 +86,6 @@ int main( int, char*[] )
|
||||
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 );
|
||||
|
@ -152,7 +152,7 @@ void do_test_bits()
|
||||
if(boost::detail::test_errors() != last_error_count)
|
||||
{
|
||||
last_error_count = boost::detail::test_errors();
|
||||
std::cout << "Errors occurred while testing with bit count = " << Bits << std::endl;
|
||||
std::cout << "Errors occured while testing with bit count = " << Bits << std::endl;
|
||||
std::cout << "Type int_t<" << Bits << ">::least was " << get_name_of_type(least_int(0)) << std::endl;
|
||||
std::cout << "Type int_t<" << Bits << ">::fast was " << get_name_of_type(fast_int(0)) << std::endl;
|
||||
std::cout << "Type uint_t<" << Bits << ">::least was " << get_name_of_type(least_uint(0)) << std::endl;
|
||||
|
Reference in New Issue
Block a user