Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52532 - in sandbox/memory: boost/memory libs/memory/build libs/memory/src
From: xushiweizh_at_[hidden]
Date: 2009-04-22 00:56:50


Author: xushiwei
Date: 2009-04-22 00:56:47 EDT (Wed, 22 Apr 2009)
New Revision: 52532
URL: http://svn.boost.org/trac/boost/changeset/52532

Log:
1. refactor boost-memory header files.
 1). add: boost/memory/block_pool.hpp
 2). merge: boost/memory/auto_alloc.hpp, scoped_alloc.hpp to region_alloc.hpp
2. rename _boost_TlsBlockPool to boost_TlsBlockPool
Added:
   sandbox/memory/boost/memory/block_pool.hpp (contents, props changed)
   sandbox/memory/boost/memory/region_alloc.hpp (contents, props changed)
Removed:
   sandbox/memory/libs/memory/src/gc_alloc.cpp
Text files modified:
   sandbox/memory/boost/memory/auto_alloc.hpp | 298 ---------------------------------------
   sandbox/memory/boost/memory/scoped_alloc.hpp | 196 -------------------------
   sandbox/memory/libs/memory/build/build.def | 3
   sandbox/memory/libs/memory/src/block_pool.cpp | 2
   4 files changed, 8 insertions(+), 491 deletions(-)

Modified: sandbox/memory/boost/memory/auto_alloc.hpp
==============================================================================
--- sandbox/memory/boost/memory/auto_alloc.hpp (original)
+++ sandbox/memory/boost/memory/auto_alloc.hpp 2009-04-22 00:56:47 EDT (Wed, 22 Apr 2009)
@@ -12,307 +12,13 @@
 #ifndef BOOST_MEMORY_AUTO_ALLOC_HPP
 #define BOOST_MEMORY_AUTO_ALLOC_HPP
 
