File indexing completed on 2025-12-16 09:45:00
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_CONTEXT_SEGMENTED_H
0008 #define BOOST_CONTEXT_SEGMENTED_H
0009
0010 #include <cstddef>
0011 #include <new>
0012
0013 #include <boost/config.hpp>
0014
0015 #include <boost/context/detail/config.hpp>
0016 #include <boost/context/stack_context.hpp>
0017 #include <boost/context/stack_traits.hpp>
0018
0019 #ifdef BOOST_HAS_ABI_HEADERS
0020 # include BOOST_ABI_PREFIX
0021 #endif
0022
0023
0024 extern "C" {
0025 void *__splitstack_makecontext( std::size_t,
0026 void * [BOOST_CONTEXT_SEGMENTS],
0027 std::size_t *);
0028
0029 void __splitstack_releasecontext( void * [BOOST_CONTEXT_SEGMENTS]);
0030
0031 void __splitstack_resetcontext( void * [BOOST_CONTEXT_SEGMENTS]);
0032
0033 void __splitstack_block_signals_context( void * [BOOST_CONTEXT_SEGMENTS],
0034 int * new_value, int * old_value);
0035 }
0036
0037 namespace boost {
0038 namespace context {
0039
0040 template< typename traitsT >
0041 class basic_segmented_stack {
0042 private:
0043 std::size_t size_;
0044
0045 public:
0046 typedef traitsT traits_type;
0047
0048 basic_segmented_stack( std::size_t size = traits_type::default_size() ) BOOST_NOEXCEPT_OR_NOTHROW :
0049 size_( size) {
0050 }
0051
0052 stack_context allocate() {
0053 stack_context sctx;
0054 void * vp = __splitstack_makecontext( size_, sctx.segments_ctx, & sctx.size);
0055 if ( ! vp) throw std::bad_alloc();
0056
0057
0058 sctx.sp = static_cast< char * >( vp) + sctx.size;
0059
0060 int off = 0;
0061 __splitstack_block_signals_context( sctx.segments_ctx, & off, 0);
0062
0063 return sctx;
0064 }
0065
0066 void deallocate( stack_context & sctx) BOOST_NOEXCEPT_OR_NOTHROW {
0067 __splitstack_releasecontext( sctx.segments_ctx);
0068 }
0069 };
0070
0071 typedef basic_segmented_stack< stack_traits > segmented_stack;
0072 # if defined(BOOST_USE_SEGMENTED_STACKS)
0073 typedef segmented_stack default_stack;
0074 # endif
0075
0076 }}
0077
0078 #ifdef BOOST_HAS_ABI_HEADERS
0079 # include BOOST_ABI_SUFFIX
0080 #endif
0081
0082 #endif