Boost logo

Boost-Commit :

From: xushiweizh_at_[hidden]
Date: 2008-05-03 12:50:19


Author: xushiwei
Date: 2008-05-03 12:50:18 EDT (Sat, 03 May 2008)
New Revision: 45075
URL: http://svn.boost.org/trac/boost/changeset/45075

Log:
issue #1885: system_pool
Added:
   sandbox/memory/libs/memory/src/system_pool.cpp (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/basic.hpp | 12 ++++++++++++
   sandbox/memory/boost/memory/policy.hpp | 1 +
   sandbox/memory/boost/memory/scoped_alloc.hpp | 8 ++++++++
   sandbox/memory/boost/memory/system_alloc.hpp | 25 +++++++++++++++++++++++++
   sandbox/memory/boost/memory/threadmodel/multi_thread.hpp | 5 +++++
   sandbox/memory/boost/memory/threadmodel/single_thread.hpp | 3 +++
   sandbox/memory/libs/memory/memory.dsp | 4 ++++
   sandbox/memory/libs/memory/memory_w32.def | 3 +++
   sandbox/memory/libs/memory/src/block_pool.cpp | 2 +-
   9 files changed, 62 insertions(+), 1 deletions(-)

Modified: sandbox/memory/boost/memory/basic.hpp
==============================================================================
--- sandbox/memory/boost/memory/basic.hpp (original)
+++ sandbox/memory/boost/memory/basic.hpp 2008-05-03 12:50:18 EDT (Sat, 03 May 2008)
@@ -291,6 +291,18 @@
 #endif
 }
 
+template <class StrucType>
+inline bool BOOST_MEMORY_CALL isInitialized(const StrucType& stru)
+{
+ const char* p = (const char*)&stru;
+ for (size_t i = 0; i < sizeof(stru); ++i)
+ {
+ if (p[i] != 0)
+ return true;
+ }
+ return false;
+}
+
 NS_BOOST_MEMORY_END
 
 // =========================================================================

Modified: sandbox/memory/boost/memory/policy.hpp
==============================================================================
--- sandbox/memory/boost/memory/policy.hpp (original)
+++ sandbox/memory/boost/memory/policy.hpp 2008-05-03 12:50:18 EDT (Sat, 03 May 2008)
@@ -127,6 +127,7 @@
 public:
         enum { MemBlockSize = BOOST_MEMORY_BLOCK_SIZE };
         typedef system_alloc allocator_type;
+ typedef default_threadmodel threadmodel_type;
 
         enum { RecycleSizeMin = 256 };
         enum { AllocSizeBig = Default };

Modified: sandbox/memory/boost/memory/scoped_alloc.hpp
==============================================================================
--- sandbox/memory/boost/memory/scoped_alloc.hpp (original)
+++ sandbox/memory/boost/memory/scoped_alloc.hpp 2008-05-03 12:50:18 EDT (Sat, 03 May 2008)
@@ -142,6 +142,8 @@
 // -------------------------------------------------------------------------
 // class tls_block_pool
 
+#if !defined(BOOST_MEMORY_NO_SYSTEM_POOL_DYN_)
+
 typedef tls_object<block_pool> tls_block_pool_t;
 
 STDAPI_(tls_block_pool_t*) _boost_TlsBlockPool();
@@ -171,6 +173,12 @@
 
 typedef tls_block_pool_imp<int> tls_block_pool;
 
+#else
+
+class tls_block_pool {};
+
+#endif
+
 // -------------------------------------------------------------------------
 // class scoped_alloc
 

Modified: sandbox/memory/boost/memory/system_alloc.hpp
==============================================================================
--- sandbox/memory/boost/memory/system_alloc.hpp (original)
+++ sandbox/memory/boost/memory/system_alloc.hpp 2008-05-03 12:50:18 EDT (Sat, 03 May 2008)
@@ -127,9 +127,34 @@
 };
 
 // -------------------------------------------------------------------------
