Merge branch 'develop'

This commit is contained in:
Oliver Kowalke 2015-06-21 18:30:43 +02:00
commit 03fee3bc4a
4 changed files with 110 additions and 3 deletions

View File

@ -20,6 +20,8 @@ project boost/coroutine2
<threading>multi
: usage-requirements
<link>shared:<define>BOOST_COROUTINES2_DYN_LINK=1
<optimization>speed:<define>BOOST_DISABLE_ASSERTS
<variant>release:<define>BOOST_DISABLE_ASSERTS
: source-location ../src
;

View File

@ -8,6 +8,7 @@
#define BOOST_COROUTINES2_DETAIL_PULL_COROUTINE_IPP
#include <algorithm>
#include <memory>
#include <utility>
#include <boost/assert.hpp>
@ -51,8 +52,23 @@ template< typename StackAllocator, typename Fn >
pull_coroutine< T >::pull_coroutine( StackAllocator salloc, Fn && fn, bool preserve_fpu) :
cb_( nullptr) {
context::stack_context sctx( salloc.allocate() );
// reserve space for control structure
#if defined(BOOST_NO_CXX14_CONSTEXPR) || defined(BOOST_NO_CXX11_STD_ALIGN)
void * sp = static_cast< char * >( sctx.sp) - sizeof( control_block);
std::size_t size = sctx.size - sizeof( control_block);
#else
constexpr std::size_t func_alignment = 64; // alignof( control_block);
constexpr std::size_t func_size = sizeof( control_block);
// reserve space on stack
void * sp = static_cast< char * >( sctx.sp) - func_size - func_alignment;
// align sp pointer
std::size_t space = func_size + func_alignment;
sp = std::align( func_alignment, func_size, sp, space);
BOOST_ASSERT( nullptr != sp);
// calculate remaining size
std::size_t size = sctx.size - ( static_cast< char * >( sctx.sp) - static_cast< char * >( sp) );
#endif
// placment new for control structure on coroutine stack
cb_ = new ( sp) control_block( context::preallocated( sp, size, sctx),
salloc, std::forward< Fn >( fn), preserve_fpu);
}
@ -119,8 +135,23 @@ template< typename StackAllocator, typename Fn >
pull_coroutine< T & >::pull_coroutine( StackAllocator salloc, Fn && fn, bool preserve_fpu) :
cb_( nullptr) {
context::stack_context sctx( salloc.allocate() );
// reserve space for control structure
#if defined(BOOST_NO_CXX14_CONSTEXPR) || defined(BOOST_NO_CXX11_STD_ALIGN)
void * sp = static_cast< char * >( sctx.sp) - sizeof( control_block);
std::size_t size = sctx.size - sizeof( control_block);
#else
constexpr std::size_t func_alignment = 64; // alignof( control_block);
constexpr std::size_t func_size = sizeof( control_block);
// reserve space on stack
void * sp = static_cast< char * >( sctx.sp) - func_size - func_alignment;
// align sp pointer
std::size_t space = func_size + func_alignment;
sp = std::align( func_alignment, func_size, sp, space);
BOOST_ASSERT( nullptr != sp);
// calculate remaining size
std::size_t size = sctx.size - ( static_cast< char * >( sctx.sp) - static_cast< char * >( sp) );
#endif
// placment new for control structure on coroutine stack
cb_ = new ( sp) control_block( context::preallocated( sp, size, sctx),
salloc, std::forward< Fn >( fn), preserve_fpu);
}
@ -179,8 +210,23 @@ template< typename StackAllocator, typename Fn >
pull_coroutine< void >::pull_coroutine( StackAllocator salloc, Fn && fn, bool preserve_fpu) :
cb_( nullptr) {
context::stack_context sctx( salloc.allocate() );
// reserve space for control structure
#if defined(BOOST_NO_CXX14_CONSTEXPR) || defined(BOOST_NO_CXX11_STD_ALIGN)
void * sp = static_cast< char * >( sctx.sp) - sizeof( control_block);
std::size_t size = sctx.size - sizeof( control_block);
#else
constexpr std::size_t func_alignment = 64; // alignof( control_block);
constexpr std::size_t func_size = sizeof( control_block);
// reserve space on stack
void * sp = static_cast< char * >( sctx.sp) - func_size - func_alignment;
// align sp pointer
std::size_t space = func_size + func_alignment;
sp = std::align( func_alignment, func_size, sp, space);
BOOST_ASSERT( nullptr != sp);
// calculate remaining size
std::size_t size = sctx.size - ( static_cast< char * >( sctx.sp) - static_cast< char * >( sp) );
#endif
// placment new for control structure on coroutine stack
cb_ = new ( sp) control_block( context::preallocated( sp, size, sctx),
salloc, std::forward< Fn >( fn), preserve_fpu);
}

View File

