From 4fadd968fa12130524c8380f33fcfe25d4de79e5 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Wed, 13 Sep 2017 11:24:46 +0900 Subject: Imported Upstream version 1.65.0 Change-Id: Icf8400b375482cb11bcf77440a6934ba360d6ba4 Signed-off-by: DongHun Kwak --- boost/context/windows/protected_fixedsize_stack.hpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'boost/context/windows/protected_fixedsize_stack.hpp') diff --git a/boost/context/windows/protected_fixedsize_stack.hpp b/boost/context/windows/protected_fixedsize_stack.hpp index 437f091088..26d2086095 100644 --- a/boost/context/windows/protected_fixedsize_stack.hpp +++ b/boost/context/windows/protected_fixedsize_stack.hpp @@ -41,15 +41,13 @@ public: } stack_context allocate() { - // page at bottom will be used as guard-page - const std::size_t pages( - static_cast< std::size_t >( - std::floor( + // calculate how many pages are required + const std::size_t pages( + static_cast< std::size_t >( + std::ceil( static_cast< float >( size_) / traits_type::page_size() ) ) ); - BOOST_ASSERT_MSG( 2 <= pages, "at least two pages must fit into stack (one page is guard-page)"); - const std::size_t size__( pages * traits_type::page_size() ); - BOOST_ASSERT( 0 != size_ && 0 != size__); - BOOST_ASSERT( size__ <= size_); + // add one page at bottom that will be used as guard-page + const std::size_t size__ = ( pages + 1) * traits_type::page_size(); void * vp = ::VirtualAlloc( 0, size__, MEM_COMMIT, PAGE_READWRITE); if ( ! vp) throw std::bad_alloc(); -- cgit v1.2.3