+// class system_pool_dyn
+
+STDAPI_(void*) _boost_SystemPoolAlloc(size_t cb);
+STDAPI_(void) _boost_SystemPoolFree(void* p);
+STDAPI_(size_t) _boost_SystemPoolSize(void* p);
+
+class system_pool_dyn
+{
+public:
+ static void* BOOST_MEMORY_CALL allocate(size_t cb) { return _boost_SystemPoolAlloc(cb); }
+ static void BOOST_MEMORY_CALL deallocate(void* p) { _boost_SystemPoolFree(p); }
+ static size_t BOOST_MEMORY_CALL alloc_size(void* p) {
+ return _boost_SystemPoolSize(p);
+ }
+};
+
+// -------------------------------------------------------------------------
 // class system_alloc
 
+#if defined(_WIN32) && defined(BOOST_MEMORY_NO_SYSTEM_POOL)
+#define BOOST_MEMORY_NO_SYSTEM_POOL_DYN_
+#endif
+
+#if !defined(BOOST_MEMORY_NO_SYSTEM_POOL_DYN_)
+typedef system_pool_dyn system_alloc;
+#else
 typedef stdlib_alloc system_alloc;
+#endif
 
 // -------------------------------------------------------------------------
 // $Log: $

Modified: sandbox/memory/boost/memory/threadmodel/multi_thread.hpp
==============================================================================
--- sandbox/memory/boost/memory/threadmodel/multi_thread.hpp (original)
+++ sandbox/memory/boost/memory/threadmodel/multi_thread.hpp 2008-05-03 12:50:18 EDT (Sat, 03 May 2008)
@@ -87,6 +87,11 @@
         {
                 LeaveCriticalSection(&m_cs);
         }
+
+ bool BOOST_MEMORY_CALL good() const
+ {
+ return isInitialized(m_cs);
+ }
 };
 
 // -------------------------------------------------------------------------

Modified: sandbox/memory/boost/memory/threadmodel/single_thread.hpp
==============================================================================
--- sandbox/memory/boost/memory/threadmodel/single_thread.hpp (original)
+++ sandbox/memory/boost/memory/threadmodel/single_thread.hpp 2008-05-03 12:50:18 EDT (Sat, 03 May 2008)
@@ -51,6 +51,9 @@
 public:
         void BOOST_MEMORY_CALL acquire() {}
         void BOOST_MEMORY_CALL release() {}
+ bool BOOST_MEMORY_CALL good() const {
+ return true;
+ }
 };
 
 // -------------------------------------------------------------------------

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-03 12:50:18 EDT (Sat, 03 May 2008)
@@ -94,6 +94,10 @@
 
 SOURCE=.\src\block_pool.cpp
 # End Source File
+# Begin Source File
+
+SOURCE=.\src\system_pool.cpp
+# End Source File
 # End Group
 # Begin Group "misc"
 

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-03 12:50:18 EDT (Sat, 03 May 2008)
@@ -1,2 +1,5 @@
 EXPORTS
         _boost_TlsBlockPool
+ _boost_SystemPoolAlloc
+ _boost_SystemPoolFree
+ _boost_SystemPoolSize

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 2008-05-03 12:50:18 EDT (Sat, 03 May 2008)
@@ -33,7 +33,7 @@
         ~tls_block_pool_init() { g_tls_blockPool.term(); }
 };
 
-tls_block_pool_init _tls_blockPoolInit;
+tls_block_pool_init g_tls_blockPoolInit;
 
 // -------------------------------------------------------------------------
 // $Log: $

Added: sandbox/memory/libs/memory/src/system_pool.cpp
==============================================================================
--- (empty file)
+++ sandbox/memory/libs/memory/src/system_pool.cpp 2008-05-03 12:50:18 EDT (Sat, 03 May 2008)
@@ -0,0 +1,40 @@
+//
+// boost/memory/system_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"
+
+// -------------------------------------------------------------------------
+
+#if defined(_WIN32)
+
+#include <boost/memory/system_pool.hpp>
+
+using namespace NS_BOOST_MEMORY;
+
+STDAPI_(void*) _boost_SystemPoolAlloc(size_t cb)
+{
+ return system_pool::allocate(cb);
+}
+
+STDAPI_(void) _boost_SystemPoolFree(void* p)
+{
+ system_pool::deallocate(p);
+}
+
+STDAPI_(size_t) _boost_SystemPoolSize(void* p)
+{
+ return system_pool::alloc_size(p);
+}
+
+#endif
+
+// -------------------------------------------------------------------------
+// $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