From 99ac322223f5b3ad5c08a567ba276813cf090b19 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Sun, 22 Jun 2014 19:13:01 +0400 Subject: [PATCH 1/4] Fix warnings about redefining a defined macro The warnings appear when a dependent project (e.g. Boost.Log tests and examples) builds with link=shared and defines BOOST_ALL_DYN_LINK macro. In this case BOOST_THREAD_USE_DLL is defined by both thread/build/Jamfile.v2 and boost/thread/detail/config.hpp. This commit makes sure that doesn't happen. --- include/boost/thread/detail/config.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/boost/thread/detail/config.hpp b/include/boost/thread/detail/config.hpp index 62461c51..5ffe5e49 100644 --- a/include/boost/thread/detail/config.hpp +++ b/include/boost/thread/detail/config.hpp @@ -379,7 +379,9 @@ // compatibility with the rest of Boost's auto-linking code: #if defined(BOOST_THREAD_DYN_LINK) || defined(BOOST_ALL_DYN_LINK) # undef BOOST_THREAD_USE_LIB -# define BOOST_THREAD_USE_DLL +# if !defined(BOOST_THREAD_USE_DLL) +# define BOOST_THREAD_USE_DLL +# endif #endif #if defined(BOOST_THREAD_BUILD_DLL) //Build dll From 00ad9dddb906c7cb71a245543188127f3345b4ce Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Sun, 29 Jun 2014 23:04:34 +0200 Subject: [PATCH 2/4] Added nested type op_status. --- include/boost/thread/sync_queue.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/boost/thread/sync_queue.hpp b/include/boost/thread/sync_queue.hpp index 45538ef0..b781ec23 100644 --- a/include/boost/thread/sync_queue.hpp +++ b/include/boost/thread/sync_queue.hpp @@ -34,6 +34,7 @@ namespace boost typedef ValueType value_type; typedef csbl::deque underlying_queue_type; typedef std::size_t size_type; + typedef queue_op_status op_status; // Constructors/Assignment/Destructors BOOST_THREAD_NO_COPYABLE(sync_queue) From c266790b8d4015fa23ef76e284972000e3bee525 Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Sun, 29 Jun 2014 23:48:18 +0200 Subject: [PATCH 3/4] Try to fix phisical_concurrency on PowerPC arch. --- src/pthread/thread.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pthread/thread.cpp b/src/pthread/thread.cpp index b09f015f..f1ebd905 100644 --- a/src/pthread/thread.cpp +++ b/src/pthread/thread.cpp @@ -572,6 +572,11 @@ namespace boost unsigned thread::physical_concurrency() BOOST_NOEXCEPT { #ifdef __linux__ +#ifdef __powerpc__ + + return hardware_concurrency(); + +#endif try { using namespace std; From c6817aeb1ce7857bc399909a2892f7c446fe7c67 Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Thu, 3 Jul 2014 07:08:07 +0200 Subject: [PATCH 4/4] fall back to harware concurrency when physical concurrency doesn't works. --- src/pthread/thread.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/pthread/thread.cpp b/src/pthread/thread.cpp index f1ebd905..4eab832b 100644 --- a/src/pthread/thread.cpp +++ b/src/pthread/thread.cpp @@ -444,7 +444,7 @@ namespace boost { # if defined(BOOST_HAS_PTHREAD_DELAY_NP) - # if defined(__IBMCPP__) + # if defined(__IBMCPP__) || defined(_AIX) BOOST_VERIFY(!pthread_delay_np(const_cast(&ts))); # else BOOST_VERIFY(!pthread_delay_np(&ts)); @@ -572,11 +572,6 @@ namespace boost unsigned thread::physical_concurrency() BOOST_NOEXCEPT { #ifdef __linux__ -#ifdef __powerpc__ - - return hardware_concurrency(); - -#endif try { using namespace std; @@ -599,7 +594,7 @@ namespace boost boost::split(key_val, line, boost::is_any_of(":")); if (key_val.size() != 2) - return 0; + return hardware_concurrency(); string key = key_val[0]; string value = key_val[1]; @@ -617,9 +612,11 @@ namespace boost continue; } } - return cores.size(); + // Fall back to hardware_concurrency() in case + // /proc/cpuinfo is formatted differently than we expect. + return cores.size() != 0 ? cores.size() : hardware_concurrency(); } catch(...) { - return 0; + return hardware_concurrency(); } #elif defined(__APPLE__) int count;