-#ifndef BOOST_MEMORY_SYSTEM_ALLOC_HPP
-#include "system_alloc.hpp"
-#endif
-
-#if !defined(_GLIBCXX_ALGORITHM) && !defined(_ALGORITHM)
-#include <algorithm>
-#endif
-
-NS_BOOST_MEMORY_BEGIN
-
-// -------------------------------------------------------------------------
-// class region_alloc
-
-template <class PolicyT>
-class region_alloc
-{
-private:
- typedef typename PolicyT::alloc_type AllocT;
-
-public:
- enum { MemBlockSize = PolicyT::MemBlockBytes - AllocT::Padding };
- enum { IsGCAllocator = 1 };
-
- typedef AllocT alloc_type;
-
-private:
- enum { HeaderSize = sizeof(void*) };
- enum { BlockSize = MemBlockSize - HeaderSize };
-
-#pragma pack(1)
-private:
- struct MemBlock;
- friend struct MemBlock;
-
- struct MemBlock
- {
- MemBlock* pPrev;
- char buffer[BlockSize];
- };
- struct DestroyNode
- {
- DestroyNode* pPrev;
- destructor_t fnDestroy;
- };
-#pragma pack()
-
- char* m_begin;
- char* m_end;
- AllocT m_alloc;
- DestroyNode* m_destroyChain;
-
-private:
- const region_alloc& operator=(const region_alloc&);
-
- MemBlock* BOOST_MEMORY_CALL chainHeader_() const
- {
- return (MemBlock*)(m_begin - HeaderSize);
- }
-
- void BOOST_MEMORY_CALL init_()
- {
- MemBlock* pNew = (MemBlock*)m_alloc.allocate(sizeof(MemBlock));
- pNew->pPrev = NULL;
- m_begin = pNew->buffer;
- m_end = (char*)pNew + m_alloc.alloc_size(pNew);
- }
-
-public:
- region_alloc() : m_destroyChain(NULL)
- {
- init_();
- }
- explicit region_alloc(AllocT alloc) : m_alloc(alloc), m_destroyChain(NULL)
- {
- init_();
- }
- explicit region_alloc(region_alloc& owner)
- : m_alloc(owner.m_alloc), m_destroyChain(NULL)
- {
- init_();
- }
-
- ~region_alloc()
- {
- clear();
- }
-
- void BOOST_MEMORY_CALL swap(region_alloc& o)
- {
- std::swap(m_begin, o.m_begin);
- std::swap(m_end, o.m_end);
- std::swap(m_destroyChain, o.m_destroyChain);
- m_alloc.swap(o.m_alloc);
- }
-
- void BOOST_MEMORY_CALL clear()
- {
- while (m_destroyChain)
- {
- DestroyNode* curr = m_destroyChain;
- m_destroyChain = m_destroyChain->pPrev;
- curr->fnDestroy(curr + 1);
- }
- MemBlock* pHeader = chainHeader_();
- while (pHeader)
- {
- MemBlock* curr = pHeader;
- pHeader = pHeader->pPrev;
- m_alloc.deallocate(curr);
- }
- m_begin = m_end = (char*)HeaderSize;
- }
-
-private:
- void* BOOST_MEMORY_CALL do_allocate_(size_t cb)
- {
- if (cb >= BlockSize)
- {
- MemBlock* pHeader = chainHeader_();
- MemBlock* pNew = (MemBlock*)m_alloc.allocate(HeaderSize + cb);
- if (pHeader)
- {
- pNew->pPrev = pHeader->pPrev;
- pHeader->pPrev = pNew;
- }
- else
- {
- m_end = m_begin = pNew->buffer;
- pNew->pPrev = NULL;
- }
- return pNew->buffer;
- }
- else
- {
- MemBlock* pNew = (MemBlock*)m_alloc.allocate(sizeof(MemBlock));
- pNew->pPrev = chainHeader_();
- m_begin = pNew->buffer;
- m_end = (char*)pNew + m_alloc.alloc_size(pNew);
- return m_end -= cb;
- }
- }
-
-public:
- __forceinline void* BOOST_MEMORY_CALL allocate(size_t cb)
- {
- if ((size_t)(m_end - m_begin) >= cb)
- {
- return m_end -= cb;
- }
- return do_allocate_(cb);
- }
-
-#if defined(BOOST_MEMORY_NO_STRICT_EXCEPTION_SEMANTICS)
- __forceinline void* BOOST_MEMORY_CALL allocate(size_t cb, int fnZero)
- {
- return allocate(cb);
- }
-
- __forceinline void* BOOST_MEMORY_CALL allocate(size_t cb, destructor_t fn)
- {
- DestroyNode* pNode = (DestroyNode*)allocate(sizeof(DestroyNode) + cb);
- pNode->fnDestroy = fn;
- pNode->pPrev = m_destroyChain;
- m_destroyChain = pNode;
- return pNode + 1;
- }
-#endif
-
- __forceinline void* BOOST_MEMORY_CALL unmanaged_alloc(size_t cb, destructor_t fn)
- {
- DestroyNode* pNode = (DestroyNode*)allocate(sizeof(DestroyNode) + cb);
- pNode->fnDestroy = fn;
- return pNode + 1;
- }
-
- __forceinline void BOOST_MEMORY_CALL manage(void* p, destructor_t fn)
- {
- DestroyNode* pNode = (DestroyNode*)p - 1;
- BOOST_MEMORY_ASSERT(pNode->fnDestroy == fn);
-
- pNode->pPrev = m_destroyChain;
- m_destroyChain = pNode;
- }
-
- __forceinline void* BOOST_MEMORY_CALL unmanaged_alloc(size_t cb, int fnZero)
- {
- return allocate(cb);
- }
-
- __forceinline void BOOST_MEMORY_CALL manage(void* p, int fnZero)
- {
- // no action
- }
-
- void* BOOST_MEMORY_CALL reallocate(void* p, size_t oldSize, size_t newSize)
- {
- if (oldSize >= newSize)
- return p;
- void* p2 = allocate(newSize);
- memcpy(p2, p, oldSize);
- return p2;
- }
-
- void BOOST_MEMORY_CALL deallocate(void* p, size_t cb)
- {
- // no action
- }
-
- template <class Type>
- void BOOST_MEMORY_CALL destroy(Type* obj)
- {
- // no action
- }
-
- template <class Type>
- void BOOST_MEMORY_CALL destroyArray(Type* array, size_t count)
- {
- // no action
- }
-};
-
 // -------------------------------------------------------------------------
