diff --git a/include/boost/interprocess/detail/os_thread_functions.hpp b/include/boost/interprocess/detail/os_thread_functions.hpp index 32e019d..cc4149c 100644 --- a/include/boost/interprocess/detail/os_thread_functions.hpp +++ b/include/boost/interprocess/detail/os_thread_functions.hpp @@ -95,7 +95,7 @@ inline unsigned long get_system_tick_us() typedef unsigned __int64 OS_highres_count_t; -inline OS_highres_count_t get_system_tick_in_highres_counts() +inline unsigned long get_system_tick_in_highres_counts() { __int64 freq; unsigned long curres; @@ -103,13 +103,13 @@ inline OS_highres_count_t get_system_tick_in_highres_counts() //Frequency in counts per second if(!winapi::query_performance_frequency(&freq)){ //Tick resolution in ms - return (curres-1)/10000u + 1; + return (curres-1ul)/10000ul + 1ul; } else{ //In femtoseconds - __int64 count_fs = __int64(1000000000000000LL - 1LL)/freq + 1LL; - __int64 tick_counts = (__int64(curres)*100000000LL - 1LL)/count_fs + 1LL; - return static_cast(tick_counts); + __int64 count_fs = (1000000000000000LL - 1LL)/freq + 1LL; + __int64 tick_counts = (static_cast<__int64>(curres)*100000000LL - 1LL)/count_fs + 1LL; + return static_cast(tick_counts); } } @@ -141,6 +141,9 @@ inline OS_highres_count_t system_highres_count_subtract(const OS_highres_count_t inline bool system_highres_count_less(const OS_highres_count_t &l, const OS_highres_count_t &r) { return l < r; } +inline bool system_highres_count_less_ul(const OS_highres_count_t &l, unsigned long r) +{ return l < static_cast(r); } + inline void thread_sleep_tick() { winapi::sleep_tick(); } @@ -278,18 +281,15 @@ inline unsigned long get_system_tick_ns() #endif } -inline OS_highres_count_t get_system_tick_in_highres_counts() +inline unsigned long get_system_tick_in_highres_counts() { #ifndef BOOST_INTERPROCESS_MATCH_ABSOLUTE_TIME - struct timespec ts; - ts.tv_sec = 0; - ts.tv_nsec = get_system_tick_ns(); - return ts; + return get_system_tick_ns(); #else mach_timebase_info_data_t info; mach_timebase_info(&info); //ns - return static_cast + return static_cast ( static_cast(get_system_tick_ns()) / (static_cast(info.numer) / info.denom) @@ -346,7 +346,10 @@ inline OS_highres_count_t system_highres_count_subtract(const OS_highres_count_t } inline bool system_highres_count_less(const OS_highres_count_t &l, const OS_highres_count_t &r) -{ return l.tv_sec < r.tv_sec || (l.tv_sec == r.tv_sec && l.tv_nsec < r.tv_nsec); } +{ return l.tv_sec < r.tv_sec || (l.tv_sec == r.tv_sec && l.tv_nsec < r.tv_nsec); } + +inline bool system_highres_count_less_ul(const OS_highres_count_t &l, unsigned long r) +{ return !l.tv_sec && (static_cast(l.tv_nsec) < r); } #else @@ -367,7 +370,10 @@ inline OS_highres_count_t system_highres_count_subtract(const OS_highres_count_t { return l - r; } inline bool system_highres_count_less(const OS_highres_count_t &l, const OS_highres_count_t &r) -{ return l < r; } +{ return l < r; } + +inline bool system_highres_count_less_ul(const OS_highres_count_t &l, unsigned long r) +{ return l < static_cast(r); } #endif diff --git a/include/boost/interprocess/segment_manager.hpp b/include/boost/interprocess/segment_manager.hpp index a0f948f..9113acb 100644 --- a/include/boost/interprocess/segment_manager.hpp +++ b/include/boost/interprocess/segment_manager.hpp @@ -847,7 +847,6 @@ class segment_manager { (void)is_intrusive; typedef IndexType > index_type; - typedef ipcdetail::index_key index_key_t; typedef typename index_type::iterator index_it; //------------------------------- @@ -949,7 +948,6 @@ class segment_manager { (void)is_intrusive_index; typedef IndexType > index_type; - typedef ipcdetail::index_key index_key_t; typedef typename index_type::iterator index_it; typedef typename index_type::value_type intrusive_value_type; diff --git a/include/boost/interprocess/sync/spin/wait.hpp b/include/boost/interprocess/sync/spin/wait.hpp index 1bf28f3..0707bd8 100644 --- a/include/boost/interprocess/sync/spin/wait.hpp +++ b/include/boost/interprocess/sync/spin/wait.hpp @@ -1,7 +1,7 @@ ////////////////////////////////////////////////////////////////////////////// // // (C) Copyright Peter Dimov 2008. -// (C) Copyright Ion Gaztanaga 2013. Distributed under the Boost +// (C) Copyright Ion Gaztanaga 2013-2013. 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) // @@ -73,13 +73,11 @@ unsigned int num_core_holder::num_cores = ipcdetail::get_num_cores(); class spin_wait { public: + + static const unsigned int nop_pause_limit = 32u; spin_wait() - : m_k(0u) - { - (void)m_nop_pause_limit; - (void)m_yield_only_counts; - (void)m_count_start; - } + : m_count_start(), m_ul_yield_only_counts(), m_k() + {} #ifdef BOOST_INTERPROCESS_SPIN_WAIT_DEBUG ~spin_wait() @@ -101,19 +99,19 @@ class spin_wait this->init_limits(); } //Nop tries - if( m_k < (m_nop_pause_limit >> 2) ){ + if( m_k < (nop_pause_limit >> 2) ){ } //Pause tries if the processor supports it #if defined(BOOST_INTERPROCESS_SMT_PAUSE) - else if( m_k < m_nop_pause_limit ){ + else if( m_k < nop_pause_limit ){ BOOST_INTERPROCESS_SMT_PAUSE } #endif //Yield/Sleep strategy else{ //Lazy initialization of tick information - if(m_k == m_nop_pause_limit){ + if(m_k == nop_pause_limit){ this->init_tick_info(); } else if( this->yield_or_sleep() ){ @@ -129,7 +127,6 @@ class spin_wait void reset() { m_k = 0u; - m_count_start = ipcdetail::get_current_system_highres_count(); } private: @@ -137,45 +134,43 @@ class spin_wait void init_limits() { unsigned int num_cores = ipcdetail::num_core_holder<0>::get(); - m_nop_pause_limit = num_cores > 1u ? 32u : 0u; + m_k = num_cores > 1u ? 0u : nop_pause_limit; } void init_tick_info() { - m_yield_only_counts = ipcdetail::get_system_tick_in_highres_counts(); + m_ul_yield_only_counts = ipcdetail::get_system_tick_in_highres_counts(); m_count_start = ipcdetail::get_current_system_highres_count(); } //Returns true if yield must be called, false is sleep must be called bool yield_or_sleep() { - if(ipcdetail::is_highres_count_zero(m_yield_only_counts)){ //If yield-only limit was reached then yield one in every two tries + if(!m_ul_yield_only_counts){ //If yield-only limit was reached then yield one in every two tries return (m_k & 1u) != 0; } else{ //Try to see if we've reched yield-only time limit const ipcdetail::OS_highres_count_t now = ipcdetail::get_current_system_highres_count(); const ipcdetail::OS_highres_count_t elapsed = ipcdetail::system_highres_count_subtract(now, m_count_start); - if(!ipcdetail::system_highres_count_less(elapsed, m_yield_only_counts)){ + if(!ipcdetail::system_highres_count_less_ul(elapsed, m_ul_yield_only_counts)){ #ifdef BOOST_INTERPROCESS_SPIN_WAIT_DEBUG std::cout << "elapsed!\n" - << " m_yield_only_counts: "; - ipcdetail::ostream_highres_count(std::cout, m_yield_only_counts) + << " m_ul_yield_only_counts: " << m_ul_yield_only_counts << " system tick(us): " << ipcdetail::get_system_tick_us() << '\n' << " m_k: " << m_k << " elapsed counts: "; ipcdetail::ostream_highres_count(std::cout, elapsed) << std::endl; #endif //Yield-only time reached, now it's time to sleep - ipcdetail::zero_highres_count(m_yield_only_counts); + m_ul_yield_only_counts = 0ul; return false; } } return true; //Otherwise yield } - unsigned int m_k; - unsigned int m_nop_pause_limit; - ipcdetail::OS_highres_count_t m_yield_only_counts; ipcdetail::OS_highres_count_t m_count_start; + unsigned long m_ul_yield_only_counts; + unsigned int m_k; }; } // namespace interprocess diff --git a/test/check_equal_containers.hpp b/test/check_equal_containers.hpp index 48eb9c2..573657e 100644 --- a/test/check_equal_containers.hpp +++ b/test/check_equal_containers.hpp @@ -48,8 +48,6 @@ bool CheckEqualContainers(MyShmCont *shmcont, MyStdCont *stdcont) if(shmcont->size() != stdcont->size()) return false; - typedef typename MyShmCont::value_type value_type; - typename MyShmCont::iterator itshm(shmcont->begin()), itshmend(shmcont->end()); typename MyStdCont::iterator itstd(stdcont->begin()); typename MyStdCont::size_type dist = (typename MyStdCont::size_type)std::distance(itshm, itshmend); diff --git a/test/data_test.cpp b/test/data_test.cpp index 717c84c..7c4e58b 100644 --- a/test/data_test.cpp +++ b/test/data_test.cpp @@ -47,7 +47,6 @@ int main () const char *allocName = "testAllocation"; typedef boost::interprocess::vector MyVect; - typedef boost::interprocess::list MyList; //---- ALLOC, NAMED_ALLOC, NAMED_NEW TEST ----// { diff --git a/test/named_allocation_test_template.hpp b/test/named_allocation_test_template.hpp index 94c1bc7..b3f1507 100644 --- a/test/named_allocation_test_template.hpp +++ b/test/named_allocation_test_template.hpp @@ -100,7 +100,6 @@ template bool test_named_iterators(ManagedMemory &m) { typedef typename ManagedMemory::char_type char_type; - typedef std::char_traits char_traits_type; std::vector buffers; const int BufferLen = 100; char_type name[BufferLen]; @@ -172,7 +171,6 @@ template bool test_shrink_to_fit(ManagedMemory &m) { typedef typename ManagedMemory::char_type char_type; - typedef std::char_traits char_traits_type; std::vector buffers; const int BufferLen = 100; char_type name[BufferLen]; @@ -214,7 +212,6 @@ template bool test_direct_named_allocation_destruction(ManagedMemory &m) { typedef typename ManagedMemory::char_type char_type; - typedef std::char_traits char_traits_type; std::vector buffers; const int BufferLen = 100; char_type name[BufferLen]; @@ -255,7 +252,6 @@ template bool test_named_allocation_inverse_destruction(ManagedMemory &m) { typedef typename ManagedMemory::char_type char_type; - typedef std::char_traits char_traits_type; std::vector buffers; const int BufferLen = 100; @@ -295,7 +291,6 @@ template bool test_named_allocation_mixed_destruction(ManagedMemory &m) { typedef typename ManagedMemory::char_type char_type; - typedef std::char_traits char_traits_type; std::vector buffers; const int BufferLen = 100; @@ -337,7 +332,6 @@ template bool test_inverse_named_allocation_destruction(ManagedMemory &m) { typedef typename ManagedMemory::char_type char_type; - typedef std::char_traits char_traits_type; std::vector buffers; const int BufferLen = 100; diff --git a/test/shared_ptr_test.cpp b/test/shared_ptr_test.cpp index 7ca0942..3e9c61a 100644 --- a/test/shared_ptr_test.cpp +++ b/test/shared_ptr_test.cpp @@ -53,7 +53,6 @@ int simple_test() typedef deleter base_deleter_t; typedef shared_ptr base_shared_ptr; - typedef weak_ptr base_weak_ptr; std::string process_name; test::get_process_id_name(process_name); @@ -561,17 +560,11 @@ void test_alias() typedef allocator v_allocator_t; - typedef deleter - alias_tester_deleter_t; - typedef deleter int_deleter_t; - typedef shared_ptr alias_tester_shared_ptr; - typedef shared_ptr int_shared_ptr; typedef shared_ptr const_int_shared_ptr; - typedef shared_ptr volatile_int_shared_ptr; std::string process_name; test::get_process_id_name(process_name);