|
Boost-Commit : |
From: xushiweizh_at_[hidden]
Date: 2008-05-21 03:52:49
Author: xushiwei
Date: 2008-05-21 03:52:48 EDT (Wed, 21 May 2008)
New Revision: 45599
URL: http://svn.boost.org/trac/boost/changeset/45599
Log:
class tls_gc_alloc
Added:
sandbox/memory/boost/memory/tls_gc_alloc.hpp (contents, props changed)
Binary files modified:
sandbox/memory/libs/memory/bin/win32/boost-memory.dll
sandbox/memory/libs/memory/lib/boost-memory.lib
Text files modified:
sandbox/memory/boost/memory.hpp | 4 ++++
sandbox/memory/boost/memory/gc_alloc.hpp | 10 +++++-----
sandbox/memory/boost/memory/system_pool.hpp | 13 -------------
sandbox/memory/libs/memory/memory.dsp | 4 ++++
sandbox/memory/libs/memory/memory_w32.def | 1 +
5 files changed, 14 insertions(+), 18 deletions(-)
Modified: sandbox/memory/boost/memory.hpp
==============================================================================
--- sandbox/memory/boost/memory.hpp (original)
+++ sandbox/memory/boost/memory.hpp 2008-05-21 03:52:48 EDT (Wed, 21 May 2008)
@@ -30,6 +30,10 @@
#include "memory/gc_alloc.hpp"
#endif
+#ifndef BOOST_MEMORY_TLS_GC_ALLOC_HPP
+#include "memory/tls_gc_alloc.hpp"
+#endif
+
// -------------------------------------------------------------------------
// class stl_allocator
Modified: sandbox/memory/boost/memory/gc_alloc.hpp
==============================================================================
--- sandbox/memory/boost/memory/gc_alloc.hpp (original)
+++ sandbox/memory/boost/memory/gc_alloc.hpp 2008-05-21 03:52:48 EDT (Wed, 21 May 2008)
@@ -334,7 +334,7 @@
pNode->getNodeType() == nodeAlloced &&
_null.begin() == m_begin && m_begin == m_end);
- pNode->dataMemHeader = sizeof(FreeMemHeader) + (m_end - m_begin);
+ pNode->dataMemHeader = sizeof(FreeMemHeader) + (HeaderSizeT)(m_end - m_begin);
}
FreeMemHeader* BOOST_MEMORY_CALL _newBlock(size_t cbBlock)
@@ -344,7 +344,7 @@
m_blockList = pBlock;
FreeMemHeader* pNew = (FreeMemHeader*)pBlock->buffer;
- pNew->dataMemHeader = m_alloc.alloc_size(pBlock) - HeaderSize;
+ pNew->dataMemHeader = (HeaderSizeT)(m_alloc.alloc_size(pBlock) - HeaderSize);
return pNew;
}
@@ -420,7 +420,7 @@
if ((size_t)(m_end - m_begin) >= cbData)
{
MemHeader* pAlloc = (MemHeader*)m_begin - 1;
- pAlloc->dataMemHeader = (nodeAlloced | (m_end - (char*)pAlloc));
+ pAlloc->dataMemHeader = (nodeAlloced | (HeaderSizeT)(m_end - (char*)pAlloc));
m_begin = m_end = _null.begin();
return pAlloc + 1;
}
@@ -456,7 +456,7 @@
BOOST_MEMORY_ASSERT((size_t)(m_end - m_begin) >= cb);
MemHeader* pAlloc = (MemHeader*)(m_end -= cb);
- pAlloc->dataMemHeader = (nodeAlloced | cb);
+ pAlloc->dataMemHeader = (nodeAlloced | (HeaderSizeT)cb);
return pAlloc + 1;
}
@@ -467,7 +467,7 @@
if ((size_t)(m_end - m_begin) >= cb)
{
MemHeader* pAlloc = (MemHeader*)(m_end -= cb);
- pAlloc->dataMemHeader = (nodeAlloced | cb);
+ pAlloc->dataMemHeader = (nodeAlloced | (HeaderSizeT)cb);
return pAlloc + 1;
}
return _do_allocate(cb, cbData);
Modified: sandbox/memory/boost/memory/system_pool.hpp
==============================================================================
--- sandbox/memory/boost/memory/system_pool.hpp (original)
+++ sandbox/memory/boost/memory/system_pool.hpp 2008-05-21 03:52:48 EDT (Wed, 21 May 2008)
@@ -175,19 +175,6 @@
system_pool_imp<PolicyT, StackT> system_pool_s<PolicyT, StackT>::s_impl;
// -------------------------------------------------------------------------
-// class system_pool
-
-NS_BOOST_MEMORY_POLICY_BEGIN
-
-class stdlib : public sys
-{
-public:
- typedef stdlib_alloc allocator_type;
-};
-
-NS_BOOST_MEMORY_POLICY_END
-
-// -------------------------------------------------------------------------
#if defined(BOOST_MEMORY_NO_LOCKFREE)
typedef system_pool_s<NS_BOOST_MEMORY_POLICY::stdlib, normal_stack> system_pool;
Added: sandbox/memory/boost/memory/tls_gc_alloc.hpp
==============================================================================
--- (empty file)
+++ sandbox/memory/boost/memory/tls_gc_alloc.hpp 2008-05-21 03:52:48 EDT (Wed, 21 May 2008)
@@ -0,0 +1,130 @@
+//
+// boost/memory/gc_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_TLS_GC_ALLOC_HPP
+#define BOOST_MEMORY_TLS_GC_ALLOC_HPP
+
+#ifndef BOOST_MEMORY_GC_ALLOC_HPP
+#include "gc_alloc.hpp"
+#endif
+
+NS_BOOST_MEMORY_BEGIN
+
+// -------------------------------------------------------------------------
+// class tls_gc_alloc
+
+typedef tls_object<gc_alloc> tls_gc_alloc_t;
+
+STDAPI_(tls_gc_alloc_t*) _boost_TlsGcAlloc();
+
+template <class Unused>
+class tls_gc_alloc_imp
+{
+private:
+ static tls_gc_alloc_t* _tls_gcAlloc;
+
+public:
+ typedef gc_alloc allocator_type;
+
+ tls_gc_alloc_imp() {
+ _tls_gcAlloc->init();
+ }
+ ~tls_gc_alloc_imp() {
+ _tls_gcAlloc->term();
+ }
+
+ static allocator_type& BOOST_MEMORY_CALL instance()
+ {
+ return _tls_gcAlloc->get();
+ }
+
+ static void BOOST_MEMORY_CALL clear()
+ {
+ _tls_gcAlloc->get().clear();
+ }
+
+ static void* BOOST_MEMORY_CALL allocate(const size_t cbData)
+ {
+ _tls_gcAlloc->get().allocate(cbData);
+ }
+
+ static void* BOOST_MEMORY_CALL allocate(const size_t cbData0, destructor_t fn)
+ {
+ _tls_gcAlloc->get().allocate(cbData0, fn);
+ }
+
+ static void* BOOST_MEMORY_CALL allocate(size_t cb, int fnZero)
+ {
+ return _tls_gcAlloc->get().allocate(cb);
+ }
+
+ static void* BOOST_MEMORY_CALL unmanaged_alloc(size_t cbData0, destructor_t fn)
+ {
+ return _tls_gcAlloc->get().unmanaged_alloc(cbData0, fn);
+ }
+
+ static void* BOOST_MEMORY_CALL manage(void* p, destructor_t fn)
+ {
+ return _tls_gcAlloc->get().manage(p, fn);
+ }
+
+ static void* BOOST_MEMORY_CALL unmanaged_alloc(size_t cb, int fnZero)
+ {
+ return _tls_gcAlloc->get().allocate(cb);
+ }
+
+ static void* BOOST_MEMORY_CALL manage(void* p, int fnZero)
+ {
+ return p;
+ }
+
+ static void BOOST_MEMORY_CALL deallocate(void* pData, const size_t cbData)
+ {
+ _tls_gcAlloc->get().deallocate(pData, cbData);
+ }
+
+ static void* BOOST_MEMORY_CALL reallocate(void* p, size_t oldSize, size_t newSize)
+ {
+ return _tls_gcAlloc->get().reallocate(p, oldSize, newSize);
+ }
+
+ template <class Type>
+ static void BOOST_MEMORY_CALL destroy(Type* obj)
+ {
+ _tls_gcAlloc->get().destroy(obj);
+ }
+
+ template <class Type>
+ static Type* BOOST_MEMORY_CALL newArray(size_t count, Type* zero)
+ {
+ return _tls_gcAlloc->get().newArray(count, zero);
+ }
+
+ template <class Type>
+ static void BOOST_MEMORY_CALL destroyArray(Type* array, size_t count)
+ {
+ return _tls_gcAlloc->get().destroyArray(array, count);
+ }
+
+ BOOST_MEMORY_FAKE_DBG_ALLOCATE_();
+};
+
+template <class Unused>
+tls_gc_alloc_t* tls_gc_alloc_imp<Unused>::_tls_gcAlloc = _boost_TlsGcAlloc();
+
+typedef tls_gc_alloc_imp<int> tls_gc_alloc;
+
+// -------------------------------------------------------------------------
+// $Log: tls_gc_alloc.hpp,v $
+
+NS_BOOST_MEMORY_END
+
+#endif /* BOOST_MEMORY_TLS_GC_ALLOC_HPP */
Modified: sandbox/memory/libs/memory/bin/win32/boost-memory.dll
==============================================================================
Binary files. No diff available.
Modified: sandbox/memory/libs/memory/lib/boost-memory.lib
==============================================================================
Binary files. No diff available.
Modified: sandbox/memory/libs/memory/memory.dsp
==============================================================================
--- sandbox/memory/libs/memory/memory.dsp (original)
+++ sandbox/memory/libs/memory/memory.dsp 2008-05-21 03:52:48 EDT (Wed, 21 May 2008)
@@ -125,6 +125,10 @@
# End Source File
# Begin Source File
+SOURCE=.\src\gc_alloc.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\src\system_pool.cpp
# End Source File
# End Group
Modified: sandbox/memory/libs/memory/memory_w32.def
==============================================================================
--- sandbox/memory/libs/memory/memory_w32.def (original)
+++ sandbox/memory/libs/memory/memory_w32.def 2008-05-21 03:52:48 EDT (Wed, 21 May 2008)
@@ -1,5 +1,6 @@
EXPORTS
_boost_TlsBlockPool
+ _boost_TlsGcAlloc
_boost_SystemPoolAlloc
_boost_SystemPoolFree
_boost_SystemPoolSize
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