diff options
Diffstat (limited to 'libs/context/src')
-rw-r--r-- | libs/context/src/asm/jump_arm64_aapcs_elf_gas.S | 131 | ||||
-rw-r--r-- | libs/context/src/asm/jump_arm64_aapcs_macho_gas.S | 120 | ||||
-rw-r--r-- | libs/context/src/asm/jump_arm_aapcs_macho_gas.S | 2 | ||||
-rw-r--r-- | libs/context/src/asm/make_arm64_aapcs_elf_gas.S | 85 | ||||
-rw-r--r-- | libs/context/src/asm/make_arm64_aapcs_macho_gas.S | 83 | ||||
-rw-r--r-- | libs/context/src/execution_context.cpp | 36 | ||||
-rw-r--r-- | libs/context/src/posix/stack_traits.cpp | 110 | ||||
-rw-r--r-- | libs/context/src/windows/stack_traits.cpp | 124 |
8 files changed, 690 insertions, 1 deletions
diff --git a/libs/context/src/asm/jump_arm64_aapcs_elf_gas.S b/libs/context/src/asm/jump_arm64_aapcs_elf_gas.S new file mode 100644 index 000000000..09bd7b522 --- /dev/null +++ b/libs/context/src/asm/jump_arm64_aapcs_elf_gas.S @@ -0,0 +1,131 @@ +/* + Copyright Edward Nevill 2015 + 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) +*/ +/******************************************************* + * * + * ------------------------------------------------- * + * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * + * ------------------------------------------------- * + * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * + * ------------------------------------------------- * + * | d8 | d9 | d10 | d11 | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * + * ------------------------------------------------- * + * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * + * ------------------------------------------------- * + * | d12 | d13 | d14 | d15 | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * + * ------------------------------------------------- * + * | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| * + * ------------------------------------------------- * + * | x19 | x20 | x21 | x22 | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * + * ------------------------------------------------- * + * | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| * + * ------------------------------------------------- * + * | x23 | x24 | x25 | x26 | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * + * ------------------------------------------------- * + * | 0x80| 0x84| 0x88| 0x8c| 0x90| 0x94| 0x98| 0x9c| * + * ------------------------------------------------- * + * | x27 | x28 | FP | LR | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 40 | 41 | 42 | 43 | | | * + * ------------------------------------------------- * + * | 0xa0| 0xa4| 0xa8| 0xac| | | * + * ------------------------------------------------- * + * | PC | align | | | * + * ------------------------------------------------- * + * * + *******************************************************/ + +.cpu generic+fp+simd +.text +.align 2 +.global jump_fcontext +.type jump_fcontext, %function +jump_fcontext: + # prepare stack for GP + FPU + sub sp, sp, #0xb0 + +# Because gcc may save integer registers in fp registers across a +# function call we cannot skip saving the fp registers. +# +# Do not reinstate this test unless you fully understand what you +# are doing. +# +# # test if fpu env should be preserved +# cmp w3, #0 +# b.eq 1f + + # save d8 - d15 + stp d8, d9, [sp, #0x00] + stp d10, d11, [sp, #0x10] + stp d12, d13, [sp, #0x20] + stp d14, d15, [sp, #0x30] + +1: + # save x19-x30 + stp x19, x20, [sp, #0x40] + stp x21, x22, [sp, #0x50] + stp x23, x24, [sp, #0x60] + stp x25, x26, [sp, #0x70] + stp x27, x28, [sp, #0x80] + stp x29, x30, [sp, #0x90] + + # save LR as PC + str x30, [sp, #0xa0] + + # store RSP (pointing to context-data) in first argument (x0). + # STR cannot have sp as a target register + mov x4, sp + str x4, [x0] + + # restore RSP (pointing to context-data) from A2 (x1) + mov sp, x1 + +# # test if fpu env should be preserved +# cmp w3, #0 +# b.eq 2f + + # load d8 - d15 + ldp d8, d9, [sp, #0x00] + ldp d10, d11, [sp, #0x10] + ldp d12, d13, [sp, #0x20] + ldp d14, d15, [sp, #0x30] + +2: + # load x19-x30 + ldp x19, x20, [sp, #0x40] + ldp x21, x22, [sp, #0x50] + ldp x23, x24, [sp, #0x60] + ldp x25, x26, [sp, #0x70] + ldp x27, x28, [sp, #0x80] + ldp x29, x30, [sp, #0x90] + + # use third arg as return value after jump + # and as first arg in context function + mov x0, x2 + + # load pc + ldr x4, [sp, #0xa0] + + # restore stack from GP + FPU + add sp, sp, #0xb0 + + ret x4 +.size jump_fcontext,.-jump_fcontext +# Mark that we don't need executable stack. +.section .note.GNU-stack,"",%progbits diff --git a/libs/context/src/asm/jump_arm64_aapcs_macho_gas.S b/libs/context/src/asm/jump_arm64_aapcs_macho_gas.S new file mode 100644 index 000000000..958178ee7 --- /dev/null +++ b/libs/context/src/asm/jump_arm64_aapcs_macho_gas.S @@ -0,0 +1,120 @@ +/******************************************************* + * * + * ------------------------------------------------- * + * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * + * ------------------------------------------------- * + * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * + * ------------------------------------------------- * + * | d8 | d9 | d10 | d11 | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * + * ------------------------------------------------- * + * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * + * ------------------------------------------------- * + * | d12 | d13 | d14 | d15 | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * + * ------------------------------------------------- * + * | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| * + * ------------------------------------------------- * + * | x19 | x20 | x21 | x22 | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * + * ------------------------------------------------- * + * | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| * + * ------------------------------------------------- * + * | x23 | x24 | x25 | x26 | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * + * ------------------------------------------------- * + * | 0x80| 0x84| 0x88| 0x8c| 0x90| 0x94| 0x98| 0x9c| * + * ------------------------------------------------- * + * | x27 | x28 | FP | LR | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 40 | 41 | 42 | 43 | | | * + * ------------------------------------------------- * + * | 0xa0| 0xa4| 0xa8| 0xac| | | * + * ------------------------------------------------- * + * | PC | align | | | * + * ------------------------------------------------- * + * * + *******************************************************/ + +.text +.globl _jump_fcontext +.balign 16 +_jump_fcontext: + ; prepare stack for GP + FPU + sub sp, sp, #0xb0 + +#if (defined(__VFP_FP__) && !defined(__SOFTFP__)) + ; test if fpu env should be preserved + cmp w3, #0 + b.eq 1f + + ; save d8 - d15 + stp d8, d9, [sp, #0x00] + stp d10, d11, [sp, #0x10] + stp d12, d13, [sp, #0x20] + stp d14, d15, [sp, #0x30] + +1: +#endif + + ; save x19-x30 + stp x19, x20, [sp, #0x40] + stp x21, x22, [sp, #0x50] + stp x23, x24, [sp, #0x60] + stp x25, x26, [sp, #0x70] + stp x27, x28, [sp, #0x80] + stp fp, lr, [sp, #0x90] + + ; save LR as PC + str lr, [sp, #0xa0] + + ; store RSP (pointing to context-data) in first argument (x0). + ; STR cannot have sp as a target register + mov x4, sp + str x4, [x0] + + ; restore RSP (pointing to context-data) from A2 (x1) + mov sp, x1 + +#if (defined(__VFP_FP__) && !defined(__SOFTFP__)) + ; test if fpu env should be preserved + cmp w3, #0 + b.eq 2f + + ; load d8 - d15 + ldp d8, d9, [sp, #0x00] + ldp d10, d11, [sp, #0x10] + ldp d12, d13, [sp, #0x20] + ldp d14, d15, [sp, #0x30] + +2: +#endif + + ; load x19-x30 + ldp x19, x20, [sp, #0x40] + ldp x21, x22, [sp, #0x50] + ldp x23, x24, [sp, #0x60] + ldp x25, x26, [sp, #0x70] + ldp x27, x28, [sp, #0x80] + ldp fp, lr, [sp, #0x90] + + ; use third arg as return value after jump + ; and as first arg in context function + mov x0, x2 + + ; load pc + ldr x4, [sp, #0xa0] + + ; restore stack from GP + FPU + add sp, sp, #0xb0 + + ret x4 diff --git a/libs/context/src/asm/jump_arm_aapcs_macho_gas.S b/libs/context/src/asm/jump_arm_aapcs_macho_gas.S index 618487531..759353474 100644 --- a/libs/context/src/asm/jump_arm_aapcs_macho_gas.S +++ b/libs/context/src/asm/jump_arm_aapcs_macho_gas.S @@ -91,7 +91,7 @@ _jump_fcontext: add sp, sp, #64 @ restore SjLj handler - pop v1 + pop {v1} @ store SjLj handler in TLS str v1, [v2, #72] diff --git a/libs/context/src/asm/make_arm64_aapcs_elf_gas.S b/libs/context/src/asm/make_arm64_aapcs_elf_gas.S new file mode 100644 index 000000000..b208ab7f3 --- /dev/null +++ b/libs/context/src/asm/make_arm64_aapcs_elf_gas.S @@ -0,0 +1,85 @@ +/* + Copyright Edward Nevill 2015 + 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) +*/ +/******************************************************* + * * + * ------------------------------------------------- * + * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * + * ------------------------------------------------- * + * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * + * ------------------------------------------------- * + * | d8 | d9 | d10 | d11 | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * + * ------------------------------------------------- * + * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * + * ------------------------------------------------- * + * | d12 | d13 | d14 | d15 | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * + * ------------------------------------------------- * + * | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| * + * ------------------------------------------------- * + * | x19 | x20 | x21 | x22 | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * + * ------------------------------------------------- * + * | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| * + * ------------------------------------------------- * + * | x23 | x24 | x25 | x26 | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * + * ------------------------------------------------- * + * | 0x80| 0x84| 0x88| 0x8c| 0x90| 0x94| 0x98| 0x9c| * + * ------------------------------------------------- * + * | x27 | x28 | FP | LR | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 40 | 41 | 42 | 43 | | | * + * ------------------------------------------------- * + * | 0xa0| 0xa4| 0xa8| 0xac| | | * + * ------------------------------------------------- * + * | PC | align | | | * + * ------------------------------------------------- * + * * + *******************************************************/ + +.cpu generic+fp+simd +.text +.align 2 +.global make_fcontext +.type make_fcontext, %function +make_fcontext: + # shift address in x0 (allocated stack) to lower 16 byte boundary + and x0, x0, ~0xF + + # reserve space for context-data on context-stack + sub x0, x0, #0xb0 + + # third arg of make_fcontext() == address of context-function + # store address as a PC to jump in + str x2, [x0, #0xa0] + + # save address of finish as return-address for context-function + # will be entered after context-function returns (LR register) + adr x1, finish + str x1, [x0, #0x98] + + ret x30 // return pointer to context-data (x0) + +finish: + # exit code is zero + mov x0, #0 + # exit application + bl _exit + +.size make_fcontext,.-make_fcontext +# Mark that we don't need executable stack. +.section .note.GNU-stack,"",%progbits diff --git a/libs/context/src/asm/make_arm64_aapcs_macho_gas.S b/libs/context/src/asm/make_arm64_aapcs_macho_gas.S new file mode 100644 index 000000000..6b55a08ad --- /dev/null +++ b/libs/context/src/asm/make_arm64_aapcs_macho_gas.S @@ -0,0 +1,83 @@ +/******************************************************* + * * + * ------------------------------------------------- * + * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * + * ------------------------------------------------- * + * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * + * ------------------------------------------------- * + * | d8 | d9 | d10 | d11 | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * + * ------------------------------------------------- * + * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * + * ------------------------------------------------- * + * | d12 | d13 | d14 | d15 | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * + * ------------------------------------------------- * + * | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| * + * ------------------------------------------------- * + * | x19 | x20 | x21 | x22 | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * + * ------------------------------------------------- * + * | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| * + * ------------------------------------------------- * + * | x23 | x24 | x25 | x26 | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * + * ------------------------------------------------- * + * | 0x80| 0x84| 0x88| 0x8c| 0x90| 0x94| 0x98| 0x9c| * + * ------------------------------------------------- * + * | x27 | x28 | FP | LR | * + * ------------------------------------------------- * + * ------------------------------------------------- * + * | 40 | 41 | 42 | 43 | | | * + * ------------------------------------------------- * + * | 0xa0| 0xa4| 0xa8| 0xac| | | * + * ------------------------------------------------- * + * | PC | align | | | * + * ------------------------------------------------- * + * * + *******************************************************/ + + +.text +.globl _make_fcontext +.balign 16 + +_make_fcontext: + ; shift address in x0 (allocated stack) to lower 16 byte boundary + and x0, x0, ~0xF + + ; reserve space for context-data on context-stack + sub x0, x0, #0xb0 + + ; third arg of make_fcontext() == address of context-function + ; store address as a PC to jump in + str x2, [x0, #0xa0] + + ; compute abs address of label finish + ; 0x0c = 3 instructions * size (4) before label 'finish' + + ; TODO: Numeric offset since llvm still does not support labels in ADR. Fix: + ; http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140407/212336.html + adr x1, 0x0c + + ; save address of finish as return-address for context-function + ; will be entered after context-function returns (LR register) + str x1, [x0, #0x98] + + ret lr ; return pointer to context-data (x0) + +finish: + ; exit code is zero + mov x0, #0 + ; exit application + bl __exit + + diff --git a/libs/context/src/execution_context.cpp b/libs/context/src/execution_context.cpp new file mode 100644 index 000000000..969a74bdd --- /dev/null +++ b/libs/context/src/execution_context.cpp @@ -0,0 +1,36 @@ + +// Copyright Oliver Kowalke 2009. +// 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/context/detail/config.hpp> + +#if ! defined(BOOST_CONTEXT_NO_EXECUTION_CONTEXT) + +# include "boost/context/execution_context.hpp" + +# include <boost/config.hpp> + +# ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +# endif + +namespace boost { +namespace context { + +thread_local +execution_context::fcontext +execution_context::main_ctx_; + +thread_local +execution_context::ptr_t +execution_context::current_ctx_ = & execution_context::main_ctx_; + +}} + +# ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +# endif + +#endif diff --git a/libs/context/src/posix/stack_traits.cpp b/libs/context/src/posix/stack_traits.cpp new file mode 100644 index 000000000..83b54a746 --- /dev/null +++ b/libs/context/src/posix/stack_traits.cpp @@ -0,0 +1,110 @@ + +// 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/context/stack_traits.hpp" + +extern "C" { +#include <signal.h> +#include <sys/resource.h> +#include <sys/time.h> +#include <unistd.h> +} + +//#if _POSIX_C_SOURCE >= 200112L + +#include <algorithm> +#include <cmath> + +#include <boost/assert.hpp> +#include <boost/config.hpp> +# include <boost/thread.hpp> + +#if !defined (SIGSTKSZ) +# define SIGSTKSZ (8 * 1024) +# define UDEF_SIGSTKSZ +#endif + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif + +namespace boost { +namespace context { + +void pagesize_( std::size_t * size) +{ + // conform to POSIX.1-2001 + * size = ::sysconf( _SC_PAGESIZE); +} + +void stacksize_limit_( rlimit * limit) +{ + // conforming to POSIX.1-2001 +#if defined(BOOST_DISABLE_ASSERTS) + ::getrlimit( RLIMIT_STACK, limit); +#else + const int result = ::getrlimit( RLIMIT_STACK, limit); + BOOST_ASSERT( 0 == result); + (void)result; +#endif +} + +std::size_t pagesize() +{ + static std::size_t size = 0; + static boost::once_flag flag; + boost::call_once( flag, pagesize_, & size); + return size; +} + +rlimit stacksize_limit() +{ + static rlimit limit; + static boost::once_flag flag; + boost::call_once( flag, stacksize_limit_, & limit); + return limit; +} + +bool +stack_traits::is_unbounded() BOOST_NOEXCEPT +{ return RLIM_INFINITY == stacksize_limit().rlim_max; } + +std::size_t +stack_traits::page_size() BOOST_NOEXCEPT +{ return pagesize(); } + +std::size_t +stack_traits::default_size() BOOST_NOEXCEPT +{ + std::size_t size = 8 * minimum_size(); + if ( is_unbounded() ) return size; + + BOOST_ASSERT( maximum_size() >= minimum_size() ); + return maximum_size() == size + ? size + : (std::min)( size, maximum_size() ); +} + +std::size_t +stack_traits::minimum_size() BOOST_NOEXCEPT +{ return SIGSTKSZ; } + +std::size_t +stack_traits::maximum_size() BOOST_NOEXCEPT +{ + BOOST_ASSERT( ! is_unbounded() ); + return static_cast< std::size_t >( stacksize_limit().rlim_max); +} + +}} + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif + +#ifdef UDEF_SIGSTKSZ +# undef SIGSTKSZ +#endif diff --git a/libs/context/src/windows/stack_traits.cpp b/libs/context/src/windows/stack_traits.cpp new file mode 100644 index 000000000..7e67232e7 --- /dev/null +++ b/libs/context/src/windows/stack_traits.cpp @@ -0,0 +1,124 @@ + +// 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/context/stack_traits.hpp" + +extern "C" { +#include <windows.h> +} + +//#if defined (BOOST_WINDOWS) || _POSIX_C_SOURCE >= 200112L + +#include <algorithm> +#include <cmath> +#include <cstddef> +#include <cstring> +#include <stdexcept> + +#include <boost/assert.hpp> +#include <boost/context/detail/config.hpp> +#if __cplusplus < 201103L +# include <boost/thread.hpp> +#else +# include <mutex> +#endif + +#include <boost/context/stack_context.hpp> + +// x86_64 +// test x86_64 before i386 because icc might +// define __i686__ for x86_64 too +#if defined(__x86_64__) || defined(__x86_64) \ + || defined(__amd64__) || defined(__amd64) \ + || defined(_M_X64) || defined(_M_AMD64) + +// Windows seams not to provide a constant or function +// telling the minimal stacksize +# define MIN_STACKSIZE 8 * 1024 +#else +# define MIN_STACKSIZE 4 * 1024 +#endif + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_PREFIX +#endif + +namespace boost { +namespace context { + +#if __cplusplus < 201103L +void system_info_( SYSTEM_INFO * si) +{ ::GetSystemInfo( si); } + +SYSTEM_INFO system_info() +{ + static SYSTEM_INFO si; + static boost::once_flag flag; + boost::call_once( flag, static_cast< void(*)( SYSTEM_INFO *) >( system_info_), & si); + return si; +} +#else +SYSTEM_INFO system_info() +{ + static SYSTEM_INFO si; + static std::once_flag flag; + std::call_once( flag, [](){ ::GetSystemInfo( & si); } ); + return si; +} +#endif + +std::size_t pagesize() +{ return static_cast< std::size_t >( system_info().dwPageSize); } + +std::size_t page_count( std::size_t stacksize) +{ + return static_cast< std::size_t >( + std::floor( + static_cast< float >( stacksize) / pagesize() ) ); +} + +// Windows seams not to provide a limit for the stacksize +// libcoco uses 32k+4k bytes as minimum +bool +stack_traits::is_unbounded() BOOST_NOEXCEPT +{ return true; } + +std::size_t +stack_traits::page_size() BOOST_NOEXCEPT +{ return pagesize(); } + +std::size_t +stack_traits::default_size() BOOST_NOEXCEPT +{ + std::size_t size = 64 * 1024; // 64 kB + if ( is_unbounded() ) + return (std::max)( size, minimum_size() ); + + BOOST_ASSERT( maximum_size() >= minimum_size() ); + return maximum_size() == minimum_size() + ? minimum_size() + : ( std::min)( size, maximum_size() ); +} + +// because Windows seams not to provide a limit for minimum stacksize +std::size_t +stack_traits::minimum_size() BOOST_NOEXCEPT +{ return MIN_STACKSIZE; } + +// because Windows seams not to provide a limit for maximum stacksize +// maximum_size() can never be called (pre-condition ! is_unbounded() ) +std::size_t +stack_traits::maximum_size() BOOST_NOEXCEPT +{ + BOOST_ASSERT( ! is_unbounded() ); + return 1 * 1024 * 1024 * 1024; // 1GB +} + +}} + +#ifdef BOOST_HAS_ABI_HEADERS +# include BOOST_ABI_SUFFIX +#endif |