-// class auto_alloc
-
-#if defined(_MSC_VER) && (_MSC_VER <= 1200) // VC++ 6.0
-
-class auto_alloc : public region_alloc<NS_BOOST_MEMORY_POLICY::stdlib>
-{
-private:
- typedef region_alloc<NS_BOOST_MEMORY_POLICY::stdlib> BaseClass;
-
-public:
- auto_alloc() {}
- explicit auto_alloc(auto_alloc&) {}
-
- __forceinline void BOOST_MEMORY_CALL swap(auto_alloc& o) {
- BaseClass::swap(o);
- }
-
- __forceinline void BOOST_MEMORY_CALL clear() {
- BaseClass::clear();
- }
-
- __forceinline void* BOOST_MEMORY_CALL allocate(size_t cb) {
- return BaseClass::allocate(cb);
- }
-
-#if defined(BOOST_MEMORY_NO_STRICT_EXCEPTION_SEMANTICS)
- __forceinline void* BOOST_MEMORY_CALL allocate(size_t cb, int fnZero) {
- return BaseClass::allocate(cb);
- }
-
- __forceinline void* BOOST_MEMORY_CALL allocate(size_t cb, destructor_t fn) {
- return BaseClass::allocate(cb, fn);
- }
-#endif
-
- __forceinline void* BOOST_MEMORY_CALL unmanaged_alloc(size_t cb, destructor_t fn) {
- return BaseClass::unmanaged_alloc(cb, fn);
- }
-
- __forceinline void BOOST_MEMORY_CALL manage(void* p, destructor_t fn) {
- BaseClass::manage(p, fn);
- }
-
- __forceinline void* BOOST_MEMORY_CALL unmanaged_alloc(size_t cb, int fnZero) {
- return BaseClass::allocate(cb);
- }
-
- __forceinline void BOOST_MEMORY_CALL manage(void* p, int fnZero) {
- // no action
- }
-
- void* BOOST_MEMORY_CALL reallocate(void* p, size_t oldSize, size_t newSize) {
- return BaseClass::reallocate(p, oldSize, newSize);
- }
-
- void BOOST_MEMORY_CALL deallocate(void* p, size_t cb) {
- // no action
- }
-
- template <class Type>
- void BOOST_MEMORY_CALL destroy(Type* obj) {
- // no action
- }
-
- template <class Type>
- void BOOST_MEMORY_CALL destroyArray(Type* array, size_t count) {
- // no action
- }
-};
-
-#else
-
-typedef region_alloc<NS_BOOST_MEMORY_POLICY::stdlib> auto_alloc;
 
+#ifndef BOOST_MEMORY_REGION_ALLOC_HPP
+#include "region_alloc.hpp"
 #endif
 
 // -------------------------------------------------------------------------
 // $Log: auto_alloc.hpp,v $
 
-NS_BOOST_MEMORY_END
-
 #endif /* BOOST_MEMORY_AUTO_ALLOC_HPP */

