]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | <html> |
2 | <head> | |
3 | <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> | |
4 | <title>Stack allocation</title> | |
5 | <link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css"> | |
6 | <meta name="generator" content="DocBook XSL Stylesheets V1.75.2"> | |
7 | <link rel="home" href="../index.html" title="Chapter 1. Context"> | |
8 | <link rel="up" href="../index.html" title="Chapter 1. Context"> | |
9 | <link rel="prev" href="ecv1.html" title="Class execution_context (version 1)"> | |
10 | <link rel="next" href="stack/protected_fixedsize.html" title="Class protected_fixedsize"> | |
11 | </head> | |
12 | <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> | |
13 | <table cellpadding="2" width="100%"><tr> | |
14 | <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> | |
15 | <td align="center"><a href="../../../../../index.html">Home</a></td> | |
16 | <td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> | |
17 | <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> | |
18 | <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> | |
19 | <td align="center"><a href="../../../../../more/index.htm">More</a></td> | |
20 | </tr></table> | |
21 | <hr> | |
22 | <div class="spirit-nav"> | |
23 | <a accesskey="p" href="ecv1.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="stack/protected_fixedsize.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> | |
24 | </div> | |
25 | <div class="section"> | |
26 | <div class="titlepage"><div><div><h2 class="title" style="clear: both"> | |
27 | <a name="context.stack"></a><a name="stack"></a><a class="link" href="stack.html" title="Stack allocation">Stack allocation</a> | |
28 | </h2></div></div></div> | |
29 | <div class="toc"><dl> | |
30 | <dt><span class="section"><a href="stack/protected_fixedsize.html">Class <span class="emphasis"><em>protected_fixedsize</em></span></a></span></dt> | |
31 | <dt><span class="section"><a href="stack/pooled_fixedsize.html">Class <span class="emphasis"><em>pooled_fixedsize_stack</em></span></a></span></dt> | |
32 | <dt><span class="section"><a href="stack/fixedsize.html">Class <span class="emphasis"><em>fixedsize_stack</em></span></a></span></dt> | |
33 | <dt><span class="section"><a href="stack/segmented.html">Class <span class="emphasis"><em>segmented_stack</em></span></a></span></dt> | |
34 | <dt><span class="section"><a href="stack/stack_traits.html">Class <span class="emphasis"><em>stack_traits</em></span></a></span></dt> | |
35 | <dt><span class="section"><a href="stack/stack_context.html">Class <span class="emphasis"><em>stack_context</em></span></a></span></dt> | |
36 | <dt><span class="section"><a href="stack/valgrind.html">Support for valgrind</a></span></dt> | |
37 | </dl></div> | |
38 | <p> | |
39 | The memory used by the stack is allocated/deallocated via a <span class="emphasis"><em>StackAllocator</em></span> | |
40 | which is required to model a <span class="emphasis"><em>stack-allocator concept</em></span>. | |
41 | </p> | |
42 | <h4> | |
43 | <a name="context.stack.h0"></a> | |
44 | <span><a name="context.stack._emphasis_stack_allocator_concept__emphasis_"></a></span><a class="link" href="stack.html#context.stack._emphasis_stack_allocator_concept__emphasis_"><span class="emphasis"><em>stack-allocator | |
45 | concept</em></span></a> | |
46 | </h4> | |
47 | <p> | |
48 | A <span class="emphasis"><em>StackAllocator</em></span> must satisfy the <span class="emphasis"><em>stack-allocator | |
49 | concept</em></span> requirements shown in the following table, in which <code class="computeroutput"><span class="identifier">a</span></code> is an object of a <span class="emphasis"><em>StackAllocator</em></span> | |
50 | type, <code class="computeroutput"><span class="identifier">sctx</span></code> is a <code class="computeroutput"><span class="identifier">stack_context</span></code>, and <code class="computeroutput"><span class="identifier">size</span></code> | |
51 | is a <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span></code>: | |
52 | </p> | |
53 | <div class="informaltable"><table class="table"> | |
54 | <colgroup> | |
55 | <col> | |
56 | <col> | |
57 | <col> | |
58 | </colgroup> | |
59 | <thead><tr> | |
60 | <th> | |
61 | <p> | |
62 | expression | |
63 | </p> | |
64 | </th> | |
65 | <th> | |
66 | <p> | |
67 | return type | |
68 | </p> | |
69 | </th> | |
70 | <th> | |
71 | <p> | |
72 | notes | |
73 | </p> | |
74 | </th> | |
75 | </tr></thead> | |
76 | <tbody> | |
77 | <tr> | |
78 | <td> | |
79 | <p> | |
80 | <code class="computeroutput"><span class="identifier">a</span><span class="special">(</span><span class="identifier">size</span><span class="special">)</span></code> | |
81 | </p> | |
82 | </td> | |
83 | <td> | |
84 | </td> | |
85 | <td> | |
86 | <p> | |
87 | creates a stack allocator | |
88 | </p> | |
89 | </td> | |
90 | </tr> | |
91 | <tr> | |
92 | <td> | |
93 | <p> | |
94 | <code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">allocate</span><span class="special">()</span></code> | |
95 | </p> | |
96 | </td> | |
97 | <td> | |
98 | <p> | |
99 | <code class="computeroutput"><span class="identifier">stack_context</span></code> | |
100 | </p> | |
101 | </td> | |
102 | <td> | |
103 | <p> | |
104 | creates a stack | |
105 | </p> | |
106 | </td> | |
107 | </tr> | |
108 | <tr> | |
109 | <td> | |
110 | <p> | |
111 | <code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">deallocate</span><span class="special">(</span> | |
112 | <span class="identifier">sctx</span><span class="special">)</span></code> | |
113 | </p> | |
114 | </td> | |
115 | <td> | |
116 | <p> | |
117 | <code class="computeroutput"><span class="keyword">void</span></code> | |
118 | </p> | |
119 | </td> | |
120 | <td> | |
121 | <p> | |
122 | deallocates the stack created by <code class="computeroutput"><span class="identifier">a</span><span class="special">.</span><span class="identifier">allocate</span><span class="special">()</span></code> | |
123 | </p> | |
124 | </td> | |
125 | </tr> | |
126 | </tbody> | |
127 | </table></div> | |
128 | <div class="important"><table border="0" summary="Important"> | |
129 | <tr> | |
130 | <td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="../../../../../doc/src/images/important.png"></td> | |
131 | <th align="left">Important</th> | |
132 | </tr> | |
133 | <tr><td align="left" valign="top"><p> | |
134 | The implementation of <code class="computeroutput"><span class="identifier">allocate</span><span class="special">()</span></code> might include logic to protect against | |
135 | exceeding the context's available stack size rather than leaving it as undefined | |
136 | behaviour. | |
137 | </p></td></tr> | |
138 | </table></div> | |
139 | <div class="important"><table border="0" summary="Important"> | |
140 | <tr> | |
141 | <td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="../../../../../doc/src/images/important.png"></td> | |
142 | <th align="left">Important</th> | |
143 | </tr> | |
144 | <tr><td align="left" valign="top"><p> | |
145 | Calling <code class="computeroutput"><span class="identifier">deallocate</span><span class="special">()</span></code> | |
146 | with a <code class="computeroutput"><span class="identifier">stack_context</span></code> not | |
147 | set by <code class="computeroutput"><span class="identifier">allocate</span><span class="special">()</span></code> | |
148 | results in undefined behaviour. | |
149 | </p></td></tr> | |
150 | </table></div> | |
151 | <div class="note"><table border="0" summary="Note"> | |
152 | <tr> | |
153 | <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/src/images/note.png"></td> | |
154 | <th align="left">Note</th> | |
155 | </tr> | |
156 | <tr><td align="left" valign="top"><p> | |
157 | The stack is not required to be aligned; alignment takes place inside <span class="emphasis"><em>execution_context</em></span>. | |
158 | </p></td></tr> | |
159 | </table></div> | |
160 | <div class="note"><table border="0" summary="Note"> | |
161 | <tr> | |
162 | <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../doc/src/images/note.png"></td> | |
163 | <th align="left">Note</th> | |
164 | </tr> | |
165 | <tr><td align="left" valign="top"><p> | |
166 | Depending on the architecture <code class="computeroutput"><span class="identifier">allocate</span><span class="special">()</span></code> stores an address from the top of the stack | |
167 | (growing downwards) or the bottom of the stack (growing upwards). | |
168 | </p></td></tr> | |
169 | </table></div> | |
170 | </div> | |
171 | <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> | |
172 | <td align="left"></td> | |
173 | <td align="right"><div class="copyright-footer">Copyright © 2014 Oliver Kowalke<p> | |
174 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
175 | file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) | |
176 | </p> | |
177 | </div></td> | |
178 | </tr></table> | |
179 | <hr> | |
180 | <div class="spirit-nav"> | |
181 | <a accesskey="p" href="ecv1.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="stack/protected_fixedsize.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> | |
182 | </div> | |
183 | </body> | |
184 | </html> |