$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r58750 - sandbox/memory/boost/memory
From: xushiweizh_at_[hidden]
Date: 2010-01-06 04:47:33
Author: xushiwei
Date: 2010-01-06 04:47:32 EST (Wed, 06 Jan 2010)
New Revision: 58750
URL: http://svn.boost.org/trac/boost/changeset/58750
Log:
boost memory: log2 - bug fixed
Text files modified: 
   sandbox/memory/boost/memory/pools.hpp |    37 ++-----------------------------------   
   1 files changed, 2 insertions(+), 35 deletions(-)
Modified: sandbox/memory/boost/memory/pools.hpp
==============================================================================
--- sandbox/memory/boost/memory/pools.hpp	(original)
+++ sandbox/memory/boost/memory/pools.hpp	2010-01-06 04:47:32 EST (Wed, 06 Jan 2010)
@@ -43,53 +43,21 @@
         };
 }
 
-#define BOOST_MEMORY_LOG2(val) NS_BOOST_MEMORY::detail::log2(val)
-
 #if _MSC_VER > 1200
 #pragma warning(pop)
 #endif
 
 #elif defined(__GNUG__) || defined(__GNUC__) // g++/gcc
 
-#if (1)
-
 __forceinline unsigned int log2(unsigned int val)
 {
         BOOST_MEMORY_ASSERT(val != 0);
         unsigned int result;
         __asm__("bsr %0, %%eax"::"m"(val));
-	__asm__("movl %%eax, %0":"=m"(result));
-#if (0)
-	unsigned int base = (1 << result);
-	if (val < base || val >= (base << 1))
-	{
-		printf("WARN: log2 algorithm failed!\n");
-	}
-#endif
+	__asm__("movl %%eax, %0":"=m"(result)::"eax");
         return result;
 }
 
-#define BOOST_MEMORY_LOG2(val) NS_BOOST_MEMORY::detail::log2(val)
-
-#else
-
-#define BOOST_MEMORY_LOG2(val) \
-({ \
-	unsigned int const boost_memory_val_ = (val); \
-	unsigned int boost_memory_result_; \
-	BOOST_MEMORY_ASSERT(boost_memory_val_ != 0); \
-	__asm__("bsr %0, %%eax"::"m"(boost_memory_val_)); \
-	__asm__("movl %%eax, %0":"=m"(boost_memory_result_)); \
-	unsigned int base = (1 << boost_memory_result_); \
-	if (boost_memory_val_ < base || boost_memory_val_ >= (base << 1)) \
-	{ \
-		printf("WARN: log2 algorithm failed!\n"); \
-	} \
-	boost_memory_result_; \
-})
-
-#endif
-
 #else
 
 __forceinline unsigned int log2(unsigned int val)
@@ -109,7 +77,6 @@
         }
 }
 
-#define BOOST_MEMORY_LOG2(val) NS_BOOST_MEMORY::detail::log2(val)
 #pragma message("Warning: unknown compiler and use a slow log2 algorithm!"
 
 #endif
@@ -201,7 +168,7 @@
                 BOOST_MEMORY_ASSERT(!has_pool1(cb));
                 BOOST_MEMORY_ASSERT(has_pool(cb));
 
-		const size_type index = BOOST_MEMORY_LOG2(cb + (PADDING2 - 1)) + (NPOOL1 - (MIN_BITS2 - 1));
+		const size_type index = detail::log2(cb + (PADDING2 - 1)) + (NPOOL1 - (MIN_BITS2 - 1));
                 pool_type* p = m_pools[index];
                 if (p == NULL)
                 {