2
0
mirror of https://github.com/boostorg/fiber.git synced 2026-02-20 02:32:19 +00:00

use context::detail::stack_helper

This commit is contained in:
Oliver Kowalke
2011-03-04 19:34:13 +01:00
parent 3c824d7de0
commit 1222c63bab
2 changed files with 10 additions and 114 deletions

View File

@@ -8,74 +8,22 @@
#include <boost/fiber/asym_fiber.hpp>
#include <boost/config.hpp>
extern "C" {
#if defined(BOOST_WINDOWS)
#include <windows.h>
#else
#include <sys/resource.h>
#include <sys/time.h>
#endif
}
#include <csignal>
#include <boost/config.hpp>
#include <boost/context/detail/stack_helper.hpp>
#include <boost/fiber/exceptions.hpp>
#ifdef BOOST_HAS_ABI_HEADERS
# include BOOST_ABI_PREFIX
#endif
namespace {
#if defined(BOOST_WINDOWS)
struct stack_helper
{
static std::size_t max_size()
{ return 8 * 1024 * 1024; }
static std::size_t min_size()
{
SYSTEM_INFO si;
::GetSystemInfo( & si);
return si.dwAllocationGranularity;
}
};
#else
struct stack_helper
{
static std::size_t max_size()
{
rlimit limit;
if ( 0 > ::getrlimit( RLIMIT_STACK, & limit) )
return 8 * 1024 * 1024;
return RLIM_INFINITY != limit.rlim_max
? limit.rlim_max
: 8 * 1024 * 1024;
}
static std::size_t min_size()
{ return SIGSTKSZ; }
};
#endif
}
namespace boost {
namespace fibers {
#if defined(BOOST_WINDOWS)
std::size_t asym_fiber::max_stacksize = stack_helper::max_size();
std::size_t asym_fiber::min_stacksize = stack_helper::min_size();
#else
std::size_t asym_fiber::max_stacksize = stack_helper::max_size();
std::size_t asym_fiber::min_stacksize = stack_helper::min_size();
#endif
std::size_t asym_fiber::max_stacksize = boost::contexts::detail::stack_helper::maximal_stacksize();
std::size_t asym_fiber::min_stacksize = boost::contexts::detail::stack_helper::minimal_stacksize();
std::size_t asym_fiber::default_stacksize = 256 * 1024;
asym_fiber::asym_fiber() :

View File

@@ -8,74 +8,22 @@
#include <boost/fiber/sym_fiber.hpp>
#include <boost/config.hpp>
extern "C" {
#if defined(BOOST_WINDOWS)
#include <windows.h>
#else
#include <sys/resource.h>
#include <sys/time.h>
#endif
}
#include <csignal>
#include <boost/config.hpp>
#include <boost/context/detail/stack_helper.hpp>
#include <boost/fiber/exceptions.hpp>
#ifdef BOOST_HAS_ABI_HEADERS
# include BOOST_ABI_PREFIX
#endif
namespace {
#if defined(BOOST_WINDOWS)
struct stack_helper
{
static std::size_t max_size()
{ return 8 * 1024 * 1024; }
static std::size_t min_size()
{
SYSTEM_INFO si;
::GetSystemInfo( & si);
return si.dwAllocationGranularity;
}
};
#else
struct stack_helper
{
static std::size_t max_size()
{
rlimit limit;
if ( 0 > ::getrlimit( RLIMIT_STACK, & limit) )
return 8 * 1024 * 1024;
return RLIM_INFINITY != limit.rlim_max
? limit.rlim_max
: 8 * 1024 * 1024;
}
static std::size_t min_size()
{ return SIGSTKSZ; }
};
#endif
}
namespace boost {
namespace fibers {
#if defined(BOOST_WINDOWS)
std::size_t sym_fiber::max_stacksize = stack_helper::max_size();
std::size_t sym_fiber::min_stacksize = stack_helper::min_size();
#else
std::size_t sym_fiber::max_stacksize = stack_helper::max_size();
std::size_t sym_fiber::min_stacksize = stack_helper::min_size();
#endif
std::size_t sym_fiber::max_stacksize = boost::contexts::detail::stack_helper::maximal_stacksize();
std::size_t sym_fiber::min_stacksize = boost::contexts::detail::stack_helper::minimal_stacksize();
std::size_t sym_fiber::default_stacksize = 256 * 1024;
sym_fiber