]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/context/src/posix/stack_traits.cpp
bump version to 18.2.2-pve1
[ceph.git] / ceph / src / boost / libs / context / src / posix / stack_traits.cpp
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 #include "boost/context/stack_traits.hpp"
8
9 extern "C" {
10 #include <signal.h>
11 #include <sys/resource.h>
12 #include <sys/time.h>
13 #include <unistd.h>
14 }
15
16 //#if _POSIX_C_SOURCE >= 200112L
17
18 #include <algorithm>
19 #include <cmath>
20
21 #include <boost/assert.hpp>
22 #include <boost/config.hpp>
23
24 #if !defined (SIGSTKSZ)
25 # define SIGSTKSZ (32768) // 32kb minimum allowable stack
26 # define UDEF_SIGSTKSZ
27 #endif
28
29 #if !defined (MINSIGSTKSZ)
30 # define MINSIGSTKSZ (131072) // 128kb recommended stack size
31 # define UDEF_MINSIGSTKSZ
32 #endif
33
34 #ifdef BOOST_HAS_ABI_HEADERS
35 # include BOOST_ABI_PREFIX
36 #endif
37
38 namespace {
39
40 std::size_t pagesize() BOOST_NOEXCEPT_OR_NOTHROW {
41 // conform to POSIX.1-2001
42 return ::sysconf( _SC_PAGESIZE);
43 }
44
45 rlim_t stacksize_limit_() BOOST_NOEXCEPT_OR_NOTHROW {
46 rlimit limit;
47 // conforming to POSIX.1-2001
48 ::getrlimit( RLIMIT_STACK, & limit);
49 return limit.rlim_max;
50 }
51
52 rlim_t stacksize_limit() BOOST_NOEXCEPT_OR_NOTHROW {
53 static rlim_t limit = stacksize_limit_();
54 return limit;
55 }
56
57 }
58
59 namespace boost {
60 namespace context {
61
62 bool
63 stack_traits::is_unbounded() BOOST_NOEXCEPT_OR_NOTHROW {
64 return RLIM_INFINITY == stacksize_limit();
65 }
66
67 std::size_t
68 stack_traits::page_size() BOOST_NOEXCEPT_OR_NOTHROW {
69 static std::size_t size = pagesize();
70 return size;
71 }
72
73 std::size_t
74 stack_traits::default_size() BOOST_NOEXCEPT_OR_NOTHROW {
75 return 128 * 1024;
76 }
77
78 std::size_t
79 stack_traits::minimum_size() BOOST_NOEXCEPT_OR_NOTHROW {
80 return MINSIGSTKSZ;
81 }
82
83 std::size_t
84 stack_traits::maximum_size() BOOST_NOEXCEPT_OR_NOTHROW {
85 BOOST_ASSERT( ! is_unbounded() );
86 return static_cast< std::size_t >( stacksize_limit() );
87 }
88
89 }}
90
91 #ifdef BOOST_HAS_ABI_HEADERS
92 # include BOOST_ABI_SUFFIX
93 #endif
94
95 #ifdef UDEF_SIGSTKSZ
96 # undef SIGSTKSZ
97 #endif
98
99 #ifdef UDEF_MINSIGSTKSZ
100 # undef MINSIGSTKSZ
101 #endif