////////////////////////////////////////////////////////////////////////////// // // (C) Copyright Ion Gaztanaga 2006-2012. 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 #include #include #include #include #include #include //make_unsigned, alignment_of #include "memory_algorithm_test_template.hpp" #include #include #include "get_process_id_name.hpp" using namespace boost::interprocess; const int Memsize = 16384; const char *const shMemName = test::get_process_id_name(); int test_simple_seq_fit() { //A shared memory with simple sequential fit algorithm typedef basic_managed_shared_memory ,null_index > my_managed_shared_memory; //Create shared memory shared_memory_object::remove(shMemName); my_managed_shared_memory segment(create_only, shMemName, Memsize); //Now take the segment manager and launch memory test if(!test::test_all_allocation(*segment.get_segment_manager())){ return 1; } return 0; } template int test_rbtree_best_fit() { //A shared memory with red-black tree best fit algorithm typedef basic_managed_shared_memory , Alignment> ,null_index > my_managed_shared_memory; //Create shared memory shared_memory_object::remove(shMemName); my_managed_shared_memory segment(create_only, shMemName, Memsize); //Now take the segment manager and launch memory test if(!test::test_all_allocation(*segment.get_segment_manager())){ return 1; } return 0; } int main () { const std::size_t void_ptr_align = ::boost::container::dtl::alignment_of >::value; if(test_simple_seq_fit()){ return 1; } if(test_rbtree_best_fit()){ return 1; } if(test_rbtree_best_fit<2*void_ptr_align>()){ return 1; } if(test_rbtree_best_fit<4*void_ptr_align>()){ return 1; } shared_memory_object::remove(shMemName); return 0; } #include