BVB Source Codes

mars Show segmented_stack.hpp Source code

Return Download mars: download segmented_stack.hpp Source code - Download mars Source code - Type:.hpp
  1.  
  2. //          Copyright Oliver Kowalke 2014.
  3. // Distributed under the Boost Software License, Version 1.0.
  4. //    (See accompanying file LICENSE_1_0.txt or copy at
  5. //          http://www.boost.org/LICENSE_1_0.txt)
  6.  
  7. #ifndef BOOST_CONTEXT_SEGMENTED_H
  8. #define BOOST_CONTEXT_SEGMENTED_H
  9.  
  10. #include <cstddef>
  11. #include <new>
  12.  
  13. #include <boost/config.hpp>
  14.  
  15. #include <boost/context/detail/config.hpp>
  16. #include <boost/context/stack_context.hpp>
  17. #include <boost/context/stack_traits.hpp>
  18.  
  19. #ifdef BOOST_HAS_ABI_HEADERS
  20. #  include BOOST_ABI_PREFIX
  21. #endif
  22.  
  23. // forward declaration for splitstack-functions defined in libgcc
  24. extern "C" {
  25. void *__splitstack_makecontext( std::size_t,
  26.                                 void * [BOOST_CONTEXT_SEGMENTS],
  27.                                 std::size_t *);
  28.  
  29. void __splitstack_releasecontext( void * [BOOST_CONTEXT_SEGMENTS]);
  30.  
  31. void __splitstack_resetcontext( void * [BOOST_CONTEXT_SEGMENTS]);
  32.  
  33. void __splitstack_block_signals_context( void * [BOOST_CONTEXT_SEGMENTS],
  34.                                          int * new_value, int * old_value);
  35. }
  36.  
  37. namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost {
  38. namespace context {
  39.  
  40. template< typename traitsT >
  41. class basic_segmented_stack {
  42. private:
  43.     std::size_t     size_;
  44.  
  45. public:
  46.     typedef traitsT traits_type;
  47.  
  48.     basic_segmented_stack( std::size_t size = traits_type::default_size() ) BOOST_NOEXCEPT_OR_NOTHROW :
  49.         size_( size) {
  50.         BOOST_ASSERT( traits_type::minimum_size() <= size_);
  51.         BOOST_ASSERT( traits_type::is_unbounded() || ( traits_type::maximum_size() >= size_) );
  52.     }
  53.  
  54.     stack_context allocate() {
  55.         stack_context sctx;
  56.         void * vp = __splitstack_makecontext( size_, sctx.segments_ctx, & sctx.size);
  57.         if ( ! vp) throw std::bad_alloc();
  58.  
  59.         // sctx.size is already filled by __splitstack_makecontext
  60.         sctx.sp = static_cast< char * >( vp) + sctx.size;
  61.  
  62.         int off = 0;
  63.         __splitstack_block_signals_context( sctx.segments_ctx, & off, 0);
  64.  
  65.         return sctx;
  66.     }
  67.  
  68.     void deallocate( stack_context & sctx) BOOST_NOEXCEPT_OR_NOTHROW {
  69.         __splitstack_releasecontext( sctx.segments_ctx);
  70.     }
  71. };
  72.  
  73. typedef basic_segmented_stack< stack_traits > segmented_stack;
  74. # if defined(BOOST_USE_SEGMENTED_STACKS)
  75. typedef segmented_stack default_stack;
  76. # endif
  77.  
  78. }}
  79.  
  80. #ifdef BOOST_HAS_ABI_HEADERS
  81. #  include BOOST_ABI_SUFFIX
  82. #endif
  83.  
  84. #endif // BOOST_CONTEXT_SEGMENTED_H
  85.  
downloadsegmented_stack.hpp Source code - Download mars Source code
Related Source Codes/Software:
Hero - Elegant transition library for iOS & tvOS 2017-06-09
deep-photo-styletransfer - Code and data for paper "Deep Photo Style Transfer... 2017-06-09
mastodon - A GNU Social-compatible microblogging server ... 2017-06-09
plyr - A simple HTML5, YouTube and Vimeo player ... 2017-06-08
prepack - Prepack is a partial evaluator for JavaScript. Pre... 2017-06-08
Public-APIs - 2017-06-09
lottie-ios - An iOS library to natively render After Effects ve... 2017-06-09
Awesome-Hacking - A collection of various awesome lists for hackers,... 2017-06-09
algorithms - Minimal examples of data structures and algorithms... 2017-06-10
lectures - Oxford Deep NLP 2017 course 2017-06-10
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top