Added: sandbox/memory/boost/memory/block_pool.hpp
==============================================================================
--- (empty file)
+++ sandbox/memory/boost/memory/block_pool.hpp 2009-04-22 00:56:47 EDT (Wed, 22 Apr 2009)
@@ -0,0 +1,203 @@
+//
+// boost/memory/block_pool.hpp
+//
+// Copyright (c) 2004 - 2008 xushiwei (xushiweizh_at_[hidden])
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/memory/index.htm for documentation.
+//
+#ifndef BOOST_MEMORY_BLOCKPOOL_HPP
+#define BOOST_MEMORY_BLOCKPOOL_HPP
+
+#ifndef BOOST_MEMORY_BASIC_HPP
+#include "basic.hpp"
+#endif
+
+#ifndef BOOST_MEMORY_THREAD_TLS_HPP
+#include "thread/tls.hpp"
+#endif
+
+#if !defined(_CLIMITS_) && !defined(_CLIMITS)
+#include <climits> // INT_MAX
+#endif
+
+NS_BOOST_MEMORY_BEGIN
+
+// -------------------------------------------------------------------------
+// class proxy_alloc
+
+template <class AllocT, class TlsAllocT>
+class proxy_alloc
+{
+private:
+ AllocT* m_alloc;
+
+public:
+ proxy_alloc(AllocT& alloc) : m_alloc(&alloc) {}
+ proxy_alloc() : m_alloc(&TlsAllocT::instance()) {}
+
+public:
+ enum { Padding = AllocT::Padding };
+
+public:
+ void* BOOST_MEMORY_CALL allocate(size_t cb) { return m_alloc->allocate(cb); }
+ void BOOST_MEMORY_CALL deallocate(void* p) { m_alloc->deallocate(p); }
+ void BOOST_MEMORY_CALL swap(proxy_alloc& o) { std::swap(m_alloc, o.m_alloc); }
+ size_t BOOST_MEMORY_CALL alloc_size(void* p) const { return m_alloc->alloc_size(p); }
+};
+
+// -------------------------------------------------------------------------
+// class block_pool
+
+template <class PolicyT>
+class block_pool_
+{
+private:
+ typedef typename PolicyT::alloc_type AllocT;
+ enum { m_cbBlock = PolicyT::MemBlockBytes - AllocT::Padding };
+
+#pragma pack(1)
+ struct Block {
+ Block* next;
+ };
+#pragma pack()
+
+ Block* m_freeList;
+
+ int m_nFree;
+ const int m_nFreeLimit;
+
+private:
+ block_pool_(const block_pool_&);
+ void operator=(const block_pool_&);
+
+public:
+ block_pool_(int cbFreeLimit = INT_MAX)
+ : m_freeList(NULL), m_nFree(0),
+ m_nFreeLimit(cbFreeLimit / m_cbBlock + 1)
+ {
+ }
+ ~block_pool_()
+ {
+ clear();
+ }
+
+public:
+ enum { Padding = AllocT::Padding };
+
+public:
+ void* BOOST_MEMORY_CALL allocate(size_t cb)
+ {
+ BOOST_MEMORY_ASSERT(cb >= (size_t)m_cbBlock);
+
+ if (cb > (size_t)m_cbBlock)
+ return AllocT::allocate(cb);
+ else
+ {
+ if (m_freeList)
+ {
+ BOOST_MEMORY_ASSERT(AllocT::alloc_size(m_freeList) >= cb);
+ Block* blk = m_freeList;
+ m_freeList = blk->next;
+ --m_nFree;
+ return blk;
+ }
+ return AllocT::allocate(m_cbBlock);
+ }
+ }
+
+ void BOOST_MEMORY_CALL deallocate(void* p)
+ {
+ if (m_nFree >= m_nFreeLimit) {
+ AllocT::deallocate(p);
+ }
+ else {
+ Block* blk = (Block*)p;
+ blk->next = m_freeList;
+ m_freeList = blk;
+ ++m_nFree;
+ }
+ }
+
+ static size_t BOOST_MEMORY_CALL alloc_size(void* p)
+ {
+ return AllocT::alloc_size(p);
+ }
+
+ void BOOST_MEMORY_CALL clear()
+ {
+ while (m_freeList)
+ {
+ Block* blk = m_freeList;
+ m_freeList = blk->next;
+ AllocT::deallocate(blk);
+ }
+ m_nFree = 0;
+ }
+};
+
+typedef block_pool_<NS_BOOST_MEMORY_POLICY::sys> block_pool;
+
+// -------------------------------------------------------------------------
+// class tls_block_pool
+
+typedef tls_object<block_pool> tls_block_pool_t;
+
+STDAPI_(tls_block_pool_t*) boost_TlsBlockPool();
+
+template <class Unused>
+class tls_block_pool_
+{
+private:
+ static tls_block_pool_t* g_blockPool;
+
+public:
+ tls_block_pool_() {
+ init();
+ }
+ ~tls_block_pool_() {
+ term();
+ }
+
+ static void BOOST_MEMORY_CALL init() {
+ g_blockPool->init();
+ }
+
+ static void BOOST_MEMORY_CALL term() {
+ g_blockPool->term();
+ }
+
+ static block_pool& BOOST_MEMORY_CALL instance() {
+ return g_blockPool->get();
+ }
+};
+
+template <class Unused>
+tls_block_pool_t* tls_block_pool_<Unused>::g_blockPool = boost_TlsBlockPool();
+
+typedef tls_block_pool_<int> tls_block_pool;
+
+// -------------------------------------------------------------------------
+// class pool
+
+typedef proxy_alloc<block_pool, tls_block_pool> proxy_block_pool;
+
+NS_BOOST_MEMORY_POLICY_BEGIN
+
+class pool : public sys
+{
+public:
+ typedef proxy_block_pool alloc_type;
+};
+
+NS_BOOST_MEMORY_POLICY_END
+
+// -------------------------------------------------------------------------
+// $Log: $
+
+NS_BOOST_MEMORY_END
+
+#endif /* BOOST_MEMORY_BLOCKPOOL_HPP */

