mirror of
https://github.com/boostorg/context.git
synced 2026-01-19 04:02:17 +00:00
fix minimum/default stacksize for POSIX
This commit is contained in:
@@ -26,6 +26,10 @@ project boost/context/example
|
||||
<threading>multi
|
||||
;
|
||||
|
||||
exe stack
|
||||
: stack.cpp
|
||||
;
|
||||
|
||||
exe jump_void
|
||||
: jump_void.cpp
|
||||
;
|
||||
|
||||
25
example/stack.cpp
Normal file
25
example/stack.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
// Copyright Oliver Kowalke 2016.
|
||||
// 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 <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
#include <boost/context/continuation.hpp>
|
||||
|
||||
namespace ctx = boost::context;
|
||||
|
||||
int main() {
|
||||
std::cout << "minimum stack size: " << ctx::stack_traits::minimum_size() << " byte\n";
|
||||
std::cout << "default stack size: " << ctx::stack_traits::default_size() << " byte\n";
|
||||
std::cout << "maximum stack size: ";
|
||||
if ( ctx::stack_traits::is_unbounded() ) {
|
||||
std::cout << "unlimited\n";
|
||||
} else {
|
||||
std::cout << ctx::stack_traits::maximum_size() << " byte\n";
|
||||
}
|
||||
std::cout << "main: done" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -27,10 +27,15 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#if !defined (SIGSTKSZ)
|
||||
# define SIGSTKSZ (8 * 1024)
|
||||
# define SIGSTKSZ (32768) // 32kb minimum allowable stack
|
||||
# define UDEF_SIGSTKSZ
|
||||
#endif
|
||||
|
||||
#if !defined (MINSIGSTKSZ)
|
||||
# define MINSIGSTKSZ (131072) // 128kb recommended stack size
|
||||
# define UDEF_MINSIGSTKSZ
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_HAS_ABI_HEADERS
|
||||
# include BOOST_ABI_PREFIX
|
||||
#endif
|
||||
@@ -88,20 +93,12 @@ stack_traits::page_size() BOOST_NOEXCEPT_OR_NOTHROW {
|
||||
|
||||
std::size_t
|
||||
stack_traits::default_size() BOOST_NOEXCEPT_OR_NOTHROW {
|
||||
const std::size_t size = 64 * 1024;
|
||||
if ( is_unbounded() ) {
|
||||
return size;
|
||||
}
|
||||
|
||||
BOOST_ASSERT( maximum_size() >= minimum_size() );
|
||||
return maximum_size() == size
|
||||
? size
|
||||
: (std::min)( size, maximum_size() );
|
||||
return SIGSTKSZ;
|
||||
}
|
||||
|
||||
std::size_t
|
||||
stack_traits::minimum_size() BOOST_NOEXCEPT_OR_NOTHROW {
|
||||
return SIGSTKSZ;
|
||||
return MINSIGSTKSZ;
|
||||
}
|
||||
|
||||
std::size_t
|
||||
@@ -117,5 +114,9 @@ stack_traits::maximum_size() BOOST_NOEXCEPT_OR_NOTHROW {
|
||||
#endif
|
||||
|
||||
#ifdef UDEF_SIGSTKSZ
|
||||
# undef SIGSTKSZ
|
||||
# undef SIGSTKSZ;
|
||||
#endif
|
||||
|
||||
#ifdef UDEF_MINSIGSTKSZ
|
||||
# undef MINSIGSTKSZ
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user