diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 index 1a88d0102..50f46aefe 100644 --- a/build/Jamfile.v2 +++ b/build/Jamfile.v2 @@ -16,6 +16,8 @@ # You need to provide the include path and lib path in the variables # PTW32_INCLUDE and PTW32_LIB respectively. You can specify these # paths in site-config.jam, user-config.jam or in the environment. +# Additionally, you can provide PTW32_LIB_NAME to overwrite the name hardcoded +# by Boost.Thread. # A new feature is provided to request a specific API: # win32 and pthread. # @@ -165,12 +167,16 @@ rule win32_pthread_paths ( properties * ) local result ; local PTW32_INCLUDE ; local PTW32_LIB ; - PTW32_INCLUDE = [ modules.peek : PTW32_INCLUDE ] ; - PTW32_LIB = [ modules.peek : PTW32_LIB ] ; - PTW32_INCLUDE ?= [ modules.peek user-config : PTW32_INCLUDE ] ; - PTW32_LIB ?= [ modules.peek user-config : PTW32_LIB ] ; - PTW32_INCLUDE ?= [ modules.peek site-config : PTW32_INCLUDE ] ; - PTW32_LIB ?= [ modules.peek site-config : PTW32_LIB ] ; + local PTW32_LIB_NAME ; + PTW32_INCLUDE = [ modules.peek : PTW32_INCLUDE ] ; + PTW32_LIB = [ modules.peek : PTW32_LIB ] ; + PTW32_LIB_NAME = [ modules.peek : PTW32_LIB_NAME ] ; + PTW32_INCLUDE ?= [ modules.peek user-config : PTW32_INCLUDE ] ; + PTW32_LIB ?= [ modules.peek user-config : PTW32_LIB ] ; + PTW32_LIB_NAME ?= [ modules.peek user-config : PTW32_LIB_NAME ] ; + PTW32_INCLUDE ?= [ modules.peek site-config : PTW32_INCLUDE ] ; + PTW32_LIB ?= [ modules.peek site-config : PTW32_LIB ] ; + PTW32_LIB_NAME ?= [ modules.peek site-config : PTW32_LIB_NAME ] ; if ! ( $(PTW32_INCLUDE) && $(PTW32_LIB) ) { @@ -192,16 +198,23 @@ rule win32_pthread_paths ( properties * ) { local include_path = [ path.make $(PTW32_INCLUDE) ] ; local lib_path = [ path.make $(PTW32_LIB) ] ; - local libname = pthread ; + local libname = $(PTW32_LIB_NAME) ; if msvc in $(properties) { - libname = $(libname)VC2.lib ; + if ! $(libname) + { + libname = libpthreadVC2.lib ; + } + lib_path = [ path.glob $(lib_path) : $(libname) ] ; } if gcc in $(properties) { - libname = lib$(libname)GC2.a ; + if ! $(libname) + { + libname = libpthreadGC2.a ; + } + lib_path = [ path.glob $(lib_path) : $(libname) ] ; } - lib_path = [ path.glob $(lib_path) : $(libname) ] ; if ! $(lib_path) { if ! $(.notified) @@ -210,6 +223,7 @@ rule win32_pthread_paths ( properties * ) echo "Trying to build Boost.Thread with pthread support." ; echo "But the library" $(libname) "could not be found in path" ; echo $(PTW32_LIB) ; + echo "You can force the library name by setting PTW32_LIB_NAME " ; echo "************************************************************" ; .notified = true ; } @@ -316,4 +330,4 @@ lib boost_thread @usage-requirements ; -boost-install boost_thread ; \ No newline at end of file +boost-install boost_thread ; diff --git a/include/boost/thread/detail/config.hpp b/include/boost/thread/detail/config.hpp index faffa0778..8e89aee70 100644 --- a/include/boost/thread/detail/config.hpp +++ b/include/boost/thread/detail/config.hpp @@ -421,7 +421,9 @@ # endif #endif -#if defined(BOOST_THREAD_CHRONO_WINDOWS_API) +#if defined(BOOST_THREAD_MINGW) && defined(BOOST_THREAD_PLATFORM_PTHREAD) +// MinGW pthread does not support monotonic clocks +#elif defined(BOOST_THREAD_CHRONO_WINDOWS_API) #define BOOST_THREAD_HAS_MONO_CLOCK #define BOOST_THREAD_INTERNAL_CLOCK_IS_MONO #elif defined(BOOST_THREAD_CHRONO_MAC_API) diff --git a/include/boost/thread/detail/platform.hpp b/include/boost/thread/detail/platform.hpp index 172a601a0..1b700562a 100644 --- a/include/boost/thread/detail/platform.hpp +++ b/include/boost/thread/detail/platform.hpp @@ -17,7 +17,9 @@ #include // choose platform -#if defined(linux) || defined(__linux) || defined(__linux__) +#ifdef __MINGW32__ +#define BOOST_THREAD_MINGW +#elif defined(linux) || defined(__linux) || defined(__linux__) # define BOOST_THREAD_LINUX //# define BOOST_THREAD_WAIT_BUG boost::posix_time::microseconds(100000) #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) diff --git a/include/boost/thread/pthread/thread_data.hpp b/include/boost/thread/pthread/thread_data.hpp index aefbeb43c..e07898208 100644 --- a/include/boost/thread/pthread/thread_data.hpp +++ b/include/boost/thread/pthread/thread_data.hpp @@ -32,6 +32,10 @@ # endif #endif +#ifdef BOOST_THREAD_MINGW +#include +#endif + #include #include @@ -52,7 +56,11 @@ namespace boost // stack void set_stack_size(std::size_t size) BOOST_NOEXCEPT { if (size==0) return; -#ifdef BOOST_THREAD_USES_GETPAGESIZE +#ifdef BOOST_THREAD_MINGW + SYSTEM_INFO si; + GetSystemInfo(&si); + std::size_t page_size = si.dwPageSize; +#elif defined(BOOST_THREAD_USES_GETPAGESIZE) std::size_t page_size = getpagesize(); #else std::size_t page_size = ::sysconf( _SC_PAGESIZE);