Added: sandbox/memory/boost/memory/region_alloc.hpp
==============================================================================
--- (empty file)
+++ sandbox/memory/boost/memory/region_alloc.hpp 2009-04-22 00:56:47 EDT (Wed, 22 Apr 2009)
@@ -0,0 +1,327 @@
+//
+// boost/memory/region_alloc.hpp
+//
+// Copyright (c) 2004 - 2008 xushiwei (xushiweizh_at_[hidden])
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/memory/index.htm for documentation.
+//
+#ifndef BOOST_MEMORY_REGION_ALLOC_HPP
+#define BOOST_MEMORY_REGION_ALLOC_HPP
+
+#ifndef BOOST_MEMORY_SYSTEM_ALLOC_HPP
+#include "system_alloc.hpp"
+#endif
+
+#ifndef BOOST_MEMORY_BLOCKPOOL_HPP
+#include "block_pool.hpp"
+#endif
+
+#if !defined(_GLIBCXX_ALGORITHM) && !defined(_ALGORITHM)
+#include <algorithm> // std::swap
+#endif
+
+NS_BOOST_MEMORY_BEGIN
+
+// -------------------------------------------------------------------------
+// class region_alloc
+
+template <class PolicyT>
+class region_alloc
+{
+private:
+ typedef typename PolicyT::alloc_type AllocT;
+
+public:
+ enum { MemBlockSize = PolicyT::MemBlockBytes - AllocT::Padding };
+ enum { IsGCAllocator = 1 };
+
+ typedef AllocT alloc_type;
+
+private:
+ enum { HeaderSize = sizeof(void*) };
+ enum { BlockSize = MemBlockSize - HeaderSize };
+
+#pragma pack(1)
+private:
+ struct MemBlock;
+ friend struct MemBlock;
+
+ struct MemBlock
+ {
+ MemBlock* pPrev;
+ char buffer[BlockSize];
+ };
+ struct DestroyNode
+ {
+ DestroyNode* pPrev;
+ destructor_t fnDestroy;
+ };
+#pragma pack()
+
+ char* m_begin;
+ char* m_end;
+ AllocT m_alloc;
+ DestroyNode* m_destroyChain;
+
+private:
+ const region_alloc& operator=(const region_alloc&);
+
+ MemBlock* BOOST_MEMORY_CALL chainHeader_() const
+ {
+ return (MemBlock*)(m_begin - HeaderSize);
+ }
+
+ void BOOST_MEMORY_CALL init_()
+ {
+ MemBlock* pNew = (MemBlock*)m_alloc.allocate(sizeof(MemBlock));
+ pNew->pPrev = NULL;
+ m_begin = pNew->buffer;
+ m_end = (char*)pNew + m_alloc.alloc_size(pNew);
+ }
+
+public:
+ region_alloc() : m_destroyChain(NULL)
+ {
+ init_();
+ }
+ explicit region_alloc(AllocT alloc) : m_alloc(alloc), m_destroyChain(NULL)
+ {
+ init_();
+ }
+ explicit region_alloc(region_alloc& owner)
+ : m_alloc(owner.m_alloc), m_destroyChain(NULL)
+ {
+ init_();
+ }
+
+ ~region_alloc()
+ {
+ clear();
+ }
+
+ void BOOST_MEMORY_CALL swap(region_alloc& o)
+ {
+ std::swap(m_begin, o.m_begin);
+ std::swap(m_end, o.m_end);
+ std::swap(m_destroyChain, o.m_destroyChain);
+ m_alloc.swap(o.m_alloc);
+ }
+
+ void BOOST_MEMORY_CALL clear()
+ {
+ while (m_destroyChain)
+ {
+ DestroyNode* curr = m_destroyChain;
+ m_destroyChain = m_destroyChain->pPrev;
+ curr->fnDestroy(curr + 1);
+ }
+ MemBlock* pHeader = chainHeader_();
+ while (pHeader)
+ {
+ MemBlock* curr = pHeader;
+ pHeader = pHeader->pPrev;
+ m_alloc.deallocate(curr);
+ }
+ m_begin = m_end = (char*)HeaderSize;
+ }
+
+private:
+ void* BOOST_MEMORY_CALL do_allocate_(size_t cb)
+ {
+ if (cb >= BlockSize)
+ {
+ MemBlock* pHeader = chainHeader_();
+ MemBlock* pNew = (MemBlock*)m_alloc.allocate(HeaderSize + cb);
+ if (pHeader)
+ {
+ pNew->pPrev = pHeader->pPrev;
+ pHeader->pPrev = pNew;
+ }
+ else
+ {
+ m_end = m_begin = pNew->buffer;
+ pNew->pPrev = NULL;
+ }
+ return pNew->buffer;
+ }
+ else
+ {
+ MemBlock* pNew = (MemBlock*)m_alloc.allocate(sizeof(MemBlock));
+ pNew->pPrev = chainHeader_();
+ m_begin = pNew->buffer;
+ m_end = (char*)pNew + m_alloc.alloc_size(pNew);
+ return m_end -= cb;
+ }
+ }
+
+public:
+ __forceinline void* BOOST_MEMORY_CALL allocate(size_t cb)
+ {
+ if ((size_t)(m_end - m_begin) >= cb)
+ {
+ return m_end -= cb;
+ }
+ return do_allocate_(cb);
+ }
+
+#if defined(BOOST_MEMORY_NO_STRICT_EXCEPTION_SEMANTICS)
+ __forceinline void* BOOST_MEMORY_CALL allocate(size_t cb, int fnZero)
+ {
+ return allocate(cb);
+ }
+
+ __forceinline void* BOOST_MEMORY_CALL allocate(size_t cb, destructor_t fn)
+ {
+ DestroyNode* pNode = (DestroyNode*)allocate(sizeof(DestroyNode) + cb);
+ pNode->fnDestroy = fn;
+ pNode->pPrev = m_destroyChain;
+ m_destroyChain = pNode;
+ return pNode + 1;
+ }
+#endif
+
+ __forceinline void* BOOST_MEMORY_CALL unmanaged_alloc(size_t cb, destructor_t fn)
+ {
+ DestroyNode* pNode = (DestroyNode*)allocate(sizeof(DestroyNode) + cb);
+ pNode->fnDestroy = fn;
+ return pNode + 1;
+ }
+
+ __forceinline void BOOST_MEMORY_CALL manage(void* p, destructor_t fn)
+ {
+ DestroyNode* pNode = (DestroyNode*)p - 1;
+ BOOST_MEMORY_ASSERT(pNode->fnDestroy == fn);
+
+ pNode->pPrev = m_destroyChain;
+ m_destroyChain = pNode;
+ }
+
+ __forceinline void* BOOST_MEMORY_CALL unmanaged_alloc(size_t cb, int fnZero)
+ {
+ return allocate(cb);
+ }
+
+ __forceinline void BOOST_MEMORY_CALL manage(void* p, int fnZero)
+ {
+ // no action
+ }
+
+ void* BOOST_MEMORY_CALL reallocate(void* p, size_t oldSize, size_t newSize)
+ {
+ if (oldSize >= newSize)
+ return p;
+ void* p2 = allocate(newSize);
+ memcpy(p2, p, oldSize);
+ return p2;
+ }
+
+ void BOOST_MEMORY_CALL deallocate(void* p, size_t cb)
+ {
+ // no action
+ }
+
+ template <class Type>
+ void BOOST_MEMORY_CALL destroy(Type* obj)
+ {
+ // no action
+ }
+
+ template <class Type>
+ void BOOST_MEMORY_CALL destroyArray(Type* array, size_t count)
+ {
+ // no action
+ }
+};
+
+// -------------------------------------------------------------------------
+// class auto_alloc
+
+#if defined(_MSC_VER) && (_MSC_VER <= 1200) // VC++ 6.0
+
+class auto_alloc : public region_alloc<NS_BOOST_MEMORY_POLICY::stdlib>
+{
+private:
+ typedef region_alloc<NS_BOOST_MEMORY_POLICY::stdlib> BaseClass;
+
+public:
+ auto_alloc() {}
+ explicit auto_alloc(auto_alloc&) {}
+
+ __forceinline void BOOST_MEMORY_CALL swap(auto_alloc& o) {
+ BaseClass::swap(o);
+ }
+
+ __forceinline void BOOST_MEMORY_CALL clear() {
+ BaseClass::clear();
+ }
+
+ __forceinline void* BOOST_MEMORY_CALL allocate(size_t cb) {
+ return BaseClass::allocate(cb);
+ }
+
+#if defined(BOOST_MEMORY_NO_STRICT_EXCEPTION_SEMANTICS)
+ __forceinline void* BOOST_MEMORY_CALL allocate(size_t cb, int fnZero) {
+ return BaseClass::allocate(cb);
+ }
+
+ __forceinline void* BOOST_MEMORY_CALL allocate(size_t cb, destructor_t fn) {
+ return BaseClass::allocate(cb, fn);
+ }
+#endif
+
+ __forceinline void* BOOST_MEMORY_CALL unmanaged_alloc(size_t cb, destructor_t fn) {
+ return BaseClass::unmanaged_alloc(cb, fn);
+ }
+
+ __forceinline void BOOST_MEMORY_CALL manage(void* p, destructor_t fn) {
+ BaseClass::manage(p, fn);
+ }
+
+ __forceinline void* BOOST_MEMORY_CALL unmanaged_alloc(size_t cb, int fnZero) {
+ return BaseClass::allocate(cb);
+ }
+
+ __forceinline void BOOST_MEMORY_CALL manage(void* p, int fnZero) {
+ // no action
+ }
+
+ void* BOOST_MEMORY_CALL reallocate(void* p, size_t oldSize, size_t newSize) {
+ return BaseClass::reallocate(p, oldSize, newSize);
+ }
+
+ void BOOST_MEMORY_CALL deallocate(void* p, size_t cb) {
+ // no action
+ }
+
+ template <class Type>
+ void BOOST_MEMORY_CALL destroy(Type* obj) {
+ // no action
+ }
+
+ template <class Type>
+ void BOOST_MEMORY_CALL destroyArray(Type* array, size_t count) {
+ // no action
+ }
+};
+
+#else
+
+typedef region_alloc<NS_BOOST_MEMORY_POLICY::stdlib> auto_alloc;
+
+#endif
+
+// -------------------------------------------------------------------------
+// class scoped_alloc
+
+typedef region_alloc<NS_BOOST_MEMORY_POLICY::pool> scoped_alloc;
+
+// -------------------------------------------------------------------------
+// $Log: region_alloc.hpp,v $
+
+NS_BOOST_MEMORY_END
+
+#endif /* BOOST_MEMORY_REGION_ALLOC_HPP */

