Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57678 - sandbox/memory/boost/memory
From: xushiweizh_at_[hidden]
Date: 2009-11-15 04:21:58


Author: xushiwei
Date: 2009-11-15 04:21:57 EST (Sun, 15 Nov 2009)
New Revision: 57678
URL: http://svn.boost.org/trac/boost/changeset/57678

Log:
bsr for gcc - bug fix
Text files modified:
   sandbox/memory/boost/memory/pools.hpp | 22 ++++++++++++++++++++--
   1 files changed, 20 insertions(+), 2 deletions(-)

Modified: sandbox/memory/boost/memory/pools.hpp
==============================================================================
--- sandbox/memory/boost/memory/pools.hpp (original)
+++ sandbox/memory/boost/memory/pools.hpp 2009-11-15 04:21:57 EST (Sun, 15 Nov 2009)
@@ -51,12 +51,30 @@
 
 __forceinline unsigned int log2(IN unsigned int val) {
         BOOST_MEMORY_ASSERT(val != 0);
- __asm__ volatile("bsr %0, %%eax"::"m"(val));
+ unsigned int result;
+ __asm__("bsr %0, %%eax"::"m"(val));
+ __asm__("movl %%eax, %0":"=m"(result));
+ return result;
 }
 
 #else
 
-#error "Error: to do - unsupport compiler!"
+__forceinline unsigned int log2(IN unsigned int val)
+{
+ BOOST_MEMORY_ASSERT(val != 0);
+ if (!(val & 0xFFFFFFFFU))
+ return 0xCDCDCDCDU;
+ unsigned int result = 31, mask = (1 << 31);
+ for (;;)
+ {
+ if (val & mask)
+ return result;
+ --result;
+ mask >>= 1;
+ }
+}
+
+#pragma message("Warning: unsupport compiler, and use a slow log2 algorithm!"
 
 #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