@ -7,6 +7,7 @@
#ifndef BOOST_COROUTINES2_DETAIL_PUSH_COROUTINE_IPP
#define BOOST_COROUTINES2_DETAIL_PUSH_COROUTINE_IPP
#include <memory>
#include <utility>
#include <boost/assert.hpp>
@ -44,8 +45,23 @@ template< typename StackAllocator, typename Fn >
push_coroutine< T >::push_coroutine( StackAllocator salloc, Fn && fn, bool preserve_fpu) :
cb_( nullptr) {
context::stack_context sctx( salloc.allocate() );
// reserve space for control structure
#if defined(BOOST_NO_CXX14_CONSTEXPR) || defined(BOOST_NO_CXX11_STD_ALIGN)
void * sp = static_cast< char * >( sctx.sp) - sizeof( control_block);
std::size_t size = sctx.size - sizeof( control_block);
#else
constexpr std::size_t func_alignment = 64; // alignof( control_block);
constexpr std::size_t func_size = sizeof( control_block);
// reserve space on stack
void * sp = static_cast< char * >( sctx.sp) - func_size - func_alignment;
// align sp pointer
std::size_t space = func_size + func_alignment;
sp = std::align( func_alignment, func_size, sp, space);
BOOST_ASSERT( nullptr != sp);
// calculate remaining size
std::size_t size = sctx.size - ( static_cast< char * >( sctx.sp) - static_cast< char * >( sp) );
#endif
// placment new for control structure on coroutine stack
cb_= new ( sp) control_block( context::preallocated( sp, size, sctx),
salloc, std::forward< Fn >( fn), preserve_fpu);
}
@ -107,8 +123,23 @@ template< typename StackAllocator, typename Fn >
push_coroutine< T & >::push_coroutine( StackAllocator salloc, Fn && fn, bool preserve_fpu) :
cb_( nullptr) {
context::stack_context sctx( salloc.allocate() );
// reserve space for control structure
#if defined(BOOST_NO_CXX14_CONSTEXPR) || defined(BOOST_NO_CXX11_STD_ALIGN)
void * sp = static_cast< char * >( sctx.sp) - sizeof( control_block);
std::size_t size = sctx.size - sizeof( control_block);
#else
constexpr std::size_t func_alignment = 64; // alignof( control_block);
constexpr std::size_t func_size = sizeof( control_block);
// reserve space on stack
void * sp = static_cast< char * >( sctx.sp) - func_size - func_alignment;
// align sp pointer
std::size_t space = func_size + func_alignment;
sp = std::align( func_alignment, func_size, sp, space);
BOOST_ASSERT( nullptr != sp);
// calculate remaining size
std::size_t size = sctx.size - ( static_cast< char * >( sctx.sp) - static_cast< char * >( sp) );
#endif
// placment new for control structure on coroutine stack
cb_ = new ( sp) control_block( context::preallocated( sp, size, sctx),
salloc, std::forward< Fn >( fn), preserve_fpu);
}
@ -161,8 +192,23 @@ template< typename StackAllocator, typename Fn >
push_coroutine< void >::push_coroutine( StackAllocator salloc, Fn && fn, bool preserve_fpu) :
cb_( nullptr) {
context::stack_context sctx( salloc.allocate() );
// reserve space for control structure
#if defined(BOOST_NO_CXX14_CONSTEXPR) || defined(BOOST_NO_CXX11_STD_ALIGN)
void * sp = static_cast< char * >( sctx.sp) - sizeof( control_block);
std::size_t size = sctx.size - sizeof( control_block);
#else
constexpr std::size_t func_alignment = 64; // alignof( control_block);
constexpr std::size_t func_size = sizeof( control_block);
// reserve space on stack
void * sp = static_cast< char * >( sctx.sp) - func_size - func_alignment;
// align sp pointer
std::size_t space = func_size + func_alignment;
sp = std::align( func_alignment, func_size, sp, space);
BOOST_ASSERT( nullptr != sp);
// calculate remaining size
std::size_t size = sctx.size - ( static_cast< char * >( sctx.sp) - static_cast< char * >( sp) );
#endif
// placment new for control structure on coroutine stack
cb_ = new ( sp) control_block( context::preallocated( sp, size, sctx),
salloc, std::forward< Fn >( fn), preserve_fpu);
}

View File

@ -9,8 +9,10 @@ import feature ;
import indirect ;
import modules ;
import os ;
import path ;
import testing ;
import toolset ;
import ../../config/checks/config : requires ;
project boost/coroutine2/test
: requirements
@ -24,6 +26,17 @@ project boost/coroutine2/test
<threading>multi
;
test-suite "coroutine2" :
[ run test_coroutine.cpp ]
;
run test_coroutine.cpp :
: :
[ requires cxx11_constexpr
cxx11_decltype
cxx11_deleted_functions
cxx11_explicit_conversion_operators
cxx11_hdr_tuple cxx11_lambdas
cxx11_noexcept
cxx11_nullptr
cxx11_template_aliases
cxx11_rvalue_references
cxx11_variadic_macros
cxx11_variadic_templates
cxx14_initialized_lambda_captures ] ;