Boost logo

Boost-Commit :

From: igaztanaga_at_[hidden]
Date: 2007-10-21 05:02:25


Author: igaztanaga
Date: 2007-10-21 05:02:23 EDT (Sun, 21 Oct 2007)
New Revision: 40268
URL: http://svn.boost.org/trac/boost/changeset/40268

Log:
Doxygen bug workaround. Corrected Solaris errors. Experimental grow/shrink_to_fit for managed_shared_memory and managed_mapped_file.
Added:
   trunk/libs/interprocess/proj/vc7ide/managed_shared_memory.vcproj (contents, props changed)
   trunk/libs/interprocess/test/managed_shared_memory_test.cpp (contents, props changed)
Text files modified:
   trunk/libs/interprocess/doc/interprocess.qbk | 19 ---------
   trunk/libs/interprocess/example/doc_anonymous_upgradable_mutexA.cpp | 2
   trunk/libs/interprocess/proj/cygwin/MakeAll | 16 ++-----
   trunk/libs/interprocess/proj/vc7ide/Interprocess.sln | 8 ++++
   trunk/libs/interprocess/proj/vc7ide/interprocesslib.vcproj | 3 +
   trunk/libs/interprocess/test/deque_test.cpp | 2
   trunk/libs/interprocess/test/managed_mapped_file_test.cpp | 77 ++++++++++++++++++++++++++++++++++++++-
   trunk/libs/interprocess/test/mapped_file_test.cpp | 2
   trunk/libs/interprocess/test/named_allocation_test_template.hpp | 23 ++++++++---
   trunk/libs/interprocess/test/named_condition_test.cpp | 16 ++++++-
   trunk/libs/interprocess/test/named_mutex_test.cpp | 33 +++++++++++++++--
   trunk/libs/interprocess/test/named_recursive_mutex_test.cpp | 32 ++++++++++++++--
   trunk/libs/interprocess/test/named_semaphore_test.cpp | 24 ++++++++----
   trunk/libs/interprocess/test/named_upgradable_mutex_test.cpp | 39 ++++++++++++++++---
   trunk/libs/interprocess/test/node_pool_test.cpp | 1
   trunk/libs/interprocess/test/shared_memory_test.cpp | 2
   trunk/libs/interprocess/test/user_buffer_test.cpp | 2 +
   17 files changed, 231 insertions(+), 70 deletions(-)

Modified: trunk/libs/interprocess/doc/interprocess.qbk
==============================================================================
--- trunk/libs/interprocess/doc/interprocess.qbk (original)
+++ trunk/libs/interprocess/doc/interprocess.qbk 2007-10-21 05:02:23 EDT (Sun, 21 Oct 2007)
@@ -70,7 +70,6 @@
 * GCC 3.4.4 Cygwin
 * Intel 9.1 Windows XP
 * GCC 4.1.2 Linux
-* Codewarrior 9.4 Windows XP
 * GCC 3.4.3 Solaris 11
 * GCC 4.0 MacOs 10.4.1
 
@@ -6336,24 +6335,6 @@
 of this software for any purpose. It is provided "as is" without express or implied
 warranty.
 
-[*Boost.Interprocess] atomic integer manipulation functions are based on
-Apache Portable Runtime:
-
-Copyright 2000-2005 The Apache Software Foundation or its licensors, as
-applicable.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
 [endsect]
 
 [endsect]

Modified: trunk/libs/interprocess/example/doc_anonymous_upgradable_mutexA.cpp
==============================================================================
--- trunk/libs/interprocess/example/doc_anonymous_upgradable_mutexA.cpp (original)
+++ trunk/libs/interprocess/example/doc_anonymous_upgradable_mutexA.cpp 2007-10-21 05:02:23 EDT (Sun, 21 Oct 2007)
@@ -74,4 +74,4 @@
 
    return 0;
 }
-//]
\ No newline at end of file
+//]

Modified: trunk/libs/interprocess/proj/cygwin/MakeAll
==============================================================================
--- trunk/libs/interprocess/proj/cygwin/MakeAll (original)
+++ trunk/libs/interprocess/proj/cygwin/MakeAll 2007-10-21 05:02:23 EDT (Sun, 21 Oct 2007)
@@ -5,23 +5,17 @@
 
 BOOST_ROOT=../../../..
 
