summaryrefslogtreecommitdiffstats
path: root/contrib/restricted/boost/context
diff options
context:
space:
mode:
authorbugaevskiy <[email protected]>2022-12-31 17:40:08 +0300
committerbugaevskiy <[email protected]>2022-12-31 17:40:08 +0300
commit030896f914b07ae082ccf0b6b00df926d22d2454 (patch)
treee520bd22d01faaf07ff303c49ad2fdfefa114f67 /contrib/restricted/boost/context
parent014fdab1c4bb0fedea59974a6bb13ef3ec3b67cb (diff)
Remove Boost metaproject
Diffstat (limited to 'contrib/restricted/boost/context')
-rw-r--r--contrib/restricted/boost/context/README.md21
-rw-r--r--contrib/restricted/boost/context/include/boost/context/continuation_ucontext.hpp538
-rw-r--r--contrib/restricted/boost/context/include/boost/context/continuation_winfib.hpp473
-rw-r--r--contrib/restricted/boost/context/include/boost/context/detail/disable_overload.hpp40
-rw-r--r--contrib/restricted/boost/context/include/boost/context/detail/exchange.hpp36
-rw-r--r--contrib/restricted/boost/context/include/boost/context/detail/externc.hpp23
-rw-r--r--contrib/restricted/boost/context/include/boost/context/detail/invoke.hpp50
-rw-r--r--contrib/restricted/boost/context/include/boost/context/fiber_ucontext.hpp558
-rw-r--r--contrib/restricted/boost/context/include/boost/context/fiber_winfib.hpp450
-rw-r--r--contrib/restricted/boost/context/include/boost/context/fixedsize_stack.hpp97
-rw-r--r--contrib/restricted/boost/context/include/boost/context/flags.hpp28
-rw-r--r--contrib/restricted/boost/context/include/boost/context/posix/segmented_stack.hpp82
-rw-r--r--contrib/restricted/boost/context/include/boost/context/preallocated.hpp39
-rw-r--r--contrib/restricted/boost/context/include/boost/context/segmented_stack.hpp13
-rw-r--r--contrib/restricted/boost/context/src/continuation.cpp58
-rw-r--r--contrib/restricted/boost/context/src/fiber.cpp58
16 files changed, 0 insertions, 2564 deletions
diff --git a/contrib/restricted/boost/context/README.md b/contrib/restricted/boost/context/README.md
deleted file mode 100644
index 44aeff04f3c..00000000000
--- a/contrib/restricted/boost/context/README.md
+++ /dev/null
@@ -1,21 +0,0 @@
-boost.context
-=============
-
-boost.context is a foundational library that provides a sort of cooperative multitasking on a single thread.
-By providing an abstraction of the current execution state in the current thread, including the stack (with
-local variables) and stack pointer, all registers and CPU flags, and the instruction pointer, a execution_context
-instance represents a specific point in the application's execution path. This is useful for building
-higher-level abstractions, like coroutines, cooperative threads (userland threads) or an equivalent to
-C# keyword yield in C++.
-
-A fiber provides the means to suspend the current execution path and to transfer execution control,
-thereby permitting another fiber to run on the current thread. This state full transfer mechanism
-enables a fiber to suspend execution from within nested functions and, later, to resume from where it
-was suspended. While the execution path represented by a fiber only runs on a single thread, it can be
-migrated to another thread at any given time.
-
-A context switch between threads requires system calls (involving the OS kernel), which can cost more than
-thousand CPU cycles on x86 CPUs. By contrast, transferring control among fibers requires only fewer than
-hundred CPU cycles because it does not involve system calls as it is done within a single thread.
-
-boost.context requires C++11!
diff --git a/contrib/restricted/boost/context/include/boost/context/continuation_ucontext.hpp b/contrib/restricted/boost/context/include/boost/context/continuation_ucontext.hpp
deleted file mode 100644
index 951e542983a..00000000000
--- a/contrib/restricted/boost/context/include/boost/context/continuation_ucontext.hpp
+++ /dev/null
@@ -1,538 +0,0 @@
-
-// Copyright Oliver Kowalke 2017.
-// 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)
-
-#ifndef BOOST_CONTEXT_CONTINUATION_H
-#define BOOST_CONTEXT_CONTINUATION_H
-
-#include <boost/predef.h>
-#if BOOST_OS_MACOS
-#define _XOPEN_SOURCE 600
-#endif
-
-extern "C" {
-#include <ucontext.h>
-}
-
-#include <boost/context/detail/config.hpp>
-
-#include <algorithm>
-#include <cstddef>
-#include <cstdint>
-#include <cstdlib>
-#include <cstring>
-#include <functional>
-#include <memory>
-#include <ostream>
-#include <system_error>
-#include <tuple>
-#include <utility>
-
-#include <boost/assert.hpp>
-#include <boost/config.hpp>
-
-#include <boost/context/detail/disable_overload.hpp>
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
-#include <boost/context/detail/exchange.hpp>
-#endif
-#include <boost/context/detail/externc.hpp>
-#if defined(BOOST_NO_CXX17_STD_INVOKE)
-#include <boost/context/detail/invoke.hpp>
-#endif
-#include <boost/context/fixedsize_stack.hpp>
-#include <boost/context/flags.hpp>
-#include <boost/context/preallocated.hpp>
-#if defined(BOOST_USE_SEGMENTED_STACKS)
-#include <boost/context/segmented_stack.hpp>
-#endif
-#include <boost/context/stack_context.hpp>
-
-#ifdef BOOST_HAS_ABI_HEADERS
-# include BOOST_ABI_PREFIX
-#endif
-
-namespace boost {
-namespace context {
-namespace detail {
-
-// tampoline function
-// entered if the execution context
-// is resumed for the first time
-template< typename Record >
-static void entry_func( void * data) noexcept {
- Record * record = static_cast< Record * >( data);
- BOOST_ASSERT( nullptr != record);
- // start execution of toplevel context-function
- record->run();
-}
-
-struct BOOST_CONTEXT_DECL activation_record {
- ucontext_t uctx{};
- stack_context sctx{};
- bool main_ctx{ true };
- activation_record * from{ nullptr };
- std::function< activation_record*(activation_record*&) > ontop{};
- bool terminated{ false };
- bool force_unwind{ false };
-#if defined(BOOST_USE_ASAN)
- void * fake_stack{ nullptr };
- void * stack_bottom{ nullptr };
- std::size_t stack_size{ 0 };
-#endif
-
- static activation_record *& current() noexcept;
-
- // used for toplevel-context
- // (e.g. main context, thread-entry context)
- activation_record() {
- if ( BOOST_UNLIKELY( 0 != ::getcontext( & uctx) ) ) {
- throw std::system_error(
- std::error_code( errno, std::system_category() ),
- "getcontext() failed");
- }
- }
-
- activation_record( stack_context sctx_) noexcept :
- sctx( sctx_ ),
- main_ctx( false ) {
- }
-
- virtual ~activation_record() {
- }
-
- activation_record( activation_record const&) = delete;
- activation_record & operator=( activation_record const&) = delete;
-
- bool is_main_context() const noexcept {
- return main_ctx;
- }
-
- activation_record * resume() {
- from = current();
- // store `this` in static, thread local pointer
- // `this` will become the active (running) context
- current() = this;
-#if defined(BOOST_USE_SEGMENTED_STACKS)
- // adjust segmented stack properties
- __splitstack_getcontext( from->sctx.segments_ctx);
- __splitstack_setcontext( sctx.segments_ctx);
-#endif
-#if defined(BOOST_USE_ASAN)
- if ( terminated) {
- __sanitizer_start_switch_fiber( nullptr, stack_bottom, stack_size);
- } else {
- __sanitizer_start_switch_fiber( & from->fake_stack, stack_bottom, stack_size);
- }
-#endif
- // context switch from parent context to `this`-context
- ::swapcontext( & from->uctx, & uctx);
-#if defined(BOOST_USE_ASAN)
- __sanitizer_finish_switch_fiber( current()->fake_stack,
- (const void **) & current()->from->stack_bottom,
- & current()->from->stack_size);
-#endif
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
- return exchange( current()->from, nullptr);
-#else
- return std::exchange( current()->from, nullptr);
-#endif
- }
-
- template< typename Ctx, typename Fn >
- activation_record * resume_with( Fn && fn) {
- from = current();
- // store `this` in static, thread local pointer
- // `this` will become the active (running) context
- // returned by continuation::current()
- current() = this;
-#if defined(BOOST_NO_CXX14_GENERIC_LAMBDAS)
- current()->ontop = std::bind(
- [](typename std::decay< Fn >::type & fn, activation_record *& ptr){
- Ctx c{ ptr };
- c = fn( std::move( c) );
- if ( ! c) {
- ptr = nullptr;
- }
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
- return exchange( c.ptr_, nullptr);
-#else
- return std::exchange( c.ptr_, nullptr);
-#endif
- },
- std::forward< Fn >( fn),
- std::placeholders::_1);
-#else
- current()->ontop = [fn=std::forward<Fn>(fn)](activation_record *& ptr){
- Ctx c{ ptr };
- c = fn( std::move( c) );
- if ( ! c) {
- ptr = nullptr;
- }
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
- return exchange( c.ptr_, nullptr);
-#else
- return std::exchange( c.ptr_, nullptr);
-#endif
- };
-#endif
-#if defined(BOOST_USE_SEGMENTED_STACKS)
- // adjust segmented stack properties
- __splitstack_getcontext( from->sctx.segments_ctx);
- __splitstack_setcontext( sctx.segments_ctx);
-#endif
-#if defined(BOOST_USE_ASAN)
- __sanitizer_start_switch_fiber( & from->fake_stack, stack_bottom, stack_size);
-#endif
- // context switch from parent context to `this`-context
- ::swapcontext( & from->uctx, & uctx);
-#if defined(BOOST_USE_ASAN)
- __sanitizer_finish_switch_fiber( current()->fake_stack,
- (const void **) & current()->from->stack_bottom,
- & current()->from->stack_size);
-#endif
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
- return exchange( current()->from, nullptr);
-#else
- return std::exchange( current()->from, nullptr);
-#endif
- }
-
- virtual void deallocate() noexcept {
- }
-};
-
-struct BOOST_CONTEXT_DECL activation_record_initializer {
- activation_record_initializer() noexcept;
- ~activation_record_initializer();
-};
-
-struct forced_unwind {
- activation_record * from{ nullptr };
-
- forced_unwind( activation_record * from_) noexcept :
- from{ from_ } {
- }
-};
-
-template< typename Ctx, typename StackAlloc, typename Fn >
-class capture_record : public activation_record {
-private:
- typename std::decay< StackAlloc >::type salloc_;
- typename std::decay< Fn >::type fn_;
-
- static void destroy( capture_record * p) noexcept {
- typename std::decay< StackAlloc >::type salloc = std::move( p->salloc_);
- stack_context sctx = p->sctx;
- // deallocate activation record
- p->~capture_record();
- // destroy stack with stack allocator
- salloc.deallocate( sctx);
- }
-
-public:
- capture_record( stack_context sctx, StackAlloc && salloc, Fn && fn) noexcept :
- activation_record{ sctx },
- salloc_{ std::forward< StackAlloc >( salloc) },
- fn_( std::forward< Fn >( fn) ) {
- }
-
- void deallocate() noexcept override final {
- BOOST_ASSERT( main_ctx || ( ! main_ctx && terminated) );
- destroy( this);
- }
-
- void run() {
-#if defined(BOOST_USE_ASAN)
- __sanitizer_finish_switch_fiber( fake_stack,
- (const void **) & from->stack_bottom,
- & from->stack_size);
-#endif
- Ctx c{ from };
- try {
- // invoke context-function
-#if defined(BOOST_NO_CXX17_STD_INVOKE)
- c = boost::context::detail::invoke( fn_, std::move( c) );
-#else
- c = std::invoke( fn_, std::move( c) );
-#endif
- } catch ( forced_unwind const& ex) {
- c = Ctx{ ex.from };
- }
- // this context has finished its task
- from = nullptr;
- ontop = nullptr;
- terminated = true;
- force_unwind = false;
- c.resume();
- BOOST_ASSERT_MSG( false, "continuation already terminated");
- }
-};
-
-template< typename Ctx, typename StackAlloc, typename Fn >
-static activation_record * create_context1( StackAlloc && salloc, Fn && fn) {
- typedef capture_record< Ctx, StackAlloc, Fn > capture_t;
-
- auto sctx = salloc.allocate();
- // reserve space for control structure
- void * storage = reinterpret_cast< void * >(
- ( reinterpret_cast< uintptr_t >( sctx.sp) - static_cast< uintptr_t >( sizeof( capture_t) ) )
- & ~ static_cast< uintptr_t >( 0xff) );
- // placment new for control structure on context stack
- capture_t * record = new ( storage) capture_t{
- sctx, std::forward< StackAlloc >( salloc), std::forward< Fn >( fn) };
- // stack bottom
- void * stack_bottom = reinterpret_cast< void * >(
- reinterpret_cast< uintptr_t >( sctx.sp) - static_cast< uintptr_t >( sctx.size) );
- // create user-context
- if ( BOOST_UNLIKELY( 0 != ::getcontext( & record->uctx) ) ) {
- record->~capture_t();
- salloc.deallocate( sctx);
- throw std::system_error(
- std::error_code( errno, std::system_category() ),
- "getcontext() failed");
- }
- record->uctx.uc_stack.ss_sp = stack_bottom;
- // 64byte gap between control structure and stack top
- record->uctx.uc_stack.ss_size = reinterpret_cast< uintptr_t >( storage) -
- reinterpret_cast< uintptr_t >( stack_bottom) - static_cast< uintptr_t >( 64);
- record->uctx.uc_link = nullptr;
- ::makecontext( & record->uctx, ( void (*)() ) & entry_func< capture_t >, 1, record);
-#if defined(BOOST_USE_ASAN)
- record->stack_bottom = record->uctx.uc_stack.ss_sp;
- record->stack_size = record->uctx.uc_stack.ss_size;
-#endif
- return record;
-}
-
-template< typename Ctx, typename StackAlloc, typename Fn >
-static activation_record * create_context2( preallocated palloc, StackAlloc && salloc, Fn && fn) {
- typedef capture_record< Ctx, StackAlloc, Fn > capture_t;
-
- // reserve space for control structure
- void * storage = reinterpret_cast< void * >(
- ( reinterpret_cast< uintptr_t >( palloc.sp) - static_cast< uintptr_t >( sizeof( capture_t) ) )
- & ~ static_cast< uintptr_t >( 0xff) );
- // placment new for control structure on context stack
- capture_t * record = new ( storage) capture_t{
- palloc.sctx, std::forward< StackAlloc >( salloc), std::forward< Fn >( fn) };
- // stack bottom
- void * stack_bottom = reinterpret_cast< void * >(
- reinterpret_cast< uintptr_t >( palloc.sctx.sp) - static_cast< uintptr_t >( palloc.sctx.size) );
- // create user-context
- if ( BOOST_UNLIKELY( 0 != ::getcontext( & record->uctx) ) ) {
- record->~capture_t();
- salloc.deallocate( palloc.sctx);
- throw std::system_error(
- std::error_code( errno, std::system_category() ),
- "getcontext() failed");
- }
- record->uctx.uc_stack.ss_sp = stack_bottom;
- // 64byte gap between control structure and stack top
- record->uctx.uc_stack.ss_size = reinterpret_cast< uintptr_t >( storage) -
- reinterpret_cast< uintptr_t >( stack_bottom) - static_cast< uintptr_t >( 64);
- record->uctx.uc_link = nullptr;
- ::makecontext( & record->uctx, ( void (*)() ) & entry_func< capture_t >, 1, record);
-#if defined(BOOST_USE_ASAN)
- record->stack_bottom = record->uctx.uc_stack.ss_sp;
- record->stack_size = record->uctx.uc_stack.ss_size;
-#endif
- return record;
-}
-
-}
-
-class BOOST_CONTEXT_DECL continuation {
-private:
- friend struct detail::activation_record;
-
- template< typename Ctx, typename StackAlloc, typename Fn >
- friend class detail::capture_record;
-
- template< typename Ctx, typename StackAlloc, typename Fn >
- friend detail::activation_record * detail::create_context1( StackAlloc &&, Fn &&);
-
- template< typename Ctx, typename StackAlloc, typename Fn >
- friend detail::activation_record * detail::create_context2( preallocated, StackAlloc &&, Fn &&);
-
- template< typename StackAlloc, typename Fn >
- friend continuation
- callcc( std::allocator_arg_t, StackAlloc &&, Fn &&);
-
- template< typename StackAlloc, typename Fn >
- friend continuation
- callcc( std::allocator_arg_t, preallocated, StackAlloc &&, Fn &&);
-
- detail::activation_record * ptr_{ nullptr };
-
- continuation( detail::activation_record * ptr) noexcept :
- ptr_{ ptr } {
- }
-
-public:
- continuation() = default;
-
- ~continuation() {
- if ( BOOST_UNLIKELY( nullptr != ptr_) && ! ptr_->main_ctx) {
- if ( BOOST_LIKELY( ! ptr_->terminated) ) {
- ptr_->force_unwind = true;
- ptr_->resume();
- BOOST_ASSERT( ptr_->terminated);
- }
- ptr_->deallocate();
- }
- }
-
- continuation( continuation const&) = delete;
- continuation & operator=( continuation const&) = delete;
-
- continuation( continuation && other) noexcept {
- swap( other);
- }
-
- continuation & operator=( continuation && other) noexcept {
- if ( BOOST_LIKELY( this != & other) ) {
- continuation tmp = std::move( other);
- swap( tmp);
- }
- return * this;
- }
-
- continuation resume() & {
- return std::move( * this).resume();
- }
-
- continuation resume() && {
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
- detail::activation_record * ptr = detail::exchange( ptr_, nullptr)->resume();
-#else
- detail::activation_record * ptr = std::exchange( ptr_, nullptr)->resume();
-#endif
- if ( BOOST_UNLIKELY( detail::activation_record::current()->force_unwind) ) {
- throw detail::forced_unwind{ ptr};
- } else if ( BOOST_UNLIKELY( nullptr != detail::activation_record::current()->ontop) ) {
- ptr = detail::activation_record::current()->ontop( ptr);
- detail::activation_record::current()->ontop = nullptr;
- }
- return { ptr };
- }
-
- template< typename Fn >
- continuation resume_with( Fn && fn) & {
- return std::move( * this).resume_with( std::forward< Fn >( fn) );
- }
-
- template< typename Fn >
- continuation resume_with( Fn && fn) && {
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
- detail::activation_record * ptr =
- detail::exchange( ptr_, nullptr)->resume_with< continuation >( std::forward< Fn >( fn) );
-#else
- detail::activation_record * ptr =
- std::exchange( ptr_, nullptr)->resume_with< continuation >( std::forward< Fn >( fn) );
-#endif
- if ( BOOST_UNLIKELY( detail::activation_record::current()->force_unwind) ) {
- throw detail::forced_unwind{ ptr};
- } else if ( BOOST_UNLIKELY( nullptr != detail::activation_record::current()->ontop) ) {
- ptr = detail::activation_record::current()->ontop( ptr);
- detail::activation_record::current()->ontop = nullptr;
- }
- return { ptr };
- }
-
- explicit operator bool() const noexcept {
- return nullptr != ptr_ && ! ptr_->terminated;
- }
-
- bool operator!() const noexcept {
- return nullptr == ptr_ || ptr_->terminated;
- }
-
- bool operator<( continuation const& other) const noexcept {
- return ptr_ < other.ptr_;
- }
-
- #if !defined(BOOST_EMBTC)
-
- template< typename charT, class traitsT >
- friend std::basic_ostream< charT, traitsT > &
- operator<<( std::basic_ostream< charT, traitsT > & os, continuation const& other) {
- if ( nullptr != other.ptr_) {
- return os << other.ptr_;
- } else {
- return os << "{not-a-context}";
- }
- }
-
- #else
-
- template< typename charT, class traitsT >
- friend std::basic_ostream< charT, traitsT > &
- operator<<( std::basic_ostream< charT, traitsT > & os, continuation const& other);
-
- #endif
-
- void swap( continuation & other) noexcept {
- std::swap( ptr_, other.ptr_);
- }
-};
-
-#if defined(BOOST_EMBTC)
-
- template< typename charT, class traitsT >
- inline std::basic_ostream< charT, traitsT > &
- operator<<( std::basic_ostream< charT, traitsT > & os, continuation const& other) {
- if ( nullptr != other.ptr_) {
- return os << other.ptr_;
- } else {
- return os << "{not-a-context}";
- }
- }
-
-#endif
-
-template<
- typename Fn,
- typename = detail::disable_overload< continuation, Fn >
->
-continuation
-callcc( Fn && fn) {
- return callcc(
- std::allocator_arg,
-#if defined(BOOST_USE_SEGMENTED_STACKS)
- segmented_stack(),
-#else
- fixedsize_stack(),
-#endif
- std::forward< Fn >( fn) );
-}
-
-template< typename StackAlloc, typename Fn >
-continuation
-callcc( std::allocator_arg_t, StackAlloc && salloc, Fn && fn) {
- return continuation{
- detail::create_context1< continuation >(
- std::forward< StackAlloc >( salloc), std::forward< Fn >( fn) ) }.resume();
-}
-
-template< typename StackAlloc, typename Fn >
-continuation
-callcc( std::allocator_arg_t, preallocated palloc, StackAlloc && salloc, Fn && fn) {
- return continuation{
- detail::create_context2< continuation >(
- palloc, std::forward< StackAlloc >( salloc), std::forward< Fn >( fn) ) }.resume();
-}
-
-inline
-void swap( continuation & l, continuation & r) noexcept {
- l.swap( r);
-}
-
-}}
-
-#ifdef BOOST_HAS_ABI_HEADERS
-# include BOOST_ABI_SUFFIX
-#endif
-
-#endif // BOOST_CONTEXT_CONTINUATION_H
diff --git a/contrib/restricted/boost/context/include/boost/context/continuation_winfib.hpp b/contrib/restricted/boost/context/include/boost/context/continuation_winfib.hpp
deleted file mode 100644
index 856c8684697..00000000000
--- a/contrib/restricted/boost/context/include/boost/context/continuation_winfib.hpp
+++ /dev/null
@@ -1,473 +0,0 @@
-
-// Copyright Oliver Kowalke 2017.
-// 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)
-
-#ifndef BOOST_CONTEXT_CONTINUATION_H
-#define BOOST_CONTEXT_CONTINUATION_H
-
-#include <windows.h>
-
-#include <boost/context/detail/config.hpp>
-
-#include <algorithm>
-#include <cstddef>
-#include <cstdint>
-#include <cstdlib>
-#include <cstring>
-#include <functional>
-#include <memory>
-#include <ostream>
-#include <system_error>
-#include <tuple>
-#include <utility>
-
-#include <boost/assert.hpp>
-#include <boost/config.hpp>
-
-#include <boost/context/detail/disable_overload.hpp>
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
-#include <boost/context/detail/exchange.hpp>
-#endif
-#if defined(BOOST_NO_CXX17_STD_INVOKE)
-#include <boost/context/detail/invoke.hpp>
-#endif
-#include <boost/context/fixedsize_stack.hpp>
-#include <boost/context/flags.hpp>
-#include <boost/context/preallocated.hpp>
-#include <boost/context/stack_context.hpp>
-
-#ifdef BOOST_HAS_ABI_HEADERS
-# include BOOST_ABI_PREFIX
-#endif
-
-#if defined(BOOST_MSVC)
-# pragma warning(push)
-# pragma warning(disable: 4702)
-#endif
-
-namespace boost {
-namespace context {
-namespace detail {
-
-// tampoline function
-// entered if the execution context
-// is resumed for the first time
-template< typename Record >
-static VOID WINAPI entry_func( LPVOID data) noexcept {
- Record * record = static_cast< Record * >( data);
- BOOST_ASSERT( nullptr != record);
- // start execution of toplevel context-function
- record->run();
-}
-
-struct BOOST_CONTEXT_DECL activation_record {
- LPVOID fiber{ nullptr };
- stack_context sctx{};
- bool main_ctx{ true };
- activation_record * from{ nullptr };
- std::function< activation_record*(activation_record*&) > ontop{};
- bool terminated{ false };
- bool force_unwind{ false };
-
- static activation_record *& current() noexcept;
-
- // used for toplevel-context
- // (e.g. main context, thread-entry context)
- activation_record() noexcept {
-#if ( _WIN32_WINNT > 0x0600)
- if ( ::IsThreadAFiber() ) {
- fiber = ::GetCurrentFiber();
- } else {
- fiber = ::ConvertThreadToFiber( nullptr);
- }
-#else
- fiber = ::ConvertThreadToFiber( nullptr);
- if ( BOOST_UNLIKELY( nullptr == fiber) ) {
- DWORD err = ::GetLastError();
- BOOST_ASSERT( ERROR_ALREADY_FIBER == err);
- fiber = ::GetCurrentFiber();
- BOOST_ASSERT( nullptr != fiber);
- BOOST_ASSERT( reinterpret_cast< LPVOID >( 0x1E00) != fiber);
- }
-#endif
- }
-
- activation_record( stack_context sctx_) noexcept :
- sctx{ sctx_ },
- main_ctx{ false } {
- }
-
- virtual ~activation_record() {
- if ( BOOST_UNLIKELY( main_ctx) ) {
- ::ConvertFiberToThread();
- } else {
- ::DeleteFiber( fiber);
- }
- }
-
- activation_record( activation_record const&) = delete;
- activation_record & operator=( activation_record const&) = delete;
-
- bool is_main_context() const noexcept {
- return main_ctx;
- }
-
- activation_record * resume() {
- from = current();
- // store `this` in static, thread local pointer
- // `this` will become the active (running) context
- current() = this;
- // context switch from parent context to `this`-context
- // context switch
- ::SwitchToFiber( fiber);
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
- return detail::exchange( current()->from, nullptr);
-#else
- return std::exchange( current()->from, nullptr);
-#endif
- }
-
- template< typename Ctx, typename Fn >
- activation_record * resume_with( Fn && fn) {
- from = current();
- // store `this` in static, thread local pointer
- // `this` will become the active (running) context
- // returned by continuation::current()
- current() = this;
-#if defined(BOOST_NO_CXX14_GENERIC_LAMBDAS)
- current()->ontop = std::bind(
- [](typename std::decay< Fn >::type & fn, activation_record *& ptr){
- Ctx c{ ptr };
- c = fn( std::move( c) );
- if ( ! c) {
- ptr = nullptr;
- }
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
- return exchange( c.ptr_, nullptr);
-#else
- return std::exchange( c.ptr_, nullptr);
-#endif
- },
- std::forward< Fn >( fn),
- std::placeholders::_1);
-#else
- current()->ontop = [fn=std::forward<Fn>(fn)](activation_record *& ptr){
- Ctx c{ ptr };
- c = fn( std::move( c) );
- if ( ! c) {
- ptr = nullptr;
- }
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
- return exchange( c.ptr_, nullptr);
-#else
- return std::exchange( c.ptr_, nullptr);
-#endif
- };
-#endif
- // context switch
- ::SwitchToFiber( fiber);
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
- return detail::exchange( current()->from, nullptr);
-#else
- return std::exchange( current()->from, nullptr);
-#endif
- }
-
- virtual void deallocate() noexcept {
- }
-};
-
-struct BOOST_CONTEXT_DECL activation_record_initializer {
- activation_record_initializer() noexcept;
- ~activation_record_initializer();
-};
-
-struct forced_unwind {
- activation_record * from{ nullptr };
-
- explicit forced_unwind( activation_record * from_) :
- from{ from_ } {
- }
-};
-
-template< typename Ctx, typename StackAlloc, typename Fn >
-class capture_record : public activation_record {
-private:
- typename std::decay< StackAlloc >::type salloc_;
- typename std::decay< Fn >::type fn_;
-
- static void destroy( capture_record * p) noexcept {
- typename std::decay< StackAlloc >::type salloc = std::move( p->salloc_);
- stack_context sctx = p->sctx;
- // deallocate activation record
- p->~capture_record();
- // destroy stack with stack allocator
- salloc.deallocate( sctx);
- }
-
-public:
- capture_record( stack_context sctx, StackAlloc && salloc, Fn && fn) noexcept :
- activation_record( sctx),
- salloc_( std::forward< StackAlloc >( salloc)),
- fn_( std::forward< Fn >( fn) ) {
- }
-
- void deallocate() noexcept override final {
- BOOST_ASSERT( main_ctx || ( ! main_ctx && terminated) );
- destroy( this);
- }
-
- void run() {
- Ctx c{ from };
- try {
- // invoke context-function
-#if defined(BOOST_NO_CXX17_STD_INVOKE)
- c = boost::context::detail::invoke( fn_, std::move( c) );
-#else
- c = std::invoke( fn_, std::move( c) );
-#endif
- } catch ( forced_unwind const& ex) {
- c = Ctx{ ex.from };
- }
- // this context has finished its task
- from = nullptr;
- ontop = nullptr;
- terminated = true;
- force_unwind = false;
- c.resume();
- BOOST_ASSERT_MSG( false, "continuation already terminated");
- }
-};
-
-template< typename Ctx, typename StackAlloc, typename Fn >
-static activation_record * create_context1( StackAlloc && salloc, Fn && fn) {
- typedef capture_record< Ctx, StackAlloc, Fn > capture_t;
-
- auto sctx = salloc.allocate();
- BOOST_ASSERT( ( sizeof( capture_t) ) < sctx.size);
- // reserve space for control structure
- void * storage = reinterpret_cast< void * >(
- ( reinterpret_cast< uintptr_t >( sctx.sp) - static_cast< uintptr_t >( sizeof( capture_t) ) )
- & ~ static_cast< uintptr_t >( 0xff) );
- // placment new for control structure on context stack
- capture_t * record = new ( storage) capture_t{
- sctx, std::forward< StackAlloc >( salloc), std::forward< Fn >( fn) };
- // create user-context
- record->fiber = ::CreateFiber( sctx.size, & detail::entry_func< capture_t >, record);
- return record;
-}
-
-template< typename Ctx, typename StackAlloc, typename Fn >
-static activation_record * create_context2( preallocated palloc, StackAlloc && salloc, Fn && fn) {
- typedef capture_record< Ctx, StackAlloc, Fn > capture_t;
-
- BOOST_ASSERT( ( sizeof( capture_t) ) < palloc.size);
- // reserve space for control structure
- void * storage = reinterpret_cast< void * >(
- ( reinterpret_cast< uintptr_t >( palloc.sp) - static_cast< uintptr_t >( sizeof( capture_t) ) )
- & ~ static_cast< uintptr_t >( 0xff) );
- // placment new for control structure on context stack
- capture_t * record = new ( storage) capture_t{
- palloc.sctx, std::forward< StackAlloc >( salloc), std::forward< Fn >( fn) };
- // create user-context
- record->fiber = ::CreateFiber( palloc.sctx.size, & detail::entry_func< capture_t >, record);
- return record;
-}
-
-}
-
-class BOOST_CONTEXT_DECL continuation {
-private:
- friend struct detail::activation_record;
-
- template< typename Ctx, typename StackAlloc, typename Fn >
- friend class detail::capture_record;
-
- template< typename Ctx, typename StackAlloc, typename Fn >
- friend detail::activation_record * detail::create_context1( StackAlloc &&, Fn &&);
-
- template< typename Ctx, typename StackAlloc, typename Fn >
- friend detail::activation_record * detail::create_context2( preallocated, StackAlloc &&, Fn &&);
-
- template< typename StackAlloc, typename Fn >
- friend continuation
- callcc( std::allocator_arg_t, StackAlloc &&, Fn &&);
-
- template< typename StackAlloc, typename Fn >
- friend continuation
- callcc( std::allocator_arg_t, preallocated, StackAlloc &&, Fn &&);
-
- detail::activation_record * ptr_{ nullptr };
-
- continuation( detail::activation_record * ptr) noexcept :
- ptr_{ ptr } {
- }
-
-public:
- continuation() = default;
-
- ~continuation() {
- if ( BOOST_UNLIKELY( nullptr != ptr_) && ! ptr_->main_ctx) {
- if ( BOOST_LIKELY( ! ptr_->terminated) ) {
- ptr_->force_unwind = true;
- ptr_->resume();
- BOOST_ASSERT( ptr_->terminated);
- }
- ptr_->deallocate();
- }
- }
-
- continuation( continuation const&) = delete;
- continuation & operator=( continuation const&) = delete;
-
- continuation( continuation && other) noexcept {
- swap( other);
- }
-
- continuation & operator=( continuation && other) noexcept {
- if ( BOOST_LIKELY( this != & other) ) {
- continuation tmp = std::move( other);
- swap( tmp);
- }
- return * this;
- }
-
- continuation resume() & {
- return std::move( * this).resume();
- }
-
- continuation resume() && {
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
- detail::activation_record * ptr = detail::exchange( ptr_, nullptr)->resume();
-#else
- detail::activation_record * ptr = std::exchange( ptr_, nullptr)->resume();
-#endif
- if ( BOOST_UNLIKELY( detail::activation_record::current()->force_unwind) ) {
- throw detail::forced_unwind{ ptr};
- } else if ( BOOST_UNLIKELY( nullptr != detail::activation_record::current()->ontop) ) {
- ptr = detail::activation_record::current()->ontop( ptr);
- detail::activation_record::current()->ontop = nullptr;
- }
- return { ptr };
- }
-
- template< typename Fn >
- continuation resume_with( Fn && fn) & {
- return std::move( * this).resume_with( std::forward< Fn >( fn) );
- }
-
- template< typename Fn >
- continuation resume_with( Fn && fn) && {
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
- detail::activation_record * ptr =
- detail::exchange( ptr_, nullptr)->resume_with< continuation >( std::forward< Fn >( fn) );
-#else
- detail::activation_record * ptr =
- std::exchange( ptr_, nullptr)->resume_with< continuation >( std::forward< Fn >( fn) );
-#endif
- if ( BOOST_UNLIKELY( detail::activation_record::current()->force_unwind) ) {
- throw detail::forced_unwind{ ptr};
- } else if ( BOOST_UNLIKELY( nullptr != detail::activation_record::current()->ontop) ) {
- ptr = detail::activation_record::current()->ontop( ptr);
- detail::activation_record::current()->ontop = nullptr;
- }
- return { ptr };
- }
-
- explicit operator bool() const noexcept {
- return nullptr != ptr_ && ! ptr_->terminated;
- }
-
- bool operator!() const noexcept {
- return nullptr == ptr_ || ptr_->terminated;
- }
-
- bool operator<( continuation const& other) const noexcept {
- return ptr_ < other.ptr_;
- }
-
- #if !defined(BOOST_EMBTC)
-
- template< typename charT, class traitsT >
- friend std::basic_ostream< charT, traitsT > &
- operator<<( std::basic_ostream< charT, traitsT > & os, continuation const& other) {
- if ( nullptr != other.ptr_) {
- return os << other.ptr_;
- } else {
- return os << "{not-a-context}";
- }
- }
-
- #else
-
- template< typename charT, class traitsT >
- friend std::basic_ostream< charT, traitsT > &
- operator<<( std::basic_ostream< charT, traitsT > & os, continuation const& other);
-
- #endif
-
- void swap( continuation & other) noexcept {
- std::swap( ptr_, other.ptr_);
- }
-};
-
-#if defined(BOOST_EMBTC)
-
- template< typename charT, class traitsT >
- inline std::basic_ostream< charT, traitsT > &
- operator<<( std::basic_ostream< charT, traitsT > & os, continuation const& other) {
- if ( nullptr != other.ptr_) {
- return os << other.ptr_;
- } else {
- return os << "{not-a-context}";
- }
- }
-
-#endif
-
-template<
- typename Fn,
- typename = detail::disable_overload< continuation, Fn >
->
-continuation
-callcc( Fn && fn) {
- return callcc(
- std::allocator_arg,
- fixedsize_stack(),
- std::forward< Fn >( fn) );
-}
-
-template< typename StackAlloc, typename Fn >
-continuation
-callcc( std::allocator_arg_t, StackAlloc && salloc, Fn && fn) {
- return continuation{
- detail::create_context1< continuation >(
- std::forward< StackAlloc >( salloc), std::forward< Fn >( fn) ) }.resume();
-}
-
-template< typename StackAlloc, typename Fn >
-continuation
-callcc( std::allocator_arg_t, preallocated palloc, StackAlloc && salloc, Fn && fn) {
- return continuation{
- detail::create_context2< continuation >(
- palloc, std::forward< StackAlloc >( salloc), std::forward< Fn >( fn) ) }.resume();
-}
-
-inline
-void swap( continuation & l, continuation & r) noexcept {
- l.swap( r);
-}
-
-}}
-
-#if defined(BOOST_MSVC)
-# pragma warning(pop)
-#endif
-
-#ifdef BOOST_HAS_ABI_HEADERS
-# include BOOST_ABI_SUFFIX
-#endif
-
-#endif // BOOST_CONTEXT_CONTINUATION_H
diff --git a/contrib/restricted/boost/context/include/boost/context/detail/disable_overload.hpp b/contrib/restricted/boost/context/include/boost/context/detail/disable_overload.hpp
deleted file mode 100644
index c88f916e399..00000000000
--- a/contrib/restricted/boost/context/include/boost/context/detail/disable_overload.hpp
+++ /dev/null
@@ -1,40 +0,0 @@
-
-// Copyright Oliver Kowalke 2014.
-// 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)
-
-#ifndef BOOST_CONTEXT_DETAIL_DISABLE_OVERLOAD_H
-#define BOOST_CONTEXT_DETAIL_DISABLE_OVERLOAD_H
-
-#include <type_traits>
-
-#include <boost/config.hpp>
-
-#include <boost/context/detail/config.hpp>
-
-#ifdef BOOST_HAS_ABI_HEADERS
-# include BOOST_ABI_PREFIX
-#endif
-
-namespace boost {
-namespace context {
-namespace detail {
-
-// http://ericniebler.com/2013/08/07/universal-references-and-the-copy-constructo/
-template< typename X, typename Y >
-using disable_overload =
- typename std::enable_if<
- ! std::is_base_of<
- X,
- typename std::decay< Y >::type
- >::value
- >::type;
-
-}}}
-
-#ifdef BOOST_HAS_ABI_HEADERS
-#include BOOST_ABI_SUFFIX
-#endif
-
-#endif // BOOST_CONTEXT_DETAIL_DISABLE_OVERLOAD_H
diff --git a/contrib/restricted/boost/context/include/boost/context/detail/exchange.hpp b/contrib/restricted/boost/context/include/boost/context/detail/exchange.hpp
deleted file mode 100644
index c5ee91284e8..00000000000
--- a/contrib/restricted/boost/context/include/boost/context/detail/exchange.hpp
+++ /dev/null
@@ -1,36 +0,0 @@
-
-// Copyright Oliver Kowalke 2014.
-// 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)
-
-#ifndef BOOST_CONTEXT_DETAIL_EXCHANGE_H
-#define BOOST_CONTEXT_DETAIL_EXCHANGE_H
-
-#include <algorithm>
-#include <utility>
-
-#include <boost/config.hpp>
-
-#ifdef BOOST_HAS_ABI_HEADERS
-# include BOOST_ABI_PREFIX
-#endif
-
-namespace boost {
-namespace context {
-namespace detail {
-
-template< typename T, typename U = T >
-T exchange( T & t, U && nv) {
- T ov = std::move( t);
- t = std::forward< U >( nv);
- return ov;
-}
-
-}}}
-
-#ifdef BOOST_HAS_ABI_HEADERS
-#include BOOST_ABI_SUFFIX
-#endif
-
-#endif // BOOST_CONTEXT_DETAIL_EXCHANGE_H
diff --git a/contrib/restricted/boost/context/include/boost/context/detail/externc.hpp b/contrib/restricted/boost/context/include/boost/context/detail/externc.hpp
deleted file mode 100644
index 850bc1a3d7d..00000000000
--- a/contrib/restricted/boost/context/include/boost/context/detail/externc.hpp
+++ /dev/null
@@ -1,23 +0,0 @@
-
-// Copyright Oliver Kowalke 2014.
-// 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 <boost/config.hpp>
-#include <boost/context/detail/config.hpp>
-
-#if defined(BOOST_USE_ASAN)
-extern "C" {
-void __sanitizer_start_switch_fiber( void **, const void *, size_t);
-void __sanitizer_finish_switch_fiber( void *, const void **, size_t *);
-}
-#endif
-
-#if defined(BOOST_USE_SEGMENTED_STACKS)
-extern "C" {
-void __splitstack_getcontext( void * [BOOST_CONTEXT_SEGMENTS]);
-void __splitstack_setcontext( void * [BOOST_CONTEXT_SEGMENTS]);
-}
-#endif
diff --git a/contrib/restricted/boost/context/include/boost/context/detail/invoke.hpp b/contrib/restricted/boost/context/include/boost/context/detail/invoke.hpp
deleted file mode 100644
index 9173cbc7938..00000000000
--- a/contrib/restricted/boost/context/include/boost/context/detail/invoke.hpp
+++ /dev/null
@@ -1,50 +0,0 @@
-
-// Copyright Oliver Kowalke 2014.
-// 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)
-
-#ifndef BOOST_CONTEXT_DETAIL_INVOKE_H
-#define BOOST_CONTEXT_DETAIL_INVOKE_H
-
-#include <functional>
-#include <type_traits>
-#include <utility>
-
-#include <boost/config.hpp>
-
-#include <boost/context/detail/config.hpp>
-
-#ifdef BOOST_HAS_ABI_HEADERS
-# include BOOST_ABI_PREFIX
-#endif
-
-namespace boost {
-namespace context {
-namespace detail {
-
-template< typename Fn, typename ... Args >
-typename std::enable_if<
- std::is_member_pointer< typename std::decay< Fn >::type >::value,
- typename std::result_of< Fn &&( Args && ... ) >::type
->::type
-invoke( Fn && fn, Args && ... args) {
- return std::mem_fn( fn)( std::forward< Args >( args) ... );
-}
-
-template< typename Fn, typename ... Args >
-typename std::enable_if<
- ! std::is_member_pointer< typename std::decay< Fn >::type >::value,
- typename std::result_of< Fn &&( Args && ... ) >::type
->::type
-invoke( Fn && fn, Args && ... args) {
- return std::forward< Fn >( fn)( std::forward< Args >( args) ... );
-}
-
-}}}
-
-#ifdef BOOST_HAS_ABI_HEADERS
-#include BOOST_ABI_SUFFIX
-#endif
-
-#endif // BOOST_CONTEXT_DETAIL_INVOKE_H
diff --git a/contrib/restricted/boost/context/include/boost/context/fiber_ucontext.hpp b/contrib/restricted/boost/context/include/boost/context/fiber_ucontext.hpp
deleted file mode 100644
index 696ce580840..00000000000
--- a/contrib/restricted/boost/context/include/boost/context/fiber_ucontext.hpp
+++ /dev/null
@@ -1,558 +0,0 @@
-
-// Copyright Oliver Kowalke 2017.
-// 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)
-
-#ifndef BOOST_CONTEXT_FIBER_H
-#define BOOST_CONTEXT_FIBER_H
-
-#include <boost/predef.h>
-#if BOOST_OS_MACOS
-#define _XOPEN_SOURCE 600
-#endif
-
-extern "C" {
-#include <ucontext.h>
-}
-
-#include <boost/context/detail/config.hpp>
-
-#include <algorithm>
-#include <cstddef>
-#include <cstdint>
-#include <cstdlib>
-#include <cstring>
-#include <functional>
-#include <memory>
-#include <ostream>
-#include <system_error>
-#include <tuple>
-#include <utility>
-
-#include <boost/assert.hpp>
-#include <boost/config.hpp>
-#include <boost/predef.h>
-
-#include <boost/context/detail/disable_overload.hpp>
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
-#include <boost/context/detail/exchange.hpp>
-#endif
-#include <boost/context/detail/externc.hpp>
-#if defined(BOOST_NO_CXX17_STD_INVOKE)
-#include <boost/context/detail/invoke.hpp>
-#endif
-#include <boost/context/fixedsize_stack.hpp>
-#include <boost/context/flags.hpp>
-#include <boost/context/preallocated.hpp>
-#if defined(BOOST_USE_SEGMENTED_STACKS)
-#include <boost/context/segmented_stack.hpp>
-#endif
-#include <boost/context/stack_context.hpp>
-
-#ifdef BOOST_HAS_ABI_HEADERS
-# include BOOST_ABI_PREFIX
-#endif
-
-#ifdef BOOST_USE_TSAN
-#include <sanitizer/tsan_interface.h>
-#endif
-
-namespace boost {
-namespace context {
-namespace detail {
-
-// tampoline function
-// entered if the execution context
-// is resumed for the first time
-template< typename Record >
-static void fiber_entry_func( void * data) noexcept {
- Record * record = static_cast< Record * >( data);
- BOOST_ASSERT( nullptr != record);
- // start execution of toplevel context-function
- record->run();
-}
-
-struct BOOST_CONTEXT_DECL fiber_activation_record {
- ucontext_t uctx{};
- stack_context sctx{};
- bool main_ctx{ true };
- fiber_activation_record * from{ nullptr };
- std::function< fiber_activation_record*(fiber_activation_record*&) > ontop{};
- bool terminated{ false };
- bool force_unwind{ false };
-#if defined(BOOST_USE_ASAN)
- void * fake_stack{ nullptr };
- void * stack_bottom{ nullptr };
- std::size_t stack_size{ 0 };
-#endif
-
-#if defined(BOOST_USE_TSAN)
- void * tsan_fiber{ nullptr };
- bool destroy_tsan_fiber{ true };
-#endif
-
- static fiber_activation_record *& current() noexcept;
-
- // used for toplevel-context
- // (e.g. main context, thread-entry context)
- fiber_activation_record() {
- if ( BOOST_UNLIKELY( 0 != ::getcontext( & uctx) ) ) {
- throw std::system_error(
- std::error_code( errno, std::system_category() ),
- "getcontext() failed");
- }
-
-#if defined(BOOST_USE_TSAN)
- tsan_fiber = __tsan_get_current_fiber();
- destroy_tsan_fiber = false;
-#endif
- }
-
- fiber_activation_record( stack_context sctx_) noexcept :
- sctx( sctx_ ),
- main_ctx( false ) {
- }
-
- virtual ~fiber_activation_record() {
-#if defined(BOOST_USE_TSAN)
- if (destroy_tsan_fiber)
- __tsan_destroy_fiber(tsan_fiber);
-#endif
- }
-
- fiber_activation_record( fiber_activation_record const&) = delete;
- fiber_activation_record & operator=( fiber_activation_record const&) = delete;
-
- bool is_main_context() const noexcept {
- return main_ctx;
- }
-
- fiber_activation_record * resume() {
- from = current();
- // store `this` in static, thread local pointer
- // `this` will become the active (running) context
- current() = this;
-#if defined(BOOST_USE_SEGMENTED_STACKS)
- // adjust segmented stack properties
- __splitstack_getcontext( from->sctx.segments_ctx);
- __splitstack_setcontext( sctx.segments_ctx);
-#endif
-#if defined(BOOST_USE_ASAN)
- if ( terminated) {
- __sanitizer_start_switch_fiber( nullptr, stack_bottom, stack_size);
- } else {
- __sanitizer_start_switch_fiber( & from->fake_stack, stack_bottom, stack_size);
- }
-#endif
-#if defined (BOOST_USE_TSAN)
- __tsan_switch_to_fiber(tsan_fiber, 0);
-#endif
- // context switch from parent context to `this`-context
- ::swapcontext( & from->uctx, & uctx);
-#if defined(BOOST_USE_ASAN)
- __sanitizer_finish_switch_fiber( current()->fake_stack,
- (const void **) & current()->from->stack_bottom,
- & current()->from->stack_size);
-#endif
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
- return exchange( current()->from, nullptr);
-#else
- return std::exchange( current()->from, nullptr);
-#endif
- }
-
- template< typename Ctx, typename Fn >
- fiber_activation_record * resume_with( Fn && fn) {
- from = current();
- // store `this` in static, thread local pointer
- // `this` will become the active (running) context
- // returned by fiber::current()
- current() = this;
-#if defined(BOOST_NO_CXX14_GENERIC_LAMBDAS)
- current()->ontop = std::bind(
- [](typename std::decay< Fn >::type & fn, fiber_activation_record *& ptr){
- Ctx c{ ptr };
- c = fn( std::move( c) );
- if ( ! c) {
- ptr = nullptr;
- }
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
- return exchange( c.ptr_, nullptr);
-#else
- return std::exchange( c.ptr_, nullptr);
-#endif
- },
- std::forward< Fn >( fn),
- std::placeholders::_1);
-#else
- current()->ontop = [fn=std::forward<Fn>(fn)](fiber_activation_record *& ptr){
- Ctx c{ ptr };
- c = fn( std::move( c) );
- if ( ! c) {
- ptr = nullptr;
- }
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
- return exchange( c.ptr_, nullptr);
-#else
- return std::exchange( c.ptr_, nullptr);
-#endif
- };
-#endif
-#if defined(BOOST_USE_SEGMENTED_STACKS)
- // adjust segmented stack properties
- __splitstack_getcontext( from->sctx.segments_ctx);
- __splitstack_setcontext( sctx.segments_ctx);
-#endif
-#if defined(BOOST_USE_ASAN)
- __sanitizer_start_switch_fiber( & from->fake_stack, stack_bottom, stack_size);
-#endif
-#if defined (BOOST_USE_TSAN)
- __tsan_switch_to_fiber(tsan_fiber, 0);
-#endif
- // context switch from parent context to `this`-context
- ::swapcontext( & from->uctx, & uctx);
-#if defined(BOOST_USE_ASAN)
- __sanitizer_finish_switch_fiber( current()->fake_stack,
- (const void **) & current()->from->stack_bottom,
- & current()->from->stack_size);
-#endif
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
- return exchange( current()->from, nullptr);
-#else
- return std::exchange( current()->from, nullptr);
-#endif
- }
-
- virtual void deallocate() noexcept {
- }
-};
-
-struct BOOST_CONTEXT_DECL fiber_activation_record_initializer {
- fiber_activation_record_initializer() noexcept;
- ~fiber_activation_record_initializer();
-};
-
-struct forced_unwind {
- fiber_activation_record * from{ nullptr };
-
- forced_unwind( fiber_activation_record * from_) noexcept :
- from{ from_ } {
- }
-};
-
-template< typename Ctx, typename StackAlloc, typename Fn >
-class fiber_capture_record : public fiber_activation_record {
-private:
- typename std::decay< StackAlloc >::type salloc_;
- typename std::decay< Fn >::type fn_;
-
- static void destroy( fiber_capture_record * p) noexcept {
- typename std::decay< StackAlloc >::type salloc = std::move( p->salloc_);
- stack_context sctx = p->sctx;
- // deallocate activation record
- p->~fiber_capture_record();
- // destroy stack with stack allocator
- salloc.deallocate( sctx);
- }
-
-public:
- fiber_capture_record( stack_context sctx, StackAlloc && salloc, Fn && fn) noexcept :
- fiber_activation_record{ sctx },
- salloc_{ std::forward< StackAlloc >( salloc) },
- fn_( std::forward< Fn >( fn) ) {
- }
-
- void deallocate() noexcept override final {
- BOOST_ASSERT( main_ctx || ( ! main_ctx && terminated) );
- destroy( this);
- }
-
- void run() {
-#if defined(BOOST_USE_ASAN)
- __sanitizer_finish_switch_fiber( fake_stack,
- (const void **) & from->stack_bottom,
- & from->stack_size);
-#endif
- Ctx c{ from };
- try {
- // invoke context-function
-#if defined(BOOST_NO_CXX17_STD_INVOKE)
- c = boost::context::detail::invoke( fn_, std::move( c) );
-#else
- c = std::invoke( fn_, std::move( c) );
-#endif
- } catch ( forced_unwind const& ex) {
- c = Ctx{ ex.from };
- }
- // this context has finished its task
- from = nullptr;
- ontop = nullptr;
- terminated = true;
- force_unwind = false;
- std::move( c).resume();
- BOOST_ASSERT_MSG( false, "fiber already terminated");
- }
-};
-
-template< typename Ctx, typename StackAlloc, typename Fn >
-static fiber_activation_record * create_fiber1( StackAlloc && salloc, Fn && fn) {
- typedef fiber_capture_record< Ctx, StackAlloc, Fn > capture_t;
-
- auto sctx = salloc.allocate();
- // reserve space for control structure
- void * storage = reinterpret_cast< void * >(
- ( reinterpret_cast< uintptr_t >( sctx.sp) - static_cast< uintptr_t >( sizeof( capture_t) ) )
- & ~ static_cast< uintptr_t >( 0xff) );
- // placment new for control structure on context stack
- capture_t * record = new ( storage) capture_t{
- sctx, std::forward< StackAlloc >( salloc), std::forward< Fn >( fn) };
- // stack bottom
- void * stack_bottom = reinterpret_cast< void * >(
- reinterpret_cast< uintptr_t >( sctx.sp) - static_cast< uintptr_t >( sctx.size) );
- // create user-context
- if ( BOOST_UNLIKELY( 0 != ::getcontext( & record->uctx) ) ) {
- record->~capture_t();
- salloc.deallocate( sctx);
- throw std::system_error(
- std::error_code( errno, std::system_category() ),
- "getcontext() failed");
- }
-#if BOOST_OS_BSD_FREE
- // because FreeBSD defines stack_t::ss_sp as char *
- record->uctx.uc_stack.ss_sp = static_cast< char * >( stack_bottom);
-#else
- record->uctx.uc_stack.ss_sp = stack_bottom;
-#endif
- // 64byte gap between control structure and stack top
- record->uctx.uc_stack.ss_size = reinterpret_cast< uintptr_t >( storage) -
- reinterpret_cast< uintptr_t >( stack_bottom) - static_cast< uintptr_t >( 64);
- record->uctx.uc_link = nullptr;
- ::makecontext( & record->uctx, ( void (*)() ) & fiber_entry_func< capture_t >, 1, record);
-#if defined(BOOST_USE_ASAN)
- record->stack_bottom = record->uctx.uc_stack.ss_sp;
- record->stack_size = record->uctx.uc_stack.ss_size;
-#endif
-#if defined (BOOST_USE_TSAN)
- record->tsan_fiber = __tsan_create_fiber(0);
-#endif
- return record;
-}
-
-template< typename Ctx, typename StackAlloc, typename Fn >
-static fiber_activation_record * create_fiber2( preallocated palloc, StackAlloc && salloc, Fn && fn) {
- typedef fiber_capture_record< Ctx, StackAlloc, Fn > capture_t;
-
- // reserve space for control structure
- void * storage = reinterpret_cast< void * >(
- ( reinterpret_cast< uintptr_t >( palloc.sp) - static_cast< uintptr_t >( sizeof( capture_t) ) )
- & ~ static_cast< uintptr_t >( 0xff) );
- // placment new for control structure on context stack
- capture_t * record = new ( storage) capture_t{
- palloc.sctx, std::forward< StackAlloc >( salloc), std::forward< Fn >( fn) };
- // stack bottom
- void * stack_bottom = reinterpret_cast< void * >(
- reinterpret_cast< uintptr_t >( palloc.sctx.sp) - static_cast< uintptr_t >( palloc.sctx.size) );
- // create user-context
- if ( BOOST_UNLIKELY( 0 != ::getcontext( & record->uctx) ) ) {
- record->~capture_t();
- salloc.deallocate( palloc.sctx);
- throw std::system_error(
- std::error_code( errno, std::system_category() ),
- "getcontext() failed");
- }
-#if BOOST_OS_BSD_FREE
- // because FreeBSD defines stack_t::ss_sp as char *
- record->uctx.uc_stack.ss_sp = static_cast< char * >( stack_bottom);
-#else
- record->uctx.uc_stack.ss_sp = stack_bottom;
-#endif
- // 64byte gap between control structure and stack top
- record->uctx.uc_stack.ss_size = reinterpret_cast< uintptr_t >( storage) -
- reinterpret_cast< uintptr_t >( stack_bottom) - static_cast< uintptr_t >( 64);
- record->uctx.uc_link = nullptr;
- ::makecontext( & record->uctx, ( void (*)() ) & fiber_entry_func< capture_t >, 1, record);
-#if defined(BOOST_USE_ASAN)
- record->stack_bottom = record->uctx.uc_stack.ss_sp;
- record->stack_size = record->uctx.uc_stack.ss_size;
-#endif
-#if defined (BOOST_USE_TSAN)
- record->tsan_fiber = __tsan_create_fiber(0);
-#endif
- return record;
-}
-
-}
-
-class BOOST_CONTEXT_DECL fiber {
-private:
- friend struct detail::fiber_activation_record;
-
- template< typename Ctx, typename StackAlloc, typename Fn >
- friend class detail::fiber_capture_record;
-
- template< typename Ctx, typename StackAlloc, typename Fn >
- friend detail::fiber_activation_record * detail::create_fiber1( StackAlloc &&, Fn &&);
-
- template< typename Ctx, typename StackAlloc, typename Fn >
- friend detail::fiber_activation_record * detail::create_fiber2( preallocated, StackAlloc &&, Fn &&);
-
- detail::fiber_activation_record * ptr_{ nullptr };
-
- fiber( detail::fiber_activation_record * ptr) noexcept :
- ptr_{ ptr } {
- }
-
-public:
- fiber() = default;
-
- template< typename Fn, typename = detail::disable_overload< fiber, Fn > >
- fiber( Fn && fn) :
- fiber{
- std::allocator_arg,
-#if defined(BOOST_USE_SEGMENTED_STACKS)
- segmented_stack(),
-#else
- fixedsize_stack(),
-#endif
- std::forward< Fn >( fn) } {
- }
-
- template< typename StackAlloc, typename Fn >
- fiber( std::allocator_arg_t, StackAlloc && salloc, Fn && fn) :
- ptr_{ detail::create_fiber1< fiber >(
- std::forward< StackAlloc >( salloc), std::forward< Fn >( fn) ) } {
- }
-
- template< typename StackAlloc, typename Fn >
- fiber( std::allocator_arg_t, preallocated palloc, StackAlloc && salloc, Fn && fn) :
- ptr_{ detail::create_fiber2< fiber >(
- palloc, std::forward< StackAlloc >( salloc), std::forward< Fn >( fn) ) } {
- }
-
- ~fiber() {
- if ( BOOST_UNLIKELY( nullptr != ptr_) && ! ptr_->main_ctx) {
- if ( BOOST_LIKELY( ! ptr_->terminated) ) {
- ptr_->force_unwind = true;
- ptr_->resume();
- BOOST_ASSERT( ptr_->terminated);
- }
- ptr_->deallocate();
- }
- }
-
- fiber( fiber const&) = delete;
- fiber & operator=( fiber const&) = delete;
-
- fiber( fiber && other) noexcept {
- swap( other);
- }
-
- fiber & operator=( fiber && other) noexcept {
- if ( BOOST_LIKELY( this != & other) ) {
- fiber tmp = std::move( other);
- swap( tmp);
- }
- return * this;
- }
-
- fiber resume() && {
- BOOST_ASSERT( nullptr != ptr_);
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
- detail::fiber_activation_record * ptr = detail::exchange( ptr_, nullptr)->resume();
-#else
- detail::fiber_activation_record * ptr = std::exchange( ptr_, nullptr)->resume();
-#endif
- if ( BOOST_UNLIKELY( detail::fiber_activation_record::current()->force_unwind) ) {
- throw detail::forced_unwind{ ptr};
- } else if ( BOOST_UNLIKELY( nullptr != detail::fiber_activation_record::current()->ontop) ) {
- ptr = detail::fiber_activation_record::current()->ontop( ptr);
- detail::fiber_activation_record::current()->ontop = nullptr;
- }
- return { ptr };
- }
-
- template< typename Fn >
- fiber resume_with( Fn && fn) && {
- BOOST_ASSERT( nullptr != ptr_);
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
- detail::fiber_activation_record * ptr =
- detail::exchange( ptr_, nullptr)->resume_with< fiber >( std::forward< Fn >( fn) );
-#else
- detail::fiber_activation_record * ptr =
- std::exchange( ptr_, nullptr)->resume_with< fiber >( std::forward< Fn >( fn) );
-#endif
- if ( BOOST_UNLIKELY( detail::fiber_activation_record::current()->force_unwind) ) {
- throw detail::forced_unwind{ ptr};
- } else if ( BOOST_UNLIKELY( nullptr != detail::fiber_activation_record::current()->ontop) ) {
- ptr = detail::fiber_activation_record::current()->ontop( ptr);
- detail::fiber_activation_record::current()->ontop = nullptr;
- }
- return { ptr };
- }
-
- explicit operator bool() const noexcept {
- return nullptr != ptr_ && ! ptr_->terminated;
- }
-
- bool operator!() const noexcept {
- return nullptr == ptr_ || ptr_->terminated;
- }
-
- bool operator<( fiber const& other) const noexcept {
- return ptr_ < other.ptr_;
- }
-
- #if !defined(BOOST_EMBTC)
-
- template< typename charT, class traitsT >
- friend std::basic_ostream< charT, traitsT > &
- operator<<( std::basic_ostream< charT, traitsT > & os, fiber const& other) {
- if ( nullptr != other.ptr_) {
- return os << other.ptr_;
- } else {
- return os << "{not-a-context}";
- }
- }
-
- #else
-
- template< typename charT, class traitsT >
- friend std::basic_ostream< charT, traitsT > &
- operator<<( std::basic_ostream< charT, traitsT > & os, fiber const& other);
-
- #endif
-
- void swap( fiber & other) noexcept {
- std::swap( ptr_, other.ptr_);
- }
-};
-
-#if defined(BOOST_EMBTC)
-
- template< typename charT, class traitsT >
- inline std::basic_ostream< charT, traitsT > &
- operator<<( std::basic_ostream< charT, traitsT > & os, fiber const& other) {
- if ( nullptr != other.ptr_) {
- return os << other.ptr_;
- } else {
- return os << "{not-a-context}";
- }
- }
-
-#endif
-
-inline
-void swap( fiber & l, fiber & r) noexcept {
- l.swap( r);
-}
-
-typedef fiber fiber_context;
-
-}}
-
-#ifdef BOOST_HAS_ABI_HEADERS
-# include BOOST_ABI_SUFFIX
-#endif
-
-#endif // BOOST_CONTEXT_FIBER_H
diff --git a/contrib/restricted/boost/context/include/boost/context/fiber_winfib.hpp b/contrib/restricted/boost/context/include/boost/context/fiber_winfib.hpp
deleted file mode 100644
index cd496d1be15..00000000000
--- a/contrib/restricted/boost/context/include/boost/context/fiber_winfib.hpp
+++ /dev/null
@@ -1,450 +0,0 @@
-
-// Copyright Oliver Kowalke 2017.
-// 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)
-
-#ifndef BOOST_CONTEXT_FIBER_H
-#define BOOST_CONTEXT_FIBER_H
-
-#include <windows.h>
-
-#include <boost/context/detail/config.hpp>
-
-#include <algorithm>
-#include <cstddef>
-#include <cstdint>
-#include <cstdlib>
-#include <cstring>
-#include <functional>
-#include <memory>
-#include <ostream>
-#include <system_error>
-#include <tuple>
-#include <utility>
-
-#include <boost/assert.hpp>
-#include <boost/config.hpp>
-
-#include <boost/context/detail/disable_overload.hpp>
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
-#include <boost/context/detail/exchange.hpp>
-#endif
-#if defined(BOOST_NO_CXX17_STD_INVOKE)
-#include <boost/context/detail/invoke.hpp>
-#endif
-#include <boost/context/fixedsize_stack.hpp>
-#include <boost/context/flags.hpp>
-#include <boost/context/preallocated.hpp>
-#include <boost/context/stack_context.hpp>
-
-#ifdef BOOST_HAS_ABI_HEADERS
-# include BOOST_ABI_PREFIX
-#endif
-
-#if defined(BOOST_MSVC)
-# pragma warning(push)
-# pragma warning(disable: 4702)
-#endif
-
-namespace boost {
-namespace context {
-namespace detail {
-
-// tampoline function
-// entered if the execution context
-// is resumed for the first time
-template< typename Record >
-static VOID WINAPI fiber_entry_func( LPVOID data) noexcept {
- Record * record = static_cast< Record * >( data);
- BOOST_ASSERT( nullptr != record);
- // start execution of toplevel context-function
- record->run();
-}
-
-struct BOOST_CONTEXT_DECL fiber_activation_record {
- LPVOID fiber{ nullptr };
- stack_context sctx{};
- bool main_ctx{ true };
- fiber_activation_record * from{ nullptr };
- std::function< fiber_activation_record*(fiber_activation_record*&) > ontop{};
- bool terminated{ false };
- bool force_unwind{ false };
-
- static fiber_activation_record *& current() noexcept;
-
- // used for toplevel-context
- // (e.g. main context, thread-entry context)
- fiber_activation_record() noexcept {
-#if ( _WIN32_WINNT > 0x0600)
- if ( ::IsThreadAFiber() ) {
- fiber = ::GetCurrentFiber();
- } else {
- fiber = ::ConvertThreadToFiber( nullptr);
- }
-#else
- fiber = ::ConvertThreadToFiber( nullptr);
- if ( BOOST_UNLIKELY( nullptr == fiber) ) {
- BOOST_ASSERT( ERROR_ALREADY_FIBER == ::GetLastError());
- fiber = ::GetCurrentFiber();
- BOOST_ASSERT( nullptr != fiber);
- BOOST_ASSERT( reinterpret_cast< LPVOID >( 0x1E00) != fiber);
- }
-#endif
- }
-
- fiber_activation_record( stack_context sctx_) noexcept :
- sctx{ sctx_ },
- main_ctx{ false } {
- }
-
- virtual ~fiber_activation_record() {
- if ( BOOST_UNLIKELY( main_ctx) ) {
- ::ConvertFiberToThread();
- } else {
- ::DeleteFiber( fiber);
- }
- }
-
- fiber_activation_record( fiber_activation_record const&) = delete;
- fiber_activation_record & operator=( fiber_activation_record const&) = delete;
-
- bool is_main_context() const noexcept {
- return main_ctx;
- }
-
- fiber_activation_record * resume() {
- from = current();
- // store `this` in static, thread local pointer
- // `this` will become the active (running) context
- current() = this;
- // context switch from parent context to `this`-context
- // context switch
- ::SwitchToFiber( fiber);
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
- return detail::exchange( current()->from, nullptr);
-#else
- return std::exchange( current()->from, nullptr);
-#endif
- }
-
- template< typename Ctx, typename Fn >
- fiber_activation_record * resume_with( Fn && fn) {
- from = current();
- // store `this` in static, thread local pointer
- // `this` will become the active (running) context
- // returned by fiber::current()
- current() = this;
-#if defined(BOOST_NO_CXX14_GENERIC_LAMBDAS)
- current()->ontop = std::bind(
- [](typename std::decay< Fn >::type & fn, fiber_activation_record *& ptr){
- Ctx c{ ptr };
- c = fn( std::move( c) );
- if ( ! c) {
- ptr = nullptr;
- }
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
- return exchange( c.ptr_, nullptr);
-#else
- return std::exchange( c.ptr_, nullptr);
-#endif
- },
- std::forward< Fn >( fn),
- std::placeholders::_1);
-#else
- current()->ontop = [fn=std::forward<Fn>(fn)](fiber_activation_record *& ptr){
- Ctx c{ ptr };
- c = fn( std::move( c) );
- if ( ! c) {
- ptr = nullptr;
- }
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
- return exchange( c.ptr_, nullptr);
-#else
- return std::exchange( c.ptr_, nullptr);
-#endif
- };
-#endif
- // context switch
- ::SwitchToFiber( fiber);
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
- return detail::exchange( current()->from, nullptr);
-#else
- return std::exchange( current()->from, nullptr);
-#endif
- }
-
- virtual void deallocate() noexcept {
- }
-};
-
-struct BOOST_CONTEXT_DECL fiber_activation_record_initializer {
- fiber_activation_record_initializer() noexcept;
- ~fiber_activation_record_initializer();
-};
-
-struct forced_unwind {
- fiber_activation_record * from{ nullptr };
-
- explicit forced_unwind( fiber_activation_record * from_) :
- from{ from_ } {
- }
-};
-
-template< typename Ctx, typename StackAlloc, typename Fn >
-class fiber_capture_record : public fiber_activation_record {
-private:
- typename std::decay< StackAlloc >::type salloc_;
- typename std::decay< Fn >::type fn_;
-
- static void destroy( fiber_capture_record * p) noexcept {
- typename std::decay< StackAlloc >::type salloc = std::move( p->salloc_);
- stack_context sctx = p->sctx;
- // deallocate activation record
- p->~fiber_capture_record();
- // destroy stack with stack allocator
- salloc.deallocate( sctx);
- }
-
-public:
- fiber_capture_record( stack_context sctx, StackAlloc && salloc, Fn && fn) noexcept :
- fiber_activation_record( sctx),
- salloc_( std::forward< StackAlloc >( salloc)),
- fn_( std::forward< Fn >( fn) ) {
- }
-
- void deallocate() noexcept override final {
- BOOST_ASSERT( main_ctx || ( ! main_ctx && terminated) );
- destroy( this);
- }
-
- void run() {
- Ctx c{ from };
- try {
- // invoke context-function
-#if defined(BOOST_NO_CXX17_STD_INVOKE)
- c = boost::context::detail::invoke( fn_, std::move( c) );
-#else
- c = std::invoke( fn_, std::move( c) );
-#endif
- } catch ( forced_unwind const& ex) {
- c = Ctx{ ex.from };
- }
- // this context has finished its task
- from = nullptr;
- ontop = nullptr;
- terminated = true;
- force_unwind = false;
- std::move( c).resume();
- BOOST_ASSERT_MSG( false, "fiber already terminated");
- }
-};
-
-template< typename Ctx, typename StackAlloc, typename Fn >
-static fiber_activation_record * create_fiber1( StackAlloc && salloc, Fn && fn) {
- typedef fiber_capture_record< Ctx, StackAlloc, Fn > capture_t;
-
- auto sctx = salloc.allocate();
- BOOST_ASSERT( ( sizeof( capture_t) ) < sctx.size);
- // reserve space for control structure
- void * storage = reinterpret_cast< void * >(
- ( reinterpret_cast< uintptr_t >( sctx.sp) - static_cast< uintptr_t >( sizeof( capture_t) ) )
- & ~ static_cast< uintptr_t >( 0xff) );
- // placment new for control structure on context stack
- capture_t * record = new ( storage) capture_t{
- sctx, std::forward< StackAlloc >( salloc), std::forward< Fn >( fn) };
- // create user-context
- record->fiber = ::CreateFiber( sctx.size, & detail::fiber_entry_func< capture_t >, record);
- return record;
-}
-
-template< typename Ctx, typename StackAlloc, typename Fn >
-static fiber_activation_record * create_fiber2( preallocated palloc, StackAlloc && salloc, Fn && fn) {
- typedef fiber_capture_record< Ctx, StackAlloc, Fn > capture_t;
-
- BOOST_ASSERT( ( sizeof( capture_t) ) < palloc.size);
- // reserve space for control structure
- void * storage = reinterpret_cast< void * >(
- ( reinterpret_cast< uintptr_t >( palloc.sp) - static_cast< uintptr_t >( sizeof( capture_t) ) )
- & ~ static_cast< uintptr_t >( 0xff) );
- // placment new for control structure on context stack
- capture_t * record = new ( storage) capture_t{
- palloc.sctx, std::forward< StackAlloc >( salloc), std::forward< Fn >( fn) };
- // create user-context
- record->fiber = ::CreateFiber( palloc.sctx.size, & detail::fiber_entry_func< capture_t >, record);
- return record;
-}
-
-}
-
-class BOOST_CONTEXT_DECL fiber {
-private:
- friend struct detail::fiber_activation_record;
-
- template< typename Ctx, typename StackAlloc, typename Fn >
- friend class detail::fiber_capture_record;
-
- template< typename Ctx, typename StackAlloc, typename Fn >
- friend detail::fiber_activation_record * detail::create_fiber1( StackAlloc &&, Fn &&);
-
- template< typename Ctx, typename StackAlloc, typename Fn >
- friend detail::fiber_activation_record * detail::create_fiber2( preallocated, StackAlloc &&, Fn &&);
-
- detail::fiber_activation_record * ptr_{ nullptr };
-
- fiber( detail::fiber_activation_record * ptr) noexcept :
- ptr_{ ptr } {
- }
-
-public:
- fiber() = default;
-
- template< typename Fn, typename = detail::disable_overload< fiber, Fn > >
- fiber( Fn && fn) :
- fiber{ std::allocator_arg,
- fixedsize_stack(),
- std::forward< Fn >( fn) } {
- }
-
- template< typename StackAlloc, typename Fn >
- fiber( std::allocator_arg_t, StackAlloc && salloc, Fn && fn) :
- ptr_{ detail::create_fiber1< fiber >(
- std::forward< StackAlloc >( salloc), std::forward< Fn >( fn) ) } {;
- }
-
- template< typename StackAlloc, typename Fn >
- fiber( std::allocator_arg_t, preallocated palloc, StackAlloc && salloc, Fn && fn) :
- ptr_{ detail::create_fiber2< fiber >(
- palloc, std::forward< StackAlloc >( salloc), std::forward< Fn >( fn) ) } {
- }
-
- ~fiber() {
- if ( BOOST_UNLIKELY( nullptr != ptr_) && ! ptr_->main_ctx) {
- if ( BOOST_LIKELY( ! ptr_->terminated) ) {
- ptr_->force_unwind = true;
- ptr_->resume();
- BOOST_ASSERT( ptr_->terminated);
- }
- ptr_->deallocate();
- }
- }
-
- fiber( fiber const&) = delete;
- fiber & operator=( fiber const&) = delete;
-
- fiber( fiber && other) noexcept {
- swap( other);
- }
-
- fiber & operator=( fiber && other) noexcept {
- if ( BOOST_LIKELY( this != & other) ) {
- fiber tmp = std::move( other);
- swap( tmp);
- }
- return * this;
- }
-
- fiber resume() && {
- BOOST_ASSERT( nullptr != ptr_);
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
- detail::fiber_activation_record * ptr = detail::exchange( ptr_, nullptr)->resume();
-#else
- detail::fiber_activation_record * ptr = std::exchange( ptr_, nullptr)->resume();
-#endif
- if ( BOOST_UNLIKELY( detail::fiber_activation_record::current()->force_unwind) ) {
- throw detail::forced_unwind{ ptr};
- } else if ( BOOST_UNLIKELY( nullptr != detail::fiber_activation_record::current()->ontop) ) {
- ptr = detail::fiber_activation_record::current()->ontop( ptr);
- detail::fiber_activation_record::current()->ontop = nullptr;
- }
- return { ptr };
- }
-
- template< typename Fn >
- fiber resume_with( Fn && fn) && {
- BOOST_ASSERT( nullptr != ptr_);
-#if defined(BOOST_NO_CXX14_STD_EXCHANGE)
- detail::fiber_activation_record * ptr =
- detail::exchange( ptr_, nullptr)->resume_with< fiber >( std::forward< Fn >( fn) );
-#else
- detail::fiber_activation_record * ptr =
- std::exchange( ptr_, nullptr)->resume_with< fiber >( std::forward< Fn >( fn) );
-#endif
- if ( BOOST_UNLIKELY( detail::fiber_activation_record::current()->force_unwind) ) {
- throw detail::forced_unwind{ ptr};
- } else if ( BOOST_UNLIKELY( nullptr != detail::fiber_activation_record::current()->ontop) ) {
- ptr = detail::fiber_activation_record::current()->ontop( ptr);
- detail::fiber_activation_record::current()->ontop = nullptr;
- }
- return { ptr };
- }
-
- explicit operator bool() const noexcept {
- return nullptr != ptr_ && ! ptr_->terminated;
- }
-
- bool operator!() const noexcept {
- return nullptr == ptr_ || ptr_->terminated;
- }
-
- bool operator<( fiber const& other) const noexcept {
- return ptr_ < other.ptr_;
- }
-
- #if !defined(BOOST_EMBTC)
-
- template< typename charT, class traitsT >
- friend std::basic_ostream< charT, traitsT > &
- operator<<( std::basic_ostream< charT, traitsT > & os, fiber const& other) {
- if ( nullptr != other.ptr_) {
- return os << other.ptr_;
- } else {
- return os << "{not-a-context}";
- }
- }
-
- #else
-
- template< typename charT, class traitsT >
- friend std::basic_ostream< charT, traitsT > &
- operator<<( std::basic_ostream< charT, traitsT > & os, fiber const& other);
-
- #endif
-
- void swap( fiber & other) noexcept {
- std::swap( ptr_, other.ptr_);
- }
-};
-
-#if defined(BOOST_EMBTC)
-
- template< typename charT, class traitsT >
- inline std::basic_ostream< charT, traitsT > &
- operator<<( std::basic_ostream< charT, traitsT > & os, fiber const& other) {
- if ( nullptr != other.ptr_) {
- return os << other.ptr_;
- } else {
- return os << "{not-a-context}";
- }
- }
-
-#endif
-
-inline
-void swap( fiber & l, fiber & r) noexcept {
- l.swap( r);
-}
-
-typedef fiber fiber_context;
-
-}}
-
-#if defined(BOOST_MSVC)
-# pragma warning(pop)
-#endif
-
-#ifdef BOOST_HAS_ABI_HEADERS
-# include BOOST_ABI_SUFFIX
-#endif
-
-#endif // BOOST_CONTEXT_FIBER_H
diff --git a/contrib/restricted/boost/context/include/boost/context/fixedsize_stack.hpp b/contrib/restricted/boost/context/include/boost/context/fixedsize_stack.hpp
deleted file mode 100644
index c309347935a..00000000000
--- a/contrib/restricted/boost/context/include/boost/context/fixedsize_stack.hpp
+++ /dev/null
@@ -1,97 +0,0 @@
-
-// Copyright Oliver Kowalke 2014.
-// 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)
-
-#ifndef BOOST_CONTEXT_FIXEDSIZE_H
-#define BOOST_CONTEXT_FIXEDSIZE_H
-
-#include <cstddef>
-#include <cstdlib>
-#include <new>
-
-#include <boost/assert.hpp>
-#include <boost/config.hpp>
-
-#include <boost/context/detail/config.hpp>
-#include <boost/context/stack_context.hpp>
-#include <boost/context/stack_traits.hpp>
-
-#if defined(BOOST_CONTEXT_USE_MAP_STACK)
-extern "C" {
-#include <sys/mman.h>
-}
-#endif
-
-#if defined(BOOST_USE_VALGRIND)
-#include <valgrind/valgrind.h>
-#endif
-
-#ifdef BOOST_HAS_ABI_HEADERS
-# include BOOST_ABI_PREFIX
-#endif
-
-namespace boost {
-namespace context {
-
-template< typename traitsT >
-class basic_fixedsize_stack {
-private:
- std::size_t size_;
-
-public:
- typedef traitsT traits_type;
-
- basic_fixedsize_stack( std::size_t size = traits_type::default_size() ) BOOST_NOEXCEPT_OR_NOTHROW :
- size_( size) {
- }
-
- stack_context allocate() {
-#if defined(BOOST_CONTEXT_USE_MAP_STACK)
- void * vp = ::mmap( 0, size_, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | MAP_STACK, -1, 0);
- if ( vp == MAP_FAILED) {
- throw std::bad_alloc();
- }
-#else
- void * vp = std::malloc( size_);
- if ( ! vp) {
- throw std::bad_alloc();
- }
-#endif
- stack_context sctx;
- sctx.size = size_;
- sctx.sp = static_cast< char * >( vp) + sctx.size;
-#if defined(BOOST_USE_VALGRIND)
- sctx.valgrind_stack_id = VALGRIND_STACK_REGISTER( sctx.sp, vp);
-#endif
- return sctx;
- }
-
- void deallocate( stack_context & sctx) BOOST_NOEXCEPT_OR_NOTHROW {
- BOOST_ASSERT( sctx.sp);
-
-#if defined(BOOST_USE_VALGRIND)
- VALGRIND_STACK_DEREGISTER( sctx.valgrind_stack_id);
-#endif
- void * vp = static_cast< char * >( sctx.sp) - sctx.size;
-#if defined(BOOST_CONTEXT_USE_MAP_STACK)
- ::munmap( vp, sctx.size);
-#else
- std::free( vp);
-#endif
- }
-};
-
-typedef basic_fixedsize_stack< stack_traits > fixedsize_stack;
-# if ! defined(BOOST_USE_SEGMENTED_STACKS)
-typedef fixedsize_stack default_stack;
-# endif
-
-}}
-
-#ifdef BOOST_HAS_ABI_HEADERS
-# include BOOST_ABI_SUFFIX
-#endif
-
-#endif // BOOST_CONTEXT_FIXEDSIZE_H
diff --git a/contrib/restricted/boost/context/include/boost/context/flags.hpp b/contrib/restricted/boost/context/include/boost/context/flags.hpp
deleted file mode 100644
index c7ff1179da5..00000000000
--- a/contrib/restricted/boost/context/include/boost/context/flags.hpp
+++ /dev/null
@@ -1,28 +0,0 @@
-
-// Copyright Oliver Kowalke 2014.
-// 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)
-
-#ifndef BOOST_CONTEXT_FLAGS_H
-#define BOOST_CONTEXT_FLAGS_H
-
-# include <boost/config.hpp>
-
-# ifdef BOOST_HAS_ABI_HEADERS
-# include BOOST_ABI_PREFIX
-# endif
-
-namespace boost {
-namespace context {
-
-struct exec_ontop_arg_t {};
-const exec_ontop_arg_t exec_ontop_arg{};
-
-}}
-
-# ifdef BOOST_HAS_ABI_HEADERS
-# include BOOST_ABI_SUFFIX
-# endif
-
-#endif // BOOST_CONTEXT_FLAGS_H
diff --git a/contrib/restricted/boost/context/include/boost/context/posix/segmented_stack.hpp b/contrib/restricted/boost/context/include/boost/context/posix/segmented_stack.hpp
deleted file mode 100644
index e3d2efcb5b1..00000000000
--- a/contrib/restricted/boost/context/include/boost/context/posix/segmented_stack.hpp
+++ /dev/null
@@ -1,82 +0,0 @@
-
-// Copyright Oliver Kowalke 2014.
-// 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)
-
-#ifndef BOOST_CONTEXT_SEGMENTED_H
-#define BOOST_CONTEXT_SEGMENTED_H
-
-#include <cstddef>
-#include <new>
-
-#include <boost/config.hpp>
-
-#include <boost/context/detail/config.hpp>
-#include <boost/context/stack_context.hpp>
-#include <boost/context/stack_traits.hpp>
-
-#ifdef BOOST_HAS_ABI_HEADERS
-# include BOOST_ABI_PREFIX
-#endif
-
-// forward declaration for splitstack-functions defined in libgcc
-extern "C" {
-void *__splitstack_makecontext( std::size_t,
- void * [BOOST_CONTEXT_SEGMENTS],
- std::size_t *);
-
-void __splitstack_releasecontext( void * [BOOST_CONTEXT_SEGMENTS]);
-
-void __splitstack_resetcontext( void * [BOOST_CONTEXT_SEGMENTS]);
-
-void __splitstack_block_signals_context( void * [BOOST_CONTEXT_SEGMENTS],
- int * new_value, int * old_value);
-}
-
-namespace boost {
-namespace context {
-
-template< typename traitsT >
-class basic_segmented_stack {
-private:
- std::size_t size_;
-
-public:
- typedef traitsT traits_type;
-
- basic_segmented_stack( std::size_t size = traits_type::default_size() ) BOOST_NOEXCEPT_OR_NOTHROW :
- size_( size) {
- }
-
- stack_context allocate() {
- stack_context sctx;
- void * vp = __splitstack_makecontext( size_, sctx.segments_ctx, & sctx.size);
- if ( ! vp) throw std::bad_alloc();
-
- // sctx.size is already filled by __splitstack_makecontext
- sctx.sp = static_cast< char * >( vp) + sctx.size;
-
- int off = 0;
- __splitstack_block_signals_context( sctx.segments_ctx, & off, 0);
-
- return sctx;
- }
-
- void deallocate( stack_context & sctx) BOOST_NOEXCEPT_OR_NOTHROW {
- __splitstack_releasecontext( sctx.segments_ctx);
- }
-};
-
-typedef basic_segmented_stack< stack_traits > segmented_stack;
-# if defined(BOOST_USE_SEGMENTED_STACKS)
-typedef segmented_stack default_stack;
-# endif
-
-}}
-
-#ifdef BOOST_HAS_ABI_HEADERS
-# include BOOST_ABI_SUFFIX
-#endif
-
-#endif // BOOST_CONTEXT_SEGMENTED_H
diff --git a/contrib/restricted/boost/context/include/boost/context/preallocated.hpp b/contrib/restricted/boost/context/include/boost/context/preallocated.hpp
deleted file mode 100644
index 862a6a5060f..00000000000
--- a/contrib/restricted/boost/context/include/boost/context/preallocated.hpp
+++ /dev/null
@@ -1,39 +0,0 @@
-
-// Copyright Oliver Kowalke 2014.
-// 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)
-
-#ifndef BOOST_CONTEXT_PREALLOCATED_H
-#define BOOST_CONTEXT_PREALLOCATED_H
-
-#include <cstddef>
-
-#include <boost/config.hpp>
-
-#include <boost/context/detail/config.hpp>
-
-#ifdef BOOST_HAS_ABI_HEADERS
-# include BOOST_ABI_PREFIX
-#endif
-
-namespace boost {
-namespace context {
-
-struct preallocated {
- void * sp;
- std::size_t size;
- stack_context sctx;
-
- preallocated( void * sp_, std::size_t size_, stack_context sctx_) noexcept :
- sp( sp_), size( size_), sctx( sctx_) {
- }
-};
-
-}}
-
-#ifdef BOOST_HAS_ABI_HEADERS
-# include BOOST_ABI_SUFFIX
-#endif
-
-#endif // BOOST_CONTEXT_PREALLOCATED_H
diff --git a/contrib/restricted/boost/context/include/boost/context/segmented_stack.hpp b/contrib/restricted/boost/context/include/boost/context/segmented_stack.hpp
deleted file mode 100644
index 88e3e6a61f5..00000000000
--- a/contrib/restricted/boost/context/include/boost/context/segmented_stack.hpp
+++ /dev/null
@@ -1,13 +0,0 @@
-
-// Copyright Oliver Kowalke 2014.
-// 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 <boost/config.hpp>
-
-#if defined(BOOST_USE_SEGMENTED_STACKS)
-# if ! defined(BOOST_WINDOWS)
-# include <boost/context/posix/segmented_stack.hpp>
-# endif
-#endif
diff --git a/contrib/restricted/boost/context/src/continuation.cpp b/contrib/restricted/boost/context/src/continuation.cpp
deleted file mode 100644
index 2d7769602a7..00000000000
--- a/contrib/restricted/boost/context/src/continuation.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-
-// Copyright Oliver Kowalke 2017.
-// 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)
-
-#if defined(BOOST_USE_UCONTEXT)
-#include "boost/context/continuation_ucontext.hpp"
-#elif defined(BOOST_USE_WINFIB)
-#include "boost/context/continuation_winfib.hpp"
-#endif
-
-#include <boost/config.hpp>
-
-#ifdef BOOST_HAS_ABI_HEADERS
-# include BOOST_ABI_PREFIX
-#endif
-
-namespace boost {
-namespace context {
-namespace detail {
-
-// zero-initialization
-thread_local activation_record * current_rec;
-thread_local static std::size_t counter;
-
-// schwarz counter
-activation_record_initializer::activation_record_initializer() noexcept {
- if ( 0 == counter++) {
- current_rec = new activation_record();
- }
-}
-
-activation_record_initializer::~activation_record_initializer() {
- if ( 0 == --counter) {
- BOOST_ASSERT( current_rec->is_main_context() );
- delete current_rec;
- }
-}
-
-}
-
-namespace detail {
-
-activation_record *&
-activation_record::current() noexcept {
- // initialized the first time control passes; per thread
- thread_local static activation_record_initializer initializer;
- return current_rec;
-}
-
-}
-
-}}
-
-#ifdef BOOST_HAS_ABI_HEADERS
-# include BOOST_ABI_SUFFIX
-#endif
diff --git a/contrib/restricted/boost/context/src/fiber.cpp b/contrib/restricted/boost/context/src/fiber.cpp
deleted file mode 100644
index b6b790df544..00000000000
--- a/contrib/restricted/boost/context/src/fiber.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-
-// Copyright Oliver Kowalke 2017.
-// 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)
-
-#if defined(BOOST_USE_UCONTEXT)
-#include "boost/context/fiber_ucontext.hpp"
-#elif defined(BOOST_USE_WINFIB)
-#include "boost/context/fiber_winfib.hpp"
-#endif
-
-#include <boost/config.hpp>
-
-#ifdef BOOST_HAS_ABI_HEADERS
-# include BOOST_ABI_PREFIX
-#endif
-
-namespace boost {
-namespace context {
-namespace detail {
-
-// zero-initialization
-thread_local fiber_activation_record * fib_current_rec;
-thread_local static std::size_t counter;
-
-// schwarz counter
-fiber_activation_record_initializer::fiber_activation_record_initializer() noexcept {
- if ( 0 == counter++) {
- fib_current_rec = new fiber_activation_record();
- }
-}
-
-fiber_activation_record_initializer::~fiber_activation_record_initializer() {
- if ( 0 == --counter) {
- BOOST_ASSERT( fib_current_rec->is_main_context() );
- delete fib_current_rec;
- }
-}
-
-}
-
-namespace detail {
-
-fiber_activation_record *&
-fiber_activation_record::current() noexcept {
- // initialized the first time control passes; per thread
- thread_local static fiber_activation_record_initializer initializer;
- return fib_current_rec;
-}
-
-}
-
-}}
-
-#ifdef BOOST_HAS_ABI_HEADERS
-# include BOOST_ABI_SUFFIX
-#endif