From cfc703732a287b05f505005a1468fe0ba489c37f Mon Sep 17 00:00:00 2001 From: Oliver Kowalke Date: Sun, 18 Oct 2015 19:17:56 +0200 Subject: [PATCH] segmented-stacks=on -> only segmented_stack is available --- doc/stack.qbk | 3 +++ example/parser.cpp | 1 - example/segmented.cpp | 5 ----- include/boost/coroutine2/detail/config.hpp | 12 ------------ include/boost/coroutine2/detail/pull_coroutine.ipp | 7 ++++--- include/boost/coroutine2/detail/push_coroutine.ipp | 7 ++++--- include/boost/coroutine2/fixedsize_stack.hpp | 3 +++ include/boost/coroutine2/segmented_stack.hpp | 3 ++- 8 files changed, 16 insertions(+), 25 deletions(-) diff --git a/doc/stack.qbk b/doc/stack.qbk index 522424e..72a9b60 100644 --- a/doc/stack.qbk +++ b/doc/stack.qbk @@ -194,6 +194,9 @@ address of the stack.]] [[Effects:] [Deallocates the stack space.]] ] +[note If the library is compiled for segmented stacks, __segmented_stack__ is the only +available stack allocator.] + [endsect] diff --git a/example/parser.cpp b/example/parser.cpp index 41f2df3..e960fc5 100644 --- a/example/parser.cpp +++ b/example/parser.cpp @@ -100,7 +100,6 @@ int main() { std::istringstream is("1+1"); // invert control flow coro_t::pull_type seq( - boost::coroutines2::fixedsize_stack(), [&is]( coro_t::push_type & yield) { Parser p( is, [&yield](char ch){ diff --git a/example/segmented.cpp b/example/segmented.cpp index eb24309..3486183 100644 --- a/example/segmented.cpp +++ b/example/segmented.cpp @@ -47,11 +47,6 @@ int main() { #endif boost::coroutines2::coroutine< void >::push_type sink( -#if defined(BOOST_USE_SEGMENTED_STACKS) - boost::coroutines2::segmented_stack(), -#else - boost::coroutines2::fixedsize_stack(), -#endif [&]( boost::coroutines2::coroutine< void >::pull_type & source) { bar( count); source(); diff --git a/include/boost/coroutine2/detail/config.hpp b/include/boost/coroutine2/detail/config.hpp index c439ecc..cfb9584 100644 --- a/include/boost/coroutine2/detail/config.hpp +++ b/include/boost/coroutine2/detail/config.hpp @@ -36,16 +36,4 @@ # include #endif -#if defined(BOOST_USE_SEGMENTED_STACKS) -# if ! ( (defined(__GNUC__) && __GNUC__ > 3 && __GNUC_MINOR__ > 6) || \ - (defined(__clang__) && __clang_major__ > 2 && __clang_minor__ > 3) ) -# error "compiler does not support segmented_stack stacks" -# endif -# define BOOST_COROUTINES2_SEGMENTS 10 -#endif - -#if defined(BOOST_CONTEXT_NO_EXECUTION_CONTEXT) -# error "execution_context from boost.context not supported" -#endif - #endif // BOOST_COROUTINES2_DETAIL_CONFIG_H diff --git a/include/boost/coroutine2/detail/pull_coroutine.ipp b/include/boost/coroutine2/detail/pull_coroutine.ipp index f59bb3c..e18436f 100644 --- a/include/boost/coroutine2/detail/pull_coroutine.ipp +++ b/include/boost/coroutine2/detail/pull_coroutine.ipp @@ -19,6 +19,7 @@ #include #include +#include #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_PREFIX @@ -44,7 +45,7 @@ pull_coroutine< T >::has_result_() const { template< typename T > template< typename Fn > pull_coroutine< T >::pull_coroutine( Fn && fn, bool preserve_fpu) : - pull_coroutine( fixedsize_stack(), std::forward< Fn >( fn), preserve_fpu) { + pull_coroutine( default_stack(), std::forward< Fn >( fn), preserve_fpu) { } template< typename T > @@ -127,7 +128,7 @@ pull_coroutine< T & >::has_result_() const { template< typename T > template< typename Fn > pull_coroutine< T & >::pull_coroutine( Fn && fn, bool preserve_fpu) : - pull_coroutine( fixedsize_stack(), std::forward< Fn >( fn), preserve_fpu) { + pull_coroutine( default_stack(), std::forward< Fn >( fn), preserve_fpu) { } template< typename T > @@ -203,7 +204,7 @@ pull_coroutine< void >::pull_coroutine( control_block * cb) : template< typename Fn > pull_coroutine< void >::pull_coroutine( Fn && fn, bool preserve_fpu) : - pull_coroutine( fixedsize_stack(), std::forward< Fn >( fn), preserve_fpu) { + pull_coroutine( default_stack(), std::forward< Fn >( fn), preserve_fpu) { } template< typename StackAllocator, typename Fn > diff --git a/include/boost/coroutine2/detail/push_coroutine.ipp b/include/boost/coroutine2/detail/push_coroutine.ipp index 4617e73..5f48178 100644 --- a/include/boost/coroutine2/detail/push_coroutine.ipp +++ b/include/boost/coroutine2/detail/push_coroutine.ipp @@ -18,6 +18,7 @@ #include #include +#include #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_PREFIX @@ -37,7 +38,7 @@ push_coroutine< T >::push_coroutine( control_block * cb) : template< typename T > template< typename Fn > push_coroutine< T >::push_coroutine( Fn && fn, bool preserve_fpu) : - push_coroutine( fixedsize_stack(), std::forward< Fn >( fn), preserve_fpu) { + push_coroutine( default_stack(), std::forward< Fn >( fn), preserve_fpu) { } template< typename T > @@ -115,7 +116,7 @@ push_coroutine< T & >::push_coroutine( control_block * cb) : template< typename T > template< typename Fn > push_coroutine< T & >::push_coroutine( Fn && fn, bool preserve_fpu) : - push_coroutine( fixedsize_stack(), std::forward< Fn >( fn), preserve_fpu) { + push_coroutine( default_stack(), std::forward< Fn >( fn), preserve_fpu) { } template< typename T > @@ -185,7 +186,7 @@ push_coroutine< void >::push_coroutine( control_block * cb) : template< typename Fn > push_coroutine< void >::push_coroutine( Fn && fn, bool preserve_fpu) : - push_coroutine( fixedsize_stack(), std::forward< Fn >( fn), preserve_fpu) { + push_coroutine( default_stack(), std::forward< Fn >( fn), preserve_fpu) { } template< typename StackAllocator, typename Fn > diff --git a/include/boost/coroutine2/fixedsize_stack.hpp b/include/boost/coroutine2/fixedsize_stack.hpp index 56523ab..8aa66fe 100644 --- a/include/boost/coroutine2/fixedsize_stack.hpp +++ b/include/boost/coroutine2/fixedsize_stack.hpp @@ -23,6 +23,9 @@ namespace boost { namespace coroutines2 { typedef boost::context::fixedsize_stack fixedsize_stack; +#if !defined(BOOST_USE_SEGMENTED_STACKS) +typedef boost::context::default_stack default_stack; +#endif }} diff --git a/include/boost/coroutine2/segmented_stack.hpp b/include/boost/coroutine2/segmented_stack.hpp index a252ae4..8443bc3 100644 --- a/include/boost/coroutine2/segmented_stack.hpp +++ b/include/boost/coroutine2/segmented_stack.hpp @@ -24,7 +24,8 @@ namespace coroutines2 { #if defined(BOOST_USE_SEGMENTED_STACKS) # if ! defined(BOOST_WINDOWS) -typedef boost::context::segmented_stack segmented_stack; +typedef boost::context::segmented_stack segmented_stack; +typedef boost::context::default_stack default_stack; # endif #endif