X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=libs%2Fcontext%2Fdoc%2Fstack.qbk;h=5d179a7c6f9c4be775bcec1dcd1acbd3609051de;hb=08c1e93fa36a49f49325a07fe91ff92c964c2b6c;hp=306ca278428ab0035eb472beb43c2b2b43e8067a;hpb=bb4dd8289b351fae6b55e303f189127a394a1edd;p=platform%2Fupstream%2Fboost.git diff --git a/libs/context/doc/stack.qbk b/libs/context/doc/stack.qbk index 306ca27..5d179a7 100644 --- a/libs/context/doc/stack.qbk +++ b/libs/context/doc/stack.qbk @@ -1,5 +1,4 @@ -[/ - Copyright Oliver Kowalke 2009. +[/ 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 @@ -8,109 +7,19 @@ [section:stack Stack allocation] A __fcontext__ requires a stack which will be allocated/deallocated -by a __stack_allocator__. -__boost_context__ uses `stack_allocator` by default but a -customized `stack allocator` can be passed to the context constructor -instead. -If a context is constructed it invokes __stack_alloc__ function and by its -destruction the stack gets released by __stack_dealloc__. +by a __stack_allocator__ (examples contain an implementation +of [@boost:/libs/context/example/simple_stack_allocator.hpp +simple_stack_allocator]). -[heading __stack_allocator_concept__] -A __stack_allocator__ must satisfy the __stack_allocator_concept__ requirements -shown in the following table, in which `a` is an object of a -__stack_allocator__ type, `p` is a `void *`, and `s` is a `std::size_t`: - -[table - [[expression][return type][notes]] - [ - [`a.allocate( s)`] - [`void *`] - [returns a pointer to `s` bytes allocated from the stack] - ] - [ - [`a.deallocate( p, s)`] - [`void`] - [deallocates `s` bytes of memory beginning at `p`, - a pointer previously returned by `a.allocate()`] - ] -] - -[important The implementation of `allocate()` might include logic to protect +[note The implementation of a __stack_allocator__ might include logic to protect against exceeding the context's available stack size rather than leaving it as undefined behaviour.] -[important Calling `deallocate()` with a pointer not returned by `allocate()` -results in undefined behaviour.] - [note The stack is not required to be aligned; alignment takes place inside -`make_fcontext()`.] - - -[section:stack_allocator Class `stack_allocator`] - -__boost_context__ provides a __stack_allocator__ `stack_allocator` which models -the __stack_allocator_concept__ concept. -It appends a __guard_page__ to protect against exceeding the stack. If the guard -page is accessed (read or write operation) a segmentation fault/access violation -is generated by the operating system. - -[endsect] - - -[section:stack_helper Helper functions] - -__boost_context__ provides easy access to the stack related limits defined by -the environment. - - std::size_t default_stacksize(); - - std::size_t minimum_stacksize(); - - std::size_t maximum_stacksize(); - - bool is_stack_unbound(); +__make_fcontext__.] - std::size_t pagesize(); - - std::size_t page_count( std::size_t stacksize); - -[heading `std::size_t default_stacksize()`] -[variablelist -[[Returns:] [Returns a default stack size, which may be platform specific. -The present implementation returns a value of 256 kB.]] -] - -[heading `std::size_t minimum_stacksize()`] -[variablelist -[[Returns:] [Returns the minimum size in bytes of stack defined by the environment.]] -[[Throws:] [Nothing.]] -] - -[heading `std::size_t maximum_stacksize()`] -[variablelist -[[Preconditions:] [`is_stack_unbound()` returns `false`.]] -[[Returns:] [Returns the maximum size in bytes of stack defined by the environment.]] -[[Throws:] [Nothing.]] -] - -[heading `bool is_stack_unbound()`] -[variablelist -[[Returns:] [Returns `true` if the environment defines no limit for the size of a stack.]] -[[Throws:] [Nothing.]] -] - -[heading `std::size_t pagesize()`] -[variablelist -[[Returns:] [Returns how many bytes the operating system allocates for one page.]] -[[Throws:] [Nothing.]] -] - -[heading `std::size_t page_count( std::size_t stacksize)`] -[variablelist -[[Returns:] [Returns how many pages have to be allocated for a stack of `stacksize` bytes.]] -[[Throws:] [Nothing.]] -] - -[endsect] +[note Depending on the architecture __stack_allocator__ returns an address from +the top of the stack (grows downwards) or the bottom of the stack (grows +upwards).] [endsect]