Modified: sandbox/memory/boost/memory/scoped_alloc.hpp
==============================================================================
--- sandbox/memory/boost/memory/scoped_alloc.hpp (original)
+++ sandbox/memory/boost/memory/scoped_alloc.hpp 2009-04-22 00:56:47 EDT (Wed, 22 Apr 2009)
@@ -12,201 +12,13 @@
 #ifndef BOOST_MEMORY_SCOPED_ALLOC_HPP
 #define BOOST_MEMORY_SCOPED_ALLOC_HPP
 
-#ifndef BOOST_MEMORY_BASIC_HPP
-#include "basic.hpp"
-#endif
-
-#ifndef BOOST_MEMORY_AUTO_ALLOC_HPP
-#include "auto_alloc.hpp"
-#endif
-
-#ifndef BOOST_MEMORY_THREAD_TLS_HPP
-#include "thread/tls.hpp"
-#endif
-
-#if !defined(_CLIMITS_) && !defined(_CLIMITS)
-#include <climits> // INT_MAX
-#endif
-
-NS_BOOST_MEMORY_BEGIN
-
-// -------------------------------------------------------------------------
-// class proxy_alloc
-
-template <class AllocT, class TlsAllocT>
-class proxy_alloc
-{
-private:
- AllocT* m_alloc;
-
-public:
- proxy_alloc(AllocT& alloc) : m_alloc(&alloc) {}
- proxy_alloc() : m_alloc(&TlsAllocT::instance()) {}
-
-public:
- enum { Padding = AllocT::Padding };
-
-public:
- void* BOOST_MEMORY_CALL allocate(size_t cb) { return m_alloc->allocate(cb); }
- void BOOST_MEMORY_CALL deallocate(void* p) { m_alloc->deallocate(p); }
- void BOOST_MEMORY_CALL swap(proxy_alloc& o) { std::swap(m_alloc, o.m_alloc); }
- size_t BOOST_MEMORY_CALL alloc_size(void* p) const { return m_alloc->alloc_size(p); }
-};
-
-// -------------------------------------------------------------------------
-// class block_pool
-
-template <class PolicyT>
-class block_pool_
-{
-private:
- typedef typename PolicyT::alloc_type AllocT;
- enum { m_cbBlock = PolicyT::MemBlockBytes - AllocT::Padding };
-
-#pragma pack(1)
- struct Block {
- Block* next;
- };
-#pragma pack()
-
- Block* m_freeList;
-
- int m_nFree;
- const int m_nFreeLimit;
-
-private:
- block_pool_(const block_pool_&);
- void operator=(const block_pool_&);
-
-public:
- block_pool_(int cbFreeLimit = INT_MAX)
- : m_freeList(NULL), m_nFree(0),
- m_nFreeLimit(cbFreeLimit / m_cbBlock + 1)
- {
- }
- ~block_pool_()
- {
- clear();
- }
-
-public:
- enum { Padding = AllocT::Padding };
-
-public:
- void* BOOST_MEMORY_CALL allocate(size_t cb)
- {
- BOOST_MEMORY_ASSERT(cb >= (size_t)m_cbBlock);
-
- if (cb > (size_t)m_cbBlock)
- return AllocT::allocate(cb);
- else
- {
- if (m_freeList)
- {
- BOOST_MEMORY_ASSERT(AllocT::alloc_size(m_freeList) >= cb);
- Block* blk = m_freeList;
- m_freeList = blk->next;
- --m_nFree;
- return blk;
- }
- return AllocT::allocate(m_cbBlock);
- }
- }
-
- void BOOST_MEMORY_CALL deallocate(void* p)
- {
- if (m_nFree >= m_nFreeLimit) {
- AllocT::deallocate(p);
- }
- else {
- Block* blk = (Block*)p;
- blk->next = m_freeList;
- m_freeList = blk;
- ++m_nFree;
- }
- }
-
- static size_t BOOST_MEMORY_CALL alloc_size(void* p)
- {
- return AllocT::alloc_size(p);
- }
-
- void BOOST_MEMORY_CALL clear()
- {
- while (m_freeList)
- {
- Block* blk = m_freeList;
- m_freeList = blk->next;
- AllocT::deallocate(blk);
- }
- m_nFree = 0;
- }
-};
-
-typedef block_pool_<NS_BOOST_MEMORY_POLICY::sys> block_pool;
-
-// -------------------------------------------------------------------------
-// class tls_block_pool
-
-typedef tls_object<block_pool> tls_block_pool_t;
-
-STDAPI_(tls_block_pool_t*) _boost_TlsBlockPool();
-
-template <class Unused>
-class tls_block_pool_
-{
-private:
- static tls_block_pool_t* _tls_blockPool;
-
-public:
- tls_block_pool_() {
- init();
- }
- ~tls_block_pool_() {
- term();
- }
-
- static void BOOST_MEMORY_CALL init() {
- _tls_blockPool->init();
- }
-
- static void BOOST_MEMORY_CALL term() {
- _tls_blockPool->term();
- }
-
- static block_pool& BOOST_MEMORY_CALL instance() {
- return _tls_blockPool->get();
- }
-};
-
-template <class Unused>
-tls_block_pool_t* tls_block_pool_<Unused>::_tls_blockPool = _boost_TlsBlockPool();
-
-typedef tls_block_pool_<int> tls_block_pool;
-
-// -------------------------------------------------------------------------
-// class pool
-
-typedef proxy_alloc<block_pool, tls_block_pool> proxy_block_pool;
-
-NS_BOOST_MEMORY_POLICY_BEGIN
-
-class pool : public sys
-{
-public:
- typedef proxy_block_pool alloc_type;
-};
-
-NS_BOOST_MEMORY_POLICY_END
-
 // -------------------------------------------------------------------------
