|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r64014 - sandbox/SOC/2010/bits_and_ints/boost/integer
From: muriloufg_at_[hidden]
Date: 2010-07-14 14:20:53
Author: murilov
Date: 2010-07-14 14:20:51 EDT (Wed, 14 Jul 2010)
New Revision: 64014
URL: http://svn.boost.org/trac/boost/changeset/64014
Log:
Renamed swap() to swap_in_place() to avoid conflicts with another boost::swap() implementation
Text files modified:
sandbox/SOC/2010/bits_and_ints/boost/integer/count_leading_zeros.hpp | 17 ++++++++++++++++-
sandbox/SOC/2010/bits_and_ints/boost/integer/count_trailing_zeros.hpp | 19 +++++++++++++++++--
sandbox/SOC/2010/bits_and_ints/boost/integer/pop_count.hpp | 19 +++++++++++++++++--
3 files changed, 50 insertions(+), 5 deletions(-)
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 14:20:51 EDT (Wed, 14 Jul 2010)
@@ -27,6 +27,19 @@
*/
namespace boost {
+#ifdef __GNUC__
+
+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
+}
+
+#else
template <typename T>
typename enable_if_c<sizeof(T) == 1, int>::type
@@ -77,7 +90,9 @@
return pop_count(T(~value));
}
-
+
+#endif
+
} // boost
#endif
Modified: sandbox/SOC/2010/bits_and_ints/boost/integer/count_trailing_zeros.hpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/boost/integer/count_trailing_zeros.hpp (original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/count_trailing_zeros.hpp 2010-07-14 14:20:51 EDT (Wed, 14 Jul 2010)
@@ -27,10 +27,25 @@
namespace boost {
-int count_trailing_zeros(uintmax_t value)
+#ifdef __GNUC__
+
+inline int count_trailing_zeros(uintmax_t value)
+{
+#ifndef BOOST_HAS_NO_INT64_T
+ return __builtin_ctzll(value);
+#else
+ return __builtin_ctz(value);
+#endif
+}
+
+#else
+
+inline int count_trailing_zeros(uintmax_t value)
{
return pop_count(~value & (value - 1));
-} // count_trailing_zeros
+}
+
+#endif // __GNUC__
} // boost
Modified: sandbox/SOC/2010/bits_and_ints/boost/integer/pop_count.hpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/boost/integer/pop_count.hpp (original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/pop_count.hpp 2010-07-14 14:20:51 EDT (Wed, 14 Jul 2010)
@@ -27,7 +27,20 @@
namespace boost {
-int pop_count(uintmax_t value)
+#ifdef __GNUC__
+
+inline int pop_count(uintmax_t value)
+{
+#ifndef BOOST_NO_INT64_T
+ return __builtin_popcountll(value);
+#else
+ return __builtin_popcount(value);
+#endif
+}
+
+#else
+
+inline int pop_count(uintmax_t value)
{
using integer_detail::pop_count_mask;
value = (value & pop_count_mask[0]) + ((value >> 1) & pop_count_mask[0]);
@@ -40,8 +53,10 @@
#endif
return int(value);
-} // pop_count
+}
+#endif // __GNUC__
+
} // boost
#endif
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