diff options
Diffstat (limited to 'boost/context/posix/protected_fixedsize_stack.hpp')
-rw-r--r-- | boost/context/posix/protected_fixedsize_stack.hpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/boost/context/posix/protected_fixedsize_stack.hpp b/boost/context/posix/protected_fixedsize_stack.hpp index f36d451b40..b0c7f7e675 100644 --- a/boost/context/posix/protected_fixedsize_stack.hpp +++ b/boost/context/posix/protected_fixedsize_stack.hpp @@ -49,15 +49,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(); // conform to POSIX.4 (POSIX.1b-1993, _POSIX_C_SOURCE=199309L) #if defined(MAP_ANON) |