-// class scoped_alloc
 
-typedef region_alloc<NS_BOOST_MEMORY_POLICY::pool> scoped_alloc;
+#ifndef BOOST_MEMORY_REGION_ALLOC_HPP
+#include "region_alloc.hpp"
+#endif
 
 // -------------------------------------------------------------------------
-// $Log: $
-
-NS_BOOST_MEMORY_END
+// $Log: scoped_alloc.hpp,v $
 
 #endif /* BOOST_MEMORY_SCOPED_ALLOC_HPP */

Modified: sandbox/memory/libs/memory/build/build.def
==============================================================================
--- sandbox/memory/libs/memory/build/build.def (original)
+++ sandbox/memory/libs/memory/build/build.def 2009-04-22 00:56:47 EDT (Wed, 22 Apr 2009)
@@ -1,3 +1,2 @@
 EXPORTS
- _boost_TlsBlockPool
-
+ boost_TlsBlockPool

Modified: sandbox/memory/libs/memory/src/block_pool.cpp
==============================================================================
--- sandbox/memory/libs/memory/src/block_pool.cpp (original)
+++ sandbox/memory/libs/memory/src/block_pool.cpp 2009-04-22 00:56:47 EDT (Wed, 22 Apr 2009)
@@ -18,7 +18,7 @@
 
 tls_block_pool_t g_tls_blockPool;
 
