diff --git a/CMakeLists.txt b/CMakeLists.txt index d05dcf2d..a0c2e926 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -174,8 +174,6 @@ target_link_libraries(boost_context Boost::pool Boost::predef Boost::smart_ptr - PRIVATE - Boost::thread ) target_compile_definitions(boost_context diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 index eb83bbb7..9a81210a 100644 --- a/build/Jamfile.v2 +++ b/build/Jamfile.v2 @@ -850,26 +850,13 @@ alias impl_sources explicit impl_sources ; -obj cxx11_hdr_mutex_check : ../build/cxx11_hdr_mutex.cpp ; -explicit cxx11_hdr_mutex_check ; -local cxx11_mutex = [ check-target-builds - cxx11_hdr_mutex_check "C++11 mutex" - : - : /boost/thread//boost_thread - ] ; - alias stack_traits_sources : windows/stack_traits.cpp : windows - : - : $(cxx11_mutex) ; alias stack_traits_sources : posix/stack_traits.cpp - : - : - : $(cxx11_mutex) ; explicit stack_traits_sources ; diff --git a/build/cxx11_hdr_mutex.cpp b/build/cxx11_hdr_mutex.cpp deleted file mode 100644 index d16a7a15..00000000 --- a/build/cxx11_hdr_mutex.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright Kohei Takahashi 2016. -// 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) - -#include - -#ifdef BOOST_NO_CXX11_HDR_MUTEX -#error "C++11 is not available." -#endif diff --git a/src/posix/stack_traits.cpp b/src/posix/stack_traits.cpp index a1086f78..4dd1829f 100644 --- a/src/posix/stack_traits.cpp +++ b/src/posix/stack_traits.cpp @@ -20,11 +20,6 @@ extern "C" { #include #include -#if defined(BOOST_NO_CXX11_HDR_MUTEX) -# include -#else -# include -#endif #if !defined (SIGSTKSZ) # define SIGSTKSZ (32768) // 32kb minimum allowable stack @@ -42,37 +37,20 @@ extern "C" { namespace { -void pagesize_( std::size_t * size) BOOST_NOEXCEPT_OR_NOTHROW { +std::size_t pagesize() BOOST_NOEXCEPT_OR_NOTHROW { // conform to POSIX.1-2001 - * size = ::sysconf( _SC_PAGESIZE); + return ::sysconf( _SC_PAGESIZE); } -void stacksize_limit_( rlimit * limit) BOOST_NOEXCEPT_OR_NOTHROW { +rlim_t stacksize_limit_() BOOST_NOEXCEPT_OR_NOTHROW { + rlimit limit; // conforming to POSIX.1-2001 - ::getrlimit( RLIMIT_STACK, limit); + ::getrlimit( RLIMIT_STACK, & limit); + return limit.rlim_max; } -std::size_t pagesize() BOOST_NOEXCEPT_OR_NOTHROW { - static std::size_t size = 0; -#if defined(BOOST_NO_CXX11_HDR_MUTEX) - static boost::once_flag flag = BOOST_ONCE_INIT; - boost::call_once( flag, pagesize_, & size); -#else - static std::once_flag flag; - std::call_once( flag, pagesize_, & size); -#endif - return size; -} - -rlimit stacksize_limit() BOOST_NOEXCEPT_OR_NOTHROW { - static rlimit limit; -#if defined(BOOST_NO_CXX11_HDR_MUTEX) - static boost::once_flag flag = BOOST_ONCE_INIT; - boost::call_once( flag, stacksize_limit_, & limit); -#else - static std::once_flag flag; - std::call_once( flag, stacksize_limit_, & limit); -#endif +rlim_t stacksize_limit() BOOST_NOEXCEPT_OR_NOTHROW { + static rlim_t limit = stacksize_limit_(); return limit; } @@ -83,12 +61,13 @@ namespace context { bool stack_traits::is_unbounded() BOOST_NOEXCEPT_OR_NOTHROW { - return RLIM_INFINITY == stacksize_limit().rlim_max; + return RLIM_INFINITY == stacksize_limit(); } std::size_t stack_traits::page_size() BOOST_NOEXCEPT_OR_NOTHROW { - return pagesize(); + static std::size_t size = pagesize(); + return size; } std::size_t @@ -104,7 +83,7 @@ stack_traits::minimum_size() BOOST_NOEXCEPT_OR_NOTHROW { std::size_t stack_traits::maximum_size() BOOST_NOEXCEPT_OR_NOTHROW { BOOST_ASSERT( ! is_unbounded() ); - return static_cast< std::size_t >( stacksize_limit().rlim_max); + return static_cast< std::size_t >( stacksize_limit() ); } }} diff --git a/src/windows/stack_traits.cpp b/src/windows/stack_traits.cpp index 14016b1b..4edada09 100644 --- a/src/windows/stack_traits.cpp +++ b/src/windows/stack_traits.cpp @@ -20,11 +20,6 @@ extern "C" { #include #include -#if defined(BOOST_NO_CXX11_HDR_MUTEX) -# include -#else -# include -#endif #include @@ -48,24 +43,10 @@ extern "C" { namespace { -void system_info_( SYSTEM_INFO * si) BOOST_NOEXCEPT_OR_NOTHROW { - ::GetSystemInfo( si); -} - -SYSTEM_INFO system_info() BOOST_NOEXCEPT_OR_NOTHROW { - static SYSTEM_INFO si; -#if defined(BOOST_NO_CXX11_HDR_MUTEX) - static boost::once_flag flag = BOOST_ONCE_INIT; - boost::call_once( flag, static_cast< void(*)( SYSTEM_INFO *) >( system_info_), & si); -#else - static std::once_flag flag; - std::call_once( flag, static_cast< void(*)( SYSTEM_INFO *) >( system_info_), & si); -#endif - return si; -} - std::size_t pagesize() BOOST_NOEXCEPT_OR_NOTHROW { - return static_cast< std::size_t >( system_info().dwPageSize); + SYSTEM_INFO si; + ::GetSystemInfo(&si); + return static_cast< std::size_t >( si.dwPageSize ); } } @@ -84,7 +65,8 @@ stack_traits::is_unbounded() BOOST_NOEXCEPT_OR_NOTHROW { BOOST_CONTEXT_DECL std::size_t stack_traits::page_size() BOOST_NOEXCEPT_OR_NOTHROW { - return pagesize(); + static std::size_t size = pagesize(); + return size; } BOOST_CONTEXT_DECL