|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r64028 - in sandbox/SOC/2010/bits_and_ints: boost/integer libs/integer/test
From: muriloufg_at_[hidden]
Date: 2010-07-14 19:52:36
Author: murilov
Date: 2010-07-14 19:52:35 EDT (Wed, 14 Jul 2010)
New Revision: 64028
URL: http://svn.boost.org/trac/boost/changeset/64028
Log:
Changes on count_leading_zeros.hpp
Text files modified:
sandbox/SOC/2010/bits_and_ints/boost/integer/bits_and_ints.hpp | 4 +++-
sandbox/SOC/2010/bits_and_ints/boost/integer/count_leading_zeros.hpp | 19 +++++++++++++++----
sandbox/SOC/2010/bits_and_ints/boost/integer/ilog2.hpp | 2 +-
sandbox/SOC/2010/bits_and_ints/libs/integer/test/count_leading_zeros_test.cpp | 7 ++-----
sandbox/SOC/2010/bits_and_ints/libs/integer/test/ilog2_test.cpp | 1 -
5 files changed, 21 insertions(+), 12 deletions(-)
Modified: sandbox/SOC/2010/bits_and_ints/boost/integer/bits_and_ints.hpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/boost/integer/bits_and_ints.hpp (original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/bits_and_ints.hpp 2010-07-14 19:52:35 EDT (Wed, 14 Jul 2010)
@@ -28,7 +28,7 @@
#include <boost/integer/static_count_trailing_zeros.hpp>
#include <boost/integer/clear_least_bit_set.hpp>
#include <boost/integer/static_clear_least_bit_set.hpp>
-#include <boost/integer/swap.hpp>
+#include <boost/integer/swap_in_place.hpp>
#include <boost/integer/safe_avg.hpp>
#include <boost/integer/static_safe_avg.hpp>
#include <boost/integer/round_pow2.hpp>
@@ -38,4 +38,6 @@
#include <boost/integer/static_abs.hpp>
#include <boost/integer/static_gcd.hpp>
#include <boost/integer/static_lcm.hpp>
+#include <boost/integer/count_leading_zeros.hpp>
+#include <boost/integer/ilog2.hpp>
#endif
Modified: sandbox/SOC/2010/bits_and_ints/boost/integer/count_leading_zeros.hpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/boost/integer/count_leading_zeros.hpp (original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/count_leading_zeros.hpp 2010-07-14 19:52:35 EDT (Wed, 14 Jul 2010)
@@ -32,11 +32,22 @@
template <typename T>
inline int count_leading_zeros(T value)
{
-#ifndef BOOST_HAS_NO_INT64_T
- return __builtin_clzll(value) - (64 - (sizeof(T) << 3));
-#else
return __builtin_clz(value) - (32 - (sizeof(T) << 3));
-#endif
+}
+
+inline int count_leading_zeros(unsigned int value)
+{
+ return __builtin_clz(value);
+}
+
+inline int count_leading_zeros(unsigned long int value)
+{
+ return __builtin_clzl(value);
+}
+
+inline int count_leading_zeros(unsigned long long int value)
+{
+ return __builtin_clzll(value);
}
#else
Modified: sandbox/SOC/2010/bits_and_ints/boost/integer/ilog2.hpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/boost/integer/ilog2.hpp (original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/ilog2.hpp 2010-07-14 19:52:35 EDT (Wed, 14 Jul 2010)
@@ -20,7 +20,7 @@
* This function returns the integer value of
* logarithm in base 2 of an unsigned integral `value`
*
- * If `value` is equal to 0, the value returned is -1
+ * If `value` is equal to 0, the value returned is undefined
*
* `value` must be unsigned.
*/
Modified: sandbox/SOC/2010/bits_and_ints/libs/integer/test/count_leading_zeros_test.cpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/libs/integer/test/count_leading_zeros_test.cpp (original)
+++ sandbox/SOC/2010/bits_and_ints/libs/integer/test/count_leading_zeros_test.cpp 2010-07-14 19:52:35 EDT (Wed, 14 Jul 2010)
@@ -11,7 +11,8 @@
#include <iostream>
#define CLZ_TEST(x, y) \
-BOOST_TEST((::boost::count_leading_zeros(x) == y))
+BOOST_TEST((::boost::count_leading_zeros(x) == y)); \
+std::cout << "era pra dar " << y << " deu: " << ::boost::count_leading_zeros(x) << std::endl
// Main testing function
int main(int, char* [])
@@ -27,14 +28,11 @@
CLZ_TEST(uint8_t(0x07), 5);
CLZ_TEST(uint8_t(0x03), 6);
CLZ_TEST(uint8_t(0x01), 7);
- CLZ_TEST(uint8_t(0x00), 8);
CLZ_TEST(uint16_t(0xF000), 0);
CLZ_TEST(uint16_t(0xAA00), 0);
- CLZ_TEST(uint16_t(0x0000), 16);
CLZ_TEST(uint16_t(0x0002), 14);
- CLZ_TEST(uint32_t(0x0), 32);
CLZ_TEST(uint32_t(0xFFFFFFFF), 0);
CLZ_TEST(uint32_t(0x0001FFFF), 15);
CLZ_TEST(uint32_t(0x00FFFFFF), 8);
@@ -42,7 +40,6 @@
#ifndef BOOST_HAS_NO_INT64_T
- CLZ_TEST(0x0LL, 64);
CLZ_TEST(0xFLL, 60);
CLZ_TEST(0xFFFFFFFFLL, 32);
CLZ_TEST(0x7FFFFFFFLL, 33);
Modified: sandbox/SOC/2010/bits_and_ints/libs/integer/test/ilog2_test.cpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/libs/integer/test/ilog2_test.cpp (original)
+++ sandbox/SOC/2010/bits_and_ints/libs/integer/test/ilog2_test.cpp 2010-07-14 19:52:35 EDT (Wed, 14 Jul 2010)
@@ -20,7 +20,6 @@
using namespace boost;
std::cout << "Doing tests on ilog2 function." << std::endl;
- ILOG2_TEST((unsigned)0, -1);
ILOG2_TEST((unsigned)100, 6);
ILOG2_TEST((unsigned)265, 8);
ILOG2_TEST((unsigned)158741, 17);
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