-STDAPI_(tls_block_pool_t*) _boost_TlsBlockPool()
+STDAPI_(tls_block_pool_t*) boost_TlsBlockPool()
 {
         return &g_tls_blockPool;
 }

Deleted: sandbox/memory/libs/memory/src/gc_alloc.cpp
==============================================================================
--- sandbox/memory/libs/memory/src/gc_alloc.cpp 2009-04-22 00:56:47 EDT (Wed, 22 Apr 2009)
+++ (empty file)
@@ -1,39 +0,0 @@
-//
-// boost/memory/block_pool.cpp
-//
-// Copyright (c) 2004 - 2008 xushiwei (xushiweizh_at_[hidden])
-//
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-//
-// See http://www.boost.org/libs/memory/index.htm for documentation.
-//
-#include "stdafx.h"
-#include <boost/memory/tls_gc_alloc.hpp>
-
-// -------------------------------------------------------------------------
-
-using namespace NS_BOOST_MEMORY;
-
-tls_gc_alloc_t g_tls_gcAlloc;
-
-STDAPI_(tls_gc_alloc_t*) _boost_TlsGcAlloc()
-{
- return &g_tls_gcAlloc;
-}
-
-// -------------------------------------------------------------------------
-// class tls_gc_alloc_init
-
-class tls_gc_alloc_init
-{
-public:
- tls_gc_alloc_init() { g_tls_gcAlloc.init(); }
- ~tls_gc_alloc_init() { g_tls_gcAlloc.term(); }
-};
-
-tls_gc_alloc_init g_tls_gcAllocInit;
-
-// -------------------------------------------------------------------------
-// $Log: $


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