-INTERPROCESS_CPP := $(wildcard ../../src/*.cpp)
-INTERPROCESS_OBJ := $(patsubst ../../src/%.cpp, lib_%.o, $(INTERPROCESS_CPP))
-
 INTERPROCESSTEST_CPP := $(wildcard ../../test/*.cpp)
 INTERPROCESSTEST_OUT := $(patsubst ../../test/%.cpp, ../../bin/cygwin/test_%.out, $(INTERPROCESSTEST_CPP))
 
-INTERPROCESSEXAMPLE_CPP := $(wildcard ../../example/*.cpp)
-INTERPROCESSEXAMPLE_OUT := $(patsubst ../../example/%.cpp, ../../bin/cygwin/ex_%.out, $(INTERPROCESSEXAMPLE_CPP))
-
-INTERPROCESSEXAMPLE_CPP := $(wildcard ../../example/*.cpp)
-INTERPROCESSEXAMPLE_OUT := $(patsubst ../../example/%.cpp, ../../bin/cygwin/ex__%.out, $(INTERPROCESSEXAMPLE_CPP))
+#INTERPROCESSEXAMPLE_CPP := $(wildcard ../../example/*.cpp)
+#INTERPROCESSEXAMPLE_OUT := $(patsubst ../../example/%.cpp, ../../bin/cygwin/ex_%.out, $(INTERPROCESSEXAMPLE_CPP))
 
 LIBDIR:= ../../../../stage/lib
 
 .PHONY: createdir clean
  
-all: createdir $(INTERPROCESSEXAMPLE_OUT) $(INTERPROCESSTEST_OUT) $(INTERPROCESSEXAMPLE_OUT)
+all: createdir $(INTERPROCESSEXAMPLE_OUT) $(INTERPROCESSTEST_OUT)
         @cd .
 
 createdir:
@@ -30,8 +24,8 @@
 ../../bin/cygwin/test_%.out: ../../test/%.cpp
         $(CC) -g $< -Wall -DBOOST_DATE_TIME_NO_LIB -L$(LIBDIR) -lboost_thread-gcc-mt -I$(BOOST_ROOT) -lstdc++ -o $@
 
-../../bin/cygwin/ex_%.out: ../../example/%.cpp
- $(CC) -g $< -Wall -DBOOST_DATE_TIME_NO_LIB -L$(LIBDIR)-lboost_thread-gcc-mt -I$(BOOST_ROOT) -lstdc++ -o $@
+#../../bin/cygwin/ex_%.out: ../../example/%.cpp
+# $(CC) -g $< -Wall -DBOOST_DATE_TIME_NO_LIB -L$(LIBDIR)-lboost_thread-gcc-mt -I$(BOOST_ROOT) -lstdc++ -o $@
 
 
 clean:

Modified: trunk/libs/interprocess/proj/vc7ide/Interprocess.sln
==============================================================================
--- trunk/libs/interprocess/proj/vc7ide/Interprocess.sln (original)
+++ trunk/libs/interprocess/proj/vc7ide/Interprocess.sln 2007-10-21 05:02:23 EDT (Sun, 21 Oct 2007)
@@ -403,6 +403,10 @@
         ProjectSection(ProjectDependencies) = postProject
         EndProjectSection
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "managed_shared_memory_test", "managed_shared_memory.vcproj", "{58DF28E3-0926-F47A-E28A-B03A4D619631}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
 Global
         GlobalSection(SolutionConfiguration) = preSolution
                 Debug = Debug
@@ -815,6 +819,10 @@
                 {51CE89A3-6092-F4EA-48A7-B4B9AC326093}.Debug.Build.0 = Debug|Win32
                 {51CE89A3-6092-F4EA-48A7-B4B9AC326093}.Release.ActiveCfg = Release|Win32
                 {51CE89A3-6092-F4EA-48A7-B4B9AC326093}.Release.Build.0 = Release|Win32
+ {58DF28E3-0926-F47A-E28A-B03A4D619631}.Debug.ActiveCfg = Debug|Win32
+ {58DF28E3-0926-F47A-E28A-B03A4D619631}.Debug.Build.0 = Debug|Win32
+ {58DF28E3-0926-F47A-E28A-B03A4D619631}.Release.ActiveCfg = Release|Win32
+ {58DF28E3-0926-F47A-E28A-B03A4D619631}.Release.Build.0 = Release|Win32
         EndGlobalSection
         GlobalSection(ExtensibilityGlobals) = postSolution
         EndGlobalSection

Modified: trunk/libs/interprocess/proj/vc7ide/interprocesslib.vcproj
==============================================================================
--- trunk/libs/interprocess/proj/vc7ide/interprocesslib.vcproj (original)
+++ trunk/libs/interprocess/proj/vc7ide/interprocesslib.vcproj 2007-10-21 05:02:23 EDT (Sun, 21 Oct 2007)
@@ -387,6 +387,9 @@
                                 RelativePath="..\..\..\..\boost\interprocess\detail\in_place_interface.hpp">
                         </File>
                         <File
+ RelativePath="..\..\..\..\boost\interprocess\detail\interprocess_tester.hpp">
+ </File>
+ <File
                                 RelativePath="..\..\..\..\boost\interprocess\detail\iterators.hpp">
                         </File>
                         <File

Added: trunk/libs/interprocess/proj/vc7ide/managed_shared_memory.vcproj
==============================================================================
--- (empty file)
+++ trunk/libs/interprocess/proj/vc7ide/managed_shared_memory.vcproj 2007-10-21 05:02:23 EDT (Sun, 21 Oct 2007)
@@ -0,0 +1,136 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="managed_shared_memory_test"
+ ProjectGUID="{58DF28E3-0926-F47A-E28A-B03A4D619631}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="../../Bin/Win32/Debug"
+ IntermediateDirectory="Debug/managed_shared_memory_test"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../.."
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ ForceConformanceInForLoopScope="TRUE"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="winmm.lib"
+ OutputFile="$(OutDir)/managed_shared_memory_test_d.exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../stage/lib"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/managed_shared_memory_test.pdb"
+ SubSystem="1"
+ TargetMachine="1"
+ FixedBaseAddress="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="../../Bin/Win32/Release"
+ IntermediateDirectory="Release/managed_shared_memory_test"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../../../.."
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
+ RuntimeLibrary="2"
+ ForceConformanceInForLoopScope="TRUE"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="winmm.lib"
+ OutputFile="$(OutDir)/managed_shared_memory_test.exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="../../../../stage/lib"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4F277FC0-57BA-6A06-3746-225FD52A32AB}">
+ <File
+ RelativePath="..\..\test\managed_shared_memory_test.cpp">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93899C50-B034-89BD-8E7B-EB52EF6B2A7F}">
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>

Modified: trunk/libs/interprocess/test/deque_test.cpp
==============================================================================
--- trunk/libs/interprocess/test/deque_test.cpp (original)
+++ trunk/libs/interprocess/test/deque_test.cpp 2007-10-21 05:02:23 EDT (Sun, 21 Oct 2007)
@@ -28,6 +28,7 @@
 #include <boost/interprocess/detail/move_iterator.hpp>
 #include <boost/interprocess/detail/move.hpp>
 #include <boost/interprocess/detail/mpl.hpp>
+#include <boost/interprocess/detail/type_traits.hpp>
 #include <string>
 #include "get_process_id_name.hpp"
 
@@ -177,7 +178,6 @@
          }
 
          if(!copyable_only(shmdeque, stddeque
-// ,boost::integral_constant
                         ,detail::bool_<!is_movable<IntType>::value>())){
             return false;
          }

Modified: trunk/libs/interprocess/test/managed_mapped_file_test.cpp
==============================================================================
--- trunk/libs/interprocess/test/managed_mapped_file_test.cpp (original)
+++ trunk/libs/interprocess/test/managed_mapped_file_test.cpp 2007-10-21 05:02:23 EDT (Sun, 21 Oct 2007)
@@ -79,6 +79,25 @@
       mfile.flush();
    }
    {
+ //Map preexisting file again in memory
+ managed_mapped_file mfile(open_only, FileName);
+
+ //Check vector is still there
+ MyVect *mfile_vect = mfile.find<MyVect>("MyVector").first;
+ if(!mfile_vect)
+ return -1;
+ }
+
+ {
+ std::size_t old_free_memory;
+ {
+ //Map preexisting file again in memory
+ managed_mapped_file mfile(open_only, FileName);
+ old_free_memory = mfile.get_free_memory();
+ }
+
+ //Now grow the file
+ managed_mapped_file::grow(FileName, FileSize);
 
       //Map preexisting file again in memory
       managed_mapped_file mfile(open_only, FileName);
@@ -88,11 +107,63 @@
       if(!mfile_vect)
          return -1;
 
- //Destroy and check it is not present
- mfile.destroy_ptr(mfile_vect);
- if(0 != mfile.find<MyVect>("MyVector").first)
+ if(mfile.get_size() != (FileSize*2))
+ return -1;
+ if(mfile.get_free_memory() <= old_free_memory)
          return -1;
    }
+ {
+ std::size_t old_free_memory, next_free_memory,
+ old_file_size, next_file_size, final_file_size;
+ {
+ //Map preexisting file again in memory
+ managed_mapped_file mfile(open_only, FileName);
+ old_free_memory = mfile.get_free_memory();
+ old_file_size = mfile.get_size();
+ }
+
+ //Now shrink the file
+ managed_mapped_file::shrink_to_fit(FileName);
+
+ {
+ //Map preexisting file again in memory
+ managed_mapped_file mfile(open_only, FileName);
+ next_file_size = mfile.get_size();
+
+ //Check vector is still there
+ MyVect *mfile_vect = mfile.find<MyVect>("MyVector").first;
+ if(!mfile_vect)
+ return -1;
+
+ next_free_memory = mfile.get_free_memory();
+ if(next_free_memory >= old_free_memory)
+ return -1;
+ if(old_file_size <= next_file_size)
+ return -1;
+ }
+
+ //Now destroy the vector
+ {
+ //Map preexisting file again in memory
+ managed_mapped_file mfile(open_only, FileName);
+
+ //Destroy and check it is not present
+ mfile.destroy<MyVect>("MyVector");
+ if(0 != mfile.find<MyVect>("MyVector").first)
+ return -1;
+ }
+
+ //Now shrink the file
+ managed_mapped_file::shrink_to_fit(FileName);
+ {
+ //Map preexisting file again in memory
+ managed_mapped_file mfile(open_only, FileName);
+ final_file_size = mfile.get_size();
+ if(next_file_size <= final_file_size)
+ return -1;
+ }
+ }
+
    std::remove(FileName);
    return 0;
 }

Added: trunk/libs/interprocess/test/managed_shared_memory_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/interprocess/test/managed_shared_memory_test.cpp 2007-10-21 05:02:23 EDT (Sun, 21 Oct 2007)
@@ -0,0 +1,168 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2004-2007. 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/interprocess for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include <boost/interprocess/detail/config_begin.hpp>
+#include <boost/interprocess/allocators/allocator.hpp>
+#include <boost/interprocess/containers/vector.hpp>
+#include <boost/interprocess/managed_shared_memory.hpp>
+#include <cstdio>
+#include <string>
+#include "get_process_id_name.hpp"
+
+using namespace boost::interprocess;
+
+int main ()
+{
+ const int ShmemSize = 65536;
+ const char *const ShmemName = test::get_process_id_name();
+
+ //STL compatible allocator object for memory-mapped shmem
+ typedef allocator<int, managed_shared_memory::segment_manager>
+ allocator_int_t;
+ //A vector that uses that allocator
+ typedef boost::interprocess::vector<int, allocator_int_t> MyVect;
+
+ {
+ //Remove the shmem it is already created
+ shared_memory_object::remove(ShmemName);
+
+ const int max = 100;
+ void *array[max];
+ //Named allocate capable shared memory allocator
+ managed_shared_memory shmem(create_only, ShmemName, ShmemSize);
+
+ int i;
+ //Let's allocate some memory
+ for(i = 0; i < max; ++i){
+ array[i] = shmem.allocate(i+1);
+ }
+
+ //Deallocate allocated memory
+ for(i = 0; i < max; ++i){
+ shmem.deallocate(array[i]);
+ }
+ }
+
+ {
+ //Remove the shmem it is already created
+ shared_memory_object::remove(ShmemName);
+
+ //Named allocate capable memory mapped shmem managed memory class
+ managed_shared_memory shmem(create_only, ShmemName, ShmemSize);
+
+ //Construct the STL-like allocator with the segment manager
+ const allocator_int_t myallocator (shmem.get_segment_manager());
+
+ //Construct vector
+ MyVect *shmem_vect = shmem.construct<MyVect> ("MyVector") (myallocator);
+
+ //Test that vector can be found via name
+ if(shmem_vect != shmem.find<MyVect>("MyVector").first)
+ return -1;
+
+ //Destroy and check it is not present
+ shmem.destroy<MyVect> ("MyVector");
+ if(0 != shmem.find<MyVect>("MyVector").first)
+ return -1;
+
+ //Construct a vector in the memory-mapped shmem
+ shmem_vect = shmem.construct<MyVect> ("MyVector") (myallocator);
+ }
+ {
+ //Map preexisting shmem again in memory
+ managed_shared_memory shmem(open_only, ShmemName);
+
+ //Check vector is still there
+ MyVect *shmem_vect = shmem.find<MyVect>("MyVector").first;
+ if(!shmem_vect)
+ return -1;
+ }
+
+ {
+ std::size_t old_free_memory;
+ {
+ //Map preexisting shmem again in memory
+ managed_shared_memory shmem(open_only, ShmemName);
+ old_free_memory = shmem.get_free_memory();
+ }
+
+ //Now grow the shmem
+ managed_shared_memory::grow(ShmemName, ShmemSize);
+
+ //Map preexisting shmem again in memory
+ managed_shared_memory shmem(open_only, ShmemName);
+
+ //Check vector is still there
+ MyVect *shmem_vect = shmem.find<MyVect>("MyVector").first;
+ if(!shmem_vect)
+ return -1;
+
+ if(shmem.get_size() != (ShmemSize*2))
+ return -1;
+ if(shmem.get_free_memory() <= old_free_memory)
+ return -1;
+ }
+ {
+ std::size_t old_free_memory, next_free_memory,
+ old_shmem_size, next_shmem_size, final_shmem_size;
+ {
+ //Map preexisting shmem again in memory
+ managed_shared_memory shmem(open_only, ShmemName);
+ old_free_memory = shmem.get_free_memory();
+ old_shmem_size = shmem.get_size();
+ }
+
+ //Now shrink the shmem
+ managed_shared_memory::shrink_to_fit(ShmemName);
+
+ {
+ //Map preexisting shmem again in memory
+ managed_shared_memory shmem(open_only, ShmemName);
+ next_shmem_size = shmem.get_size();
+
+ //Check vector is still there
+ MyVect *shmem_vect = shmem.find<MyVect>("MyVector").first;
+ if(!shmem_vect)
+ return -1;
+
+ next_free_memory = shmem.get_free_memory();
+ if(next_free_memory >= old_free_memory)
+ return -1;
+ if(old_shmem_size <= next_shmem_size)
+ return -1;
+ }
+
+ //Now destroy the vector
+ {
+ //Map preexisting shmem again in memory
+ managed_shared_memory shmem(open_only, ShmemName);
+
+ //Destroy and check it is not present
+ shmem.destroy<MyVect>("MyVector");
+ if(0 != shmem.find<MyVect>("MyVector").first)
+ return -1;
+ }
+
+ //Now shrink the shmem
+ managed_shared_memory::shrink_to_fit(ShmemName);
+ {
+ //Map preexisting shmem again in memory
+ managed_shared_memory shmem(open_only, ShmemName);
+ final_shmem_size = shmem.get_size();
+ if(next_shmem_size <= final_shmem_size)
+ return -1;
+ }
+ }
+
+ shared_memory_object::remove(ShmemName);
+ return 0;
+}
+
+#include <boost/interprocess/detail/config_end.hpp>

Modified: trunk/libs/interprocess/test/mapped_file_test.cpp
==============================================================================
--- trunk/libs/interprocess/test/mapped_file_test.cpp (original)
+++ trunk/libs/interprocess/test/mapped_file_test.cpp 2007-10-21 05:02:23 EDT (Sun, 21 Oct 2007)
@@ -73,7 +73,7 @@
       }
 
       //Overwrite all memory
- std::memset(file1.get_address(), 0, file1.get_size());
+ std::memset(file1.get_user_address(), 0, file1.get_user_size());
    }
    std::remove(FileName);
    return 0;

Modified: trunk/libs/interprocess/test/named_allocation_test_template.hpp
==============================================================================
--- trunk/libs/interprocess/test/named_allocation_test_template.hpp (original)
+++ trunk/libs/interprocess/test/named_allocation_test_template.hpp 2007-10-21 05:02:23 EDT (Sun, 21 Oct 2007)
@@ -28,6 +28,14 @@
 
 namespace boost { namespace interprocess { namespace test {
 
+namespace {
+ const wchar_t *get_prefix(wchar_t)
+ { return L"prefix_name_"; }
+
+ const char *get_prefix(char)
+ { return "prefix_name_"; }
+}
+
 //This test allocates until there is no more memory
 //and after that deallocates all in the same order
 template<class ManagedMemory>
@@ -43,7 +51,7 @@
 
    for(int i = 0; true; ++i){
       formatter.seekp(0);
- formatter << "prefix_name_" << i << std::ends;
+ formatter << get_prefix(char_type()) << i << std::ends;
 
       char *ptr = m.template construct<char>(name, std::nothrow)(i);
 
@@ -105,7 +113,7 @@
 
    for(int i = 0; true; ++i){
       formatter.seekp(0);
- formatter << "prefix_name_" << i << std::ends;
+ formatter << get_prefix(char_type()) << i << std::ends;
       char *ptr = m.template construct<char>(name, std::nothrow)(i);
       if(!ptr)
          break;
@@ -175,7 +183,7 @@
 
    for(int i = 0; true; ++i){
       formatter.seekp(0);
- formatter << "prefix_name_" << i << std::ends;
+ formatter << get_prefix(char_type()) << i << std::ends;
 
       char *ptr = m.template construct<char>(name, std::nothrow)(i);
 
@@ -215,7 +223,7 @@
 
    for(int i = 0; true; ++i){
       formatter.seekp(0);
- formatter << "prefix_name_" << i << std::ends;
+ formatter << get_prefix(char_type()) << i << std::ends;
       char *ptr = m.template construct<char>(name, std::nothrow)(i);
       if(!ptr)
          break;
@@ -257,7 +265,7 @@
 
    for(int i = 0; true; ++i){
       formatter.seekp(0);
- formatter << "prefix_name_" << i << std::ends;
+ formatter << get_prefix(char_type()) << i << std::ends;
       char *ptr = m.template construct<char>(name, std::nothrow)(i);
       if(!ptr)
          break;
@@ -297,7 +305,7 @@
 
    for(int i = 0; true; ++i){
       formatter.seekp(0);
- formatter << "prefix_name_" << i << std::ends;
+ formatter << get_prefix(char_type()) << i << std::ends;
       char *ptr = m.template construct<char>(name, std::nothrow)(i);
       if(!ptr)
          break;
@@ -339,7 +347,7 @@
 
    for(unsigned int i = 0; true; ++i){
       formatter.seekp(0);
- formatter << "prefix_name_" << i << std::ends;
+ formatter << get_prefix(char_type()) << i << std::ends;
       char *ptr = m.template construct<char>(name, std::nothrow)(i);
       if(!ptr)
          break;
@@ -426,6 +434,7 @@
 bool test_named_allocation()
 {
    using namespace boost::interprocess;
+
    const int memsize = 163840;
    const char *const shMemName = test::get_process_id_name();
    try

Modified: trunk/libs/interprocess/test/named_condition_test.cpp
==============================================================================
--- trunk/libs/interprocess/test/named_condition_test.cpp (original)
+++ trunk/libs/interprocess/test/named_condition_test.cpp 2007-10-21 05:02:23 EDT (Sun, 21 Oct 2007)
@@ -66,17 +66,27 @@
    public:
    named_condition_creation_test_wrapper(create_only_t)
       : named_condition(create_only, test::add_to_process_id_name("named_condition"))
- {}
+ { ++count_; }
 
    named_condition_creation_test_wrapper(open_only_t)
       : named_condition(open_only, test::add_to_process_id_name("named_condition"))
- {}
+ { ++count_; }
 
    named_condition_creation_test_wrapper(open_or_create_t)
       : named_condition(open_or_create, test::add_to_process_id_name("named_condition"))
- {}
+ { ++count_; }
+
+ ~named_condition_creation_test_wrapper() {
+ if(--count_){
+ detail::interprocess_tester::
+ dont_close_on_destruction(static_cast<named_condition&>(*this));
+ }
+ }
+ static int count_;
 };
 
+int named_condition_creation_test_wrapper::count_ = 0;
+
 struct mutex_deleter
 {
    std::string name;

Modified: trunk/libs/interprocess/test/named_mutex_test.cpp
==============================================================================
--- trunk/libs/interprocess/test/named_mutex_test.cpp (original)
+++ trunk/libs/interprocess/test/named_mutex_test.cpp 2007-10-21 05:02:23 EDT (Sun, 21 Oct 2007)
@@ -15,6 +15,7 @@
 #include "named_creation_template.hpp"
 #include <string>
 #include "get_process_id_name.hpp"
+#include <boost/interprocess/detail/interprocess_tester.hpp>
 
 using namespace boost::interprocess;
 
@@ -32,9 +33,21 @@
    public:
    named_mutex_lock_test_wrapper()
       : named_mutex(open_or_create, test::get_process_id_name())
- {}
+ { ++count_; }
+
+ ~named_mutex_lock_test_wrapper()
+ {
+ if(--count_){
+ detail::interprocess_tester::
+ dont_close_on_destruction(static_cast<named_mutex&>(*this));
+ }
+ }
+
+ static int count_;
 };
 
+int named_mutex_lock_test_wrapper::count_ = 0;
+
 //This wrapper is necessary to have a common constructor
 //in generic named_creation_template functions
 class named_mutex_creation_test_wrapper
@@ -43,17 +56,29 @@
    public:
    named_mutex_creation_test_wrapper(create_only_t)
       : named_mutex(create_only, test::get_process_id_name())
- {}
+ { ++count_; }
 
    named_mutex_creation_test_wrapper(open_only_t)
       : named_mutex(open_only, test::get_process_id_name())
- {}
+ { ++count_; }
 
    named_mutex_creation_test_wrapper(open_or_create_t)
       : named_mutex(open_or_create, test::get_process_id_name())
- {}
+ { ++count_; }
+
+ ~named_mutex_creation_test_wrapper()
+ {
+ if(--count_){
+ detail::interprocess_tester::
+ dont_close_on_destruction(static_cast<named_mutex&>(*this));
+ }
+ }
+
+ static int count_;
 };
 
+int named_mutex_creation_test_wrapper::count_ = 0;
+
 int main ()
 {
    try{

Modified: trunk/libs/interprocess/test/named_recursive_mutex_test.cpp
==============================================================================
--- trunk/libs/interprocess/test/named_recursive_mutex_test.cpp (original)
+++ trunk/libs/interprocess/test/named_recursive_mutex_test.cpp 2007-10-21 05:02:23 EDT (Sun, 21 Oct 2007)
@@ -33,9 +33,21 @@
    public:
    named_recursive_mutex_lock_test_wrapper()
       : named_recursive_mutex(open_or_create, test::get_process_id_name())
- {}
+ { ++count_; }
+
+ ~named_recursive_mutex_lock_test_wrapper()
+ {
+ if(--count_){
+ detail::interprocess_tester::
+ dont_close_on_destruction(static_cast<named_recursive_mutex&>(*this));
+ }
+ }
+
+ static int count_;
 };
 
+int named_recursive_mutex_lock_test_wrapper::count_ = 0;
+
 //This wrapper is necessary to have a common constructor
 //in generic named_creation_template functions
 class named_mutex_creation_test_wrapper
@@ -44,17 +56,29 @@
    public:
    named_mutex_creation_test_wrapper(create_only_t)
       : named_recursive_mutex(create_only, test::get_process_id_name())
- {}
+ { ++count_; }
 
    named_mutex_creation_test_wrapper(open_only_t)
       : named_recursive_mutex(open_only, test::get_process_id_name())
- {}
+ { ++count_; }
 
    named_mutex_creation_test_wrapper(open_or_create_t)
       : named_recursive_mutex(open_or_create, test::get_process_id_name())
- {}
+ { ++count_; }
+
+ ~named_mutex_creation_test_wrapper()
+ {
+ if(--count_){
+ detail::interprocess_tester::
+ dont_close_on_destruction(static_cast<named_recursive_mutex&>(*this));
+ }
+ }
+
+ static int count_;
 };
 
+int named_mutex_creation_test_wrapper::count_ = 0;
+
 int main ()
 {
    try{

Modified: trunk/libs/interprocess/test/named_semaphore_test.cpp
==============================================================================
--- trunk/libs/interprocess/test/named_semaphore_test.cpp (original)
+++ trunk/libs/interprocess/test/named_semaphore_test.cpp 2007-10-21 05:02:23 EDT (Sun, 21 Oct 2007)
@@ -10,6 +10,7 @@
 
 #include <boost/interprocess/detail/config_begin.hpp>
 #include <boost/interprocess/sync/named_semaphore.hpp>
+#include <boost/interprocess/detail/interprocess_tester.hpp>
 #include <boost/interprocess/exceptions.hpp>
 #include <boost/date_time/posix_time/posix_time_types.hpp>
 #include "named_creation_template.hpp"
@@ -37,26 +38,25 @@
    public:
    named_semaphore_test_wrapper()
       : named_semaphore(open_or_create, SemName, SemCount)
- {}
+ { ++count_; }
 
    named_semaphore_test_wrapper(create_only_t)
       : named_semaphore(create_only, SemName, SemCount)
- {}
+ { ++count_; }
 
    named_semaphore_test_wrapper(open_only_t)
       : named_semaphore(open_only, SemName)
- {}
+ { ++count_; }
 
    named_semaphore_test_wrapper(open_or_create_t)
       : named_semaphore(open_or_create, SemName, SemCount)
- {}
+ { ++count_; }
 
    ~named_semaphore_test_wrapper()
    {
- try{
-
- }
- catch(...){
+ if(--count_){
+ detail::interprocess_tester::
+ dont_close_on_destruction(static_cast<named_semaphore&>(*this));
       }
    }
 
@@ -76,8 +76,12 @@
    named_semaphore_test_wrapper(int initial_count)
       : named_semaphore(create_only, SemName, initial_count)
    {}
+
+ static int count_;
 };
 
+int named_semaphore_test_wrapper::count_ = 0;
+
 //This wrapper is necessary to plug this class
 //in recursive tests
 class recursive_named_semaphore_test_wrapper
@@ -87,8 +91,12 @@
    recursive_named_semaphore_test_wrapper()
       : named_semaphore_test_wrapper(RecSemCount)
    {}
+
+ static int count_;
 };
 
+int recursive_named_semaphore_test_wrapper::count_ = 0;
+
 int main ()
 {
    try{

Modified: trunk/libs/interprocess/test/named_upgradable_mutex_test.cpp
==============================================================================
--- trunk/libs/interprocess/test/named_upgradable_mutex_test.cpp (original)
+++ trunk/libs/interprocess/test/named_upgradable_mutex_test.cpp 2007-10-21 05:02:23 EDT (Sun, 21 Oct 2007)
@@ -32,9 +32,22 @@
    public:
    named_upgradable_mutex_lock_test_wrapper()
       : named_upgradable_mutex(open_or_create, test::get_process_id_name())
- {}
+ { ++count_; }
+
+ ~named_upgradable_mutex_lock_test_wrapper()
+ {
+ if(--count_){
+ detail::interprocess_tester::
+ dont_close_on_destruction(static_cast<named_upgradable_mutex&>(*this));
+ }
+ }
+
+ static int count_;
 };
 
+int named_upgradable_mutex_lock_test_wrapper::count_ = 0;
+
+
 //This wrapper is necessary to have a common constructor
 //in generic named_creation_template functions
 class named_upgradable_mutex_creation_test_wrapper
@@ -44,27 +57,39 @@
    named_upgradable_mutex_creation_test_wrapper
       (create_only_t)
       : named_upgradable_mutex(create_only, test::get_process_id_name())
- {}
+ { ++count_; }
 
    named_upgradable_mutex_creation_test_wrapper
       (open_only_t)
       : named_upgradable_mutex(open_only, test::get_process_id_name())
- {}
+ { ++count_; }
 
    named_upgradable_mutex_creation_test_wrapper
       (open_or_create_t)
       : named_upgradable_mutex(open_or_create, test::get_process_id_name())
- {}
+ { ++count_; }
+
+ ~named_upgradable_mutex_creation_test_wrapper()
+ {
+ if(--count_){
+ detail::interprocess_tester::
+ dont_close_on_destruction(static_cast<named_upgradable_mutex&>(*this));
+ }
+ }
+
+ static int count_;
 };
 
+int named_upgradable_mutex_creation_test_wrapper::count_ = 0;
+
 int main ()
 {
    try{
       named_upgradable_mutex::remove(test::get_process_id_name());
       test::test_named_creation<named_upgradable_mutex_creation_test_wrapper>();
-// test::test_all_lock<named_upgradable_mutex_lock_test_wrapper>();
-// test::test_all_mutex<true, named_upgradable_mutex_lock_test_wrapper>();
-// test::test_all_sharable_mutex<true, named_upgradable_mutex_lock_test_wrapper>();
+ test::test_all_lock<named_upgradable_mutex_lock_test_wrapper>();
+ test::test_all_mutex<true, named_upgradable_mutex_lock_test_wrapper>();
+ test::test_all_sharable_mutex<true, named_upgradable_mutex_lock_test_wrapper>();
    }
    catch(std::exception &ex){
       named_upgradable_mutex::remove(test::get_process_id_name());

Modified: trunk/libs/interprocess/test/node_pool_test.cpp
==============================================================================
--- trunk/libs/interprocess/test/node_pool_test.cpp (original)
+++ trunk/libs/interprocess/test/node_pool_test.cpp 2007-10-21 05:02:23 EDT (Sun, 21 Oct 2007)
@@ -12,6 +12,7 @@
 #include <boost/interprocess/allocators/detail/node_pool.hpp>
 #include <boost/interprocess/smart_ptr/unique_ptr.hpp>
 #include <boost/interprocess/smart_ptr/deleter.hpp>
+#include <boost/interprocess/detail/type_traits.hpp>
 #include <vector>
 #include <cstddef>
 #include <string>

Modified: trunk/libs/interprocess/test/shared_memory_test.cpp
==============================================================================
--- trunk/libs/interprocess/test/shared_memory_test.cpp (original)
+++ trunk/libs/interprocess/test/shared_memory_test.cpp 2007-10-21 05:02:23 EDT (Sun, 21 Oct 2007)
@@ -73,7 +73,7 @@
          }
 
          //Overwrite all memory
- std::memset(shm1.get_address(), 0, shm1.get_size());
+ std::memset(shm1.get_user_address(), 0, shm1.get_user_size());
       }
    }
    catch(std::exception &ex){

Modified: trunk/libs/interprocess/test/user_buffer_test.cpp
==============================================================================
--- trunk/libs/interprocess/test/user_buffer_test.cpp (original)
+++ trunk/libs/interprocess/test/user_buffer_test.cpp 2007-10-21 05:02:23 EDT (Sun, 21 Oct 2007)
@@ -189,8 +189,10 @@
    const char *insert_beg = detail::char_ptr_cast(heap_buffer.get_address());
    const char *insert_end = insert_beg + heap_buffer.get_size();
    std::vector<char> grow_copy (insert_beg, insert_end);
+
    //Destroy old list
    heap_buffer.destroy<MyHeapList>(L"MyHeapList");
+
    //Resize copy buffer
    grow_copy.resize(memsize*2);
 


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