diff --git a/Jamfile.v2 b/Jamfile.v2 new file mode 100644 index 0000000..9fbcdc6 --- /dev/null +++ b/Jamfile.v2 @@ -0,0 +1,5 @@ +import testing ; + +# Tests from Jamfiles in individual library test subdirectories +build-project example ; # test-suite interprocess_example +build-project test ; # test-suite interprocess_test diff --git a/doc/interprocess.qbk b/doc/interprocess.qbk index f2a7183..d54ae05 100644 --- a/doc/interprocess.qbk +++ b/doc/interprocess.qbk @@ -664,6 +664,38 @@ that the shared memory won't be destroyed before the client is launched. [endsect] +[section:xsi_shared_memory XSI shared memory] + +In many UNIX systems, the OS offers another shared memory memory mechanism, XSI +(X/Open System Interfaces) shared memory segments, also known as "System V" shared memory. +This shared memory mechanism is quite popular and portable, and it's not based in file-mapping +semantics, but it uses special functions (`shmget`, `shmat`, `shmdt`, `shmctl`...). + +Unlike POSIX shared memory segments, XSI shared memory segments are not identified by names but +by 'keys' usually created with `ftok`. XSI shared memory segments have kernel lifetime and +must be explicitly removed. XSI shared memory does not support copy-on-write and partial shared memory mapping +but it supports anonymous shared memory. + +[*Boost.Interprocess] offers simple ([classref boost::interprocess::xsi_shared_memory xsi_shared_memory]) +and managed ([classref boost::interprocess::managed_xsi_shared_memory managed_xsi_shared_memory]) +shared memory classes to ease the use of XSI shared memory. It also wraps key creation with the +simple [classref boost::interprocess::xsi_key xsi_key] class. + +Let's repeat the same example presented for the portable shared memory object: +A server process creates a shared memory object, maps it and initializes all the bytes to a value. After that, +a client process opens the shared memory, maps it, and checks +that the data is correctly initialized. + +This is the server process: + +[import ../example/doc_xsi_shared_memory.cpp] +[doc_xsi_shared_memory] + +As we can see, native windows shared memory needs synchronization to make sure +that the shared memory won't be destroyed before the client is launched. + +[endsect] + [endsect] [section:mapped_file Memory Mapped Files] @@ -3151,7 +3183,7 @@ add the mapping address as an extra parameter: Windows users might also want to use native windows shared memory instead of the portable [classref boost::interprocess::shared_memory_object shared_memory_object] -based managed memory. This is achieved through the +managed memory. This is achieved through the [classref boost::interprocess::basic_managed_windows_shared_memory basic_managed_windows_shared_memory] class. To use it just include: @@ -3172,6 +3204,24 @@ please read the explanations given in chapter [endsect] +[section:xsi_managed_memory_common_shm Using XSI (system V) shared memory] + +Unix users might also want to use XSI (system V) instead of +the portable [classref boost::interprocess::shared_memory_object shared_memory_object] +managed memory. This is achieved through the +[classref boost::interprocess::basic_managed_xsi_shared_memory basic_managed_xsi_shared_memory] +class. To use it just include: + +[c++] + + #include + +This class has nearly the same interface as +[classref boost::interprocess::basic_managed_shared_memory basic_managed_shared_memory] +but uses XSI shared memory as backend. + +[endsect] + For more information about managed shared memory capabilities, see [classref boost::interprocess::basic_managed_shared_memory basic_managed_shared_memory] class reference. diff --git a/example/doc_file_mapping.cpp b/example/doc_file_mapping.cpp index cc33585..b2efade 100644 --- a/example/doc_file_mapping.cpp +++ b/example/doc_file_mapping.cpp @@ -25,49 +25,43 @@ int main(int argc, char *argv[]) { using namespace boost::interprocess; + + //Define file names + //<- + #if 1 + std::string file_name(boost::interprocess::detail::get_temporary_path()); + file_name += "/"; file_name += test::get_process_id_name(); + const char *FileName = file_name.c_str(); + #else + //-> + const char *FileName = "file.bin"; + //<- + #endif + //-> const std::size_t FileSize = 10000; + if(argc == 1){ //Parent process executes this { //Create a file + file_mapping::remove(FileName); std::filebuf fbuf; - //<- - #if 1 - fbuf.open(test::get_process_id_name(), std::ios_base::in | std::ios_base::out + fbuf.open(FileName, std::ios_base::in | std::ios_base::out | std::ios_base::trunc | std::ios_base::binary); - #else - //-> - fbuf.open("file.bin", std::ios_base::in | std::ios_base::out - | std::ios_base::trunc | std::ios_base::binary); - //<- - #endif - //-> //Set the size fbuf.pubseekoff(FileSize-1, std::ios_base::beg); fbuf.sputc(0); } - //Remove file on exit + + //Remove on exit struct file_remove { - //<- - #if 1 - ~file_remove (){ file_mapping::remove(test::get_process_id_name()); } - #else - //-> - ~file_remove (){ file_mapping::remove("file.bin"); } - //<- - #endif - //-> - } destroy_on_exit; + file_remove(const char *FileName) + : FileName_(FileName) {} + ~file_remove(){ file_mapping::remove(FileName_); } + const char *FileName_; + } remover(FileName); //Create a file mapping - //<- - #if 1 - file_mapping m_file(test::get_process_id_name(), read_write); - #else - //-> - file_mapping m_file("file.bin", read_write); - //<- - #endif - //-> + file_mapping m_file(FileName, read_write); //Map the whole file with read-write permissions in this process mapped_region region(m_file, read_write); @@ -82,7 +76,7 @@ int main(int argc, char *argv[]) //Launch child process std::string s(argv[0]); s += " child "; //<- - s += test::get_process_id_name(); + s += "\""; s+= FileName; s += "\""; //-> if(0 != std::system(s.c_str())) return 1; @@ -94,7 +88,7 @@ int main(int argc, char *argv[]) file_mapping m_file(argv[2], read_only); #else //-> - file_mapping m_file("file.bin", read_only); + file_mapping m_file(FileName, read_only); //<- #endif //-> @@ -118,7 +112,7 @@ int main(int argc, char *argv[]) fbuf.open(argv[2], std::ios_base::in | std::ios_base::binary); #else //-> - fbuf.open("file.bin", std::ios_base::in | std::ios_base::binary); + fbuf.open(FileName, std::ios_base::in | std::ios_base::binary); //<- #endif //-> diff --git a/example/doc_managed_copy_on_write.cpp b/example/doc_managed_copy_on_write.cpp index 43941eb..15aba88 100644 --- a/example/doc_managed_copy_on_write.cpp +++ b/example/doc_managed_copy_on_write.cpp @@ -8,28 +8,50 @@ // ////////////////////////////////////////////////////////////////////////////// #include +#include //[doc_managed_copy_on_write #include #include //std::fstream #include //std::distance +//<- +#include "../test/get_process_id_name.hpp" +//-> + int main() { using namespace boost::interprocess; + //Define file names + //<- + #if 1 + std::string managed_file(boost::interprocess::detail::get_temporary_path()); + managed_file += "/"; managed_file += test::get_process_id_name(); + const char *ManagedFile = managed_file.c_str(); + std::string managed_file2(boost::interprocess::detail::get_temporary_path()); + managed_file2 += "/"; managed_file2 += test::get_process_id_name(); managed_file2 += "_2"; + const char *ManagedFile2 = managed_file2.c_str(); + #else + //-> + const char *ManagedFile = "MyManagedFile"; + const char *ManagedFile2 = "MyManagedFile2"; + //<- + #endif + //-> + //Try to erase any previous managed segment with the same name - file_mapping::remove("MyManagedFile"); - file_mapping::remove("MyManagedFile2"); - remove_file_on_destroy destroyer1("MyManagedFile"); - remove_file_on_destroy destroyer2("MyManagedFile2"); + file_mapping::remove(ManagedFile); + file_mapping::remove(ManagedFile2); + remove_file_on_destroy destroyer1(ManagedFile); + remove_file_on_destroy destroyer2(ManagedFile2); { //Create an named integer in a managed mapped file - managed_mapped_file managed_file(create_only, "MyManagedFile", 65536); + managed_mapped_file managed_file(create_only, ManagedFile, 65536); managed_file.construct("MyInt")(0u); //Now create a copy on write version - managed_mapped_file managed_file_cow(open_copy_on_write, "MyManagedFile"); + managed_mapped_file managed_file_cow(open_copy_on_write, ManagedFile); //Erase the int and create a new one if(!managed_file_cow.destroy("MyInt")) @@ -45,20 +67,20 @@ int main() throw int(0); { //Dump the modified copy on write segment to a file - std::fstream file("MyManagedFile2", std::ios_base::out | std::ios_base::binary); + std::fstream file(ManagedFile2, std::ios_base::out | std::ios_base::binary); if(!file) throw int(0); file.write(static_cast(managed_file_cow.get_address()), managed_file_cow.get_size()); } //Now open the modified file and test changes - managed_mapped_file managed_file_cow2(open_only, "MyManagedFile2"); + managed_mapped_file managed_file_cow2(open_only, ManagedFile2); if(managed_file_cow2.find("MyInt").first && !managed_file_cow2.find("MyInt2").first) throw int(0); } { //Now create a read-only version - managed_mapped_file managed_file_ro(open_read_only, "MyManagedFile"); + managed_mapped_file managed_file_ro(open_read_only, ManagedFile); //Check the original is intact if(!managed_file_ro.find("MyInt").first && managed_file_ro.find("MyInt2").first) diff --git a/example/doc_managed_mapped_file.cpp b/example/doc_managed_mapped_file.cpp index 536e5e9..a43a56b 100644 --- a/example/doc_managed_mapped_file.cpp +++ b/example/doc_managed_mapped_file.cpp @@ -16,15 +16,32 @@ #include #include +//<- +#include "../test/get_process_id_name.hpp" +//-> + using namespace boost::interprocess; typedef list > MyList; int main () -{ +{ + //Define file names + //<- + #if 1 + std::string file(boost::interprocess::detail::get_temporary_path()); + file += "/"; file += test::get_process_id_name(); + const char *FileName = file.c_str(); + #else + //-> const char *FileName = "file_mapping"; + //<- + #endif + //-> + const std::size_t FileSize = 1000; file_mapping::remove(FileName); + try{ std::size_t old_size = 0; managed_mapped_file::handle_t list_handle; diff --git a/example/doc_shared_ptr.cpp b/example/doc_shared_ptr.cpp index 3f64abb..6352eea 100644 --- a/example/doc_shared_ptr.cpp +++ b/example/doc_shared_ptr.cpp @@ -48,31 +48,29 @@ struct shared_ptr_owner int main () { - //Destroy any previous file with the name to be used. - struct file_remove - { + //Define file names //<- #if 1 - file_remove() { file_mapping::remove(test::get_process_id_name()); } - ~file_remove(){ file_mapping::remove(test::get_process_id_name()); } + std::string mapped_file(boost::interprocess::detail::get_temporary_path()); + mapped_file += "/"; mapped_file += test::get_process_id_name(); + const char *MappedFile = mapped_file.c_str(); #else //-> - file_remove() { file_mapping::remove("MyMappedFile"); } - ~file_remove(){ file_mapping::remove("MyMappedFile"); } + const char *MappedFile = "MyMappedFile"; //<- #endif //-> - } remover; + + //Destroy any previous file with the name to be used. + struct file_remove { - //<- - #if 1 - managed_mapped_file file(create_only, test::get_process_id_name(), 4096); - #else - //-> - managed_mapped_file file(create_only, "MyMappedFile", 4096); - //<- - #endif - //-> + file_remove(const char *MappedFile) + : MappedFile_(MappedFile) { file_mapping::remove(MappedFile_); } + ~file_remove(){ file_mapping::remove(MappedFile_); } + const char *MappedFile_; + } remover(MappedFile); + { + managed_mapped_file file(create_only, MappedFile, 65536); //Construct the shared type in the file and //pass ownership to this local shared pointer @@ -101,15 +99,7 @@ int main () } { //Reopen the mapped file and find again all owners - //<- - #if 1 - managed_mapped_file file(open_only, test::get_process_id_name()); - #else - //-> - managed_mapped_file file(open_only, "MyMappedFile"); - //<- - #endif - //-> + managed_mapped_file file(open_only, MappedFile); shared_ptr_owner *owner1 = file.find("owner1").first; shared_ptr_owner *owner2 = file.find("owner2").first; diff --git a/example/doc_unique_ptr.cpp b/example/doc_unique_ptr.cpp index adf46c0..8a4bdc0 100644 --- a/example/doc_unique_ptr.cpp +++ b/example/doc_unique_ptr.cpp @@ -50,31 +50,29 @@ typedef list int main () { - //Destroy any previous file with the name to be used. - struct file_remove - { + //Define file names //<- #if 1 - file_remove() { file_mapping::remove(test::get_process_id_name()); } - ~file_remove(){ file_mapping::remove(test::get_process_id_name()); } + std::string mapped_file(boost::interprocess::detail::get_temporary_path()); + mapped_file += "/"; mapped_file += test::get_process_id_name(); + const char *MappedFile = mapped_file.c_str(); #else //-> - file_remove() { file_mapping::remove("MyMappedFile"); } - ~file_remove(){ file_mapping::remove("MyMappedFile"); } + const char *MappedFile = "MyMappedFile"; //<- #endif //-> - } remover; + + //Destroy any previous file with the name to be used. + struct file_remove { - //<- - #if 1 - managed_mapped_file file(create_only, test::get_process_id_name(), 65536); - #else - //-> - managed_mapped_file file(create_only, "MyMappedFile", 65536); - //<- - #endif - //-> + file_remove(const char *MappedFile) + : MappedFile_(MappedFile) { file_mapping::remove(MappedFile_); } + ~file_remove(){ file_mapping::remove(MappedFile_); } + const char *MappedFile_; + } remover(MappedFile); + { + managed_mapped_file file(create_only, MappedFile, 65536); //Construct an object in the file and //pass ownership to this local unique pointer @@ -122,15 +120,7 @@ int main () } { //Reopen the mapped file and find again the list - //<- - #if 1 - managed_mapped_file file(open_only, test::get_process_id_name()); - #else - //-> - managed_mapped_file file(open_only, "MyMappedFile"); - //<- - #endif - //-> + managed_mapped_file file(open_only, MappedFile); unique_ptr_list_t *unique_list = file.find("unique list").first; diff --git a/example/doc_windows_shared_memory.cpp b/example/doc_windows_shared_memory.cpp index 6cc80aa..8779ac3 100644 --- a/example/doc_windows_shared_memory.cpp +++ b/example/doc_windows_shared_memory.cpp @@ -8,8 +8,9 @@ // ////////////////////////////////////////////////////////////////////////////// #include +#include -#ifdef BOOST_INTERPROCESS_WINDOWS +#if defined(BOOST_INTERPROCESS_WINDOWS) || defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) //[doc_windows_shared_memory #include @@ -56,7 +57,7 @@ int main(int argc, char *argv[]) //Open already created shared memory object. //<- #if 1 - windows_shared_memory shm (open_only, test::get_process_id_name(), read_only); + windows_shared_memory shm (open_only, argv[2], read_only); #else //-> windows_shared_memory shm (open_only, "MySharedMemory", read_only); diff --git a/example/doc_xsi_shared_memory.cpp b/example/doc_xsi_shared_memory.cpp new file mode 100644 index 0000000..a3a3784 --- /dev/null +++ b/example/doc_xsi_shared_memory.cpp @@ -0,0 +1,95 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2006-2009. 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 +#include + +#if defined(BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS) || defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED) + +//[doc_xsi_shared_memory +#include +#include +#include +#include +#include + +using namespace boost::interprocess; + +void remove_old_shared_memory(const xsi_key &key) +{ + try{ + xsi_shared_memory xsi(open_only, key); + xsi_shared_memory::remove(xsi.get_shmid()); + } + catch(interprocess_exception &e){ + if(e.get_error_code() != not_found_error) + throw; + } +} + +int main(int argc, char *argv[]) +{ + if(argc == 1){ //Parent process + //Build XSI key (ftok based) + xsi_key key(argv[0], 1); + + remove_old_shared_memory(key); + + //Create a shared memory object. + xsi_shared_memory shm (create_only, key, 1000); + + //Remove shared memory on destruction + struct shm_remove + { + int shmid_; + shm_remove(int shmid) : shmid_(shmid){} + ~shm_remove(){ xsi_shared_memory::remove(shmid_); } + } remover(shm.get_shmid()); + + //Map the whole shared memory in this process + mapped_region region(shm, read_write); + + //Write all the memory to 1 + std::memset(region.get_address(), 1, region.get_size()); + + //Launch child process + std::string s(argv[0]); s += " child "; + if(0 != std::system(s.c_str())) + return 1; + } + else{ + //Build XSI key (ftok based) + xsi_key key(argv[0], 1); + + //Create a shared memory object. + xsi_shared_memory shm (open_only, key); + + //Map the whole shared memory in this process + mapped_region region(shm, read_only); + + //Check that memory was initialized to 1 + char *mem = static_cast(region.get_address()); + for(std::size_t i = 0; i < region.get_size(); ++i) + if(*mem++ != 1) + return 1; //Error checking memory + } + return 0; +} +//] + +#else //BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS + +int main() +{ + return 0; +} + +#endif //BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS + +#include diff --git a/proj/vc7ide/Interprocess.sln b/proj/vc7ide/Interprocess.sln index 950df02..d7052b1 100644 --- a/proj/vc7ide/Interprocess.sln +++ b/proj/vc7ide/Interprocess.sln @@ -1,68 +1,4 @@ Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "doc_map", "doc_map.vcproj", "{59CEC183-8192-8F6D-4FB7-BA260A79D352}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "windows_shared_memory_test", "windows_shared_memory_test.vcproj", "{E385C28C-0691-4FA7-F48E-935BA0D06310}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "windows_shared_memory_mapping_test", "windows_shared_memory_mapping_test.vcproj", "{518CE8C3-6512-FA75-46EF-B917A3A116D1}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "managed_windows_shared_memory_test", "managed_windows_shared_memory.vcproj", "{5D18CE83-1926-7AE4-FE94-B606D9B23131}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "adaptive_pool_test", "adaptive_pool_test.vcproj", "{58CE1D84-1962-4FE9-BA0D-A4F7973A4652}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cached_adaptive_pool_test", "cached_adaptive_pool_test.vcproj", "{5188E3CE-2964-F43E-FB87-B037AC692D59}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "private_adaptive_pool_test", "private_adaptive_pool_test.vcproj", "{5CE14C83-4962-8F5E-4FA7-B0D3A7B93635}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "doc_allocator", "doc_allocator.vcproj", "{581B1C83-4E12-9526-020F-012482540054}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "doc_node_allocator", "doc_node_allocator.vcproj", "{51B17C83-E172-5396-0FA2-825472008554}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "doc_private_node_allocator", "doc_private_node_allocator.vcproj", "{2B75C833-17D2-4956-A23F-820854254175}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "doc_cached_node_allocator", "doc_cached_node_allocator.vcproj", "{283AD375-7D12-5866-23BF-854308651275}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "doc_adaptive_pool", "doc_adaptive_pool.vcproj", "{57C832B1-17D2-9537-FA12-827220448554}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "doc_cached_adaptive_pool", "doc_cached_adaptive_pool.vcproj", "{536C8251-7E12-9537-A1E2-822073258554}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "doc_private_adaptive_pool", "doc_private_adaptive_pool.vcproj", "{83258CB1-127E-9375-F872-8324A1054454}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "doc_managed_raw_allocation", "doc_managed_raw_allocation.vcproj", "{5198EFC3-2731-F34E-4FD8-1859AC94F761}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "doc_managed_aligned_allocation", "doc_managed_aligned_allocation.vcproj", "{58DE18C3-3261-2F3E-FD47-83760B9FA761}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_interprocesslib", "interprocesslib.vcproj", "{FFAA56F1-32EC-4B22-B6BD-95A311A67C35}" ProjectSection(ProjectDependencies) = postProject EndProjectSection @@ -447,76 +383,26 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "recursive_mutex_test", "rec ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xsi_shared_memory_mapping_test", "xsi_shared_memory_mapping_test.vcproj", "{518CE8C3-5DA7-6256-46EF-97A116702AD1}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "managed_xsi_shared_memory_test", "managed_xsi_shared_memory.vcproj", "{58DF28E3-0926-F47A-E28A-B03A4D619631}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "doc_xsi_shared_memory", "doc_xsi_shared_memory.vcproj", "{8C5CE183-0326-47FC-12FE-8B6F7963A071}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug Release = Release EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution - {59CEC183-8192-8F6D-4FB7-BA260A79D352}.Debug.ActiveCfg = Debug|Win32 - {59CEC183-8192-8F6D-4FB7-BA260A79D352}.Debug.Build.0 = Debug|Win32 - {59CEC183-8192-8F6D-4FB7-BA260A79D352}.Release.ActiveCfg = Release|Win32 - {59CEC183-8192-8F6D-4FB7-BA260A79D352}.Release.Build.0 = Release|Win32 - {E385C28C-0691-4FA7-F48E-935BA0D06310}.Debug.ActiveCfg = Debug|Win32 - {E385C28C-0691-4FA7-F48E-935BA0D06310}.Debug.Build.0 = Debug|Win32 - {E385C28C-0691-4FA7-F48E-935BA0D06310}.Release.ActiveCfg = Release|Win32 - {E385C28C-0691-4FA7-F48E-935BA0D06310}.Release.Build.0 = Release|Win32 - {518CE8C3-6512-FA75-46EF-B917A3A116D1}.Debug.ActiveCfg = Debug|Win32 - {518CE8C3-6512-FA75-46EF-B917A3A116D1}.Debug.Build.0 = Debug|Win32 - {518CE8C3-6512-FA75-46EF-B917A3A116D1}.Release.ActiveCfg = Release|Win32 - {518CE8C3-6512-FA75-46EF-B917A3A116D1}.Release.Build.0 = Release|Win32 - {5D18CE83-1926-7AE4-FE94-B606D9B23131}.Debug.ActiveCfg = Debug|Win32 - {5D18CE83-1926-7AE4-FE94-B606D9B23131}.Debug.Build.0 = Debug|Win32 - {5D18CE83-1926-7AE4-FE94-B606D9B23131}.Release.ActiveCfg = Release|Win32 - {5D18CE83-1926-7AE4-FE94-B606D9B23131}.Release.Build.0 = Release|Win32 - {58CE1D84-1962-4FE9-BA0D-A4F7973A4652}.Debug.ActiveCfg = Debug|Win32 - {58CE1D84-1962-4FE9-BA0D-A4F7973A4652}.Debug.Build.0 = Debug|Win32 - {58CE1D84-1962-4FE9-BA0D-A4F7973A4652}.Release.ActiveCfg = Release|Win32 - {58CE1D84-1962-4FE9-BA0D-A4F7973A4652}.Release.Build.0 = Release|Win32 - {5188E3CE-2964-F43E-FB87-B037AC692D59}.Debug.ActiveCfg = Debug|Win32 - {5188E3CE-2964-F43E-FB87-B037AC692D59}.Debug.Build.0 = Debug|Win32 - {5188E3CE-2964-F43E-FB87-B037AC692D59}.Release.ActiveCfg = Release|Win32 - {5188E3CE-2964-F43E-FB87-B037AC692D59}.Release.Build.0 = Release|Win32 - {5CE14C83-4962-8F5E-4FA7-B0D3A7B93635}.Debug.ActiveCfg = Debug|Win32 - {5CE14C83-4962-8F5E-4FA7-B0D3A7B93635}.Debug.Build.0 = Debug|Win32 - {5CE14C83-4962-8F5E-4FA7-B0D3A7B93635}.Release.ActiveCfg = Release|Win32 - {5CE14C83-4962-8F5E-4FA7-B0D3A7B93635}.Release.Build.0 = Release|Win32 - {581B1C83-4E12-9526-020F-012482540054}.Debug.ActiveCfg = Debug|Win32 - {581B1C83-4E12-9526-020F-012482540054}.Debug.Build.0 = Debug|Win32 - {581B1C83-4E12-9526-020F-012482540054}.Release.ActiveCfg = Release|Win32 - {581B1C83-4E12-9526-020F-012482540054}.Release.Build.0 = Release|Win32 - {51B17C83-E172-5396-0FA2-825472008554}.Debug.ActiveCfg = Debug|Win32 - {51B17C83-E172-5396-0FA2-825472008554}.Debug.Build.0 = Debug|Win32 - {51B17C83-E172-5396-0FA2-825472008554}.Release.ActiveCfg = Release|Win32 - {51B17C83-E172-5396-0FA2-825472008554}.Release.Build.0 = Release|Win32 - {2B75C833-17D2-4956-A23F-820854254175}.Debug.ActiveCfg = Debug|Win32 - {2B75C833-17D2-4956-A23F-820854254175}.Debug.Build.0 = Debug|Win32 - {2B75C833-17D2-4956-A23F-820854254175}.Release.ActiveCfg = Release|Win32 - {2B75C833-17D2-4956-A23F-820854254175}.Release.Build.0 = Release|Win32 - {283AD375-7D12-5866-23BF-854308651275}.Debug.ActiveCfg = Debug|Win32 - {283AD375-7D12-5866-23BF-854308651275}.Debug.Build.0 = Debug|Win32 - {283AD375-7D12-5866-23BF-854308651275}.Release.ActiveCfg = Release|Win32 - {283AD375-7D12-5866-23BF-854308651275}.Release.Build.0 = Release|Win32 - {57C832B1-17D2-9537-FA12-827220448554}.Debug.ActiveCfg = Debug|Win32 - {57C832B1-17D2-9537-FA12-827220448554}.Debug.Build.0 = Debug|Win32 - {57C832B1-17D2-9537-FA12-827220448554}.Release.ActiveCfg = Release|Win32 - {57C832B1-17D2-9537-FA12-827220448554}.Release.Build.0 = Release|Win32 - {536C8251-7E12-9537-A1E2-822073258554}.Debug.ActiveCfg = Debug|Win32 - {536C8251-7E12-9537-A1E2-822073258554}.Debug.Build.0 = Debug|Win32 - {536C8251-7E12-9537-A1E2-822073258554}.Release.ActiveCfg = Release|Win32 - {536C8251-7E12-9537-A1E2-822073258554}.Release.Build.0 = Release|Win32 - {83258CB1-127E-9375-F872-8324A1054454}.Debug.ActiveCfg = Debug|Win32 - {83258CB1-127E-9375-F872-8324A1054454}.Debug.Build.0 = Debug|Win32 - {83258CB1-127E-9375-F872-8324A1054454}.Release.ActiveCfg = Release|Win32 - {83258CB1-127E-9375-F872-8324A1054454}.Release.Build.0 = Release|Win32 - {5198EFC3-2731-F34E-4FD8-1859AC94F761}.Debug.ActiveCfg = Debug|Win32 - {5198EFC3-2731-F34E-4FD8-1859AC94F761}.Debug.Build.0 = Debug|Win32 - {5198EFC3-2731-F34E-4FD8-1859AC94F761}.Release.ActiveCfg = Release|Win32 - {5198EFC3-2731-F34E-4FD8-1859AC94F761}.Release.Build.0 = Release|Win32 - {58DE18C3-3261-2F3E-FD47-83760B9FA761}.Debug.ActiveCfg = Debug|Win32 - {58DE18C3-3261-2F3E-FD47-83760B9FA761}.Debug.Build.0 = Debug|Win32 - {58DE18C3-3261-2F3E-FD47-83760B9FA761}.Release.ActiveCfg = Release|Win32 - {58DE18C3-3261-2F3E-FD47-83760B9FA761}.Release.Build.0 = Release|Win32 {FFAA56F1-32EC-4B22-B6BD-95A311A67C35}.Debug.ActiveCfg = Debug|Win32 {FFAA56F1-32EC-4B22-B6BD-95A311A67C35}.Debug.Build.0 = Debug|Win32 {FFAA56F1-32EC-4B22-B6BD-95A311A67C35}.Release.ActiveCfg = Release|Win32 @@ -901,6 +787,18 @@ Global {83581CCE-487E-3292-A4E7-BA07926D3A14}.Debug.Build.0 = Debug|Win32 {83581CCE-487E-3292-A4E7-BA07926D3A14}.Release.ActiveCfg = Release|Win32 {83581CCE-487E-3292-A4E7-BA07926D3A14}.Release.Build.0 = Release|Win32 + {518CE8C3-5DA7-6256-46EF-97A116702AD1}.Debug.ActiveCfg = Debug|Win32 + {518CE8C3-5DA7-6256-46EF-97A116702AD1}.Debug.Build.0 = Debug|Win32 + {518CE8C3-5DA7-6256-46EF-97A116702AD1}.Release.ActiveCfg = Release|Win32 + {518CE8C3-5DA7-6256-46EF-97A116702AD1}.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 + {8C5CE183-0326-47FC-12FE-8B6F7963A071}.Debug.ActiveCfg = Debug|Win32 + {8C5CE183-0326-47FC-12FE-8B6F7963A071}.Debug.Build.0 = Debug|Win32 + {8C5CE183-0326-47FC-12FE-8B6F7963A071}.Release.ActiveCfg = Release|Win32 + {8C5CE183-0326-47FC-12FE-8B6F7963A071}.Release.Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection diff --git a/proj/vc7ide/doc_xsi_shared_memory.vcproj b/proj/vc7ide/doc_xsi_shared_memory.vcproj new file mode 100644 index 0000000..29412a2 --- /dev/null +++ b/proj/vc7ide/doc_xsi_shared_memory.vcproj @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/proj/vc7ide/interprocesslib.vcproj b/proj/vc7ide/interprocesslib.vcproj index ee979a3..e8170ad 100644 --- a/proj/vc7ide/interprocesslib.vcproj +++ b/proj/vc7ide/interprocesslib.vcproj @@ -356,6 +356,9 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/proj/vc7ide/xsi_shared_memory_mapping_test.vcproj b/proj/vc7ide/xsi_shared_memory_mapping_test.vcproj new file mode 100644 index 0000000..1cb1f18 --- /dev/null +++ b/proj/vc7ide/xsi_shared_memory_mapping_test.vcproj @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/managed_mapped_file_test.cpp b/test/managed_mapped_file_test.cpp index 0de0908..6c79bb9 100644 --- a/test/managed_mapped_file_test.cpp +++ b/test/managed_mapped_file_test.cpp @@ -29,6 +29,8 @@ inline std::string get_filename() int main () { const int FileSize = 65536*10; + std::string filename(get_filename()); + const char *FileName = filename.c_str(); //STL compatible allocator object for memory-mapped file typedef allocator @@ -38,12 +40,12 @@ int main () { //Remove the file it is already created - file_mapping::remove(get_filename().c_str()); + file_mapping::remove(FileName); const int max = 100; void *array[max]; //Named allocate capable shared memory allocator - managed_mapped_file mfile(create_only, get_filename().c_str(), FileSize); + managed_mapped_file mfile(create_only, FileName, FileSize); int i; //Let's allocate some memory @@ -59,10 +61,10 @@ int main () { //Remove the file it is already created - file_mapping::remove(get_filename().c_str()); + file_mapping::remove(FileName); //Named allocate capable memory mapped file managed memory class - managed_mapped_file mfile(create_only, get_filename().c_str(), FileSize); + managed_mapped_file mfile(create_only, FileName, FileSize); //Construct the STL-like allocator with the segment manager const allocator_int_t myallocator (mfile.get_segment_manager()); @@ -87,7 +89,7 @@ int main () } { //Map preexisting file again in memory - managed_mapped_file mfile(open_only, get_filename().c_str()); + managed_mapped_file mfile(open_only, FileName); //Check vector is still there MyVect *mfile_vect = mfile.find("MyVector").first; @@ -98,7 +100,7 @@ int main () { { //Map preexisting file again in copy-on-write - managed_mapped_file mfile(open_copy_on_write, get_filename().c_str()); + managed_mapped_file mfile(open_copy_on_write, FileName); //Check vector is still there MyVect *mfile_vect = mfile.find("MyVector").first; @@ -116,7 +118,7 @@ int main () //Now check vector is still in the file { //Map preexisting file again in copy-on-write - managed_mapped_file mfile(open_copy_on_write, get_filename().c_str()); + managed_mapped_file mfile(open_copy_on_write, FileName); //Check vector is still there MyVect *mfile_vect = mfile.find("MyVector").first; @@ -126,7 +128,7 @@ int main () } { //Map preexisting file again in copy-on-write - managed_mapped_file mfile(open_read_only, get_filename().c_str()); + managed_mapped_file mfile(open_read_only, FileName); //Check vector is still there MyVect *mfile_vect = mfile.find("MyVector").first; @@ -137,15 +139,15 @@ int main () std::size_t old_free_memory; { //Map preexisting file again in memory - managed_mapped_file mfile(open_only, get_filename().c_str()); + managed_mapped_file mfile(open_only, FileName); old_free_memory = mfile.get_free_memory(); } //Now grow the file - managed_mapped_file::grow(get_filename().c_str(), FileSize); + managed_mapped_file::grow(FileName, FileSize); //Map preexisting file again in memory - managed_mapped_file mfile(open_only, get_filename().c_str()); + managed_mapped_file mfile(open_only, FileName); //Check vector is still there MyVect *mfile_vect = mfile.find("MyVector").first; @@ -162,17 +164,17 @@ int main () old_file_size, next_file_size, final_file_size; { //Map preexisting file again in memory - managed_mapped_file mfile(open_only, get_filename().c_str()); + 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(get_filename().c_str()); + managed_mapped_file::shrink_to_fit(FileName); { //Map preexisting file again in memory - managed_mapped_file mfile(open_only, get_filename().c_str()); + managed_mapped_file mfile(open_only, FileName); next_file_size = mfile.get_size(); //Check vector is still there @@ -190,7 +192,7 @@ int main () //Now destroy the vector { //Map preexisting file again in memory - managed_mapped_file mfile(open_only, get_filename().c_str()); + managed_mapped_file mfile(open_only, FileName); //Destroy and check it is not present mfile.destroy("MyVector"); @@ -199,17 +201,17 @@ int main () } //Now shrink the file - managed_mapped_file::shrink_to_fit(get_filename().c_str()); + managed_mapped_file::shrink_to_fit(FileName); { //Map preexisting file again in memory - managed_mapped_file mfile(open_only, get_filename().c_str()); + managed_mapped_file mfile(open_only, FileName); final_file_size = mfile.get_size(); if(next_file_size <= final_file_size) return -1; } { //Now test move semantics - managed_mapped_file original(open_only, get_filename().c_str()); + managed_mapped_file original(open_only, FileName); managed_mapped_file move_ctor(boost::interprocess::move(original)); managed_mapped_file move_assign; move_assign = boost::interprocess::move(move_ctor); @@ -217,7 +219,7 @@ int main () } } - file_mapping::remove(get_filename().c_str()); + file_mapping::remove(FileName); return 0; } diff --git a/test/managed_xsi_shared_memory_test.cpp b/test/managed_xsi_shared_memory_test.cpp new file mode 100644 index 0000000..eeb851c --- /dev/null +++ b/test/managed_xsi_shared_memory_test.cpp @@ -0,0 +1,174 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2008-2009. 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 +#include + +#if defined(BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS) + +#include +#include +#include +#include +#include +#include +#include +#include +#include "get_process_id_name.hpp" + +using namespace boost::interprocess; + +void remove_shared_memory(const xsi_key &key) +{ + try{ + xsi_shared_memory xsi(open_only, key); + xsi_shared_memory::remove(xsi.get_shmid()); + } + catch(interprocess_exception &e){ + if(e.get_error_code() != not_found_error) + throw; + } +} + +class xsi_shared_memory_remover +{ + public: + xsi_shared_memory_remover(xsi_shared_memory &xsi_shm) + : xsi_shm_(xsi_shm) + {} + + ~xsi_shared_memory_remover() + { xsi_shared_memory::remove(xsi_shm_.get_shmid()); } + private: + xsi_shared_memory & xsi_shm_; +}; + +inline std::string get_filename() +{ + std::string ret (detail::get_temporary_path()); + ret += "/"; + ret += test::get_process_id_name(); + return ret; +} + +int main () +{ + const int ShmemSize = 65536; + std::string filename = get_filename(); + const char *const ShmemName = filename.c_str(); + + file_mapping::remove(ShmemName); + { detail::file_wrapper(create_only, ShmemName, read_write); } + xsi_key key(ShmemName, 1); + file_mapping::remove(ShmemName); + int shmid; + + //STL compatible allocator object for memory-mapped shmem + typedef allocator + allocator_int_t; + //A vector that uses that allocator + typedef boost::interprocess::vector MyVect; + + { + //Remove the shmem it is already created + remove_shared_memory(key); + + const int max = 100; + void *array[max]; + //Named allocate capable shared memory allocator + managed_xsi_shared_memory shmem(create_only, key, ShmemSize); + shmid = shmem.get_shmid(); + 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 + xsi_shared_memory::remove(shmid); + + //Named allocate capable memory mapped shmem managed memory class + managed_xsi_shared_memory shmem(create_only, key, ShmemSize); + shmid = shmem.get_shmid(); + + //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 ("MyVector") (myallocator); + + //Test that vector can be found via name + if(shmem_vect != shmem.find("MyVector").first) + return -1; + + //Destroy and check it is not present + shmem.destroy ("MyVector"); + if(0 != shmem.find("MyVector").first) + return -1; + + //Construct a vector in the memory-mapped shmem + shmem_vect = shmem.construct ("MyVector") (myallocator); + } + { + //Map preexisting shmem again in memory + managed_xsi_shared_memory shmem(open_only, key); + shmid = shmem.get_shmid(); + + //Check vector is still there + MyVect *shmem_vect = shmem.find("MyVector").first; + if(!shmem_vect) + return -1; + } + + + { + //Now destroy the vector + { + //Map preexisting shmem again in memory + managed_xsi_shared_memory shmem(open_only, key); + shmid = shmem.get_shmid(); + + //Destroy and check it is not present + shmem.destroy("MyVector"); + if(0 != shmem.find("MyVector").first) + return -1; + } + + { + //Now test move semantics + managed_xsi_shared_memory original(open_only, key); + managed_xsi_shared_memory move_ctor(boost::interprocess::move(original)); + managed_xsi_shared_memory move_assign; + move_assign = boost::interprocess::move(move_ctor); + move_assign.swap(original); + } + } + + xsi_shared_memory::remove(shmid); + return 0; +} + +#else + +int main() +{ + return 0; +} + +#endif //#ifndef BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS + +#include diff --git a/test/mapped_file_test.cpp b/test/mapped_file_test.cpp index 7f8866e..43f862f 100644 --- a/test/mapped_file_test.cpp +++ b/test/mapped_file_test.cpp @@ -75,11 +75,6 @@ int main () { mapped_file file1(create_only, get_filename().c_str(), FileSize, read_write, 0, permissions()); - //Compare name - if(std::strcmp(file1.get_name(), get_filename().c_str()) != 0){ - return 1; - } - //Overwrite all memory std::memset(file1.get_user_address(), 0, file1.get_user_size()); diff --git a/test/shared_memory_test.cpp b/test/shared_memory_test.cpp index 00f062e..5417187 100644 --- a/test/shared_memory_test.cpp +++ b/test/shared_memory_test.cpp @@ -66,11 +66,6 @@ int main () shared_memory_object::remove(ShmName); shared_memory shm1(create_only, ShmName, ShmSize, read_write, 0, permissions()); - //Compare name - if(std::strcmp(shm1.get_name(), ShmName) != 0){ - return 1; - } - //Overwrite all memory std::memset(shm1.get_user_address(), 0, shm1.get_user_size()); diff --git a/test/xsi_shared_memory_mapping_test.cpp b/test/xsi_shared_memory_mapping_test.cpp new file mode 100644 index 0000000..4a5b254 --- /dev/null +++ b/test/xsi_shared_memory_mapping_test.cpp @@ -0,0 +1,139 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2004-2009. 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 +#include + +#if defined(BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS) + +#include +#include +#include +#include +#include +#include +#include +#include +#include "get_process_id_name.hpp" + +using namespace boost::interprocess; + +void remove_shared_memory(const xsi_key &key) +{ + try{ + xsi_shared_memory xsi(open_only, key); + xsi_shared_memory::remove(xsi.get_shmid()); + } + catch(interprocess_exception &e){ + if(e.get_error_code() != not_found_error) + throw; + } +} + +class xsi_shared_memory_remover +{ + public: + xsi_shared_memory_remover(xsi_shared_memory &xsi_shm) + : xsi_shm_(xsi_shm) + {} + + ~xsi_shared_memory_remover() + { xsi_shared_memory::remove(xsi_shm_.get_shmid()); } + private: + xsi_shared_memory & xsi_shm_; +}; + +inline std::string get_filename() +{ + std::string ret (detail::get_temporary_path()); + ret += "/"; + ret += test::get_process_id_name(); + return ret; +} + +int main (int argc, char *argv[]) +{ + std::string filename(get_filename()); + const char *names[2] = { filename.c_str(), 0 }; + + file_mapping::remove(names[0]); + { detail::file_wrapper(create_only, names[0], read_write); } + xsi_key key(names[0], 1); + file_mapping::remove(names[0]); + remove_shared_memory(key); + + unsigned int i; + try{ + for(i = 0; i < sizeof(names)/sizeof(names[0]); ++i) + { + const std::size_t FileSize = 99999*2; + //Create a file mapping + xsi_shared_memory mapping (create_only, names[i] ? key : xsi_key(), FileSize); + xsi_shared_memory_remover rem(mapping); + try{ + { + //Partial mapping should fail fox XSI shared memory + bool thrown = false; + try{ + mapped_region region2(mapping, read_write, FileSize/2, FileSize - FileSize/2, 0); + } + catch(...){ + thrown = true; + } + if(thrown == false){ + return 1; + } + //Create a mapped region + mapped_region region (mapping, read_write, 0, FileSize, 0); + + //Fill two regions with a pattern + unsigned char *filler = static_cast(region.get_address()); + for(std::size_t i = 0; i < FileSize; ++i){ + *filler++ = static_cast(i); + } + } + + //Now check the pattern mapping a single read only mapped_region + { + //Create a single region, mapping all the file + mapped_region region (mapping, read_only); + + //Check pattern + unsigned char *pattern = static_cast(region.get_address()); + for(std::size_t i = 0; i < FileSize; ++i, ++pattern){ + if(*pattern != static_cast(i)){ + return 1; + } + } + } + } + catch(std::exception &exc){ + std::cout << "Unhandled exception: " << exc.what() << std::endl; + return 1; + } + } + } + catch(std::exception &exc){ + std::cout << "Unhandled exception: " << exc.what() << std::endl; + return 1; + } + return 0; +} + +#else + +int main() +{ + return 0; +} + +#endif //BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS + +#include