$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r78539 - in branches/release: boost/context boost/context/detail libs/context libs/context/build libs/context/config libs/context/doc libs/context/doc/pdf libs/context/example libs/context/performance libs/context/src libs/context/src/asm libs/context/test
From: oliver.kowalke_at_[hidden]
Date: 2012-05-22 11:16:56
Author: olli
Date: 2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
New Revision: 78539
URL: http://svn.boost.org/trac/boost/changeset/78539
Log:
context: added to release
Added:
   branches/release/boost/context/
   branches/release/boost/context/all.hpp   (contents, props changed)
   branches/release/boost/context/detail/
   branches/release/boost/context/detail/config.hpp   (contents, props changed)
   branches/release/boost/context/detail/fcontext_arm.hpp   (contents, props changed)
   branches/release/boost/context/detail/fcontext_i386.hpp   (contents, props changed)
   branches/release/boost/context/detail/fcontext_i386_win.hpp   (contents, props changed)
   branches/release/boost/context/detail/fcontext_mips.hpp   (contents, props changed)
   branches/release/boost/context/detail/fcontext_ppc.hpp   (contents, props changed)
   branches/release/boost/context/detail/fcontext_x86_64.hpp   (contents, props changed)
   branches/release/boost/context/detail/fcontext_x86_64_win.hpp   (contents, props changed)
   branches/release/boost/context/fcontext.hpp   (contents, props changed)
   branches/release/boost/context/stack_allocator.hpp   (contents, props changed)
   branches/release/boost/context/stack_utils.hpp   (contents, props changed)
   branches/release/libs/context/
   branches/release/libs/context/build/
   branches/release/libs/context/build/Jamfile.v2   (contents, props changed)
   branches/release/libs/context/build/architecture.jam   (contents, props changed)
   branches/release/libs/context/config/
   branches/release/libs/context/config/32.cpp   (contents, props changed)
   branches/release/libs/context/config/64.cpp   (contents, props changed)
   branches/release/libs/context/config/Jamfile.jam   (contents, props changed)
   branches/release/libs/context/config/arm.cpp   (contents, props changed)
   branches/release/libs/context/config/mips1.cpp   (contents, props changed)
   branches/release/libs/context/config/power.cpp   (contents, props changed)
   branches/release/libs/context/config/x86.cpp   (contents, props changed)
   branches/release/libs/context/doc/
   branches/release/libs/context/doc/Jamfile.v2   (contents, props changed)
   branches/release/libs/context/doc/acknowledgements.qbk   (contents, props changed)
   branches/release/libs/context/doc/config.qbk   (contents, props changed)
   branches/release/libs/context/doc/context.qbk   (contents, props changed)
   branches/release/libs/context/doc/context.xml   (contents, props changed)
   branches/release/libs/context/doc/fcontext.qbk   (contents, props changed)
   branches/release/libs/context/doc/overview.qbk   (contents, props changed)
   branches/release/libs/context/doc/pdf/
   branches/release/libs/context/doc/pdf/arm-aapcs.pdf   (contents, props changed)
   branches/release/libs/context/doc/pdf/arm-linux-aapcs.pdf   (contents, props changed)
   branches/release/libs/context/doc/pdf/calling-conventions.pdf   (contents, props changed)
   branches/release/libs/context/doc/pdf/iso_c99.pdf   (contents, props changed)
   branches/release/libs/context/doc/pdf/mips-o32.pdf   (contents, props changed)
   branches/release/libs/context/doc/pdf/ppc32-sysv.pdf   (contents, props changed)
   branches/release/libs/context/doc/pdf/ppc64-sysv.pdf   (contents, props changed)
   branches/release/libs/context/doc/pdf/x86_32-sysv.pdf   (contents, props changed)
   branches/release/libs/context/doc/pdf/x86_64-sysv.pdf   (contents, props changed)
   branches/release/libs/context/doc/performance.qbk   (contents, props changed)
   branches/release/libs/context/doc/rationale.qbk   (contents, props changed)
   branches/release/libs/context/doc/reference.qbk   (contents, props changed)
   branches/release/libs/context/doc/requirements.qbk   (contents, props changed)
   branches/release/libs/context/doc/stack.qbk   (contents, props changed)
   branches/release/libs/context/doc/tested.qbk   (contents, props changed)
   branches/release/libs/context/doc/todo.qbk   (contents, props changed)
   branches/release/libs/context/example/
   branches/release/libs/context/example/Jamfile.v2   (contents, props changed)
   branches/release/libs/context/example/exit.cpp   (contents, props changed)
   branches/release/libs/context/example/jump.cpp   (contents, props changed)
   branches/release/libs/context/example/transfer.cpp   (contents, props changed)
   branches/release/libs/context/performance/
   branches/release/libs/context/performance/Jamfile.v2   (contents, props changed)
   branches/release/libs/context/performance/bind_processor.hpp   (contents, props changed)
   branches/release/libs/context/performance/bind_processor_aix.cpp   (contents, props changed)
   branches/release/libs/context/performance/bind_processor_freebsd.cpp   (contents, props changed)
   branches/release/libs/context/performance/bind_processor_hpux.cpp   (contents, props changed)
   branches/release/libs/context/performance/bind_processor_linux.cpp   (contents, props changed)
   branches/release/libs/context/performance/bind_processor_solaris.cpp   (contents, props changed)
   branches/release/libs/context/performance/bind_processor_windows.cpp   (contents, props changed)
   branches/release/libs/context/performance/cycle.hpp   (contents, props changed)
   branches/release/libs/context/performance/cycle_i386.hpp   (contents, props changed)
   branches/release/libs/context/performance/cycle_x86-64.hpp   (contents, props changed)
   branches/release/libs/context/performance/performance.cpp   (contents, props changed)
   branches/release/libs/context/src/
   branches/release/libs/context/src/asm/
   branches/release/libs/context/src/asm/fcontext_arm_aapcs_elf_gas.S   (contents, props changed)
   branches/release/libs/context/src/asm/fcontext_i386_ms_pe_masm.asm   (contents, props changed)
   branches/release/libs/context/src/asm/fcontext_i386_sysv_elf_gas.S   (contents, props changed)
   branches/release/libs/context/src/asm/fcontext_i386_sysv_macho_gas.S   (contents, props changed)
   branches/release/libs/context/src/asm/fcontext_mips32_o32_elf_gas.S   (contents, props changed)
   branches/release/libs/context/src/asm/fcontext_ppc32_sysv_elf_gas.S   (contents, props changed)
   branches/release/libs/context/src/asm/fcontext_ppc64_sysv_elf_gas.S   (contents, props changed)
   branches/release/libs/context/src/asm/fcontext_x86_64_ms_pe_masm.asm   (contents, props changed)
   branches/release/libs/context/src/asm/fcontext_x86_64_sysv_elf_gas.S   (contents, props changed)
   branches/release/libs/context/src/asm/fcontext_x86_64_sysv_macho_gas.S   (contents, props changed)
   branches/release/libs/context/src/fcontext.cpp   (contents, props changed)
   branches/release/libs/context/src/seh.cpp   (contents, props changed)
   branches/release/libs/context/src/stack_allocator_posix.cpp   (contents, props changed)
   branches/release/libs/context/src/stack_allocator_windows.cpp   (contents, props changed)
   branches/release/libs/context/src/stack_utils_posix.cpp   (contents, props changed)
   branches/release/libs/context/src/stack_utils_windows.cpp   (contents, props changed)
   branches/release/libs/context/test/
   branches/release/libs/context/test/Jamfile.v2   (contents, props changed)
   branches/release/libs/context/test/test_context.cpp   (contents, props changed)
Added: branches/release/boost/context/all.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/context/all.hpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,14 @@
+
+//          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)
+
+#ifndef BOOST_CTX_ALL_H
+#define BOOST_CTX_ALL_H
+
+#include <boost/context/fcontext.hpp>
+#include <boost/context/stack_allocator.hpp>
+#include <boost/context/stack_utils.hpp>
+
+#endif // BOOST_CTX_ALL_H
Added: branches/release/boost/context/detail/config.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/context/detail/config.hpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,42 @@
+
+//          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)
+
+#ifndef BOOST_CTX_DETAIL_CONFIG_H
+#define BOOST_CTX_DETAIL_CONFIG_H
+
+#include <boost/config.hpp>
+#include <boost/detail/workaround.hpp>
+
+#ifdef BOOST_CONTEXT_DECL
+# undef BOOST_CONTEXT_DECL
+#endif
+
+#if defined(BOOST_HAS_DECLSPEC)
+# if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_CONTEXT_DYN_LINK)
+#  if ! defined(BOOST_DYN_LINK)
+#   define BOOST_DYN_LINK
+#  endif
+#  if defined(BOOST_CONTEXT_SOURCE)
+#   define BOOST_CONTEXT_DECL BOOST_SYMBOL_EXPORT
+#  else 
+#   define BOOST_CONTEXT_DECL BOOST_SYMBOL_IMPORT
+#  endif
+# endif
+#endif
+
+#if ! defined(BOOST_CONTEXT_DECL)
+# define BOOST_CONTEXT_DECL
+#endif
+
+#if ! defined(BOOST_CONTEXT_SOURCE) && ! defined(BOOST_ALL_NO_LIB) && ! defined(BOOST_CONTEXT_NO_LIB)
+# define BOOST_LIB_NAME boost_context
+# if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_CONTEXT_DYN_LINK)
+#  define BOOST_DYN_LINK
+# endif
+# include <boost/config/auto_link.hpp>
+#endif
+
+#endif // BOOST_CTX_DETAIL_CONFIG_H
Added: branches/release/boost/context/detail/fcontext_arm.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/context/detail/fcontext_arm.hpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,66 @@
+
+//          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)
+
+#ifndef BOOST_CTX_DETAIL_FCONTEXT_ARM_H
+#define BOOST_CTX_DETAIL_FCONTEXT_ARM_H
+
+#include <boost/config.hpp>
+#include <boost/cstdint.hpp>
+
+#include <boost/context/detail/config.hpp>
+
+#ifdef BOOST_HAS_ABI_HEADERS
+# include BOOST_ABI_PREFIX
+#endif
+
+namespace boost {
+namespace ctx {
+
+extern "C" {
+
+#define BOOST_CONTEXT_CALLDECL
+
+struct stack_t
+{
+    void    *   base;
+    void    *   limit;
+
+    stack_t() :
+        base( 0), limit( 0)
+    {}
+};
+
+struct fp_t
+{
+    boost::uint32_t     fc_freg[16];
+
+    fp_t() :
+        fc_freg()
+    {}
+};
+
+struct fcontext_t
+{
+    boost::uint32_t     fc_greg[11];
+    stack_t				fc_stack;
+    fp_t                fc_fp;
+
+    fcontext_t() :
+        fc_greg(),
+        fc_stack(),
+        fc_fp()
+    {}
+};
+
+}
+
+}}
+
+#ifdef BOOST_HAS_ABI_HEADERS
+# include BOOST_ABI_SUFFIX
+#endif
+
+#endif // BOOST_CTX_DETAIL_FCONTEXT_ARM_H
Added: branches/release/boost/context/detail/fcontext_i386.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/context/detail/fcontext_i386.hpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,68 @@
+
+//          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)
+
+#ifndef BOOST_CTX_DETAIL_FCONTEXT_I386H
+#define BOOST_CTX_DETAIL_FCONTEXT_I386H
+
+#include <cstddef>
+
+#include <boost/config.hpp>
+#include <boost/cstdint.hpp>
+
+#include <boost/context/detail/config.hpp>
+
+#ifdef BOOST_HAS_ABI_HEADERS
+# include BOOST_ABI_PREFIX
+#endif
+
+namespace boost {
+namespace ctx {
+
+extern "C" {
+
+#define BOOST_CONTEXT_CALLDECL __attribute__((cdecl))
+
+struct stack_t
+{
+    void    *   base;
+    void    *   limit;
+
+    stack_t() :
+        base( 0), limit( 0)
+    {}
+};
+
+struct fp_t
+{
+    boost::uint32_t		fc_freg[2];
+
+    fp_t() :
+        fc_freg()
+    {}
+};
+
+struct fcontext_t
+{
+    boost::uint32_t		fc_greg[6];
+    stack_t				fc_stack;
+    fp_t                fc_fp;
+
+    fcontext_t() :
+        fc_greg(),
+        fc_stack(),
+        fc_fp()
+    {}
+};
+
+}
+
+}}
+
+#ifdef BOOST_HAS_ABI_HEADERS
+# include BOOST_ABI_SUFFIX
+#endif
+
+#endif // BOOST_CTX_DETAIL_FCONTEXT_I386_H
Added: branches/release/boost/context/detail/fcontext_i386_win.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/context/detail/fcontext_i386_win.hpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,79 @@
+
+//          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)
+
+#ifndef BOOST_CTX_DETAIL_FCONTEXT_I386H
+#define BOOST_CTX_DETAIL_FCONTEXT_I386H
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <boost/config.hpp>
+#include <boost/cstdint.hpp>
+
+#include <boost/context/detail/config.hpp>
+
+#pragma warning(push)
+#pragma warning(disable:4351)
+
+#ifdef BOOST_HAS_ABI_HEADERS
+# include BOOST_ABI_PREFIX
+#endif
+
+namespace boost {
+namespace ctx {
+
+extern "C" {
+
+#define BOOST_CONTEXT_CALLDECL __cdecl
+
+struct stack_t
+{
+    void    *   base;
+    void    *   limit;
+
+    stack_t() :
+        base( 0), limit( 0)
+    {}
+};
+
+struct fp_t
+{
+    boost::uint32_t     fc_freg[2];
+
+    fp_t() :
+        fc_freg()
+    {}
+};
+
+struct fcontext_t
+{
+    boost::uint32_t     fc_greg[6];
+    stack_t				fc_stack;
+    void            *   fc_excpt_lst;
+    void            *   fc_local_storage;
+    fp_t                fc_fp;
+
+    fcontext_t() :
+        fc_greg(),
+        fc_stack(),
+        fc_excpt_lst( 0),
+        fc_local_storage( 0),
+        fc_fp()
+    {}
+};
+
+}
+
+}}
+
+#ifdef BOOST_HAS_ABI_HEADERS
+# include BOOST_ABI_SUFFIX
+#endif
+
+#pragma warning(pop)
+
+#endif // BOOST_CTX_DETAIL_FCONTEXT_I386_H
Added: branches/release/boost/context/detail/fcontext_mips.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/context/detail/fcontext_mips.hpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,68 @@
+
+//          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)
+
+#ifndef BOOST_CTX_DETAIL_FCONTEXT_MIPS_H
+#define BOOST_CTX_DETAIL_FCONTEXT_MIPS_H
+
+#include <boost/config.hpp>
+#include <boost/cstdint.hpp>
+
+#include <boost/context/detail/config.hpp>
+
+#ifdef BOOST_HAS_ABI_HEADERS
+# include BOOST_ABI_PREFIX
+#endif
+
+namespace boost {
+namespace ctx {
+
+extern "C" {
+
+#define BOOST_CONTEXT_CALLDECL
+
+// on MIPS we assume 64bit regsiters - even for 32bit ABIs
+
+struct stack_t
+{
+    void    *   base;
+    void    *   limit;
+
+    stack_t() :
+        base( 0), limit( 0)
+    {}
+};
+
+struct fp_t
+{
+    boost::uint64_t     fc_freg[6];
+
+    fp_t() :
+        fc_freg()
+    {}
+};
+
+struct fcontext_t
+{
+    boost::uint64_t     fc_greg[13];
+    stack_t				fc_stack;
+    fp_t                fc_fp;
+
+    fcontext_t() :
+        fc_greg(),
+        fc_stack(),
+        fc_fp()
+    {}
+};
+
+}
+
+}}
+
+#ifdef BOOST_HAS_ABI_HEADERS
+# include BOOST_ABI_SUFFIX
+#endif
+
+#endif // BOOST_CTX_DETAIL_FCONTEXT_MIPS_H
Added: branches/release/boost/context/detail/fcontext_ppc.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/context/detail/fcontext_ppc.hpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,70 @@
+
+//          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)
+
+#ifndef BOOST_CTX_DETAIL_FCONTEXT_PPC_H
+#define BOOST_CTX_DETAIL_FCONTEXT_PPC_H
+
+#include <boost/config.hpp>
+#include <boost/cstdint.hpp>
+
+#include <boost/context/detail/config.hpp>
+
+#ifdef BOOST_HAS_ABI_HEADERS
+# include BOOST_ABI_PREFIX
+#endif
+
+namespace boost {
+namespace ctx {
+
+extern "C" {
+
+#define BOOST_CONTEXT_CALLDECL
+
+struct stack_t
+{
+    void    *   base;
+    void    *   limit;
+
+    stack_t() :
+        base( 0), limit( 0)
+    {}
+};
+
+struct fp_t
+{
+    boost::uint64_t     fc_freg[19];
+
+    fp_t() :
+        fc_freg()
+    {}
+};
+
+struct fcontext_t
+{
+# if defined(__powerpc64__)
+    boost::uint64_t     fc_greg[23];
+# else
+    boost::uint32_t     fc_greg[23];
+# endif
+    stack_t				fc_stack;
+    fp_t                fc_fp;
+
+    fcontext_t() :
+        fc_greg(),
+        fc_stack(),
+        fc_fp()
+    {}
+};
+
+}
+
+}}
+
+#ifdef BOOST_HAS_ABI_HEADERS
+# include BOOST_ABI_SUFFIX
+#endif
+
+#endif // BOOST_CTX_DETAIL_FCONTEXT_PPC_H
Added: branches/release/boost/context/detail/fcontext_x86_64.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/context/detail/fcontext_x86_64.hpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,66 @@
+
+//          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)
+
+#ifndef BOOST_CTX_DETAIL_FCONTEXT_X86_64_H
+#define BOOST_CTX_DETAIL_FCONTEXT_X86_64_H
+
+#include <boost/config.hpp>
+#include <boost/cstdint.hpp>
+
+#include <boost/context/detail/config.hpp>
+
+#ifdef BOOST_HAS_ABI_HEADERS
+# include BOOST_ABI_PREFIX
+#endif
+
+namespace boost {
+namespace ctx {
+
+extern "C" {
+
+#define BOOST_CONTEXT_CALLDECL
+
+struct stack_t
+{
+    void    *   base;
+    void    *   limit;
+
+    stack_t() :
+        base( 0), limit( 0)
+    {}
+};
+
+struct fp_t
+{
+    boost::uint32_t     fc_freg[2];
+
+    fp_t() :
+        fc_freg()
+    {}
+};
+
+struct fcontext_t
+{
+    boost::uint64_t     fc_greg[8];
+    stack_t				fc_stack;
+    fp_t                fc_fp;
+
+    fcontext_t() :
+        fc_greg(),
+        fc_stack(),
+        fc_fp()
+    {}
+};
+
+}
+
+}}
+
+#ifdef BOOST_HAS_ABI_HEADERS
+# include BOOST_ABI_SUFFIX
+#endif
+
+#endif // BOOST_CTX_DETAIL_FCONTEXT_X86_64_H
Added: branches/release/boost/context/detail/fcontext_x86_64_win.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/context/detail/fcontext_x86_64_win.hpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,86 @@
+
+//          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)
+
+#ifndef BOOST_CTX_DETAIL_FCONTEXT_X86_64_H
+#define BOOST_CTX_DETAIL_FCONTEXT_X86_64_H
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <boost/assert.hpp>
+#include <boost/config.hpp>
+#include <boost/cstdint.hpp>
+
+#include <boost/context/detail/config.hpp>
+
+#pragma warning(push)
+#pragma warning(disable:4351)
+
+#ifdef BOOST_HAS_ABI_HEADERS
+# include BOOST_ABI_PREFIX
+#endif
+
+namespace boost {
+namespace ctx {
+
+extern "C" {
+
+#define BOOST_CONTEXT_CALLDECL
+
+struct stack_t
+{
+    void    *   base;
+    void    *   limit;
+
+    stack_t() :
+        base( 0), limit( 0)
+    {}
+};
+
+struct fp_t
+{
+    boost::uint32_t     fc_freg[2];
+    void			*	fc_xmm;
+    char                fc_buffer[175];
+
+    fp_t() :
+        fc_freg(),
+        fc_xmm( 0),
+        fc_buffer()
+    {
+		fc_xmm = fc_buffer;
+		if ( 0 != ( ( ( uintptr_t) fc_xmm) & 15) )
+			fc_xmm = ( char *) ( ( ( ( uintptr_t) fc_xmm) + 15) & ~0x0F);
+	}
+};
+
+struct fcontext_t
+{
+    boost::uint64_t     fc_greg[10];
+    stack_t				fc_stack;
+    void			*	fc_local_storage;
+    fp_t                fc_fp;
+
+    fcontext_t() :
+        fc_greg(),
+        fc_stack(),
+        fc_local_storage( 0),
+        fc_fp()
+    {}
+};
+
+}
+
+}}
+
+#ifdef BOOST_HAS_ABI_HEADERS
+# include BOOST_ABI_SUFFIX
+#endif
+
+#pragma warning(pop)
+
+#endif // BOOST_CTX_DETAIL_FCONTEXT_X86_64_H
Added: branches/release/boost/context/fcontext.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/context/fcontext.hpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,82 @@
+
+//          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)
+
+#ifndef BOOST_CTX_FCONTEXT_H
+#define BOOST_CTX_FCONTEXT_H
+
+#if defined(__PGI)
+#include <stdint.h>
+#endif
+
+#include <boost/config.hpp>
+#include <boost/cstdint.hpp>
+
+#include <boost/context/detail/config.hpp>
+
+#ifdef BOOST_HAS_ABI_HEADERS
+# include BOOST_ABI_PREFIX
+#endif
+
+// x86_64
+// test x86_64 before i386 because icc might
+// define __i686__ for x86_64 too
+#if defined(__x86_64__) || defined(__x86_64) \
+    || defined(__amd64__) || defined(__amd64) \
+    || defined(_M_X64) || defined(_M_AMD64)
+# if defined(BOOST_WINDOWS)
+#  include <boost/context/detail/fcontext_x86_64_win.hpp>
+# else
+#  include <boost/context/detail/fcontext_x86_64.hpp>
+# endif
+// i386
+#elif defined(i386) || defined(__i386__) || defined(__i386) \
+    || defined(__i486__) || defined(__i586__) || defined(__i686__) \
+    || defined(__X86__) || defined(_X86_) || defined(__THW_INTEL__) \
+    || defined(__I86__) || defined(__INTEL__) || defined(__IA32__) \
+    || defined(_M_IX86) || defined(_I86_)
+# if defined(BOOST_WINDOWS)
+#  include <boost/context/detail/fcontext_i386_win.hpp>
+# else
+#  include <boost/context/detail/fcontext_i386.hpp>
+# endif
+// arm
+#elif defined(__arm__) || defined(__thumb__) || defined(__TARGET_ARCH_ARM) \
+    || defined(__TARGET_ARCH_THUMB) || defined(_ARM)
+# include <boost/context/detail/fcontext_arm.hpp>
+// mips
+#elif (defined(__mips) && __mips == 1) || defined(_MIPS_ISA_MIPS1) \
+    || defined(_R3000)
+# include <boost/context/detail/fcontext_mips.hpp>
+// powerpc
+#elif defined(__powerpc) || defined(__powerpc__) || defined(__ppc) \
+    || defined(__ppc__) || defined(_ARCH_PPC) || defined(__POWERPC__) \
+    || defined(__PPCGECKO__) || defined(__PPCBROADWAY) || defined(_XENON)
+# include <boost/context/detail/fcontext_ppc.hpp>
+#else
+# error "platform not supported"
+#endif
+
+namespace boost {
+namespace ctx {
+namespace detail {
+
+extern "C" BOOST_CONTEXT_DECL void * BOOST_CONTEXT_CALLDECL align_stack( void * vp);
+
+}
+
+extern "C" BOOST_CONTEXT_DECL
+intptr_t BOOST_CONTEXT_CALLDECL jump_fcontext( fcontext_t * ofc, fcontext_t const* nfc, intptr_t vp, bool preserve_fpu = true);
+extern "C" BOOST_CONTEXT_DECL
+void BOOST_CONTEXT_CALLDECL make_fcontext( fcontext_t * fc, void (* fn)( intptr_t) );
+
+}}
+
+#ifdef BOOST_HAS_ABI_HEADERS
+# include BOOST_ABI_SUFFIX
+#endif
+
+#endif // BOOST_CTX_FCONTEXT_H
+
Added: branches/release/boost/context/stack_allocator.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/context/stack_allocator.hpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,37 @@
+
+//          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)
+
+#ifndef BOOST_CTX_STACK_ALLOCATOR_H
+#define BOOST_CTX_STACK_ALLOCATOR_H
+
+#include <cstddef>
+
+#include <boost/config.hpp>
+
+#include <boost/context/detail/config.hpp>
+
+#ifdef BOOST_HAS_ABI_HEADERS
+#  include BOOST_ABI_PREFIX
+#endif
+
+namespace boost {
+namespace ctx {
+
+class BOOST_CONTEXT_DECL stack_allocator
+{
+public:
+    void * allocate( std::size_t) const;
+
+    void deallocate( void *, std::size_t) const;
+};
+
+}}
+
+#ifdef BOOST_HAS_ABI_HEADERS
+#  include BOOST_ABI_SUFFIX
+#endif
+
+#endif // BOOST_CTX_STACK_ALLOCATOR_H
Added: branches/release/boost/context/stack_utils.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/context/stack_utils.hpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,41 @@
+
+//          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)
+
+#ifndef BOOST_CTX_STACK_UTILS_H
+#define BOOST_CTX_STACK_UTILS_H
+
+#include <cstddef>
+
+#include <boost/config.hpp>
+
+#include <boost/context/detail/config.hpp>
+
+#ifdef BOOST_HAS_ABI_HEADERS
+# include BOOST_ABI_PREFIX
+#endif
+
+namespace boost {
+namespace ctx {
+
+BOOST_CONTEXT_DECL std::size_t default_stacksize();
+
+BOOST_CONTEXT_DECL std::size_t minimum_stacksize();
+
+BOOST_CONTEXT_DECL std::size_t maximum_stacksize();
+
+BOOST_CONTEXT_DECL std::size_t pagesize();
+
+BOOST_CONTEXT_DECL std::size_t page_count( std::size_t stacksize);
+
+BOOST_CONTEXT_DECL bool is_stack_unbound();
+
+}}
+
+#ifdef BOOST_HAS_ABI_HEADERS
+# include BOOST_ABI_SUFFIX
+#endif
+
+#endif // BOOST_CTX_STACK_UTILS_H
Added: branches/release/libs/context/build/Jamfile.v2
==============================================================================
--- (empty file)
+++ branches/release/libs/context/build/Jamfile.v2	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,370 @@
+
+# Boost.Context Library Build Jamfile
+
+#          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)
+
+import common ;
+import feature ;
+import indirect ;
+import modules ;
+import os ;
+import toolset ;
+import architecture ;
+
+project boost/context
+    : source-location ../src
+    : usage-requirements
+      <link>shared:<define>BOOST_CONTEXT_DYN_LINK=1
+    ;
+
+local rule default_binary_format ( )
+{
+    local tmp = elf ;
+    if [ os.name ] = "MACOSX" { tmp = mach-o ; }
+    if [ os.name ] = "NT" { tmp = pe ; }
+    return $(tmp) ;
+}
+
+feature.feature binary-format
+   : elf
+     mach-o
+     pe
+   : propagated
+   ;
+feature.set-default binary-format : [ default_binary_format ] ;
+
+
+local rule default_abi ( )
+{
+    local tmp = sysv ;
+    if [ os.name ] = "NT" { tmp = ms ; }
+    else if [ os.platform ] = "ARM" { tmp = aapcs ; }
+    else if [ os.platform ] = "MIPS" { tmp = o32 ; }
+    return $(tmp) ;
+}
+
+feature.feature abi
+   : aapcs
+     eabi
+     ms
+     n32
+     n64
+     o32
+     o64
+     sysv
+   : propagated
+   ;
+feature.set-default abi : [ default_abi ] ;
+
+
+actions gas
+{
+	as -o "$(<)" "$(>)"
+}
+
+actions masm
+{
+	ml /c /Fo"$(<)" "$(>)"
+}
+
+actions masm64
+{
+	ml64 /c /Fo"$(<)" "$(>)"
+}
+
+
+rule configure ( properties * )
+{
+	local result  ;
+
+	if ( ! ( <toolset>gcc in $(properties)
+			|| <toolset>intel in $(properties)
+			|| <toolset>msvc in $(properties) ) )
+	{
+		result = <build>no ;
+		ECHO "toolset not supported" ;
+	}
+
+	return $(result) ;
+}
+
+# ARM
+alias asm_context_sources
+   : asm/fcontext_arm_aapcs_elf_gas.S
+   : <abi>aapcs
+     <architecture>arm
+     <binary-format>elf
+	 <toolset>gcc
+   ;
+
+alias asm_context_sources
+   : [ make asm/fcontext_arm_aapcs_elf_gas.o : asm/fcontext_arm_aapcs_elf_gas.S : @gas ]
+   : <abi>aapcs
+     <architecture>arm
+     <binary-format>elf
+   ;
+
+# MIPS 32bit
+alias asm_context_sources
+   : asm/fcontext_mips32_o32_elf_gas.S
+   : <abi>o32
+     <architecture>mips1
+     <binary-format>elf
+	 <toolset>gcc
+   ;
+
+alias asm_context_sources
+   : [ make asm/fcontext_mips32_o32_elf_gas.o : asm/fcontext_mips32_o32_elf_gas.S : @gas ]
+   : <abi>o32
+     <architecture>mips1
+     <binary-format>elf
+   ;
+
+# POWERPC 32bit
+alias asm_context_sources
+   : asm/fcontext_ppc32_sysv_elf_gas.S
+   : <abi>sysv
+     <address-model>32
+     <architecture>power
+     <binary-format>elf
+	 <toolset>gcc
+   ;
+
+alias asm_context_sources
+   : [ make asm/fcontext_ppc32_sysv_elf_gas.o : asm/fcontext_ppc32_sysv_elf_gas.S : @gas ]
+   : <abi>sysv
+     <address-model>32
+     <architecture>power
+     <binary-format>elf
+   ;
+
+# POWERPC 64bit
+alias asm_context_sources
+   : asm/fcontext_ppc64_sysv_elf_gas.S
+   : <abi>sysv
+     <address-model>64
+     <architecture>power
+     <binary-format>elf
+	 <toolset>gcc
+   ;
+
+alias asm_context_sources
+   : [ make asm/fcontext_ppc64_sysv_elf_gas.o : asm/fcontext_ppc64_sysv_elf_gas.S : @gas ]
+   : <abi>sysv
+     <address-model>64
+     <architecture>power
+     <binary-format>elf
+   ;
+
+# I386
+alias asm_context_sources
+   : asm/fcontext_i386_sysv_elf_gas.S
+   : <abi>sysv
+     <address-model>32
+     <architecture>x86
+     <binary-format>elf
+	 <toolset>gcc
+   ;
+
+alias asm_context_sources
+   : asm/fcontext_i386_sysv_elf_gas.S
+   : <abi>sysv
+     <address-model>32
+     <architecture>x86
+     <binary-format>elf
+	 <toolset>intel
+   ;
+
+alias asm_context_sources
+   : [ make asm/fcontext_i386_sysv_elf_gas.o : asm/fcontext_i386_sysv_elf_gas.S : @gas ]
+   : <abi>sysv
+     <address-model>32
+     <architecture>x86
+     <binary-format>elf
+   ;
+
+alias asm_context_sources
+   : asm/fcontext_i386_sysv_macho_gas.S
+   : <abi>sysv
+     <address-model>32
+     <architecture>x86
+     <binary-format>mach-o
+     <target-os>darwin
+	 <toolset>gcc
+   ;
+
+alias asm_context_sources
+   : asm/fcontext_i386_sysv_macho_gas.S
+   : <abi>sysv
+     <address-model>32
+     <architecture>x86
+     <binary-format>mach-o
+     <target-os>darwin
+	 <toolset>intel
+   ;
+
+alias asm_context_sources
+   : [ make asm/fcontext_i386_sysv_macho_gas.o : asm/fcontext_i386_sysv_macho_gas.S : @gas ]
+   : <abi>sysv
+     <address-model>32
+     <architecture>x86
+     <binary-format>mach-o
+     <target-os>darwin
+   ;
+
+alias asm_context_sources
+   : asm/fcontext_i386_ms_pe_masm.asm
+   : <abi>ms
+     <address-model>32
+     <architecture>x86
+     <binary-format>pe
+     <target-os>windows
+	 <toolset>intel
+   ;
+
+alias asm_context_sources
+   : asm/fcontext_i386_ms_pe_masm.asm
+   : <abi>ms
+     <address-model>32
+     <architecture>x86
+     <binary-format>pe
+     <target-os>windows
+	 <toolset>msvc
+   ;
+
+alias asm_context_sources
+   : [ make asm/fcontext_i386_ms_pe_masm.o : asm/fcontext_i386_ms_pe_masm.asm : @masm ]
+   : <abi>ms
+     <address-model>32
+     <architecture>x86
+     <binary-format>pe
+     <target-os>windows
+	 <toolset>gcc
+   ;
+
+
+# X86_64
+alias asm_context_sources
+   : asm/fcontext_x86_64_sysv_elf_gas.S
+   : <abi>sysv
+     <address-model>64
+     <architecture>x86
+     <binary-format>elf
+	 <toolset>gcc
+   ;
+
+alias asm_context_sources
+   : asm/fcontext_x86_64_sysv_elf_gas.S
+   : <abi>sysv
+     <address-model>64
+     <architecture>x86
+     <binary-format>elf
+	 <toolset>intel
+   ;
+
+alias asm_context_sources
+   : [ make asm/fcontext_x86_64_sysv_elf_gas.o : asm/fcontext_x86_64_sysv_elf_gas.S : @gas ]
+   : <abi>sysv
+     <address-model>64
+     <architecture>x86
+     <binary-format>elf
+   ;
+
+
+alias asm_context_sources
+   : asm/fcontext_x86_64_sysv_macho_gas.S
+   : <abi>sysv
+     <address-model>64
+     <architecture>x86
+     <binary-format>mach-o
+     <target-os>darwin
+	 <toolset>gcc
+   ;
+
+alias asm_context_sources
+   : asm/fcontext_x86_64_sysv_macho_gas.S
+   : <abi>sysv
+     <address-model>64
+     <architecture>x86
+     <binary-format>mach-o
+     <target-os>darwin
+	 <toolset>intel
+   ;
+
+alias asm_context_sources
+   : [ make asm/fcontext_x86_64_sysv_macho_gas.o : asm/fcontext_x86_64_sysv_macho_gas.S : @gas ]
+   : <abi>sysv
+     <address-model>64
+     <architecture>x86
+     <binary-format>mach-o
+     <target-os>darwin
+   ;
+
+alias asm_context_sources
+   : asm/fcontext_x86_64_ms_pe_masm.asm
+   : <abi>ms
+     <address-model>64
+     <architecture>x86
+     <binary-format>pe
+     <target-os>windows
+	 <toolset>intel
+   ;
+
+alias asm_context_sources
+   : asm/fcontext_x86_64_ms_pe_masm.asm
+   : <abi>ms
+     <address-model>64
+     <architecture>x86
+     <binary-format>pe
+     <target-os>windows
+	 <toolset>msvc
+   ;
+
+alias asm_context_sources
+   : [ make asm/fcontext_x86_64_ms_pe_masm.o : asm/fcontext_x86_64_ms_pe_masm.asm : @masm64 ]
+   : <abi>ms
+     <address-model>64
+     <architecture>x86
+     <binary-format>pe
+     <target-os>windows
+	 <toolset>gcc
+   ;
+
+explicit asm_context_sources ;
+
+
+alias select_asm_context_sources
+  : asm_context_sources
+  : [ architecture.architecture ]
+    [ architecture.address-model ]
+  ;
+
+
+alias context_sources
+   : fcontext.cpp
+     seh.cpp
+     stack_allocator_windows.cpp
+     stack_utils_windows.cpp
+   : <target-os>windows
+   ;
+
+alias context_sources
+   : fcontext.cpp
+     stack_allocator_posix.cpp
+     stack_utils_posix.cpp
+   ;
+
+explicit context_sources ;
+
+
+lib boost_context
+   : select_asm_context_sources
+     context_sources
+   : <link>shared:<define>BOOST_CONTEXT_DYN_LINK=1
+   ;
+
+
+boost-install boost_context ;
Added: branches/release/libs/context/build/architecture.jam
==============================================================================
--- (empty file)
+++ branches/release/libs/context/build/architecture.jam	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,76 @@
+# architecture.jam
+#
+# Copyright 2012 Steven Watanabe
+#
+# 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)
+
+import configure ;
+import project ;
+import path ;
+import property ;
+
+local here = [ modules.binding $(__name__) ] ;
+
+project.push-current [ project.current ] ;
+project.load [ path.join [ path.make $(here:D) ] ../config ] ;
+project.pop-current ;
+
+rule deduce-address-model ( properties * )
+{
+    local result = [ property.select <address-model> : $(properties) ] ;
+    if $(result)
+    {
+        return $(result) ;
+    }
+    else
+    {
+        if [ configure.builds /boost/architecture//32 : $(properties) : 32-bit ]
+        {
+            return <address-model>32 ;
+        }
+        else if [ configure.builds /boost/architecture//64 : $(properties) : 64-bit ]
+        {
+            return <address-model>64 ;
+        }
+    }
+}
+
+rule address-model ( )
+{
+    return <conditional>@architecture.deduce-address-model ;
+}
+
+rule deduce-architecture ( properties * )
+{
+    local result = [ property.select <architecture> : $(properties) ] ;
+    if $(result)
+    {
+        return $(result) ;
+    }
+    else
+    {
+        if [ configure.builds /boost/architecture//x86 : $(properties) : x86 ]
+        {
+            return <architecture>x86 ;
+        }
+        else if [ configure.builds /boost/architecture//power : $(properties) : power ]
+        {
+            return <architecture>power ;
+        }
+        else if [ configure.builds /boost/architecture//arm : $(properties) : arm ]
+        {
+            return <architecture>arm ;
+        }
+        else if [ configure.builds /boost/architecture//mips1 : $(properties) : mips1 ]
+        {
+            return <architecture>mips1 ;
+        }
+    }
+}
+
+rule architecture ( )
+{
+    return <conditional>@architecture.deduce-architecture ;
+}
Added: branches/release/libs/context/config/32.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/context/config/32.cpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,9 @@
+// 32.cpp
+//
+// Copyright (c) 2012 Steven Watanabe
+//
+// 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)
+
+int test[sizeof(void*) == 4? 1 : -1];
Added: branches/release/libs/context/config/64.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/context/config/64.cpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,9 @@
+// 64.cpp
+//
+// Copyright (c) 2012 Steven Watanabe
+//
+// 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)
+
+int test[sizeof(void*) == 8? 1 : -1];
Added: branches/release/libs/context/config/Jamfile.jam
==============================================================================
--- (empty file)
+++ branches/release/libs/context/config/Jamfile.jam	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,17 @@
+# Jamfile.jam
+#
+# Copyright 2012 Steven Watanabe
+#
+# 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)
+
+project /boost/architecture ;
+
+obj 32 : 32.cpp ;
+obj 64 : 64.cpp ;
+
+obj power : power.cpp ;
+obj x86 : x86.cpp ;
+obj mips1 : mips1.cpp ;
+obj arm : arm.cpp ;
Added: branches/release/libs/context/config/arm.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/context/config/arm.cpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,13 @@
+// arm.cpp
+//
+// Copyright (c) 2012 Steven Watanabe
+//
+// 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)
+
+#if !defined(__arm__) && !defined(__thumb__) && \
+    !defined(__TARGET_ARCH_ARM) && !defined(__TARGET_ARCH_THUMB) && \
+    !defined(_ARM)
+#error "Not ARM"
+#endif
Added: branches/release/libs/context/config/mips1.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/context/config/mips1.cpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,11 @@
+// mips1.cpp
+//
+// Copyright (c) 2012 Steven Watanabe
+//
+// 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)
+
+#if !((defined(__mips) && __mips == 1) || defined(_MIPS_ISA_MIPS1) || defined(_R3000))
+#error "Not MIPS1"
+#endif
Added: branches/release/libs/context/config/power.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/context/config/power.cpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,14 @@
+// power.cpp
+//
+// Copyright (c) 2012 Steven Watanabe
+//
+// 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)
+
+#if !defined(__powerpc) && !defined(__powerpc__) && !defined(__ppc) \
+    && !defined(__ppc__) && !defined(_M_PPC) && !defined(_ARCH_PPC) \
+    && !defined(__POWERPC__) && !defined(__PPCGECKO__) \
+    && !defined(__PPCBROADWAY) && !defined(_XENON)
+#error "Not PPC"
+#endif
Added: branches/release/libs/context/config/x86.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/context/config/x86.cpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,16 @@
+// x86.cpp
+//
+// Copyright (c) 2012 Steven Watanabe
+//
+// 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)
+
+#if !defined(i386) && !defined(__i386__) && !defined(__i386) \
+    && !defined(__i486__) && !defined(__i586__) && !defined(__i686__) \
+    && !defined(_M_IX86) && !defined(__X86__) && !defined(_X86_) \
+    && !defined(__THW_INTEL__) && !defined(__I86__) && !defined(__INTEL__) \
+    && !defined(__amd64__) && !defined(__x86_64__) && !defined(__amd64) \
+    && !defined(__x86_64) && !defined(_M_X64)
+#error "Not x86"
+#endif
Added: branches/release/libs/context/doc/Jamfile.v2
==============================================================================
--- (empty file)
+++ branches/release/libs/context/doc/Jamfile.v2	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,33 @@
+# (C) Copyright 2008 Anthony Williams
+#
+# 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)
+
+path-constant boost-images : ../../../doc/src/images ;
+
+xml context : context.qbk ;
+
+boostbook standalone
+    :
+        context
+    :
+        # HTML options first:
+        # Use graphics not text for navigation:
+        <xsl:param>navig.graphics=1
+        # How far down we chunk nested sections, basically all of them:
+        <xsl:param>chunk.section.depth=3
+        # Don't put the first section on the same page as the TOC:
+        <xsl:param>chunk.first.sections=1
+        # How far down sections get TOC's
+        <xsl:param>toc.section.depth=10
+        # Max depth in each TOC:
+        <xsl:param>toc.max.depth=3
+        # How far down we go with TOC's
+        <xsl:param>generate.section.toc.level=10
+        # Path for links to Boost:
+        <xsl:param>boost.root=../../../..
+        # Path for libraries index:
+        <xsl:param>boost.libraries=../../../../libs/libraries.htm
+        # Use the main Boost stylesheet:
+        <xsl:param>html.stylesheet=../../../../doc/html/boostbook.css
+    ;
Added: branches/release/libs/context/doc/acknowledgements.qbk
==============================================================================
--- (empty file)
+++ branches/release/libs/context/doc/acknowledgements.qbk	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,15 @@
+[/
+          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
+]
+
+[section:acknowledgements Acknowledgments]
+
+I'd like to thank Adreas Fett, Artyom Beilis, Fernando Pelliccioni,
+Giovanni Piero Deretta, Gordon Woodhull, Helge Bahmann, Holger Grund, 
+Jeffrey Lee Hellrung (Jr.), Keith Jeffery, Phil Endecott, Robert Stewart,
+Steven Watanabe, Vicente J. Botet Escriba.
+
+[endsect]
Added: branches/release/libs/context/doc/config.qbk
==============================================================================
--- (empty file)
+++ branches/release/libs/context/doc/config.qbk	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,60 @@
+[/
+          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
+]
+
+[section:installtion How to build and install]
+
+__boost_context__ must be built for the particular compiler(s) and CPU architecture(s)s
+being targeted. __boost_context__ includes assembly code and, therefore, requires
+GNU AS for supported POSIX systems, and MASM for Windows systems.
+
+[note The architecture, instruction set, and address model are optional __boost_build__
+properties that must be given on the bjam command line, as shown in the table below.] 
+
+[table
+    [[][]]
+    [
+        [ARM, UNIX, aapcs, elf]
+        [bjam toolset = gcc architecture = arm]
+    ]
+    [
+        [MIPS (32bit), UNIX, o32, elf]
+        [bjam toolset = gcc architecture = mips1]
+    ]
+    [
+        [I386, UNIX, sysv, elf]
+        [bjam toolset = gcc architecture = x86 instruction-set = i686 address-model = 32]
+    ]
+    [
+        [I386, UNIX, sysv, elf]
+        [bjam toolset = intel architecture = x86 instruction-set = i686 address-model = 32]
+    ]
+    [
+        [I386, Windows, ms, pe]
+        [bjam toolset = msvc-9.0 architecture = x86 instruction-set = i686 address-model = 32]
+    ]
+    [
+        [PowerPc (32bit), UNIX, sysv, elf]
+        [bjam toolset = gcc architecture = power address-model = 32]
+    ]
+    [
+        [PowerPc (64bit), UNIX, sysv, elf]
+        [bjam toolset = gcc architecture = power address-model = 64]
+    ]
+    [
+        [X86_64, UNIX, sysv, elf]
+        [bjam toolset = gcc architecture = x86 instruction-set = yorksfield address-model = 64]
+    ]
+    [
+        [X86_64, UNIX, sysv, elf]
+        [bjam toolset = intel architecture = x86 instruction-set = yorksfield address-model = 64]
+    ]
+    [
+        [X86_64, Windows, ms, pe]
+        [bjam toolset = msvc-10.0 architecture = x86 instruction-set = yorksfield address-model = 64]
+    ]
+]
+[endsect]
Added: branches/release/libs/context/doc/context.qbk
==============================================================================
--- (empty file)
+++ branches/release/libs/context/doc/context.qbk	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,75 @@
+[/
+          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
+]
+
+[article Context
+    [quickbook 1.4]
+    [authors [Kowalke, Oliver]]
+    [copyright 2009 Oliver Kowalke]
+    [purpose C++ Library for swiching different user ctx]
+    [category text]
+    [license
+        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])
+    ]
+]
+
+
+[def __boost_build__ [*Boost.Build]]
+[def __boost_context__ [*Boost.Context]]
+[def __boost_fiber__ [*Boost.Coroutine]]
+[def __boost_task__ [*Boost.Task]]
+
+[template cs_example_link[link_text] [link context.examples.enumerator [link_text]]]
+[template context_link[link_text] [link context.context.context [link_text]]]
+[template stack_link[link_text] [link context.stack [link_text]]]
+[template preformance_link[link_text] [link context.performance [link_text]]]
+
+[def __context_fn__ ['context-function]]
+[def __coroutine__ ['coroutine]]
+[def __coroutines__ ['coroutines]]
+[def __coop_threads__ ['cooperative threads (userland threads)]]
+[def __fls__ ['fiber-local storage]]
+[def __guard_page__ ['guard-page]]
+[def __not_a_context__ ['not-a-context]]
+[def __stack__ [stack_link ['stack]]]
+[def __thread__ ['thread]]
+[def __threads__ ['threads]]
+[def __tls__ ['thread-local storage]]
+[def __stack_allocator__ ['StackAllocator]]
+[def __stack_allocator_concept__ ['StackAllocator concept]]
+
+[def __fcontext__ ['fcontext_t]]
+[def __ucontext__ ['ucontext_t]]
+
+[def __fls_alloc__ ['::FlsAlloc()]]
+[def __fls_free__ ['::FlsFree()]]
+
+[def __bad_alloc__ ['std::bad_alloc]]
+[def __fc_base__ ['fc_base]]
+[def __fc_limit__ ['fc_limit]]
+[def __fc_link__ ['fc_link]]
+[def __jump_fcontext__ ['jump_fcontext()]]
+[def __make_fcontext__ ['make_fcontext()]]
+[def __invalid_argument__ ['std::invalid_argument]]
+[def __stack_alloc__ ['allocate()]]
+[def __stack_dealloc__ ['deallocate()]]
+[def __stack_helper__ ['stack_helper]]
+[def __yield__ ['yield]]
+
+[def __context_ns__ ['boost::ctx]]
+
+[include overview.qbk]
+[include requirements.qbk]
+[include fcontext.qbk]
+[include stack.qbk]
+[include performance.qbk]
+[include tested.qbk]
+[include rationale.qbk]
+[include reference.qbk]
+[include todo.qbk]
+[include acknowledgements.qbk]
Added: branches/release/libs/context/doc/context.xml
==============================================================================
--- (empty file)
+++ branches/release/libs/context/doc/context.xml	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,1469 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE article PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
+<article id="context" last-revision="$Date: 2012/04/25 17:23:32 $" xmlns:xi="http://www.w3.org/2001/XInclude">
+  <title>Context</title>
+  <articleinfo>
+    <authorgroup>
+    <author>
+      <firstname>Oliver</firstname> <surname>Kowalke</surname>
+    </author>
+    </authorgroup>
+    <copyright>
+      <year>2009</year> <holder>Oliver Kowalke</holder>
+    </copyright>
+    <legalnotice>
+      <para>
+        Distributed under the Boost Software License, Version 1.0. (See accompanying
+        file LICENSE_1_0.txt or copy at <ulink url="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt>)
+      </para>
+    </legalnotice>
+    <articlepurpose>
+      C++ Library for swiching different user ctx
+    </articlepurpose>
+    <articlecategory name="category:text"></articlecategory>
+  </articleinfo>
+  <section id="context.overview">
+    <title><link linkend="context.overview">Overview</link></title>
+    <para>
+      <emphasis role="bold">Boost.Context</emphasis> is a foundational library that
+      provides a sort of cooperative multitasking on a single thread. By providing
+      an abstraction of the current execution state in the current thread, including
+      the stack (with local variables) and stack pointer, all registers and CPU flags,
+      and the instruction pointer, a <emphasis>fcontext_t</emphasis> instance represents
+      a specific point in the application's execution path. This is useful for building
+      higher-level abstractions, like <emphasis>coroutines</emphasis>, <emphasis>cooperative
+      threads (userland threads)</emphasis> or an aquivalent to <ulink url="http://msdn.microsoft.com/en-us/library/9k7k7cf0%28v=vs.80%29.aspx">C#
+      keyword <emphasis>yield</emphasis></ulink> in C++.
+    </para>
+    <para>
+      A <emphasis>fcontext_t</emphasis> provides the means to suspend the current
+      execution path and to transfer execution control, thereby permitting another
+      <emphasis>fcontext_t</emphasis> to run on the current thread. This stateful
+      transfer mechanism enables a <emphasis>fcontext_t</emphasis> to suspend execution
+      from within nested functions and, later, to resume from where it was suspended.
+      While the execution path represented by a <emphasis>fcontext_t</emphasis> only
+      runs on a single thread, it can be migrated to another thread at any given
+      time.
+    </para>
+    <para>
+      A context switch between threads requires system calls (involving the OS kernel),
+      which can cost more than thousand CPU cycles on x86 CPUs. By contrast, transferring
+      control among them requires only fewer than hundred CPU cycles because it does
+      not involve system calls as it is done within a single thread.
+    </para>
+    <para>
+      In order to use the classes and functions described here, you can either include
+      the specific headers specified by the descriptions of each class or function,
+      or include the master library header:
+    </para>
+    
+<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">/</phrase><phrase role="identifier">context</phrase><phrase role="special">/</phrase><phrase role="identifier">all</phrase><phrase role="special">.</phrase><phrase role="identifier">hpp</phrase><phrase role="special">></phrase>
+</programlisting>
+    <para>
+      which includes all the other headers in turn.
+    </para>
+    <para>
+      All functions and classes are contained in the namespace <emphasis>boost::ctx</emphasis>.
+    </para>
+  </section>
+  <section id="context.requirements">
+    <title><link linkend="context.requirements">Requirements</link></title>
+    <para>
+      <emphasis role="bold">Boost.Context</emphasis> must be built for the particular
+      compiler(s) and CPU architecture(s)s being targeted. <emphasis role="bold">Boost.Context</emphasis>
+      includes assembly code and, therefore, requires GNU AS for supported POSIX
+      systems, and MASM for Windows systems.
+    </para>
+    <important>
+      <para>
+        Please note that address-model=64 must be given to bjam command line on 64bit
+        Windows (boost-build issue).
+      </para>
+    </important>
+  </section>
+  <section id="context.context">
+    <title><link linkend="context.context">Context</link></title>
+    <para>
+      Each instance of <emphasis>fcontext_t</emphasis> represents a context (CPU
+      registers and stack space). Together with its related functions <emphasis>jump_fcontext()</emphasis>
+      and <emphasis>make_fcontext()</emphasis> it provides a execution control transfer
+      mechanism similar interface like <ulink url="http://www.kernel.org/doc/man-pages/online/pages/man2/getcontext.2.html">ucontext_t</ulink>.
+      <emphasis>fcontext_t</emphasis> and its functions are located in <emphasis>boost::ctx</emphasis>
+      and the functions are declared as extern "C".
+    </para>
+    <warning>
+      <para>
+        If <emphasis>fcontext_t</emphasis> is used in a multithreaded application,
+        it can migrated between threads, but must not reference <emphasis>thread-local
+        storage</emphasis>.
+      </para>
+    </warning>
+    <note>
+      <para>
+        If <emphasis>fiber-local storage</emphasis> is used on Windows, the user
+        is responsible for calling <emphasis>::FlsAlloc()</emphasis>, <emphasis>::FlsFree()</emphasis>.
+      </para>
+    </note>
+    <important>
+      <para>
+        The low level API is the part to port to new platforms.
+      </para>
+    </important>
+    <anchor id="context.context.executing_a_context"/>
+    <bridgehead renderas="sect3">
+      <link linkend="context.context.executing_a_context">Executing a context</link>
+    </bridgehead>
+    <para>
+      A new context supposed to execute a <emphasis>context-function</emphasis> (returning
+      void and accepting intptr_t as argument) must be initialized by function <emphasis>make_fcontext()</emphasis>.
+    </para>
+    
+<programlisting><phrase role="comment">// context-function
+</phrase><phrase role="keyword">void</phrase> <phrase role="identifier">f</phrase><phrase role="special">(</phrase> <phrase role="identifier">intptr</phrase><phrase role="special">);</phrase>
+
+<phrase role="comment">// creates and manages a protected stack (with guard page)
+</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ctx</phrase><phrase role="special">::</phrase><phrase role="identifier">protected_stack</phrase> <phrase role="identifier">stack</phrase><phrase role="special">(</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ctx</phrase><phrase role="special">::</phrase><phrase role="identifier">default_stacksize</phrase><phrase role="special">()</phrase> <phrase role="special">);</phrase>
+
+<phrase role="comment">// let fcontext_t fc use stack
+</phrase><phrase role="identifier">fc</phrase><phrase role="special">.</phrase><phrase role="identifier">fc_stack</phrase><phrase role="special">.</phrase><phrase role="identifier">base</phrase> <phrase role="special">=</phrase> <phrase role="identifier">stack</phrase><phrase role="special">.</phrase><phrase role="identifier">address</phrase><phrase role="special">();</phrase>
+<phrase role="identifier">fc</phrase><phrase role="special">.</phrase><phrase role="identifier">fc_stack</phrase><phrase role="special">.</phrase><phrase role="identifier">limit</phrase> <phrase role="special">=</phrase>
+    <phrase role="keyword">static_cast</phrase><phrase role="special"><</phrase> <phrase role="keyword">char</phrase> <phrase role="special">*</phrase> <phrase role="special">>(</phrase> <phrase role="identifier">fc</phrase><phrase role="special">.</phrase><phrase role="identifier">fc_stack</phrase><phrase role="special">.</phrase><phrase role="identifier">base</phrase><phrase role="special">)</phrase> <phrase role="special">-</phrase> <phrase role="identifier">stack</phrase><phrase role="special">.</phrase><phrase role="identifier">size</phrase><phrase role="special">();</phrase>
+
+<phrase role="comment">// context fc uses f() as context function
+</phrase><phrase role="identifier">make_fcontext</phrase><phrase role="special">(</phrase> <phrase role="special">&</phrase> <phrase role="identifier">fc</phrase><phrase role="special">,</phrase> <phrase role="identifier">f</phrase><phrase role="special">);</phrase>
+</programlisting>
+    <para>
+      <emphasis>fcontext_t</emphasis> requires a pointer to the top of the stack
+      (<emphasis>fc_base</emphasis>) as well as a pointer to the lower bound of the
+      stack (<emphasis>fc_limit</emphasis>).
+    </para>
+    <para>
+      Calling <emphasis>jump_fcontext()</emphasis> invokes the <emphasis>context-function</emphasis>
+      in a newly created context complete with registers, flags, stack and instruction
+      pointers. When control should be returned to the original calling context,
+      call <emphasis>jump_fcontext()</emphasis>. The current context information
+      (registers, flags, and stack and instruction pointers) is saved and the original
+      context information is restored. Calling <emphasis>jump_fcontext()</emphasis>
+      again resumes execution in the second context after saving the new state of
+      the original context.
+    </para>
+    
+<programlisting><phrase role="keyword">namespace</phrase> <phrase role="identifier">ctx</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ctx</phrase><phrase role="special">;</phrase>
+
+<phrase role="identifier">ctx</phrase><phrase role="special">::</phrase><phrase role="identifier">fcontext_t</phrase> <phrase role="identifier">fcm</phrase><phrase role="special">,</phrase> <phrase role="identifier">fc1</phrase><phrase role="special">,</phrase> <phrase role="identifier">fc2</phrase><phrase role="special">;</phrase>
+
+<phrase role="keyword">void</phrase> <phrase role="identifier">f1</phrase><phrase role="special">(</phrase> <phrase role="identifier">intptr_t</phrase><phrase role="special">)</phrase>
+<phrase role="special">{</phrase>
+        <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special"><<</phrase> <phrase role="string">"f1: entered"</phrase> <phrase role="special"><<</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+        <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special"><<</phrase> <phrase role="string">"f1: call jump_fcontext( & fc1, & fc2, 0)"</phrase> <phrase role="special"><<</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+        <phrase role="identifier">ctx</phrase><phrase role="special">::</phrase><phrase role="identifier">jump_fcontext</phrase><phrase role="special">(</phrase> <phrase role="special">&</phrase> <phrase role="identifier">fc1</phrase><phrase role="special">,</phrase> <phrase role="special">&</phrase> <phrase role="identifier">fc2</phrase><phrase role="special">,</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
+        <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special"><<</phrase> <phrase role="string">"f1: return"</phrase> <phrase role="special"><<</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+        <phrase role="identifier">ctx</phrase><phrase role="special">::</phrase><phrase role="identifier">jump_fcontext</phrase><phrase role="special">(</phrase> <phrase role="special">&</phrase> <phrase role="identifier">fc1</phrase><phrase role="special">,</phrase> <phrase role="special">&</phrase> <phrase role="identifier">fcm</phrase><phrase role="special">,</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
+<phrase role="special">}</phrase>
+
+<phrase role="keyword">void</phrase> <phrase role="identifier">f2</phrase><phrase role="special">(</phrase> <phrase role="identifier">intptr_t</phrase><phrase role="special">)</phrase>
+<phrase role="special">{</phrase>
+        <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special"><<</phrase> <phrase role="string">"f2: entered"</phrase> <phrase role="special"><<</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+        <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special"><<</phrase> <phrase role="string">"f2: call jump_fcontext( & fc2, & fc1, 0)"</phrase> <phrase role="special"><<</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+        <phrase role="identifier">ctx</phrase><phrase role="special">::</phrase><phrase role="identifier">jump_fcontext</phrase><phrase role="special">(</phrase> <phrase role="special">&</phrase> <phrase role="identifier">fc2</phrase><phrase role="special">,</phrase> <phrase role="special">&</phrase> <phrase role="identifier">fc1</phrase><phrase role="special">,</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
+        <phrase role="identifier">BOOST_ASSERT</phrase><phrase role="special">(</phrase> <phrase role="keyword">false</phrase> <phrase role="special">&&</phrase> <phrase role="special">!</phrase> <phrase role="string">"f2: never returns"</phrase><phrase role="special">);</phrase>
+<phrase role="special">}</phrase>
+
+<phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">argc</phrase><phrase role="special">,</phrase> <phrase role="keyword">char</phrase> <phrase role="special">*</phrase> <phrase role="identifier">argv</phrase><phrase role="special">[])</phrase>
+<phrase role="special">{</phrase>
+        <phrase role="identifier">ctx</phrase><phrase role="special">::</phrase><phrase role="identifier">stack_allocator</phrase> <phrase role="identifier">alloc1</phrase><phrase role="special">,</phrase> <phrase role="identifier">alloc2</phrase><phrase role="special">;</phrase>
+
+        <phrase role="identifier">fc1</phrase><phrase role="special">.</phrase><phrase role="identifier">fc_stack</phrase><phrase role="special">.</phrase><phrase role="identifier">base</phrase> <phrase role="special">=</phrase> <phrase role="identifier">alloc1</phrase><phrase role="special">.</phrase><phrase role="identifier">allocate</phrase><phrase role="special">(</phrase><phrase role="identifier">ctx</phrase><phrase role="special">::</phrase><phrase role="identifier">minimum_stacksize</phrase><phrase role="special">());</phrase>
+        <phrase role="identifier">fc1</phrase><phrase role="special">.</phrase><phrase role="identifier">fc_stack</phrase><phrase role="special">.</phrase><phrase role="identifier">limit</phrase> <phrase role="special">=</phrase>
+            <phrase role="keyword">static_cast</phrase><phrase role="special"><</phrase> <phrase role="keyword">char</phrase> <phrase role="special">*</phrase> <phrase role="special">>(</phrase> <phrase role="identifier">fc1</phrase><phrase role="special">.</phrase><phrase role="identifier">fc_stack</phrase><phrase role="special">.</phrase><phrase role="identifier">base</phrase><phrase role="special">)</phrase> <phrase role="special">-</phrase> <phrase role="identifier">ctx</phrase><phrase role="special">::</phrase><phrase role="identifier">minimum_stacksize</phrase><phrase role="special">();</phrase>
+        <phrase role="identifier">ctx</phrase><phrase role="special">::</phrase><phrase role="identifier">make_fcontext</phrase><phrase role="special">(</phrase> <phrase role="special">&</phrase> <phrase role="identifier">fc1</phrase><phrase role="special">,</phrase> <phrase role="identifier">f1</phrase><phrase role="special">);</phrase>
+
+        <phrase role="identifier">fc2</phrase><phrase role="special">.</phrase><phrase role="identifier">fc_stack</phrase><phrase role="special">.</phrase><phrase role="identifier">base</phrase> <phrase role="special">=</phrase> <phrase role="identifier">alloc2</phrase><phrase role="special">.</phrase><phrase role="identifier">allocate</phrase><phrase role="special">(</phrase><phrase role="identifier">ctx</phrase><phrase role="special">::</phrase><phrase role="identifier">minimum_stacksize</phrase><phrase role="special">());</phrase>
+        <phrase role="identifier">fc2</phrase><phrase role="special">.</phrase><phrase role="identifier">fc_stack</phrase><phrase role="special">.</phrase><phrase role="identifier">limit</phrase> <phrase role="special">=</phrase>
+            <phrase role="keyword">static_cast</phrase><phrase role="special"><</phrase> <phrase role="keyword">char</phrase> <phrase role="special">*</phrase> <phrase role="special">>(</phrase> <phrase role="identifier">fc2</phrase><phrase role="special">.</phrase><phrase role="identifier">fc_stack</phrase><phrase role="special">.</phrase><phrase role="identifier">base</phrase><phrase role="special">)</phrase> <phrase role="special">-</phrase> <phrase role="identifier">ctx</phrase><phrase role="special">::</phrase><phrase role="identifier">minimum_stacksize</phrase><phrase role="special">();</phrase>
+        <phrase role="identifier">ctx</phrase><phrase role="special">::</phrase><phrase role="identifier">make_fcontext</phrase><phrase role="special">(</phrase> <phrase role="special">&</phrase> <phrase role="identifier">fc2</phrase><phrase role="special">,</phrase> <phrase role="identifier">f2</phrase><phrase role="special">);</phrase>
+
+        <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special"><<</phrase> <phrase role="string">"main: call jump_fcontext( & fcm, & fc1, 0)"</phrase> <phrase role="special"><<</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+        <phrase role="identifier">ctx</phrase><phrase role="special">::</phrase><phrase role="identifier">jump_fcontext</phrase><phrase role="special">(</phrase> <phrase role="special">&</phrase> <phrase role="identifier">fcm</phrase><phrase role="special">,</phrase> <phrase role="special">&</phrase> <phrase role="identifier">fc1</phrase><phrase role="special">,</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
+
+        <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special"><<</phrase> <phrase role="string">"main: done"</phrase> <phrase role="special"><<</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+
+        <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_SUCCESS</phrase><phrase role="special">;</phrase>
+<phrase role="special">}</phrase>
+
+<phrase role="identifier">output</phrase><phrase role="special">:</phrase>
+    <phrase role="identifier">main</phrase><phrase role="special">:</phrase> <phrase role="identifier">call</phrase> <phrase role="identifier">jump_fcontext</phrase><phrase role="special">(</phrase> <phrase role="special">&</phrase> <phrase role="identifier">fcm</phrase><phrase role="special">,</phrase> <phrase role="special">&</phrase> <phrase role="identifier">fc1</phrase><phrase role="special">,</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase>
+    <phrase role="identifier">f1</phrase><phrase role="special">:</phrase> <phrase role="identifier">entered</phrase>
+    <phrase role="identifier">f1</phrase><phrase role="special">:</phrase> <phrase role="identifier">call</phrase> <phrase role="identifier">jump_fcontext</phrase><phrase role="special">(</phrase> <phrase role="special">&</phrase> <phrase role="identifier">fc1</phrase><phrase role="special">,</phrase> <phrase role="special">&</phrase> <phrase role="identifier">fc2</phrase><phrase role="special">,</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase>
+    <phrase role="identifier">f2</phrase><phrase role="special">:</phrase> <phrase role="identifier">entered</phrase>
+    <phrase role="identifier">f2</phrase><phrase role="special">:</phrase> <phrase role="identifier">call</phrase> <phrase role="identifier">jump_fcontext</phrase><phrase role="special">(</phrase> <phrase role="special">&</phrase> <phrase role="identifier">fc2</phrase><phrase role="special">,</phrase> <phrase role="special">&</phrase> <phrase role="identifier">fc1</phrase><phrase role="special">,</phrase> <phrase role="number">0</phrase><phrase role="special">)</phrase>
+    <phrase role="identifier">f1</phrase><phrase role="special">:</phrase> <phrase role="keyword">return</phrase>
+    <phrase role="identifier">main</phrase><phrase role="special">:</phrase> <phrase role="identifier">done</phrase>
+</programlisting>
+    <para>
+      First call of <emphasis>jump_fcontext()</emphasis> enters the <emphasis>context-function</emphasis>
+      <code><phrase role="identifier">f1</phrase><phrase role="special">()</phrase></code>
+      by starting context fc1 (context fcm saves the registers of <code><phrase role="identifier">main</phrase><phrase
+      role="special">()</phrase></code>). For jumping between context's fc1 and fc2
+      <code><phrase role="identifier">jump_fcontext</phrase><phrase role="special">()</phrase></code>
+      is called. Because context fcm is chained to fc1, <code><phrase role="identifier">main</phrase><phrase
+      role="special">()</phrase></code> is entered (returning from <emphasis>jump_fcontext()</emphasis>)
+      after context fc1 becomes complete (return from <code><phrase role="identifier">f1</phrase><phrase
+      role="special">()</phrase></code>).
+    </para>
+    <warning>
+      <para>
+        Calling <emphasis>jump_fcontext()</emphasis> to the same context from inside
+        the same context results in undefined behaviour.
+      </para>
+    </warning>
+    <note>
+      <para>
+        In contrast to threads, which are preemtive, <emphasis>fcontext_t</emphasis>
+        switches are cooperative (programmer controls when switch will happen). The
+        kernel is not involved in the context switches.
+      </para>
+    </note>
+    <anchor id="context.context.transfer_of_data"/>
+    <bridgehead renderas="sect3">
+      <link linkend="context.context.transfer_of_data">Transfer of data</link>
+    </bridgehead>
+    <para>
+      The third argument passed to <emphasis>jump_fcontext()</emphasis>, in one context,
+      is passed as the first argument of the <emphasis>context-function</emphasis>
+      if the context is started for the first time. In all following invocations
+      of <emphasis>jump_fcontext()</emphasis> the intptr_t passed to <emphasis>jump_fcontext()</emphasis>,
+      in one context, is returned by <emphasis>jump_fcontext()</emphasis> in the
+      other context.
+    </para>
+    
+<programlisting><phrase role="keyword">namespace</phrase> <phrase role="identifier">ctx</phrase> <phrase role="special">=</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">ctx</phrase><phrase role="special">;</phrase>
+
+<phrase role="identifier">ctx</phrase><phrase role="special">::</phrase><phrase role="identifier">fcontext_t</phrase> <phrase role="identifier">fc1</phrase><phrase role="special">,</phrase> <phrase role="identifier">fcm</phrase><phrase role="special">;</phrase>
+
+<phrase role="keyword">typedef</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">pair</phrase><phrase role="special"><</phrase> <phrase role="keyword">int</phrase><phrase role="special">,</phrase> <phrase role="keyword">int</phrase> <phrase role="special">></phrase>   <phrase role="identifier">pair_t</phrase><phrase role="special">;</phrase>
+
+<phrase role="keyword">void</phrase> <phrase role="identifier">f1</phrase><phrase role="special">(</phrase> <phrase role="identifier">intptr_t</phrase> <phrase role="identifier">param</phrase><phrase role="special">)</phrase>
+<phrase role="special">{</phrase>
+    <phrase role="identifier">pair_t</phrase> <phrase role="special">*</phrase> <phrase role="identifier">p</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase> <phrase role="identifier">pair_t</phrase> <phrase role="special">*)</phrase> <phrase role="identifier">param</phrase><phrase role="special">;</phrase>
+
+    <phrase role="identifier">p</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase> <phrase role="identifier">pair_t</phrase> <phrase role="special">*)</phrase> <phrase role="identifier">ctx</phrase><phrase role="special">::</phrase><phrase role="identifier">jump_fcontext</phrase><phrase role="special">(</phrase> <phrase role="special">&</phrase> <phrase role="identifier">fc1</phrase><phrase role="special">,</phrase> <phrase role="special">&</phrase> <phrase role="identifier">fcm</phrase><phrase role="special">,</phrase> <phrase role="special">(</phrase> <phrase role="identifier">intptr_t</phrase><phrase role="special">)</phrase> <phrase role="special">(</phrase> <phrase role="identifier">p</phrase><phrase role="special">-></phrase><phrase role="identifier">first</phrase> <phrase role="special">+</phrase> <phrase role="identifier">p</phrase><phrase role="special">-></phrase><phrase role="identifier">second</phrase><phrase role="special">)</phrase> <phrase role="special
">);</phrase>
+
+    <phrase role="identifier">ctx</phrase><phrase role="special">::</phrase><phrase role="identifier">jump_fcontext</phrase><phrase role="special">(</phrase> <phrase role="special">&</phrase> <phrase role="identifier">fc1</phrase><phrase role="special">,</phrase> <phrase role="special">&</phrase> <phrase role="identifier">fcm</phrase><phrase role="special">,</phrase> <phrase role="special">(</phrase> <phrase role="identifier">intptr_t</phrase><phrase role="special">)</phrase> <phrase role="special">(</phrase> <phrase role="identifier">p</phrase><phrase role="special">-></phrase><phrase role="identifier">first</phrase> <phrase role="special">+</phrase> <phrase role="identifier">p</phrase><phrase role="special">-></phrase><phrase role="identifier">second</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+<phrase role="special">}</phrase>
+
+<phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">(</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">argc</phrase><phrase role="special">,</phrase> <phrase role="keyword">char</phrase> <phrase role="special">*</phrase> <phrase role="identifier">argv</phrase><phrase role="special">[])</phrase>
+<phrase role="special">{</phrase>
+    <phrase role="identifier">ctx</phrase><phrase role="special">::</phrase><phrase role="identifier">stack_allocator</phrase> <phrase role="identifier">alloc</phrase><phrase role="special">;</phrase>
+
+    <phrase role="identifier">fc1</phrase><phrase role="special">.</phrase><phrase role="identifier">fc_stack</phrase><phrase role="special">.</phrase><phrase role="identifier">base</phrase> <phrase role="special">=</phrase> <phrase role="identifier">alloc</phrase><phrase role="special">.</phrase><phrase role="identifier">allocate</phrase><phrase role="special">(</phrase><phrase role="identifier">ctx</phrase><phrase role="special">::</phrase><phrase role="identifier">minimum_stacksize</phrase><phrase role="special">());</phrase>
+    <phrase role="identifier">fc1</phrase><phrase role="special">.</phrase><phrase role="identifier">fc_stack</phrase><phrase role="special">.</phrase><phrase role="identifier">limit</phrase> <phrase role="special">=</phrase>
+        <phrase role="keyword">static_cast</phrase><phrase role="special"><</phrase> <phrase role="keyword">char</phrase> <phrase role="special">*</phrase> <phrase role="special">>(</phrase> <phrase role="identifier">fc1</phrase><phrase role="special">.</phrase><phrase role="identifier">fc_stack</phrase><phrase role="special">.</phrase><phrase role="identifier">base</phrase><phrase role="special">)</phrase> <phrase role="special">-</phrase> <phrase role="identifier">ctx</phrase><phrase role="special">::</phrase><phrase role="identifier">minimum_stacksize</phrase><phrase role="special">();</phrase>
+    <phrase role="identifier">fc1</phrase><phrase role="special">.</phrase><phrase role="identifier">fc_link</phrase> <phrase role="special">=</phrase> <phrase role="special">&</phrase> <phrase role="identifier">fcm</phrase><phrase role="special">;</phrase>
+    <phrase role="identifier">pair_t</phrase> <phrase role="identifier">p</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">make_pair</phrase><phrase role="special">(</phrase> <phrase role="number">2</phrase><phrase role="special">,</phrase> <phrase role="number">7</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+    <phrase role="identifier">ctx</phrase><phrase role="special">::</phrase><phrase role="identifier">make_fcontext</phrase><phrase role="special">(</phrase> <phrase role="special">&</phrase> <phrase role="identifier">fc1</phrase><phrase role="special">,</phrase> <phrase role="identifier">f1</phrase><phrase role="special">);</phrase>
+
+    <phrase role="keyword">int</phrase> <phrase role="identifier">res</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase> <phrase role="keyword">int</phrase><phrase role="special">)</phrase> <phrase role="identifier">ctx</phrase><phrase role="special">::</phrase><phrase role="identifier">jump_fcontext</phrase><phrase role="special">(</phrase> <phrase role="special">&</phrase> <phrase role="identifier">fcm</phrase><phrase role="special">,</phrase> <phrase role="special">&</phrase> <phrase role="identifier">fc1</phrase><phrase role="special">,</phrase> <phrase role="special">(</phrase> <phrase role="identifier">intptr_t</phrase><phrase role="special">)</phrase> <phrase role="special">&</phrase> <phrase role="identifier">p</phrase><phrase role="special">);</phrase>
+    <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special"><<</phrase> <phrase role="identifier">p</phrase><phrase role="special">.</phrase><phrase role="identifier">first</phrase> <phrase role="special"><<</phrase> <phrase role="string">" + "</phrase> <phrase role="special"><<</phrase> <phrase role="identifier">p</phrase><phrase role="special">.</phrase><phrase role="identifier">second</phrase> <phrase role="special"><<</phrase> <phrase role="string">" == "</phrase> <phrase role="special"><<</phrase> <phrase role="identifier">res</phrase> <phrase role="special"><<</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+
+    <phrase role="identifier">p</phrase> <phrase role="special">=</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">make_pair</phrase><phrase role="special">(</phrase> <phrase role="number">5</phrase><phrase role="special">,</phrase> <phrase role="number">6</phrase><phrase role="special">);</phrase>
+    <phrase role="identifier">res</phrase> <phrase role="special">=</phrase> <phrase role="special">(</phrase> <phrase role="keyword">int</phrase><phrase role="special">)</phrase> <phrase role="identifier">ctx</phrase><phrase role="special">::</phrase><phrase role="identifier">jump_fcontext</phrase><phrase role="special">(</phrase> <phrase role="special">&</phrase> <phrase role="identifier">fcm</phrase><phrase role="special">,</phrase> <phrase role="special">&</phrase> <phrase role="identifier">fc1</phrase><phrase role="special">,</phrase> <phrase role="special">(</phrase> <phrase role="identifier">intptr_t</phrase><phrase role="special">)</phrase> <phrase role="special">&</phrase> <phrase role="identifier">p</phrase><phrase role="special">);</phrase>
+    <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special"><<</phrase> <phrase role="identifier">p</phrase><phrase role="special">.</phrase><phrase role="identifier">first</phrase> <phrase role="special"><<</phrase> <phrase role="string">" + "</phrase> <phrase role="special"><<</phrase> <phrase role="identifier">p</phrase><phrase role="special">.</phrase><phrase role="identifier">second</phrase> <phrase role="special"><<</phrase> <phrase role="string">" == "</phrase> <phrase role="special"><<</phrase> <phrase role="identifier">res</phrase> <phrase role="special"><<</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+
+    <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special"><<</phrase> <phrase role="string">"main: done"</phrase> <phrase role="special"><<</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
+
+    <phrase role="keyword">return</phrase> <phrase role="identifier">EXIT_SUCCESS</phrase><phrase role="special">;</phrase>
+<phrase role="special">}</phrase>
+
+<phrase role="identifier">output</phrase><phrase role="special">:</phrase>
+    <phrase role="number">2</phrase> <phrase role="special">+</phrase> <phrase role="number">7</phrase> <phrase role="special">==</phrase> <phrase role="number">9</phrase>
+    <phrase role="number">5</phrase> <phrase role="special">+</phrase> <phrase role="number">6</phrase> <phrase role="special">==</phrase> <phrase role="number">11</phrase>
+    <phrase role="identifier">main</phrase><phrase role="special">:</phrase> <phrase role="identifier">done</phrase>
+</programlisting>
+    <anchor id="context.context.exceptions_in__emphasis_context_function__emphasis_"/>
+    <bridgehead renderas="sect3">
+      <link linkend="context.context.exceptions_in__emphasis_context_function__emphasis_">Exceptions
+      in <emphasis>context-function</emphasis></link>
+    </bridgehead>
+    <para>
+      If the <emphasis>context-function</emphasis> emits an exception, the application
+      will terminate.
+    </para>
+    <anchor id="context.context.preserving_floating_point_registers"/>
+    <bridgehead renderas="sect3">
+      <link linkend="context.context.preserving_floating_point_registers">Preserving
+      floating point registers</link>
+    </bridgehead>
+    <para>
+      Preserving the floating point registers increases the cycle count for a context
+      switch (see performance tests). The foruth argument of <emphasis>jump_fcontext()</emphasis>
+      controls if fpu registers should be preserved by the context jump.
+    </para>
+    <important>
+      <para>
+        The use of the fpu controling argument of <emphasis>jump_fcontext()</emphasis>
+        must be consistent in the application. Otherwise the behaviour is undefined.
+      </para>
+    </important>
+    <anchor id="context.context.stack_unwinding"/>
+    <bridgehead renderas="sect3">
+      <link linkend="context.context.stack_unwinding">Stack unwinding</link>
+    </bridgehead>
+    <para>
+      Sometimes it is necessary to unwind the stack of an unfinished context to destroy
+      local stack variables so they can release allocated resources (RAII pattern).
+      The user is responsible for this task.
+    </para>
+    <section id="context.context.boost_fcontext">
+      <title><link linkend="context.context.boost_fcontext">Struct <code><phrase
+      role="identifier">fcontext_t</phrase></code> and related functions</link></title>
+      
+<programlisting><phrase role="keyword">struct</phrase> <phrase role="identifier">stack_t</phrase>
+<phrase role="special">{</phrase>
+    <phrase role="keyword">void</phrase>    <phrase role="special">*</phrase>   <phrase role="identifier">base</phrase><phrase role="special">;</phrase>
+    <phrase role="keyword">void</phrase>    <phrase role="special">*</phrase>   <phrase role="identifier">limit</phrase><phrase role="special">;</phrase>
+<phrase role="special">};</phrase>
+
+<phrase role="keyword">struct</phrase> <phrase role="identifier">fcontext_t</phrase>
+<phrase role="special">{</phrase>
+    <phrase role="special"><</phrase> <phrase role="identifier">platform</phrase> <phrase role="identifier">specific</phrase> <phrase role="special">></phrase>
+
+    <phrase role="identifier">stack_t</phrase>  <phrase role="identifier">fc_stack</phrase><phrase role="special">;</phrase>
+<phrase role="special">};</phrase>
+
+<phrase role="identifier">intptr_t</phrase> <phrase role="identifier">jump_fcontext</phrase><phrase role="special">(</phrase> <phrase role="identifier">fcontext_t</phrase> <phrase role="special">*</phrase> <phrase role="identifier">ofc</phrase><phrase role="special">,</phrase> <phrase role="identifier">fcontext_t</phrase> <phrase role="keyword">const</phrase><phrase role="special">*</phrase> <phrase role="identifier">nfc</phrase><phrase role="special">,</phrase> <phrase role="identifier">intptr_t</phrase> <phrase role="identifier">vp</phrase><phrase role="special">);</phrase>
+<phrase role="keyword">void</phrase> <phrase role="identifier">make_fcontext</phrase><phrase role="special">(</phrase> <phrase role="identifier">fcontext_t</phrase> <phrase role="special">*</phrase> <phrase role="identifier">fc</phrase><phrase role="special">,</phrase> <phrase role="keyword">void</phrase><phrase role="special">(*</phrase> <phrase role="identifier">fn</phrase><phrase role="special">)(</phrase><phrase role="identifier">intptr_t</phrase><phrase role="special">)</phrase> <phrase role="special">);</phrase>
+</programlisting>
+      <anchor id="context.context.boost_fcontext._code__phrase_role__identifier__base__phrase___code_"/>
+      <bridgehead renderas="sect4">
+        <link linkend="context.context.boost_fcontext._code__phrase_role__identifier__base__phrase___code_"><code><phrase
+        role="identifier">base</phrase></code></link>
+      </bridgehead>
+      <variablelist>
+        <title></title>
+        <varlistentry>
+          <term>Member:</term>
+          <listitem>
+            <para>
+              Pointer to the top of the stack.
+            </para>
+          </listitem>
+        </varlistentry>
+      </variablelist>
+      <anchor id="context.context.boost_fcontext._code__phrase_role__identifier__limit__phrase___code_"/>
+      <bridgehead renderas="sect4">
+        <link linkend="context.context.boost_fcontext._code__phrase_role__identifier__limit__phrase___code_"><code><phrase
+        role="identifier">limit</phrase></code></link>
+      </bridgehead>
+      <variablelist>
+        <title></title>
+        <varlistentry>
+          <term>Member:</term>
+          <listitem>
+            <para>
+              Pointer to the bottom of the stack.
+            </para>
+          </listitem>
+        </varlistentry>
+      </variablelist>
+      <anchor id="context.context.boost_fcontext._code__phrase_role__identifier__fc_stack__phrase___code_"/>
+      <bridgehead renderas="sect4">
+        <link linkend="context.context.boost_fcontext._code__phrase_role__identifier__fc_stack__phrase___code_"><code><phrase
+        role="identifier">fc_stack</phrase></code></link>
+      </bridgehead>
+      <variablelist>
+        <title></title>
+        <varlistentry>
+          <term>Member:</term>
+          <listitem>
+            <para>
+              Tracks the memory for the context's stack.
+            </para>
+          </listitem>
+        </varlistentry>
+      </variablelist>
+      <anchor id="context.context.boost_fcontext._code__phrase_role__identifier__intptr_t__phrase___phrase_role__identifier__jump_fcontext__phrase__phrase_role__special_____phrase___phrase_role__identifier__fcontext_t__phrase___phrase_role__special_____phrase___phrase_role__identifier__ofc__phrase__phrase_role__special_____phrase___phrase_role__identifier__fcontext_t__phrase___phrase_role__special_____phrase___phrase_role__identifier__nfc__phrase__phrase_role__special_____phrase___phrase_role__identifier__intptr_t__phrase___phrase_role__identifier__p__phrase__phrase_role__special_____phrase___phrase_role__keyword__bool__phrase___phrase_role__identifier__preserve_fpu__phrase__phrase_role__special_____phrase___code_"/>
+      <bridgehead renderas="sect4">
+        <link linkend="context.context.boost_fcontext._code__phrase_role__identifier__intptr_t__phrase___phrase_role__identifier__jump_fcontext__phrase__phrase_role__special_____phrase___phrase_role__identifier__fcontext_t__phrase___phrase_role__special_____phrase___phrase_role__identifier__ofc__phrase__phrase_role__special_____phrase___phrase_role__identifier__fcontext_t__phrase___phrase_role__special_____phrase___phrase_role__identifier__nfc__phrase__phrase_role__special_____phrase___phrase_role__identifier__intptr_t__phrase___phrase_role__identifier__p__phrase__phrase_role__special_____phrase___phrase_role__keyword__bool__phrase___phrase_role__identifier__preserve_fpu__phrase__phrase_role__special_____phrase___code_"><code><phrase
+        role="identifier">intptr_t</phrase> <phrase role="identifier">jump_fcontext</phrase><phrase
+        role="special">(</phrase> <phrase role="identifier">fcontext_t</phrase>
+        <phrase role="special">*</phrase> <phrase role="identifier">ofc</phrase><phrase
+        role="special">,</phrase> <phrase role="identifier">fcontext_t</phrase>
+        <phrase role="special">*</phrase> <phrase role="identifier">nfc</phrase><phrase
+        role="special">,</phrase> <phrase role="identifier">intptr_t</phrase> <phrase
+        role="identifier">p</phrase><phrase role="special">,</phrase> <phrase role="keyword">bool</phrase>
+        <phrase role="identifier">preserve_fpu</phrase><phrase role="special">)</phrase></code></link>
+      </bridgehead>
+      <variablelist>
+        <title></title>
+        <varlistentry>
+          <term>Effects:</term>
+          <listitem>
+            <para>
+              Stores the current context data (stack pointer, instruction pointer,
+              and CPU registers) to <code><phrase role="special">*</phrase><phrase
+              role="identifier">ofc</phrase></code> and restores the context data
+              from <code><phrase role="special">*</phrase><phrase role="identifier">nfc</phrase></code>,
+              which implies jumping to <code><phrase role="special">*</phrase><phrase
+              role="identifier">nfc</phrase></code>'s execution context. The intptr_t
+              argument, <code><phrase role="identifier">p</phrase></code>, is passed
+              to the current context to be returned by the most recent call to <code><phrase
+              role="identifier">jump_fcontext</phrase><phrase role="special">()</phrase></code>
+              in the same thread. The last argument controls if fpu registers have
+              to be preserved.
+            </para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>Returns:</term>
+          <listitem>
+            <para>
+              The third pointer argument passed to the most recent call to <code><phrase
+              role="identifier">jump_fcontext</phrase><phrase role="special">()</phrase></code>,
+              if any.
+            </para>
+          </listitem>
+        </varlistentry>
+      </variablelist>
+      <anchor id="context.context.boost_fcontext._code__phrase_role__keyword__void__phrase___phrase_role__identifier__make_fcontext__phrase__phrase_role__special_____phrase___phrase_role__identifier__fcontext_t__phrase___phrase_role__special_____phrase___phrase_role__identifier__fc__phrase__phrase_role__special_____phrase___phrase_role__keyword__void__phrase__phrase_role__special______phrase__phrase_role__identifier__fn__phrase__phrase_role__special______phrase__phrase_role__identifier__intptr_t__phrase__phrase_role__special______phrase___code_"/>
+      <bridgehead renderas="sect4">
+        <link linkend="context.context.boost_fcontext._code__phrase_role__keyword__void__phrase___phrase_role__identifier__make_fcontext__phrase__phrase_role__special_____phrase___phrase_role__identifier__fcontext_t__phrase___phrase_role__special_____phrase___phrase_role__identifier__fc__phrase__phrase_role__special_____phrase___phrase_role__keyword__void__phrase__phrase_role__special______phrase__phrase_role__identifier__fn__phrase__phrase_role__special______phrase__phrase_role__identifier__intptr_t__phrase__phrase_role__special______phrase___code_"><code><phrase
+        role="keyword">void</phrase> <phrase role="identifier">make_fcontext</phrase><phrase
+        role="special">(</phrase> <phrase role="identifier">fcontext_t</phrase>
+        <phrase role="special">*</phrase> <phrase role="identifier">fc</phrase><phrase
+        role="special">,</phrase> <phrase role="keyword">void</phrase><phrase role="special">(*</phrase><phrase
+        role="identifier">fn</phrase><phrase role="special">)(</phrase><phrase role="identifier">intptr_t</phrase><phrase
+        role="special">))</phrase></code></link>
+      </bridgehead>
+      <variablelist>
+        <title></title>
+        <varlistentry>
+          <term>Precondition:</term>
+          <listitem>
+            <para>
+              A stack is applied to <code><phrase role="special">*</phrase><phrase
+              role="identifier">fc</phrase></code> before <code><phrase role="identifier">make_fcontext</phrase><phrase
+              role="special">()</phrase></code> is called.
+            </para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>Effects:</term>
+          <listitem>
+            <para>
+              Modifies <code><phrase role="special">*</phrase><phrase role="identifier">fc</phrase></code>
+              in order to execute <code><phrase role="identifier">fn</phrase></code>
+              when the context is activated next.
+            </para>
+          </listitem>
+        </varlistentry>
+      </variablelist>
+    </section>
+  </section>
+  <section id="context.stack">
+    <title><link linkend="context.stack">Stack allocation</link></title>
+    <para>
+      A <emphasis>fcontext_t</emphasis> requires a stack which will be allocated/deallocated
+      by a <emphasis>StackAllocator</emphasis>. <emphasis role="bold">Boost.Context</emphasis>
+      uses <code><phrase role="identifier">stack_allocator</phrase></code> by default
+      but a customized <code><phrase role="identifier">stack</phrase> <phrase role="identifier">allocator</phrase></code>
+      can be passed to the context constructor instead. If a context is constructed
+      it invokes <emphasis>allocate()</emphasis> function and by its destruction
+      the stack gets released by <emphasis>deallocate()</emphasis>.
+    </para>
+    <anchor id="context.stack._emphasis_stackallocator_concept__emphasis_"/>
+    <bridgehead renderas="sect3">
+      <link linkend="context.stack._emphasis_stackallocator_concept__emphasis_"><emphasis>StackAllocator
+      concept</emphasis></link>
+    </bridgehead>
+    <para>
+      A <emphasis>StackAllocator</emphasis> must satisfy the <emphasis>StackAllocator
+      concept</emphasis> requirements shown in the following table, in which <code><phrase
+      role="identifier">a</phrase></code> is an object of a <emphasis>StackAllocator</emphasis>
+      type, <code><phrase role="identifier">p</phrase></code> is a <code><phrase
+      role="keyword">void</phrase> <phrase role="special">*</phrase></code>, and
+      <code><phrase role="identifier">s</phrase></code> is a <code><phrase role="identifier">std</phrase><phrase
+      role="special">::</phrase><phrase role="identifier">size_t</phrase></code>:
+    </para>
+    <informaltable frame="all">
+      <tgroup cols="3">
+        <thead>
+          <row>
+            <entry>
+              <para>
+                expression
+              </para>
+            </entry>
+            <entry>
+              <para>
+                return type
+              </para>
+            </entry>
+            <entry>
+              <para>
+                notes
+              </para>
+            </entry>
+          </row>
+        </thead>
+        <tbody>
+          <row>
+            <entry>
+              <para>
+                <code><phrase role="identifier">a</phrase><phrase role="special">.</phrase><phrase
+                role="identifier">allocate</phrase><phrase role="special">(</phrase>
+                <phrase role="identifier">s</phrase><phrase role="special">)</phrase></code>
+              </para>
+            </entry>
+            <entry>
+              <para>
+                <code><phrase role="keyword">void</phrase> <phrase role="special">*</phrase></code>
+              </para>
+            </entry>
+            <entry>
+              <para>
+                returns a pointer to <code><phrase role="identifier">s</phrase></code>
+                bytes allocated from the stack
+              </para>
+            </entry>
+          </row>
+          <row>
+            <entry>
+              <para>
+                <code><phrase role="identifier">a</phrase><phrase role="special">.</phrase><phrase
+                role="identifier">deallocate</phrase><phrase role="special">(</phrase>
+                <phrase role="identifier">p</phrase><phrase role="special">,</phrase>
+                <phrase role="identifier">s</phrase><phrase role="special">)</phrase></code>
+              </para>
+            </entry>
+            <entry>
+              <para>
+                <code><phrase role="keyword">void</phrase></code>
+              </para>
+            </entry>
+            <entry>
+              <para>
+                deallocates <code><phrase role="identifier">s</phrase></code> bytes
+                of memory beginning at <code><phrase role="identifier">p</phrase></code>,
+                a pointer previously returned by <code><phrase role="identifier">a</phrase><phrase
+                role="special">.</phrase><phrase role="identifier">allocate</phrase><phrase
+                role="special">()</phrase></code>
+              </para>
+            </entry>
+          </row>
+        </tbody>
+      </tgroup>
+    </informaltable>
+    <important>
+      <para>
+        The implementation of <code><phrase role="identifier">allocate</phrase><phrase
+        role="special">()</phrase></code> might include logic to protect against
+        exceeding the context's available stack size rather than leaving it as undefined
+        behaviour.
+      </para>
+    </important>
+    <important>
+      <para>
+        Calling <code><phrase role="identifier">deallocate</phrase><phrase role="special">()</phrase></code>
+        with a pointer not returned by <code><phrase role="identifier">allocate</phrase><phrase
+        role="special">()</phrase></code> results in undefined behaviour.
+      </para>
+    </important>
+    <note>
+      <para>
+        The stack is not required to be aligned; alignment takes place inside <code><phrase
+        role="identifier">make_fcontext</phrase><phrase role="special">()</phrase></code>.
+      </para>
+    </note>
+    <section id="context.stack.stack_allocator">
+      <title><link linkend="context.stack.stack_allocator">Class <code><phrase role="identifier">stack_allocator</phrase></code></link></title>
+      <para>
+        <emphasis role="bold">Boost.Context</emphasis> provides a <emphasis>StackAllocator</emphasis>
+        <code><phrase role="identifier">stack_allocator</phrase></code> which models
+        the <emphasis>StackAllocator concept</emphasis> concept. It appends a <emphasis>guard-page</emphasis>
+        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.
+      </para>
+    </section>
+    <section id="context.stack.stack_helper">
+      <title><link linkend="context.stack.stack_helper">Helper functions</link></title>
+      <para>
+        <emphasis role="bold">Boost.Context</emphasis> provides easy access to the
+        stack related limits defined by the environment.
+      </para>
+      
+<programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">default_stacksize</phrase><phrase role="special">();</phrase>
+
+<phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">minimum_stacksize</phrase><phrase role="special">();</phrase>
+
+<phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">maximum_stacksize</phrase><phrase role="special">();</phrase>
+
+<phrase role="keyword">bool</phrase> <phrase role="identifier">is_stack_unbound</phrase><phrase role="special">();</phrase>
+
+<phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">pagesize</phrase><phrase role="special">();</phrase>
+
+<phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">page_count</phrase><phrase role="special">(</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase> <phrase role="identifier">stacksize</phrase><phrase role="special">);</phrase>
+</programlisting>
+      <anchor id="context.stack.stack_helper._code__phrase_role__identifier__std__phrase__phrase_role__special______phrase__phrase_role__identifier__size_t__phrase___phrase_role__identifier__default_stacksize__phrase__phrase_role__special______phrase___code_"/>
+      <bridgehead renderas="sect4">
+        <link linkend="context.stack.stack_helper._code__phrase_role__identifier__std__phrase__phrase_role__special______phrase__phrase_role__identifier__size_t__phrase___phrase_role__identifier__default_stacksize__phrase__phrase_role__special______phrase___code_"><code><phrase
+        role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase>
+        <phrase role="identifier">default_stacksize</phrase><phrase role="special">()</phrase></code></link>
+      </bridgehead>
+      <variablelist>
+        <title></title>
+        <varlistentry>
+          <term>Returns:</term>
+          <listitem>
+            <para>
+              Returns a default stack size, which may be platform specific. The present
+              implementation returns a value of 256 kB.
+            </para>
+          </listitem>
+        </varlistentry>
+      </variablelist>
+      <anchor id="context.stack.stack_helper._code__phrase_role__identifier__std__phrase__phrase_role__special______phrase__phrase_role__identifier__size_t__phrase___phrase_role__identifier__minimum_stacksize__phrase__phrase_role__special______phrase___code_"/>
+      <bridgehead renderas="sect4">
+        <link linkend="context.stack.stack_helper._code__phrase_role__identifier__std__phrase__phrase_role__special______phrase__phrase_role__identifier__size_t__phrase___phrase_role__identifier__minimum_stacksize__phrase__phrase_role__special______phrase___code_"><code><phrase
+        role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase>
+        <phrase role="identifier">minimum_stacksize</phrase><phrase role="special">()</phrase></code></link>
+      </bridgehead>
+      <variablelist>
+        <title></title>
+        <varlistentry>
+          <term>Returns:</term>
+          <listitem>
+            <para>
+              Returns the minimum size in bytes of stack defined by the environment.
+            </para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>Throws:</term>
+          <listitem>
+            <para>
+              Nothing.
+            </para>
+          </listitem>
+        </varlistentry>
+      </variablelist>
+      <anchor id="context.stack.stack_helper._code__phrase_role__identifier__std__phrase__phrase_role__special______phrase__phrase_role__identifier__size_t__phrase___phrase_role__identifier__maximum_stacksize__phrase__phrase_role__special______phrase___code_"/>
+      <bridgehead renderas="sect4">
+        <link linkend="context.stack.stack_helper._code__phrase_role__identifier__std__phrase__phrase_role__special______phrase__phrase_role__identifier__size_t__phrase___phrase_role__identifier__maximum_stacksize__phrase__phrase_role__special______phrase___code_"><code><phrase
+        role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase>
+        <phrase role="identifier">maximum_stacksize</phrase><phrase role="special">()</phrase></code></link>
+      </bridgehead>
+      <variablelist>
+        <title></title>
+        <varlistentry>
+          <term>Preconditions:</term>
+          <listitem>
+            <para>
+              <code><phrase role="identifier">is_stack_unbound</phrase><phrase role="special">()</phrase></code>
+              returns <code><phrase role="keyword">false</phrase></code>.
+            </para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>Returns:</term>
+          <listitem>
+            <para>
+              Returns the maximum size in bytes of stack defined by the environment.
+            </para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>Throws:</term>
+          <listitem>
+            <para>
+              Nothing.
+            </para>
+          </listitem>
+        </varlistentry>
+      </variablelist>
+      <anchor id="context.stack.stack_helper._code__phrase_role__keyword__bool__phrase___phrase_role__identifier__is_stack_unbound__phrase__phrase_role__special______phrase___code_"/>
+      <bridgehead renderas="sect4">
+        <link linkend="context.stack.stack_helper._code__phrase_role__keyword__bool__phrase___phrase_role__identifier__is_stack_unbound__phrase__phrase_role__special______phrase___code_"><code><phrase
+        role="keyword">bool</phrase> <phrase role="identifier">is_stack_unbound</phrase><phrase
+        role="special">()</phrase></code></link>
+      </bridgehead>
+      <variablelist>
+        <title></title>
+        <varlistentry>
+          <term>Returns:</term>
+          <listitem>
+            <para>
+              Returns <code><phrase role="keyword">true</phrase></code> if the environment
+              defines no limit for the size of a stack.
+            </para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>Throws:</term>
+          <listitem>
+            <para>
+              Nothing.
+            </para>
+          </listitem>
+        </varlistentry>
+      </variablelist>
+      <anchor id="context.stack.stack_helper._code__phrase_role__identifier__std__phrase__phrase_role__special______phrase__phrase_role__identifier__size_t__phrase___phrase_role__identifier__pagesize__phrase__phrase_role__special______phrase___code_"/>
+      <bridgehead renderas="sect4">
+        <link linkend="context.stack.stack_helper._code__phrase_role__identifier__std__phrase__phrase_role__special______phrase__phrase_role__identifier__size_t__phrase___phrase_role__identifier__pagesize__phrase__phrase_role__special______phrase___code_"><code><phrase
+        role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase>
+        <phrase role="identifier">pagesize</phrase><phrase role="special">()</phrase></code></link>
+      </bridgehead>
+      <variablelist>
+        <title></title>
+        <varlistentry>
+          <term>Returns:</term>
+          <listitem>
+            <para>
+              Returns how many bytes the operating system allocates for one page.
+            </para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>Throws:</term>
+          <listitem>
+            <para>
+              Nothing.
+            </para>
+          </listitem>
+        </varlistentry>
+      </variablelist>
+      <anchor id="context.stack.stack_helper._code__phrase_role__identifier__std__phrase__phrase_role__special______phrase__phrase_role__identifier__size_t__phrase___phrase_role__identifier__page_count__phrase__phrase_role__special_____phrase___phrase_role__identifier__std__phrase__phrase_role__special______phrase__phrase_role__identifier__size_t__phrase___phrase_role__identifier__stacksize__phrase__phrase_role__special_____phrase___code_"/>
+      <bridgehead renderas="sect4">
+        <link linkend="context.stack.stack_helper._code__phrase_role__identifier__std__phrase__phrase_role__special______phrase__phrase_role__identifier__size_t__phrase___phrase_role__identifier__page_count__phrase__phrase_role__special_____phrase___phrase_role__identifier__std__phrase__phrase_role__special______phrase__phrase_role__identifier__size_t__phrase___phrase_role__identifier__stacksize__phrase__phrase_role__special_____phrase___code_"><code><phrase
+        role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">size_t</phrase>
+        <phrase role="identifier">page_count</phrase><phrase role="special">(</phrase>
+        <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase
+        role="identifier">size_t</phrase> <phrase role="identifier">stacksize</phrase><phrase
+        role="special">)</phrase></code></link>
+      </bridgehead>
+      <variablelist>
+        <title></title>
+        <varlistentry>
+          <term>Returns:</term>
+          <listitem>
+            <para>
+              Returns how many pages have to be allocated for a stack of <code><phrase
+              role="identifier">stacksize</phrase></code> bytes.
+            </para>
+          </listitem>
+        </varlistentry>
+        <varlistentry>
+          <term>Throws:</term>
+          <listitem>
+            <para>
+              Nothing.
+            </para>
+          </listitem>
+        </varlistentry>
+      </variablelist>
+    </section>
+  </section>
+  <section id="context.performance">
+    <title><link linkend="context.performance">Performance</link></title>
+    <para>
+      Performance of <emphasis role="bold">Boost.Context</emphasis> was measured
+      on the platforms shown in the following table. Performance measurements were
+      taken using <code><phrase role="identifier">rdtsc</phrase></code>, with overhead
+      corrections, on x86 platforms. In each case, stack protection was active, cache
+      warm-up was accounted for, and the one running thread was pinned to a single
+      CPU. The code was compiled using the build options, 'variant = release cxxflags
+      = -DBOOST_DISABLE_ASSERTS'.
+    </para>
+    <para>
+      The numbers in the table are the number of cycles per iteration, based upon
+      an average computed over 10 iterations.
+    </para>
+    <table frame="all">
+      <title>Perfomance of context switch</title>
+      <tgroup cols="5">
+        <thead>
+          <row>
+            <entry>
+              <para>
+                Platform
+              </para>
+            </entry>
+            <entry>
+              <para>
+                ucontext_t
+              </para>
+            </entry>
+            <entry>
+              <para>
+                fcontext_t with fpu
+              </para>
+            </entry>
+            <entry>
+              <para>
+                fcontext_t without fpu
+              </para>
+            </entry>
+            <entry>
+              <para>
+                boost::function
+              </para>
+            </entry>
+          </row>
+        </thead>
+        <tbody>
+          <row>
+            <entry>
+              <para>
+                AMD Athlon 64 DualCore 4400+ (32bit Linux)
+              </para>
+            </entry>
+            <entry>
+              <para>
+                846 cycles
+              </para>
+            </entry>
+            <entry>
+              <para>
+                65 cycles
+              </para>
+            </entry>
+            <entry>
+              <para>
+                46 cycles
+              </para>
+            </entry>
+            <entry>
+              <para>
+                43 cycles
+              </para>
+            </entry>
+          </row>
+          <row>
+            <entry>
+              <para>
+                Intel Core2 Q6700 (64bit Linux)
+              </para>
+            </entry>
+            <entry>
+              <para>
+                1472 cycles
+              </para>
+            </entry>
+            <entry>
+              <para>
+                172 cycles
+              </para>
+            </entry>
+            <entry>
+              <para>
+                63 cycles
+              </para>
+            </entry>
+            <entry>
+              <para>
+                60 cycles
+              </para>
+            </entry>
+          </row>
+        </tbody>
+      </tgroup>
+    </table>
+  </section>
+  <section id="context.tested">
+    <title><link linkend="context.tested">Tested Platforms</link></title>
+    <informaltable frame="all">
+      <tgroup cols="4">
+        <thead>
+          <row>
+            <entry>
+              <para>
+                Platform
+              </para>
+            </entry>
+            <entry>
+              <para>
+                OS
+              </para>
+            </entry>
+            <entry>
+              <para>
+                Compiler
+              </para>
+            </entry>
+            <entry>
+              <para>
+                ABI
+              </para>
+            </entry>
+          </row>
+        </thead>
+        <tbody>
+          <row>
+            <entry>
+              <para>
+                ARM (ARM926EJ-S)
+              </para>
+            </entry>
+            <entry>
+              <para>
+                Debian GNU/Linux (Lenny)
+              </para>
+            </entry>
+            <entry>
+              <para>
+                GCC 4.4.4
+              </para>
+            </entry>
+            <entry>
+              <para>
+                ARM APCS (Linux)
+              </para>
+            </entry>
+          </row>
+          <row>
+            <entry>
+              <para>
+                MIPS (MIPS 24K)
+              </para>
+            </entry>
+            <entry>
+              <para>
+                Debian GNU/Linux (Lenny)
+              </para>
+            </entry>
+            <entry>
+              <para>
+                GCC 4.3.2
+              </para>
+            </entry>
+            <entry>
+              <para>
+                O32
+              </para>
+            </entry>
+          </row>
+          <row>
+            <entry>
+              <para>
+                MIPS (O2 / MIPS R5000)
+              </para>
+            </entry>
+            <entry>
+              <para>
+                Debian GNU/Linux (Lenny)
+              </para>
+            </entry>
+            <entry>
+              <para>
+                GCC 4.3.2
+              </para>
+            </entry>
+            <entry>
+              <para>
+                O32
+              </para>
+            </entry>
+          </row>
+          <row>
+            <entry>
+              <para>
+                PowerPC (7400)
+              </para>
+            </entry>
+            <entry>
+              <para>
+                Debian GNU/Linux (Lenny)
+              </para>
+            </entry>
+            <entry>
+              <para>
+                GCC 4.3.2
+              </para>
+            </entry>
+            <entry>
+              <para>
+                SYSV
+              </para>
+            </entry>
+          </row>
+          <row>
+            <entry>
+              <para>
+                X86_64 (Intel Core2 Quad)
+              </para>
+            </entry>
+            <entry>
+              <para>
+                Ubuntu GNU/Linux (Lucid Lynx)
+              </para>
+            </entry>
+            <entry>
+              <para>
+                GCC 4.4.3
+              </para>
+            </entry>
+            <entry>
+              <para>
+                SYSV
+              </para>
+            </entry>
+          </row>
+          <row>
+            <entry>
+              <para>
+                X86_64
+              </para>
+            </entry>
+            <entry>
+              <para>
+                Windows 7
+              </para>
+            </entry>
+            <entry>
+              <para>
+                MS VC 10.0
+              </para>
+            </entry>
+            <entry>
+              <para>
+                PE
+              </para>
+            </entry>
+          </row>
+          <row>
+            <entry>
+              <para>
+                I386
+              </para>
+            </entry>
+            <entry>
+              <para>
+                Debian GNU/Linux (Lenny)
+              </para>
+            </entry>
+            <entry>
+              <para>
+                GCC 4.4.3
+              </para>
+            </entry>
+            <entry>
+              <para>
+                SYSV
+              </para>
+            </entry>
+          </row>
+          <row>
+            <entry>
+              <para>
+                I386
+              </para>
+            </entry>
+            <entry>
+              <para>
+                FreeBSD 8.0
+              </para>
+            </entry>
+            <entry>
+              <para>
+                GCC 4.2.1
+              </para>
+            </entry>
+            <entry>
+              <para>
+                SYSV
+              </para>
+            </entry>
+          </row>
+          <row>
+            <entry>
+              <para>
+                I386
+              </para>
+            </entry>
+            <entry>
+              <para>
+                OpenSolaris 2009.06
+              </para>
+            </entry>
+            <entry>
+              <para>
+                GCC 4.3.2
+              </para>
+            </entry>
+            <entry>
+              <para>
+                SYSV
+              </para>
+            </entry>
+          </row>
+          <row>
+            <entry>
+              <para>
+                I386
+              </para>
+            </entry>
+            <entry>
+              <para>
+                Windows XP
+              </para>
+            </entry>
+            <entry>
+              <para>
+                MSVC 9.0
+              </para>
+            </entry>
+            <entry>
+              <para>
+                PE
+              </para>
+            </entry>
+          </row>
+        </tbody>
+      </tgroup>
+    </informaltable>
+  </section>
+  <section id="context.rationale">
+    <title><link linkend="context.rationale">Rationale</link></title> <anchor id="context.rationale.no_inline_assembler"/>
+    <bridgehead renderas="sect3">
+      <link linkend="context.rationale.no_inline_assembler">No inline-assembler</link>
+    </bridgehead>
+    <para>
+      Some newer compiler (for instance MSVC 10 for x86_64 and itanium) do not support
+      inline assembler. <footnote>
+      <para>
+        <ulink url="http://msdn.microsoft.com/en-us/library/4ks26t93.aspx">MSDN article
+        'Inline Assembler'</ulink>
+      </para>
+      </footnote>.
+    </para>
+    <anchor id="context.rationale.fcontext_t"/>
+    <bridgehead renderas="sect3">
+      <link linkend="context.rationale.fcontext_t">fcontext_t</link>
+    </bridgehead>
+    <para>
+      <emphasis role="bold">Boost.Context</emphasis> provides the low level API fcontext_t
+      which is implemented in assembler to provide context swapping operations. fcontext_t
+      is the part to port to new platforms.
+    </para>
+    <note>
+      <para>
+        Context switches do not preserve the signal mask on UNIX systems.
+      </para>
+    </note>
+    <para>
+      Because the assembler code uses the byte layout of <emphasis>fcontext_t</emphasis>
+      to access its members <emphasis>fcontext_t</emphasis> must be a POD. This requires
+      that <emphasis>fcontext_t</emphasis> has only a default constructor, no visibility
+      keywords (e.g. private, public, protected), no virtual methods and all members
+      and base clases are PODs too.
+    </para>
+    <anchor id="context.rationale.protecting_the_stack"/>
+    <bridgehead renderas="sect3">
+      <link linkend="context.rationale.protecting_the_stack">Protecting the stack</link>
+    </bridgehead>
+    <para>
+      Because the stack's size is fixed -- there is no support for split stacks yet
+      -- it is important to protect against exceeding the stack's bounds. Otherwise,
+      in the best case, overrunning the stack's memory will result in a segmentation
+      fault or access violation and, in the worst case, the application's memory
+      will be overwritten. <code><phrase role="identifier">stack_allocator</phrase></code>
+      appends a guard page to the stack to help detect overruns. The guard page consumes
+      no physical memory, but generates a segmentation fault or access violation
+      on access to the virtual memory addresses within it.
+    </para>
+    <section id="context.rationale.other_apis_">
+      <title><link linkend="context.rationale.other_apis_">Other APIs </link></title>
+      <anchor id="context.rationale.other_apis_.setjmp___longjmp__"/>
+      <bridgehead renderas="sect4">
+        <link linkend="context.rationale.other_apis_.setjmp___longjmp__">setjmp()/longjmp()</link>
+      </bridgehead>
+      <para>
+        C99 defines <code><phrase role="identifier">setjmp</phrase><phrase role="special">()</phrase></code>/<code><phrase
+        role="identifier">longjmp</phrase><phrase role="special">()</phrase></code>
+        to provide non-local jumps but it does not require that <emphasis>longjmp()</emphasis>
+        preserves the current stack frame. Therefore, jumping into a function which
+        was exited via a call to <emphasis>longjmp()</emphasis> is undefined <footnote>
+        <para>
+          <ulink url="boost:/libs/context/doc/pdf/iso_c99.pdf">ISO/IEC 9899:1999,
+          2005</ulink>, 7.13.2.1:2
+        </para>
+        </footnote>.
+      </para>
+      <anchor id="context.rationale.other_apis_.ucontext_t"/>
+      <bridgehead renderas="sect4">
+        <link linkend="context.rationale.other_apis_.ucontext_t">ucontext_t</link>
+      </bridgehead>
+      <para>
+        Since POSIX.1-2003 <code><phrase role="identifier">ucontext_t</phrase></code>
+        is deprecated and was removed in POSIX.1-2008! The function signature of
+        <code><phrase role="identifier">makecontext</phrase><phrase role="special">()</phrase></code>
+        is:
+      </para>
+      
+<programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">makecontext</phrase><phrase role="special">(</phrase><phrase role="identifier">ucontext_t</phrase> <phrase role="special">*</phrase><phrase role="identifier">ucp</phrase><phrase role="special">,</phrase> <phrase role="keyword">void</phrase> <phrase role="special">(*</phrase><phrase role="identifier">func</phrase><phrase role="special">)(),</phrase> <phrase role="keyword">int</phrase> <phrase role="identifier">argc</phrase><phrase role="special">,</phrase> <phrase role="special">...);</phrase>
+</programlisting>
+      <para>
+        The third argument of <code><phrase role="identifier">makecontext</phrase><phrase
+        role="special">()</phrase></code> specifies the number of integer arguments
+        that follow which will require function pointer cast if <code><phrase role="identifier">func</phrase></code>
+        will accept those arguments which is undefined in C99 <footnote>
+        <para>
+          <ulink url="boost:/libs/context/doc/pdf/iso_c99.pdf">ISO/IEC 9899:1999,
+          2005</ulink>, J.2
+        </para>
+        </footnote>.
+      </para>
+      <para>
+        The arguments in the var-arg list are required to be integers, passing pointers
+        in var-arg list is not guarantied to work, especially it will fail for architectures
+        where pointers are larger than integers.
+      </para>
+      <para>
+        <code><phrase role="identifier">ucontext_t</phrase></code> preserves signal
+        mask between context switches which involes system calls consuming a lot
+        of CPU cycles (ucontext_t is slower by perfomance_link[factor 13x] relative
+        to <code><phrase role="identifier">fcontext_t</phrase></code>).
+      </para>
+      <anchor id="context.rationale.other_apis_.windows_fibers"/>
+      <bridgehead renderas="sect4">
+        <link linkend="context.rationale.other_apis_.windows_fibers">Windows fibers</link>
+      </bridgehead>
+      <para>
+        A drawback of Windows Fiber API is that <code><phrase role="identifier">CreateFiber</phrase><phrase
+        role="special">()</phrase></code> does not accept a pointer to user allocated
+        stack space preventing the reuse of stacks for other context instances. Because
+        the Windows Fiber API requires to call <code><phrase role="identifier">ConvertThreadToFiber</phrase><phrase
+        role="special">()</phrase></code> if <code><phrase role="identifier">SwitchFiber</phrase><phrase
+        role="special">()</phrase></code> is called for a thread which has not been
+        converted to a fiber. For the same reason <code><phrase role="identifier">ConvertFiberToThread</phrase><phrase
+        role="special">()</phrase></code> must be called after return from <code><phrase
+        role="identifier">SwitchFiber</phrase><phrase role="special">()</phrase></code>
+        if the thread was forced to be converted to a fiber before (which is inefficient).
+      </para>
+      
+<programlisting><phrase role="keyword">if</phrase> <phrase role="special">(</phrase> <phrase role="special">!</phrase> <phrase role="identifier">is_a_fiber</phrase><phrase role="special">()</phrase> <phrase role="special">)</phrase>
+<phrase role="special">{</phrase>
+    <phrase role="identifier">ConvertThreadToFiber</phrase><phrase role="special">(</phrase> <phrase role="number">0</phrase><phrase role="special">);</phrase>
+    <phrase role="identifier">SwitchToFiber</phrase><phrase role="special">(</phrase> <phrase role="identifier">ctx</phrase><phrase role="special">);</phrase>
+    <phrase role="identifier">ConvertFiberToThread</phrase><phrase role="special">();</phrase>
+<phrase role="special">}</phrase>
+</programlisting>
+      <para>
+        If the condition <code><phrase role="identifier">_WIN32_WINNT</phrase> <phrase
+        role="special">>=</phrase> <phrase role="identifier">_WIN32_WINNT_VISTA</phrase></code>
+        is met function <code><phrase role="identifier">IsThreadAFiber</phrase><phrase
+        role="special">()</phrase></code> is provided in order to detect if the current
+        thread was already converted. Unfortunately Windows XP + SP 2/3 defines
+        <code><phrase role="identifier">_WIN32_WINNT</phrase> <phrase role="special">>=</phrase>
+        <phrase role="identifier">_WIN32_WINNT_VISTA</phrase></code> without providing
+        <code><phrase role="identifier">IsThreadAFiber</phrase><phrase role="special">()</phrase></code>.
+      </para>
+    </section>
+    <section id="context.rationale.x86_and_floating_point_env">
+      <title><link linkend="context.rationale.x86_and_floating_point_env">x86 and
+      floating-point env</link></title> <anchor id="context.rationale.x86_and_floating_point_env.i386"/>
+      <bridgehead renderas="sect4">
+        <link linkend="context.rationale.x86_and_floating_point_env.i386">i386</link>
+      </bridgehead>
+      <para>
+        "The FpCsr and the MxCsr register must be saved and restored before
+        any call or return by any procedure that needs to modify them ..."
+        <footnote>
+        <para>
+          <ulink url="boost:/libs/context/doc/pdf/calling-conventions.pdf">'Calling
+          Conventions', Agner Fog</ulink>
+        </para>
+        </footnote>.
+      </para>
+      <anchor id="context.rationale.x86_and_floating_point_env.x86_64"/>
+      <bridgehead renderas="sect4">
+        <link linkend="context.rationale.x86_and_floating_point_env.x86_64">x86_64</link>
+      </bridgehead>
+      <anchor id="context.rationale.x86_and_floating_point_env.windows"/>
+      <bridgehead renderas="sect4">
+        <link linkend="context.rationale.x86_and_floating_point_env.windows">Windows</link>
+      </bridgehead>
+      <para>
+        MxCsr - "A callee that modifies any of the nonvolatile fields within
+        MxCsr must restore them before returning to its caller. Furthermore, a caller
+        that has modified any of these fields must restore them to their standard
+        values before invoking a callee ..." <footnote>
+        <para>
+          <ulink url="http://http://msdn.microsoft.com/en-us/library/yxty7t75.aspx">MSDN
+          article 'MxCsr'</ulink>
+        </para>
+        </footnote>.
+      </para>
+      <para>
+        FpCsr - "A callee that modifies any of the fields within FpCsr must
+        restore them before returning to its caller. Furthermore, a caller that has
+        modified any of these fields must restore them to their standard values before
+        invoking a callee ..." <footnote>
+        <para>
+          <ulink url="http://http://msdn.microsoft.com/en-us/library/ms235300.aspx">MSDN
+          article 'FpCsr'</ulink>
+        </para>
+        </footnote>.
+      </para>
+      <para>
+        "The MMX and floating-point stack registers (MM0-MM7/ST0-ST7) are preserved
+        across context switches. There is no explicit calling convention for these
+        registers." <footnote>
+        <para>
+          <ulink url="http://msdn.microsoft.com/en-us/library/a32tsf7t%28VS.80%29.aspx">MSDN
+          article 'Legacy Floating-Point Support'</ulink>
+        </para>
+        </footnote>.
+      </para>
+      <para>
+        "The 64-bit Microsoft compiler does not use ST(0)-ST(7)/MM0-MM7".
+        <footnote>
+        <para>
+          <ulink url="boost:/libs/context/doc/pdf/calling-conventions.pdf">'Calling
+          Conventions', Agner Fog</ulink>
+        </para>
+        </footnote>.
+      </para>
+      <para>
+        "XMM6-XMM15 must be preserved" <footnote>
+        <para>
+          <ulink url="http://msdn.microsoft.com/en-us/library/9z1stfyw%28v=vs.100%29.aspx">MSDN
+          article 'Register Usage'</ulink>
+        </para>
+        </footnote>
+      </para>
+      <anchor id="context.rationale.x86_and_floating_point_env.sysv"/>
+      <bridgehead renderas="sect4">
+        <link linkend="context.rationale.x86_and_floating_point_env.sysv">SysV</link>
+      </bridgehead>
+      <para>
+        "The control bits of the MxCsr register are callee-saved (preserved
+        across calls), while the status bits are caller-saved (not preserved). The
+        x87 status word register is caller-saved, whereas the x87 control word (FpCsr)
+        is callee-saved." <footnote>
+        <para>
+          <ulink url="boost:/libs/context/doc/pdf/x86_64-sysv.pdf">SysV ABI AMD64
+          Architecture Processor Supplement Draft Version 0.99.4, 3.2.1</ulink>
+        </para>
+        </footnote>.
+      </para>
+    </section>
+  </section>
+  <section id="context.reference">
+    <title><link linkend="context.reference">Reference</link></title> <anchor id="context.reference.arm"/>
+    <bridgehead renderas="sect3">
+      <link linkend="context.reference.arm">ARM</link>
+    </bridgehead>
+    <itemizedlist>
+      <listitem>
+        <simpara>
+          AAPCS ABI: <ulink url="boost:/libs/context/doc/pdf/arm-aapcs.pdf">Procedure
+          Call Standard for the ARM Architecture</ulink>
+        </simpara>
+      </listitem>
+      <listitem>
+        <simpara>
+          AAPCS/LINUX: <ulink url="boost:/libs/context/doc/pdf/arm-linux-aapcs.pdf">ARM
+          GNU/Linux Application Binary Interface Supplement</ulink>
+        </simpara>
+      </listitem>
+    </itemizedlist>
+    <anchor id="context.reference.mips"/>
+    <bridgehead renderas="sect3">
+      <link linkend="context.reference.mips">MIPS</link>
+    </bridgehead>
+    <itemizedlist>
+      <listitem>
+        <simpara>
+          O32 ABI: <ulink url="boost:/libs/context/doc/pdf/mips-o32.pdf">SYSTEM V
+          APPLICATION BINARY INTERFACE, MIPS RISC Processor Supplement</ulink>
+        </simpara>
+      </listitem>
+    </itemizedlist>
+    <anchor id="context.reference.powerpc32"/>
+    <bridgehead renderas="sect3">
+      <link linkend="context.reference.powerpc32">PowerPC32</link>
+    </bridgehead>
+    <itemizedlist>
+      <listitem>
+        <simpara>
+          SYSV ABI: <ulink url="boost:/libs/context/doc/pdf/ppc32-sysv.pdf">SYSTEM
+          V APPLICATION BINARY INTERFACE PowerPC Processor Supplement</ulink>
+        </simpara>
+      </listitem>
+    </itemizedlist>
+    <anchor id="context.reference.powerpc64"/>
+    <bridgehead renderas="sect3">
+      <link linkend="context.reference.powerpc64">PowerPC64</link>
+    </bridgehead>
+    <itemizedlist>
+      <listitem>
+        <simpara>
+          SYSV ABI: <ulink url="boost:/libs/context/doc/pdf/ppc64-sysv.pdf">PowerPC
+          User Instruction Set Architecture, Book I</ulink>
+        </simpara>
+      </listitem>
+    </itemizedlist>
+    <anchor id="context.reference.x86_32"/>
+    <bridgehead renderas="sect3">
+      <link linkend="context.reference.x86_32">X86-32</link>
+    </bridgehead>
+    <itemizedlist>
+      <listitem>
+        <simpara>
+          SYSV ABI: <ulink url="boost:/libs/context/doc/pdf/x86_32-sysv.pdf">SYSTEM
+          V APPLICATION BINARY INTERFACE, Intel386TM Architecture Processor Supplement</ulink>
+        </simpara>
+      </listitem>
+      <listitem>
+        <simpara>
+          MS PE: <ulink url="http://msdn.microsoft.com/en-us/library/k2b2ssfy.aspx">Calling
+          Conventions</ulink>
+        </simpara>
+      </listitem>
+    </itemizedlist>
+    <anchor id="context.reference.x86_64"/>
+    <bridgehead renderas="sect3">
+      <link linkend="context.reference.x86_64">X86-64</link>
+    </bridgehead>
+    <itemizedlist>
+      <listitem>
+        <simpara>
+          SYSV ABI: <ulink url="boost:/libs/context/doc/pdf/x86_64-sysv.pdf">System
+          V Application Binary Interface, AMD64 Architecture Processor Supplement</ulink>
+        </simpara>
+      </listitem>
+      <listitem>
+        <simpara>
+          MS PE: <ulink url="http://msdn.microsoft.com/en-us/library/7kcdt6fy%28VS.80%29.aspx">x64
+          Software Conventions</ulink>
+        </simpara>
+      </listitem>
+    </itemizedlist>
+  </section>
+  <section id="context.todo">
+    <title><link linkend="context.todo">Todo</link></title>
+    <itemizedlist>
+      <listitem>
+        <simpara>
+          provide support for SPARC
+        </simpara>
+      </listitem>
+      <listitem>
+        <simpara>
+          support split-stack feature from gcc/gold linker
+        </simpara>
+      </listitem>
+    </itemizedlist>
+  </section>
+  <section id="context.acknowledgements">
+    <title><link linkend="context.acknowledgements">Acknowledgments</link></title>
+    <para>
+      I'd like to thank Adreas Fett, Artyom Beilis, Fernando Pelliccioni, Giovanni
+      Piero Deretta, Gordon Woodhull, Helge Bahmann, Holger Grund, Jeffrey Lee Hellrung
+      (Jr.), Keith Jeffery, Phil Endecott, Robert Stewart, Steven Watanabe, Vicente
+      J. Botet Escriba.
+    </para>
+  </section>
+</article>
Added: branches/release/libs/context/doc/fcontext.qbk
==============================================================================
--- (empty file)
+++ branches/release/libs/context/doc/fcontext.qbk	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,253 @@
+[/
+          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
+]
+
+[section:context Context]
+
+Each instance of __fcontext__ represents a context (CPU registers and stack
+space). Together with its related functions __jump_fcontext__ and
+__make_fcontext__ it provides a execution control transfer mechanism similar
+interface like
+[@http://www.kernel.org/doc/man-pages/online/pages/man2/getcontext.2.html ucontext_t].
+__fcontext__ and its functions are located in __context_ns__ and the functions
+are declared as extern "C". 
+
+[warning If __fcontext__ is used in a multithreaded application, it can migrated
+between threads, but must not reference __tls__.]
+
+[note If __fls__ is used on Windows, the user is responsible for calling 
+__fls_alloc__, __fls_free__.]
+
+[important The low level API is the part to port to new platforms.]
+
+
+[heading Executing a context]
+
+A new context supposed to execute a __context_fn__ (returning void and accepting
+intptr_t as argument) must be initialized by function __make_fcontext__.
+
+            // context-function
+            void f( intptr);
+
+            // creates and manages a protected stack (with guard page)
+            boost::ctx::protected_stack stack( boost::ctx::default_stacksize() );
+
+            // let fcontext_t fc use stack
+            fc.fc_stack.base = stack.address();
+            fc.fc_stack.limit =
+                static_cast< char * >( fc.fc_stack.base) - stack.size();
+
+            // context fc uses f() as context function
+            make_fcontext( & fc, f);
+
+__fcontext__ requires a pointer to the top of the stack (__fc_base__) as well
+as a pointer to the lower bound of the stack (__fc_limit__).
+
+Calling __jump_fcontext__ invokes the __context_fn__ in a newly created context
+complete with registers, flags, stack and instruction pointers.  When control
+should be returned to the original calling context, call __jump_fcontext__.
+The current context information (registers, flags, and stack and instruction
+pointers) is saved and the original context information is restored. Calling
+__jump_fcontext__ again resumes execution in the second context after saving the
+new state of the original context.
+
+        namespace ctx = boost::ctx;
+
+        ctx::fcontext_t fcm, fc1, fc2;
+
+        void f1( intptr_t)
+        {
+                std::cout << "f1: entered" << std::endl;
+                std::cout << "f1: call jump_fcontext( & fc1, & fc2, 0)" << std::endl;
+                ctx::jump_fcontext( & fc1, & fc2, 0);
+                std::cout << "f1: return" << std::endl;
+                ctx::jump_fcontext( & fc1, & fcm, 0);
+        }
+
+        void f2( intptr_t)
+        {
+                std::cout << "f2: entered" << std::endl;
+                std::cout << "f2: call jump_fcontext( & fc2, & fc1, 0)" << std::endl;
+                ctx::jump_fcontext( & fc2, & fc1, 0);
+                BOOST_ASSERT( false && ! "f2: never returns");
+        }
+
+        int main( int argc, char * argv[])
+        {
+                ctx::stack_allocator alloc1, alloc2;
+
+                fc1.fc_stack.base = alloc1.allocate(ctx::minimum_stacksize());
+                fc1.fc_stack.limit =
+                    static_cast< char * >( fc1.fc_stack.base) - ctx::minimum_stacksize();
+                ctx::make_fcontext( & fc1, f1);
+
+                fc2.fc_stack.base = alloc2.allocate(ctx::minimum_stacksize());
+                fc2.fc_stack.limit =
+                    static_cast< char * >( fc2.fc_stack.base) - ctx::minimum_stacksize();
+                ctx::make_fcontext( & fc2, f2);
+
+                std::cout << "main: call jump_fcontext( & fcm, & fc1, 0)" << std::endl;
+                ctx::jump_fcontext( & fcm, & fc1, 0);
+
+                std::cout << "main: done" << std::endl;
+
+                return EXIT_SUCCESS;
+        }
+
+        output:
+            main: call jump_fcontext( & fcm, & fc1, 0)
+            f1: entered
+            f1: call jump_fcontext( & fc1, & fc2, 0)
+            f2: entered
+            f2: call jump_fcontext( & fc2, & fc1, 0)
+            f1: return
+            main: done
+
+First call of __jump_fcontext__ enters the __context_fn__ `f1()` by starting
+context fc1 (context fcm saves the registers of `main()`). For jumping between
+context's fc1 and fc2 `jump_fcontext()` is called.
+Because context fcm is chained to fc1, `main()` is entered (returning from
+__jump_fcontext__) after context fc1 becomes complete (return from `f1()`).
+
+[warning Calling __jump_fcontext__ to the same context from inside the same
+context results in undefined behaviour.]
+
+[note In contrast to threads, which are preemtive, __fcontext__ switches are
+cooperative (programmer controls when switch will happen). The kernel is not
+involved in the context switches.]
+
+
+[heading Transfer of data]
+
+The third argument passed to __jump_fcontext__, in one context, is passed as
+the first argument of the __context_fn__ if the context is started for the
+first time.
+In all following invocations of __jump_fcontext__ the intptr_t passed to
+__jump_fcontext__, in one context, is returned by __jump_fcontext__ in the
+other context. 
+
+        namespace ctx = boost::ctx;
+
+        ctx::fcontext_t fc1, fcm;
+
+        typedef std::pair< int, int >   pair_t;
+
+        void f1( intptr_t param)
+        {
+            pair_t * p = ( pair_t *) param;
+
+            p = ( pair_t *) ctx::jump_fcontext( & fc1, & fcm, ( intptr_t) ( p->first + p->second) );
+
+            ctx::jump_fcontext( & fc1, & fcm, ( intptr_t) ( p->first + p->second) );
+        }
+
+        int main( int argc, char * argv[])
+        {
+            ctx::stack_allocator alloc;
+
+            fc1.fc_stack.base = alloc.allocate(ctx::minimum_stacksize());
+            fc1.fc_stack.limit =
+                static_cast< char * >( fc1.fc_stack.base) - ctx::minimum_stacksize();
+            fc1.fc_link = & fcm;
+            pair_t p( std::make_pair( 2, 7) );
+            ctx::make_fcontext( & fc1, f1);
+
+            int res = ( int) ctx::jump_fcontext( & fcm, & fc1, ( intptr_t) & p);
+            std::cout << p.first << " + " << p.second << " == " << res << std::endl;
+
+            p = std::make_pair( 5, 6);
+            res = ( int) ctx::jump_fcontext( & fcm, & fc1, ( intptr_t) & p);
+            std::cout << p.first << " + " << p.second << " == " << res << std::endl;
+
+            std::cout << "main: done" << std::endl;
+
+            return EXIT_SUCCESS;
+        }
+
+        output:
+            2 + 7 == 9
+            5 + 6 == 11
+            main: done
+
+
+[heading Exceptions in __context_fn__]
+
+If the __context_fn__ emits an exception, the application will terminate.
+
+
+[heading Preserving floating point registers]
+
+Preserving the floating point registers increases the cycle count for a context
+switch (see performance tests).
+The foruth argument of __jump_fcontext__ controls if fpu registers should be 
+preserved by the context jump.
+
+[important The use of the fpu controling argument of __jump_fcontext__ must
+be consistent in the application. Otherwise the behaviour is undefined.]
+
+
+[heading Stack unwinding]
+
+Sometimes it is necessary to unwind the stack of an unfinished context to
+destroy local stack variables so they can release allocated resources (RAII
+pattern). The user is responsible for this task.
+
+
+[section:boost_fcontext Struct `fcontext_t` and related functions]
+
+        struct stack_t
+        {
+            void    *   base;
+            void    *   limit;
+        };
+
+        struct fcontext_t
+        {
+            < platform specific >
+
+            stack_t  fc_stack;
+        };
+
+        intptr_t jump_fcontext( fcontext_t * ofc, fcontext_t const* nfc, intptr_t vp);
+        void make_fcontext( fcontext_t * fc, void(* fn)(intptr_t) );
+
+[heading `base`]
+[variablelist
+[[Member:] [Pointer to the top of the stack.]]
+]
+
+[heading `limit`]
+[variablelist
+[[Member:] [Pointer to the bottom of the stack.]]
+]
+
+[heading `fc_stack`]
+[variablelist
+[[Member:] [Tracks the memory for the context's stack.]]
+]
+
+[heading `intptr_t jump_fcontext( fcontext_t * ofc, fcontext_t * nfc, intptr_t p, bool preserve_fpu)`]
+[variablelist
+[[Effects:] [Stores the current context data (stack pointer, instruction
+pointer, and CPU registers) to `*ofc` and restores the context data from `*nfc`,
+which implies jumping to `*nfc`'s execution context. The intptr_t argument, `p`,
+is passed to the current context to be returned by the most recent call to
+`jump_fcontext()` in the same thread. The last argument controls if fpu registers
+have to be preserved.]]
+[[Returns:] [The third pointer argument passed to the most recent call to
+`jump_fcontext()`, if any.]]
+]
+
+[heading `void make_fcontext( fcontext_t * fc, void(*fn)(intptr_t))`]
+[variablelist
+[[Precondition:] [A stack is applied to `*fc` before `make_fcontext()` is called.]]
+[[Effects:] [Modifies `*fc` in order to execute `fn` when the context is
+activated next.]]
+]
+
+[endsect]
+
+[endsect]
Added: branches/release/libs/context/doc/overview.qbk
==============================================================================
--- (empty file)
+++ branches/release/libs/context/doc/overview.qbk	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,42 @@
+[/
+          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
+]
+
+[section:overview Overview]
+
+__boost_context__ is a foundational library that provides a sort of cooperative
+multitasking on a single thread. By providing an abstraction of the current
+execution state in the current thread, including the stack (with local
+variables) and stack pointer, all registers and CPU flags, and the instruction
+pointer, a __fcontext__ instance represents a specific point in the application's
+execution path. This is useful for building higher-level abstractions, like
+__coroutines__, __coop_threads__ or an aquivalent to
+[@http://msdn.microsoft.com/en-us/library/9k7k7cf0%28v=vs.80%29.aspx C# keyword __yield__]
+in C++.
+
+A __fcontext__ provides the means to suspend the current execution path and to
+transfer execution control, thereby permitting another __fcontext__ to run on the
+current thread. This stateful transfer mechanism enables a __fcontext__ to
+suspend execution from within nested functions and, later, to resume from where
+it was suspended. While the execution path represented by a __fcontext__ only
+runs on a single thread, it can be migrated to another thread at any given time.
+
+A context switch between threads requires system calls (involving the OS
+kernel), which can cost more than thousand CPU cycles on x86 CPUs. By contrast,
+transferring control among them requires only fewer than hundred CPU cycles because
+it does not involve system calls as it is done within a single thread.
+
+In order to use the classes and functions described here, you can either include
+the specific headers specified by the descriptions of each class or function, or
+include the master library header:
+
+    #include <boost/context/all.hpp>
+
+which includes all the other headers in turn.
+
+All functions and classes are contained in the namespace __context_ns__.
+
+[endsect]
Added: branches/release/libs/context/doc/pdf/arm-aapcs.pdf
==============================================================================
Binary file. No diff available.
Added: branches/release/libs/context/doc/pdf/arm-linux-aapcs.pdf
==============================================================================
Binary file. No diff available.
Added: branches/release/libs/context/doc/pdf/calling-conventions.pdf
==============================================================================
Binary file. No diff available.
Added: branches/release/libs/context/doc/pdf/iso_c99.pdf
==============================================================================
Binary file. No diff available.
Added: branches/release/libs/context/doc/pdf/mips-o32.pdf
==============================================================================
Binary file. No diff available.
Added: branches/release/libs/context/doc/pdf/ppc32-sysv.pdf
==============================================================================
Binary file. No diff available.
Added: branches/release/libs/context/doc/pdf/ppc64-sysv.pdf
==============================================================================
Binary file. No diff available.
Added: branches/release/libs/context/doc/pdf/x86_32-sysv.pdf
==============================================================================
Binary file. No diff available.
Added: branches/release/libs/context/doc/pdf/x86_64-sysv.pdf
==============================================================================
Binary file. No diff available.
Added: branches/release/libs/context/doc/performance.qbk
==============================================================================
--- (empty file)
+++ branches/release/libs/context/doc/performance.qbk	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,39 @@
+[/
+          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
+]
+
+[section:performance Performance]
+
+Performance of __boost_context__ was measured on the platforms shown in the
+following table. Performance measurements were taken using `rdtsc`, with
+overhead corrections, on x86 platforms. In each case, stack protection was
+active, cache warm-up was accounted for, and the one running thread was pinned
+to a single CPU. The code was compiled using the build options,
+'variant = release cxxflags = -DBOOST_DISABLE_ASSERTS'.
+
+The numbers in the table are the number of cycles per iteration, based upon an
+average computed over 10 iterations.
+
+[table Perfomance of context switch
+    [[Platform] [ucontext_t] [fcontext_t with fpu] [fcontext_t without fpu] [boost::function]]
+    [
+        [AMD Athlon 64 DualCore 4400+ (32bit Linux)]
+        [846 cycles]
+        [65 cycles]
+        [46 cycles]
+        [43 cycles]
+    ]
+    [
+        [Intel Core2 Q6700 (64bit Linux)]
+        [1472 cycles]
+        [172 cycles]
+        [63 cycles]
+        [60 cycles]
+    ]
+]
+
+
+[endsect]
Added: branches/release/libs/context/doc/rationale.qbk
==============================================================================
--- (empty file)
+++ branches/release/libs/context/doc/rationale.qbk	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,153 @@
+[/
+          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
+]
+
+[section:rationale Rationale]
+
+[heading No inline-assembler]
+
+Some newer compiler (for instance MSVC 10 for x86_64 and itanium) do not
+support inline assembler.
+[footnote [@http://msdn.microsoft.com/en-us/library/4ks26t93.aspx MSDN article
+'Inline Assembler']].
+
+
+[heading fcontext_t]
+
+__boost_context__ provides the low level API fcontext_t which is
+implemented in assembler to provide context swapping operations.
+fcontext_t is the part to port to new platforms.
+
+[note Context switches do not preserve the signal mask on UNIX systems.]
+
+Because the assembler code uses the byte layout of __fcontext__ to access 
+its members __fcontext__ must be a POD. This requires that __fcontext__ has only a
+default constructor, no visibility keywords (e.g. private, public, protected), no
+virtual methods and all members and base clases are PODs too.
+
+
+[heading Protecting the stack]
+
+Because the stack's size is fixed -- there is no support for split stacks yet -- it
+is important to protect against exceeding the stack's bounds. Otherwise, in the
+best case, overrunning the stack's memory will result in a segmentation fault or
+access violation and, in the worst case, the application's memory will be
+overwritten. `stack_allocator` appends a guard page to the stack to help detect
+overruns. The guard page consumes no physical memory, but generates a
+segmentation fault or access violation on access to the virtual memory addresses
+within it.
+
+
+[section Other APIs ]
+
+[heading setjmp()/longjmp()]
+
+C99 defines `setjmp()`/`longjmp()` to provide non-local jumps but it does not
+require that ['longjmp()] preserves the current stack frame. Therefore, jumping
+into a function which was exited via a call to ['longjmp()] is undefined
+[footnote [@boost:/libs/context/doc/pdf/iso_c99.pdf ISO/IEC 9899:1999, 2005],
+7.13.2.1:2].
+
+
+[heading ucontext_t]
+
+Since POSIX.1-2003 `ucontext_t` is deprecated and was removed in POSIX.1-2008!
+The function signature of `makecontext()` is:
+
+    void makecontext(ucontext_t *ucp, void (*func)(), int argc, ...);
+
+The third argument of `makecontext()` specifies the number of integer arguments
+that follow which will require function pointer cast if `func` will accept those
+arguments which is undefined in C99
+[footnote [@boost:/libs/context/doc/pdf/iso_c99.pdf ISO/IEC 9899:1999, 2005],
+J.2].
+
+The arguments in the var-arg list are required to be integers, passing pointers
+in var-arg list is not guarantied to work, especially it will fail for
+architectures where pointers are larger than integers.
+
+`ucontext_t` preserves signal mask between context switches which involes system
+calls consuming a lot of CPU cycles (ucontext_t is slower by
+perfomance_link[factor 13x] relative to `fcontext_t`).
+
+
+[heading Windows fibers]
+
+A drawback of Windows Fiber API is that `CreateFiber()` does not accept a
+pointer to user allocated stack space preventing the reuse of stacks for other
+context instances. Because the Windows Fiber API requires to call
+`ConvertThreadToFiber()` if `SwitchFiber()` is called for a thread which has not
+been converted to a fiber. For the same reason `ConvertFiberToThread()`
+must be called after return from `SwitchFiber()` if the thread was forced to be
+converted to a fiber before (which is inefficient).
+
+        if ( ! is_a_fiber() )
+        {
+            ConvertThreadToFiber( 0);
+            SwitchToFiber( ctx);
+            ConvertFiberToThread();
+        }
+
+If the condition `_WIN32_WINNT >= _WIN32_WINNT_VISTA` is met function
+`IsThreadAFiber()` is provided in order to detect if the current thread was
+already converted. Unfortunately Windows XP + SP 2/3 defines
+`_WIN32_WINNT >= _WIN32_WINNT_VISTA` without providing `IsThreadAFiber()`.
+
+[endsect]
+
+
+[section x86 and floating-point env]
+
+[heading i386]
+
+"The FpCsr and the MxCsr register must be saved and restored before any call or return
+by any procedure that needs to modify them ..."
+[footnote [@boost:/libs/context/doc/pdf/calling-conventions.pdf 'Calling Conventions',
+Agner Fog]].
+
+
+[heading x86_64]
+
+[heading Windows]
+
+MxCsr - "A callee that modifies any of the nonvolatile fields within MxCsr must restore
+them before returning to its caller. Furthermore, a caller that has modified any
+of these fields must restore them to their standard values before invoking a callee ..."
+[footnote [@http://http://msdn.microsoft.com/en-us/library/yxty7t75.aspx MSDN article
+'MxCsr']].
+
+FpCsr - "A callee that modifies any of the fields within FpCsr must restore them before
+returning to its caller. Furthermore, a caller that has modified any of these
+fields must restore them to their standard values before invoking a callee ..."
+[footnote [@http://http://msdn.microsoft.com/en-us/library/ms235300.aspx MSDN article
+'FpCsr']].
+
+"The MMX and floating-point stack registers (MM0-MM7/ST0-ST7) are preserved across
+context switches. There is no explicit calling convention for these registers."
+[footnote [@http://msdn.microsoft.com/en-us/library/a32tsf7t%28VS.80%29.aspx MSDN article
+'Legacy Floating-Point Support']].
+
+"The 64-bit Microsoft compiler does not use ST(0)-ST(7)/MM0-MM7".
+[footnote [@boost:/libs/context/doc/pdf/calling-conventions.pdf 'Calling Conventions',
+Agner Fog]].
+
+"XMM6-XMM15 must be preserved"
+[footnote [@http://msdn.microsoft.com/en-us/library/9z1stfyw%28v=vs.100%29.aspx MSDN
+article 'Register Usage']]
+
+
+[heading SysV]
+
+"The control bits of the MxCsr register are callee-saved (preserved across calls),
+while the status bits are caller-saved (not preserved). The x87 status word register is
+caller-saved, whereas the x87 control word (FpCsr) is callee-saved."
+[footnote [@boost:/libs/context/doc/pdf/x86_64-sysv.pdf SysV ABI AMD64 Architecture
+Processor Supplement Draft Version 0.99.4, 3.2.1]].
+
+[endsect]
+
+
+[endsect]
Added: branches/release/libs/context/doc/reference.qbk
==============================================================================
--- (empty file)
+++ branches/release/libs/context/doc/reference.qbk	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,43 @@
+[/
+          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
+]
+
+[section:reference Reference]
+
+[heading ARM]
+
+* AAPCS ABI: [@boost:/libs/context/doc/pdf/arm-aapcs.pdf Procedure Call Standard for the ARM Architecture]
+* AAPCS/LINUX: [@boost:/libs/context/doc/pdf/arm-linux-aapcs.pdf ARM GNU/Linux Application Binary Interface Supplement]
+
+
+[heading MIPS]
+
+* O32 ABI: [@boost:/libs/context/doc/pdf/mips-o32.pdf SYSTEM V APPLICATION BINARY INTERFACE, MIPS RISC Processor Supplement]
+
+
+[heading PowerPC32]
+
+* SYSV ABI: [@boost:/libs/context/doc/pdf/ppc32-sysv.pdf SYSTEM V APPLICATION BINARY INTERFACE PowerPC Processor Supplement]
+
+
+[heading PowerPC64]
+
+* SYSV ABI: [@boost:/libs/context/doc/pdf/ppc64-sysv.pdf PowerPC User Instruction Set Architecture, Book I]
+
+
+[heading X86-32]
+
+* SYSV ABI: [@boost:/libs/context/doc/pdf/x86_32-sysv.pdf SYSTEM V APPLICATION BINARY INTERFACE, Intel386TM Architecture Processor Supplement]
+* MS PE: [@http://msdn.microsoft.com/en-us/library/k2b2ssfy.aspx Calling Conventions]
+
+
+[heading X86-64]
+
+* SYSV ABI: [@boost:/libs/context/doc/pdf/x86_64-sysv.pdf System V Application Binary Interface, AMD64 Architecture Processor Supplement]
+* MS PE: [@http://msdn.microsoft.com/en-us/library/7kcdt6fy%28VS.80%29.aspx x64 Software Conventions]
+
+
+[endsect]
Added: branches/release/libs/context/doc/requirements.qbk
==============================================================================
--- (empty file)
+++ branches/release/libs/context/doc/requirements.qbk	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,18 @@
+[/
+          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
+]
+
+[section:requirements Requirements]
+
+__boost_context__ must be built for the particular compiler(s) and CPU
+architecture(s)s being targeted. __boost_context__ includes assembly code and,
+therefore, requires GNU AS for supported POSIX systems, and MASM for Windows
+systems.
+
+[important Please note that address-model=64 must be given to bjam command line
+on 64bit Windows (boost-build issue).]
+
+[endsect]
Added: branches/release/libs/context/doc/stack.qbk
==============================================================================
--- (empty file)
+++ branches/release/libs/context/doc/stack.qbk	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,116 @@
+[/
+          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
+]
+
+[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__.
+
+[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
+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();
+
+        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]
+
+[endsect]
Added: branches/release/libs/context/doc/tested.qbk
==============================================================================
--- (empty file)
+++ branches/release/libs/context/doc/tested.qbk	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,74 @@
+[/
+          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
+]
+
+[section:tested Tested Platforms]
+
+[table
+    [[Platform] [OS] [Compiler] [ABI]]
+    [
+        [ARM (ARM926EJ-S)]
+        [Debian GNU/Linux (Lenny)]
+        [GCC 4.4.4]
+        [ARM APCS (Linux)]
+    ]
+    [
+        [MIPS (MIPS 24K)]
+        [Debian GNU/Linux (Lenny)]
+        [GCC 4.3.2]
+        [O32]
+    ]
+    [
+        [MIPS (O2 / MIPS R5000)]
+        [Debian GNU/Linux (Lenny)]
+        [GCC 4.3.2]
+        [O32]
+    ]
+    [
+        [PowerPC (7400)]
+        [Debian GNU/Linux (Lenny)]
+        [GCC 4.3.2]
+        [SYSV]
+    ]
+    [
+        [X86_64 (Intel Core2 Quad)]
+        [Ubuntu GNU/Linux (Lucid Lynx)]
+        [GCC 4.4.3]
+        [SYSV]
+    ]
+    [
+        [X86_64]
+        [Windows 7]
+        [MS VC 10.0]
+        [PE]
+    ]
+    [
+        [I386]
+        [Debian GNU/Linux (Lenny)]
+        [GCC 4.4.3]
+        [SYSV]
+    ]
+    [
+        [I386]
+        [FreeBSD 8.0]
+        [GCC 4.2.1]
+        [SYSV]
+    ]
+    [
+        [I386]
+        [OpenSolaris 2009.06]
+        [GCC 4.3.2]
+        [SYSV]
+    ]
+    [
+        [I386]
+        [Windows XP]
+        [MSVC 9.0]
+        [PE]
+    ]
+]
+
+[endsect]
Added: branches/release/libs/context/doc/todo.qbk
==============================================================================
--- (empty file)
+++ branches/release/libs/context/doc/todo.qbk	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,13 @@
+[/
+          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
+]
+
+[section:todo Todo]
+
+* provide support for SPARC
+* support split-stack feature from gcc/gold linker
+
+[endsect]
Added: branches/release/libs/context/example/Jamfile.v2
==============================================================================
--- (empty file)
+++ branches/release/libs/context/example/Jamfile.v2	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,49 @@
+# Boost.Context Library Examples Jamfile
+
+#          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)
+
+# For more information, see http://www.boost.org/
+
+import common ;
+import feature ;
+import indirect ;
+import modules ;
+import os ;
+import toolset ;
+
+if [ os.name ] = SOLARIS
+{
+  lib socket ;
+  lib nsl ;
+}
+else if [ os.name ] = NT
+{
+  lib ws2_32 ;
+  lib mswsock ;
+}
+else if [ os.name ] = HPUX
+{
+  lib ipv6 ;
+}
+
+project boost/context/example
+    : requirements
+      <library>/boost/context//boost_context
+      <define>BOOST_ALL_NO_LIB=1
+      <link>static
+    ;
+
+exe jump
+		: jump.cpp
+		;
+
+exe exit
+		: exit.cpp
+		;
+
+exe transfer
+		: transfer.cpp
+		;
Added: branches/release/libs/context/example/exit.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/context/example/exit.cpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,57 @@
+
+//          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)
+
+#include <cstdlib>
+#include <cstring>
+#include <iostream>
+#include <vector>
+
+#include <boost/assert.hpp>
+#include <boost/context/all.hpp>
+
+namespace ctx = boost::ctx;
+
+ctx::fcontext_t fc1, fc2;
+
+void f1( intptr_t)
+{
+		std::cout << "f1: entered" << std::endl;
+		std::cout << "f1: call jump_fcontext( & fc1, & fc2, 0)" << std::endl;
+		ctx::jump_fcontext( & fc1, & fc2, 0);
+		std::cout << "f1: return" << std::endl;
+}
+
+void f2( intptr_t)
+{
+		std::cout << "f2: entered" << std::endl;
+		std::cout << "f2: call jump_fcontext( & fc2, & fc1, 0)" << std::endl;
+		ctx::jump_fcontext( & fc2, & fc1, 0);
+        BOOST_ASSERT( false && ! "f2: never returns");
+}
+
+int main( int argc, char * argv[])
+{
+        ctx::fcontext_t fcm;
+        ctx::stack_allocator alloc;
+
+        fc1.fc_stack.base = alloc.allocate(ctx::minimum_stacksize());
+        fc1.fc_stack.limit =
+            static_cast< char * >( fc1.fc_stack.base) - ctx::minimum_stacksize();
+		ctx::make_fcontext( & fc1, f1);
+
+        fc2.fc_stack.base = alloc.allocate(ctx::minimum_stacksize());
+        fc2.fc_stack.limit =
+            static_cast< char * >( fc2.fc_stack.base) - ctx::minimum_stacksize();
+		ctx::make_fcontext( & fc2, f2);
+
+		std::cout << "main: call start_fcontext( & fcm, & fc1, 0)" << std::endl;
+		ctx::jump_fcontext( & fcm, & fc1, 0);
+
+		std::cout << "main: done" << std::endl;
+        BOOST_ASSERT( false && ! "main: never returns");
+
+        return EXIT_SUCCESS;
+}
Added: branches/release/libs/context/example/jump.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/context/example/jump.cpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,56 @@
+
+//          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)
+
+#include <cstdlib>
+#include <cstring>
+#include <iostream>
+#include <vector>
+
+#include <boost/assert.hpp>
+#include <boost/context/all.hpp>
+
+namespace ctx = boost::ctx;
+
+ctx::fcontext_t fcm, fc1, fc2;
+
+void f1( intptr_t)
+{
+		std::cout << "f1: entered" << std::endl;
+		std::cout << "f1: call jump_fcontext( & fc1, & fc2, 0)" << std::endl;
+		ctx::jump_fcontext( & fc1, & fc2, 0);
+		std::cout << "f1: return" << std::endl;
+		ctx::jump_fcontext( & fc1, & fcm, 0);
+}
+
+void f2( intptr_t)
+{
+		std::cout << "f2: entered" << std::endl;
+		std::cout << "f2: call jump_fcontext( & fc2, & fc1, 0)" << std::endl;
+		ctx::jump_fcontext( & fc2, & fc1, 0);
+        BOOST_ASSERT( false && ! "f2: never returns");
+}
+
+int main( int argc, char * argv[])
+{
+        ctx::stack_allocator alloc1, alloc2;
+
+        fc1.fc_stack.base = alloc1.allocate(ctx::minimum_stacksize());
+        fc1.fc_stack.limit =
+            static_cast< char * >( fc1.fc_stack.base) - ctx::minimum_stacksize();
+		ctx::make_fcontext( & fc1, f1);
+
+        fc2.fc_stack.base = alloc2.allocate(ctx::minimum_stacksize());
+        fc2.fc_stack.limit =
+            static_cast< char * >( fc2.fc_stack.base) - ctx::minimum_stacksize();
+		ctx::make_fcontext( & fc2, f2);
+
+		std::cout << "main: call start_fcontext( & fcm, & fc1, 0)" << std::endl;
+		ctx::jump_fcontext( & fcm, & fc1, 0);
+
+		std::cout << "main: done" << std::endl;
+
+        return EXIT_SUCCESS;
+}
Added: branches/release/libs/context/example/transfer.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/context/example/transfer.cpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,51 @@
+
+//          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)
+
+#include <cstdlib>
+#include <cstring>
+#include <iostream>
+#include <utility>
+#include <vector>
+
+#include <boost/assert.hpp>
+#include <boost/context/all.hpp>
+
+namespace ctx = boost::ctx;
+
+ctx::fcontext_t fc1, fcm;
+
+typedef std::pair< int, int >   pair_t;
+
+void f1( intptr_t param)
+{
+    pair_t * p = ( pair_t *) param;
+
+	p = ( pair_t *) ctx::jump_fcontext( & fc1, & fcm, ( intptr_t) ( p->first + p->second) );
+
+	ctx::jump_fcontext( & fc1, & fcm, ( intptr_t) ( p->first + p->second) );
+}
+
+int main( int argc, char * argv[])
+{
+    ctx::stack_allocator alloc;
+    
+    fc1.fc_stack.base = alloc.allocate(ctx::minimum_stacksize());
+    fc1.fc_stack.limit =
+        static_cast< char * >( fc1.fc_stack.base) - ctx::minimum_stacksize();
+    ctx::make_fcontext( & fc1, f1);
+    
+    pair_t p( std::make_pair( 2, 7) );
+    int res = ( int) ctx::jump_fcontext( & fcm, & fc1, ( intptr_t) & p);
+    std::cout << p.first << " + " << p.second << " == " << res << std::endl;
+    
+    p = std::make_pair( 5, 6);
+    res = ( int) ctx::jump_fcontext( & fcm, & fc1, ( intptr_t) & p);
+    std::cout << p.first << " + " << p.second << " == " << res << std::endl;
+    
+    std::cout << "main: done" << std::endl;
+    
+    return EXIT_SUCCESS;
+}
Added: branches/release/libs/context/performance/Jamfile.v2
==============================================================================
--- (empty file)
+++ branches/release/libs/context/performance/Jamfile.v2	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,66 @@
+
+#          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)
+
+# For more information, see http://www.boost.org/
+
+import common ;
+import feature ;
+import indirect ;
+import modules ;
+import os ;
+import toolset ;
+
+project boost/context/performance
+    : requirements
+      <library>/boost/program_options//boost_program_options
+      <library>/boost/thread//boost_thread
+      <library>/boost/system//boost_system
+      <library>/boost/context//boost_context
+      <link>static
+      <threading>multi
+    ;
+
+alias sources
+   : performance.cpp
+     bind_processor_aix.cpp
+   : <target-os>aix
+   ;
+
+alias sources
+   : performance.cpp
+     bind_processor_freebsd.cpp
+   : <target-os>freebsd
+   ;
+
+alias sources
+   : performance.cpp
+     bind_processor_hpux.cpp
+   : <target-os>hpux
+   ;
+
+alias sources
+   : performance.cpp
+     bind_processor_linux.cpp
+   : <target-os>linux
+   ;
+
+alias sources
+   : performance.cpp
+     bind_processor_solaris.cpp
+   : <target-os>solaris
+   ;
+
+alias sources
+   : performance.cpp
+     bind_processor_windows.cpp
+   : <target-os>windows
+   ;
+
+explicit sources ;
+
+exe performance
+   : sources
+   ;
Added: branches/release/libs/context/performance/bind_processor.hpp
==============================================================================
--- (empty file)
+++ branches/release/libs/context/performance/bind_processor.hpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,12 @@
+
+//          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)
+
+#ifndef BIND_TO_PROCESSOR_H
+#define BIND_TO_PROCESSOR_H
+
+void bind_to_processor( unsigned int n);
+
+#endif // BIND_TO_PROCESSOR_H
Added: branches/release/libs/context/performance/bind_processor_aix.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/context/performance/bind_processor_aix.cpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,33 @@
+
+//          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)
+
+#include "bind_processor.hpp"
+
+extern "C"
+{
+#include <sys/processor.h>
+#include <sys/thread.h>
+}
+
+#include <boost/assert.hpp>
+#include <boost/thread.hpp>
+#include <boost/system/system_error.hpp>
+
+#include <boost/config/abi_prefix.hpp>
+
+void bind_to_processor( unsigned int n)
+{
+    BOOST_ASSERT( n >= 0);
+    BOOST_ASSERT( n < boost::thread::hardware_concurrency() );
+
+    if ( ::bindprocessor( BINDTHREAD, ::thread_self(), static_cast< cpu_t >( n) ) == -1)
+        throw boost::system::system_error(
+                boost::system::error_code(
+                    errno,
+                    boost::system::system_category() ) );
+}
+
+#include <boost/config/abi_suffix.hpp>
Added: branches/release/libs/context/performance/bind_processor_freebsd.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/context/performance/bind_processor_freebsd.cpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,37 @@
+
+//          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)
+
+#include "bind_processor.hpp"
+
+extern "C"
+{
+#include <sys/param.h>
+#include <sys/cpuset.h>
+}
+
+#include <boost/assert.hpp>
+#include <boost/thread.hpp>
+#include <boost/system/system_error.hpp>
+
+#include <boost/config/abi_prefix.hpp>
+
+void bind_to_processor( unsigned int n)
+{
+    BOOST_ASSERT( n >= 0);
+    BOOST_ASSERT( n < boost::thread::hardware_concurrency() );
+
+    cpuset_t cpuset;
+    CPU_ZERO( & cpuset);
+    CPU_SET( n, & cpuset);
+
+    if ( ::cpuset_setaffinity(  CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, sizeof( cpuset), & cpuset) == -1)
+        throw boost::system::system_error(
+                boost::system::error_code(
+                    errno,
+                    boost::system::system_category() ) );
+}
+
+#include <boost/config/abi_suffix.hpp>
Added: branches/release/libs/context/performance/bind_processor_hpux.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/context/performance/bind_processor_hpux.cpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,39 @@
+
+//          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)
+
+#include "bind_processor.hpp"
+
+extern "C"
+{
+#include <sys/pthread.h>
+}
+
+#include <boost/assert.hpp>
+#include <boost/thread.hpp>
+#include <boost/system/system_error.hpp>
+
+#include <boost/config/abi_prefix.hpp>
+
+void bind_to_processor( unsigned int n)
+{
+    BOOST_ASSERT( n >= 0);
+    BOOST_ASSERT( n < boost::thread::hardware_concurrency() );
+
+    ::pthread_spu_t spu;
+    int errno_(
+        ::pthread_processor_bind_np(
+            PTHREAD_BIND_FORCED_NP,
+            & spu,
+            static_cast< pthread_spu_t >( n),
+            PTHREAD_SELFTID_NP) );
+    if ( errno_ != 0)
+        throw boost::system::system_error(
+                boost::system::error_code(
+                    errno_,
+                    boost::system::system_category() ) );
+}
+
+#include <boost/config/abi_suffix.hpp>
Added: branches/release/libs/context/performance/bind_processor_linux.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/context/performance/bind_processor_linux.cpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,39 @@
+
+//          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)
+
+#include "bind_processor.hpp"
+
+extern "C"
+{
+#include <pthread.h>
+#include <sched.h>
+}
+
+#include <boost/assert.hpp>
+#include <boost/thread.hpp>
+#include <boost/system/system_error.hpp>
+
+#include <boost/config/abi_prefix.hpp>
+
+void bind_to_processor( unsigned int n)
+{
+    BOOST_ASSERT( n >= 0);
+    BOOST_ASSERT( n < CPU_SETSIZE);
+    BOOST_ASSERT( n < boost::thread::hardware_concurrency() );
+
+    cpu_set_t cpuset;
+    CPU_ZERO( & cpuset);
+    CPU_SET( n, & cpuset);
+
+    int errno_( ::pthread_setaffinity_np( ::pthread_self(), sizeof( cpuset), & cpuset) );
+    if ( errno_ != 0)
+        throw boost::system::system_error(
+                boost::system::error_code(
+                    errno_,
+                    boost::system::system_category() ) );
+}
+
+#include <boost/config/abi_suffix.hpp>
Added: branches/release/libs/context/performance/bind_processor_solaris.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/context/performance/bind_processor_solaris.cpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,34 @@
+
+//          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)
+
+#include "bind_processor.hpp"
+
+extern "C"
+{
+#include <sys/types.h>
+#include <sys/processor.h>
+#include <sys/procset.h>
+}
+
+#include <boost/assert.hpp>
+#include <boost/thread.hpp>
+#include <boost/system/system_error.hpp>
+
+#include <boost/config/abi_prefix.hpp>
+
+void bind_to_processor( unsigned int n)
+{
+    BOOST_ASSERT( n >= 0);
+    BOOST_ASSERT( n < boost::thread::hardware_concurrency() );
+
+    if ( ::processor_bind( P_LWPID, P_MYID, static_cast< processorid_t >( n), 0) == -1)
+        throw boost::system::system_error(
+                boost::system::error_code(
+                    errno,
+                    boost::system::system_category() ) );
+}
+
+#include <boost/config/abi_suffix.hpp>
Added: branches/release/libs/context/performance/bind_processor_windows.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/context/performance/bind_processor_windows.cpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,32 @@
+
+//          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)
+
+#include "bind_processor.hpp"
+
+extern "C"
+{
+#include <windows.h>
+}
+
+#include <boost/assert.hpp>
+#include <boost/thread.hpp>
+#include <boost/system/system_error.hpp>
+
+#include <boost/config/abi_prefix.hpp>
+
+void bind_to_processor( unsigned int n)
+{
+    BOOST_ASSERT( n >= 0);
+    BOOST_ASSERT( n < boost::thread::hardware_concurrency() );
+
+    if ( ::SetThreadAffinityMask( ::GetCurrentThread(), ( DWORD_PTR)1 << n) == 0)
+        throw boost::system::system_error(
+                boost::system::error_code(
+                    ::GetLastError(),
+                    boost::system::system_category() ) );
+}
+
+#include <boost/config/abi_suffix.hpp>
Added: branches/release/libs/context/performance/cycle.hpp
==============================================================================
--- (empty file)
+++ branches/release/libs/context/performance/cycle.hpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,28 @@
+
+//          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)
+
+#ifndef CYCLE_H
+#define CYCLE_H
+
+// x86_64
+// test x86_64 before i386 because icc might
+// define __i686__ for x86_64 too
+#if defined(__x86_64__) || defined(__x86_64) \
+    || defined(__amd64__) || defined(__amd64) \
+    || defined(_M_X64) || defined(_M_AMD64)
+# include "cycle_x86-64.hpp"
+// i386
+#elif defined(i386) || defined(__i386__) || defined(__i386) \
+    || defined(__i486__) || defined(__i586__) || defined(__i686__) \
+    || defined(__X86__) || defined(_X86_) || defined(__THW_INTEL__) \
+    || defined(__I86__) || defined(__INTEL__) || defined(__IA32__) \
+    || defined(_M_IX86) || defined(_I86_)
+# include "cycle_i386.hpp"
+#else
+# error "this platform is not supported"
+#endif
+
+#endif // CYCLE_H
Added: branches/release/libs/context/performance/cycle_i386.hpp
==============================================================================
--- (empty file)
+++ branches/release/libs/context/performance/cycle_i386.hpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,81 @@
+
+//          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)
+
+#ifndef CYCLE_I386_H
+#define CYCLE_I386_H
+
+#include <algorithm>
+#include <numeric>
+#include <cstddef>
+#include <vector>
+
+#include <boost/assert.hpp>
+#include <boost/bind.hpp>
+#include <boost/cstdint.hpp>
+
+typedef boost::uint64_t cycle_t;
+
+#if _MSC_VER
+inline
+cycle_t cycles()
+{
+    cycle_t c;
+    __asm {
+        cpuid 
+        rdtsc
+        mov dword ptr [c + 0], eax
+        mov dword ptr [c + 4], edx
+    }
+    return c;
+}
+#elif defined(__GNUC__) || \
+      defined(__INTEL_COMPILER) || defined(__ICC) || defined(_ECC) || defined(__ICL)
+inline
+cycle_t cycles()
+{
+    boost::uint32_t lo, hi;
+
+    __asm__ __volatile__ (
+        "xorl %%eax, %%eax\n"
+        "cpuid\n"
+        ::: "%eax", "%ebx", "%ecx", "%edx"
+    );
+    __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi) );
+    __asm__ __volatile__ (
+        "xorl %%eax, %%eax\n"
+        "cpuid\n"
+        ::: "%eax", "%ebx", "%ecx", "%edx"
+    );
+   
+    return ( cycle_t)hi << 32 | lo; 
+}
+#else
+# error "this compiler is not supported"
+#endif
+
+struct measure
+{
+    cycle_t operator()()
+    {
+        cycle_t start( cycles() );
+        return cycles() - start;
+    }
+};
+
+inline
+cycle_t overhead()
+{
+    std::size_t iterations( 10);
+    std::vector< cycle_t >  overhead( iterations, 0);
+    for ( std::size_t i( 0); i < iterations; ++i)
+        std::generate(
+            overhead.begin(), overhead.end(),
+            measure() );
+    BOOST_ASSERT( overhead.begin() != overhead.end() );
+    return std::accumulate( overhead.begin(), overhead.end(), 0) / iterations;
+}
+
+#endif // CYCLE_I386_H
Added: branches/release/libs/context/performance/cycle_x86-64.hpp
==============================================================================
--- (empty file)
+++ branches/release/libs/context/performance/cycle_x86-64.hpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,77 @@
+
+//          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)
+
+#ifndef CYCLE_X86_64_H
+#define CYCLE_X86_64_H
+
+#include <algorithm>
+#include <numeric>
+#include <cstddef>
+#include <vector>
+
+#include <boost/assert.hpp>
+#include <boost/bind.hpp>
+#include <boost/cstdint.hpp>
+
+typedef boost::uint64_t cycle_t;
+
+#if _MSC_VER >= 1400
+# include <intrin.h>
+# pragma intrinsic(__rdtsc)
+inline
+cycle_t cycles()
+{ return __rdtsc(); }
+#elif defined(__INTEL_COMPILER) || defined(__ICC) || defined(_ECC) || defined(__ICL)
+inline
+cycle_t cycles()
+{ return __rdtsc(); }
+#elif defined(__GNUC__) || defined(__SUNPRO_C)
+inline
+cycle_t cycles()
+{
+    boost::uint32_t lo, hi;
+    
+    __asm__ __volatile__ (
+        "xorl %%eax, %%eax\n"
+        "cpuid\n"
+        ::: "%rax", "%rbx", "%rcx", "%rdx"
+    );
+    __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi) );
+    __asm__ __volatile__ (
+        "xorl %%eax, %%eax\n"
+        "cpuid\n"
+        ::: "%rax", "%rbx", "%rcx", "%rdx"
+    );
+   
+    return ( cycle_t)hi << 32 | lo; 
+}
+#else
+# error "this compiler is not supported"
+#endif
+
+struct measure
+{
+    cycle_t operator()()
+    {
+        cycle_t start( cycles() );
+        return cycles() - start;
+    }
+};
+
+inline
+cycle_t overhead()
+{
+    std::size_t iterations( 10);
+    std::vector< cycle_t >  overhead( iterations, 0);
+    for ( std::size_t i( 0); i < iterations; ++i)
+        std::generate(
+            overhead.begin(), overhead.end(),
+            measure() );
+    BOOST_ASSERT( overhead.begin() != overhead.end() );
+    return std::accumulate( overhead.begin(), overhead.end(), 0) / iterations;
+}
+
+#endif // CYCLE_X86_64_H
Added: branches/release/libs/context/performance/performance.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/context/performance/performance.cpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,183 @@
+
+//          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)
+
+#define BOOST_PP_LIMIT_MAG  10
+
+#include <cstdio>
+#include <cstdlib>
+#include <iostream>
+#include <stdexcept>
+
+#include <boost/assert.hpp>
+#include <boost/bind.hpp>
+#include <boost/function.hpp>
+#include <boost/config.hpp>
+#include <boost/context/all.hpp>
+#include <boost/preprocessor/repetition/repeat_from_to.hpp>
+#include <boost/program_options.hpp>
+
+#ifndef BOOST_WINDOWS
+#include <ucontext.h>
+#endif
+
+#include "bind_processor.hpp"
+#include "cycle.hpp"
+
+namespace ctx = boost::ctx;
+namespace po = boost::program_options;
+
+bool preserve_fpu = true;
+
+#define CALL_FUNCTION(z,n,unused) \
+    fn();
+
+#define CALL_UCONTEXT(z,n,unused) \
+    ::swapcontext( & ucm, & uc);
+
+#define CALL_FCONTEXT(z,n,unused) \
+    ctx::jump_fcontext( & fcm, & fc, 7, preserve_fpu);
+
+#ifndef BOOST_WINDOWS
+ucontext_t uc, ucm;
+#endif
+ctx::fcontext_t fc, fcm;
+
+static void f3()
+{ }
+
+#ifndef BOOST_WINDOWS
+static void f2()
+{
+    while ( true)
+        ::swapcontext( & uc, & ucm);
+}
+#endif
+
+static void f1( intptr_t)
+{
+    while ( true)
+        ctx::jump_fcontext( & fc, & fcm, 7, preserve_fpu);
+}
+
+cycle_t test_function( cycle_t ov)
+{
+    boost::function< void() > fn( boost::bind( f3) );
+    // cache warum-up
+BOOST_PP_REPEAT_FROM_TO( 0, BOOST_PP_LIMIT_MAG, CALL_FUNCTION, ~)
+
+    cycle_t start( cycles() );
+BOOST_PP_REPEAT_FROM_TO( 0, BOOST_PP_LIMIT_MAG, CALL_FUNCTION, ~)
+    cycle_t total( cycles() - start);
+
+    // we have two jumps and two measuremt-overheads
+    total -= ov; // overhead of measurement
+    total /= BOOST_PP_LIMIT_MAG; // per call
+    total /= 2; // 2x jump_to c1->c2 && c2->c1
+
+    return total;
+}
+
+#ifndef BOOST_WINDOWS
+cycle_t test_ucontext( cycle_t ov)
+{
+    ctx::stack_allocator alloc;
+
+    ::getcontext( & uc);
+    uc.uc_stack.ss_sp = 
+        static_cast< char * >( alloc.allocate(ctx::default_stacksize() ) )
+        - ctx::default_stacksize();
+    uc.uc_stack.ss_size = ctx::default_stacksize();
+    ::makecontext( & uc, f2, 7);
+
+    // cache warum-up
+BOOST_PP_REPEAT_FROM_TO( 0, BOOST_PP_LIMIT_MAG, CALL_UCONTEXT, ~)
+
+    cycle_t start( cycles() );
+BOOST_PP_REPEAT_FROM_TO( 0, BOOST_PP_LIMIT_MAG, CALL_UCONTEXT, ~)
+    cycle_t total( cycles() - start);
+
+    // we have two jumps and two measuremt-overheads
+    total -= ov; // overhead of measurement
+    total /= BOOST_PP_LIMIT_MAG; // per call
+    total /= 2; // 2x jump_to c1->c2 && c2->c1
+
+    return total;
+}
+#endif
+
+cycle_t test_fcontext( cycle_t ov)
+{
+    ctx::stack_allocator alloc;
+    fc.fc_stack.base = alloc.allocate(ctx::default_stacksize());
+    fc.fc_stack.limit =
+        static_cast< char * >( fc.fc_stack.base) - ctx::default_stacksize();
+	ctx::make_fcontext( & fc, f1);
+
+    ctx::jump_fcontext( & fcm, & fc, 7, preserve_fpu);
+
+    // cache warum-up
+BOOST_PP_REPEAT_FROM_TO( 0, BOOST_PP_LIMIT_MAG, CALL_FCONTEXT, ~)
+
+    cycle_t start( cycles() );
+BOOST_PP_REPEAT_FROM_TO( 0, BOOST_PP_LIMIT_MAG, CALL_FCONTEXT, ~)
+    cycle_t total( cycles() - start);
+
+    // we have two jumps and two measuremt-overheads
+    total -= ov; // overhead of measurement
+    total /= BOOST_PP_LIMIT_MAG; // per call
+    total /= 2; // 2x jump_to c1->c2 && c2->c1
+
+    return total;
+}
+
+int main( int argc, char * argv[])
+{
+    try
+    {
+        po::options_description desc("allowed options");
+        desc.add_options()
+            ("help,h", "help message")
+            ("preserve-fpu,p", po::value< bool >( & preserve_fpu), "preserve floating point env");
+
+        po::variables_map vm;
+        po::store(
+            po::parse_command_line(
+                argc,
+                argv,
+                desc),
+            vm);
+        po::notify( vm);
+
+        if ( vm.count("help") )
+        {
+            std::cout << desc << std::endl;
+            return EXIT_SUCCESS;
+        }
+        bind_to_processor( 0);
+
+        cycle_t ov( overhead() );
+        std::cout << "overhead for rdtsc == " << ov << " cycles" << std::endl;
+
+        unsigned int res = test_fcontext( ov);
+        std::cout << "fcontext: average of " << res << " cycles per switch" << std::endl;
+#ifndef BOOST_WINDOWS
+        res = test_ucontext( ov);
+        std::cout << "ucontext: average of " << res << " cycles per switch" << std::endl;
+#endif
+        res = test_function( ov);
+        std::cout << "boost::function: average of " << res << " cycles per switch" << std::endl;
+
+        return EXIT_SUCCESS;
+    }
+    catch ( std::exception const& e)
+    { std::cerr << "exception: " << e.what() << std::endl; }
+    catch (...)
+    { std::cerr << "unhandled exception" << std::endl; }
+    return EXIT_FAILURE;
+}
+
+#undef CALL_FCONTEXT
+#undef CALL_UCONTEXT
Added: branches/release/libs/context/src/asm/fcontext_arm_aapcs_elf_gas.S
==============================================================================
--- (empty file)
+++ branches/release/libs/context/src/asm/fcontext_arm_aapcs_elf_gas.S	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,98 @@
+/*
+            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)
+*/
+
+/*******************************************************************
+ *                                                                 *
+ *  -------------------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  8  |  9  |  *
+ *  -------------------------------------------------------------  *
+ *  | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| 0x20| 0x24|  *
+ *  -------------------------------------------------------------  *
+ *  |  v1 |  v2 |  v3 |  v4 |  v5 |  v6 |  v7 |  v8 |  sp |  lr |  *
+ *  -------------------------------------------------------------  *
+ *  -------------------------------------------------------------  *
+ *  |  10 |                                                     |  *
+ *  -------------------------------------------------------------  *
+ *  | 0x28|                                                     |  *
+ *  -------------------------------------------------------------  *
+ *  |  pc |                                                     |  *
+ *  -------------------------------------------------------------  *
+ *  -------------------------------------------------------------  *
+ *  |  11 |  12 |                                               |  *
+ *  -------------------------------------------------------------  *
+ *  | 0x2c| 0x30|                                               |  *
+ *  -------------------------------------------------------------  *
+ *  |sbase|slimit|                                              |  *
+ *  -------------------------------------------------------------  *
+ *  -------------------------------------------------------------  *
+ *  |  13 |  14 | 15 |  16 |  17 |  18 |  19 |  20 |  21 |  22  |  *
+ *  -------------------------------------------------------------  *
+ *  | 0x34| 0x38|0x3c| 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58 |  *
+ *  -------------------------------------------------------------  *
+ *  | s16 | s17 | s18 | s19 | s20 | s21 | s22 | s23 | s24 | s25 |  *
+ *  -------------------------------------------------------------  *
+ *  -------------------------------------------------------------  *
+ *  |  23 |  24 |  25 |  26 |  27 |  28 |                       |  *
+ *  -------------------------------------------------------------  *
+ *  | 0x5c| 0x60| 0x64| 0x68| 0x6c| 0x70|                       |  *
+ *  -------------------------------------------------------------  *
+ *  | s26 | s27 | s28 | s29 | s30 | s31 |                       |  *
+ *  -------------------------------------------------------------  *
+ *                                                                 *
+ * *****************************************************************/
+
+.text
+.globl jump_fcontext
+.align 2
+.type jump_fcontext,%function
+jump_fcontext:
+    stmia   a1, {v1-v8,sp-lr}       @ save V1-V8,SP-LR
+    str     lr, [a1,#40]            @ save LR as PC
+#if (defined(__VFP_FP__) && !defined(__SOFTFP__))
+    cmp     a4, #0                  @ test if fpu env should be preserved
+    be      1f
+
+    ldr     a4, [a1,#52]
+    stmia   a4, {s16-s31}           @ save S16-S31
+
+    ldr     a4, [a2,#52]
+    ldmia   a4, {s16-s31}           @ restore S16-S31
+1:
+#endif
+
+	mov		a1, a3                  @ use third arg as return value after jump
+	                                @ and as first arg in context function
+    ldmia   a2, {v1-v8,sp-pc}       @ restore v1-V8,SP-PC
+.size jump_fcontext,.-jump_fcontext
+
+.text
+.globl make_fcontext
+.align 2
+.type make_fcontext,%function
+make_fcontext:
+    str     a1, [a1,#0]         @ save the address of passed context
+    str     a2, [a1,#40]        @ save address of the context function
+    ldr     a2, [a1,#44]        @ load the stack base
+
+	push    {a1,lr}				@ save pointer to fcontext_t
+	mov     a1, a2				@ stack pointer as arg for align_stack
+	bl		align_stack_at_PLT     @ align stack
+	mov		a2, a1				@ begin of aligned stack 
+	pop     {a1,lr}				@ restore pointer to fcontext_t
+
+    str     a2, [a1,#32]        @ save the aligned stack base
+
+    adr     a2, finish          @ address of finish; called after context function returns
+    str     a2, [a1,#36]
+
+    mov     a1, #0
+    bx      lr
+
+finish:
+    mov     a1, #0              @ exit code is zero
+    bl      _exit_at_PLT           @ exit application
+.size make_fcontext,.-make_fcontext
Added: branches/release/libs/context/src/asm/fcontext_i386_ms_pe_masm.asm
==============================================================================
--- (empty file)
+++ branches/release/libs/context/src/asm/fcontext_i386_ms_pe_masm.asm	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,151 @@
+
+;           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)
+
+;  --------------------------------------------------------------
+;  |    0    |    1    |    2    |    3    |    4     |    5    |
+;  --------------------------------------------------------------
+;  |    0h   |   04h   |   08h   |   0ch   |   010h   |   014h  |
+;  --------------------------------------------------------------
+;  |   EDI   |   ESI   |   EBX   |   EBP   |   ESP    |   EIP   |
+;  --------------------------------------------------------------
+;  --------------------------------------------------------------
+;  |    6    |    7    |                                        |
+;  --------------------------------------------------------------
+;  |   018h  |   01ch  |                                        |
+;  --------------------------------------------------------------
+;  | ss_base | ss_limit|                                        |
+;  --------------------------------------------------------------
+;  --------------------------------------------------------------
+;  |    8    |                                                  |
+;  --------------------------------------------------------------
+;  |  020h   |                                                  |
+;  --------------------------------------------------------------
+;  |fc_execpt|                                                  |
+;  --------------------------------------------------------------
+;  --------------------------------------------------------------
+;  |    9    |                                                  |
+;  --------------------------------------------------------------
+;  |  024h   |                                                  |
+;  --------------------------------------------------------------
+;  |fc_strage|                                                  |
+;  --------------------------------------------------------------
+;  --------------------------------------------------------------
+;  |   10    |    11   |                                        |
+;  --------------------------------------------------------------
+;  |  028h   |   02ch  |                                        |
+;  --------------------------------------------------------------
+;  | fc_mxcsr|fc_x87_cw|                                        |
+;  --------------------------------------------------------------
+
+.386
+.XMM
+.model flat, c
+_exit PROTO, value:SDWORD 
+align_stack PROTO, vp:DWORD
+seh_fcontext PROTO, except:DWORD, frame:DWORD, context:DWORD, dispatch:DWORD
+.code
+
+jump_fcontext PROC EXPORT
+    mov     ecx,         [esp+04h]  ; load address of the first fcontext_t arg
+    mov     [ecx],       edi        ; save EDI
+    mov     [ecx+04h],   esi        ; save ESI
+    mov     [ecx+08h],   ebx        ; save EBX
+    mov     [ecx+0ch],   ebp        ; save EBP
+
+    assume  fs:nothing
+    mov     edx,         fs:[018h]  ; load NT_TIB
+    assume  fs:error
+    mov     eax,         [edx]      ; load current SEH exception list
+    mov     [ecx+020h],  eax        ; save current exception list
+    mov     eax,         [edx+04h]  ; load current stack base
+    mov     [ecx+018h],  eax        ; save current stack base
+    mov     eax,         [edx+08h]  ; load current stack limit
+    mov     [ecx+01ch],  eax        ; save current stack limit
+    mov     eax,         [edx+010h] ; load fiber local storage
+    mov     [ecx+024h],  eax        ; save fiber local storage
+
+    lea     eax,         [esp+04h]  ; exclude the return address
+    mov     [ecx+010h],  eax        ; save as stack pointer
+    mov     eax,         [esp]      ; load return address
+    mov     [ecx+014h],  eax        ; save return address
+
+    mov     edx,        [esp+08h]   ; load address of the second fcontext_t arg
+    mov     edi,        [edx]       ; restore EDI
+    mov     esi,        [edx+04h]   ; restore ESI
+    mov     ebx,        [edx+08h]   ; restore EBX
+    mov     ebp,        [edx+0ch]   ; restore EBP
+
+    mov     eax,        [esp+010h]  ; check if fpu enve preserving was requested
+    test    eax,        eax 
+    je      nxt
+
+    stmxcsr [ecx+028h]              ; save MMX control word
+    fnstcw  [ecx+02ch]              ; save x87 control word
+    ldmxcsr [edx+028h]              ; restore MMX control word
+    fldcw   [edx+02ch]              ; restore x87 control word
+nxt:
+    mov     ecx,        edx
+    assume  fs:nothing
+    mov     edx,        fs:[018h]   ; load NT_TIB
+    assume  fs:error
+    mov     eax,        [ecx+020h]  ; load SEH exception list
+    mov     [edx],      eax         ; restore next SEH item
+    mov     eax,        [ecx+018h]  ; load stack base
+    mov     [edx+04h],  eax         ; restore stack base
+    mov     eax,        [ecx+01ch]  ; load stack limit
+    mov     [edx+08h],  eax         ; restore stack limit
+    mov     eax,        [ecx+024h]  ; load fiber local storage
+    mov     [edx+010h], eax         ; restore fiber local storage
+
+    mov     eax,        [esp+0ch]   ; use third arg as return value after jump
+
+    mov     esp,        [ecx+010h]  ; restore ESP
+    mov     [esp+04h],  eax         ; use third arg as first arg in context function
+    mov     ecx,        [ecx+014h]  ; fetch the address to return to
+
+    jmp     ecx                     ; indirect jump to context
+jump_fcontext ENDP
+
+make_fcontext PROC EXPORT
+    mov  eax,         [esp+04h]     ; load address of the fcontext_t arg0
+    mov  [eax],       eax           ; save the address of passed context
+    mov  ecx,         [esp+08h]     ; load the address of the context function
+    mov  [eax+014h],  ecx           ; save the address of the context function
+    mov  edx,         [eax+018h]    ; load the stack base
+
+    push  eax                       ; save pointer to fcontext_t
+    push  edx                       ; stack pointer as arg for align_stack
+    call  align_stack               ; align stack
+    mov   edx,        eax           ; begin of aligned stack
+    pop   eax                       ; remove arg for align_stack
+    pop   eax                       ; restore pointer to fcontext_t
+
+    lea  edx,         [edx-014h]    ; reserve space for last frame on stack, (ESP + 4) & 15 == 0
+    mov  [eax+010h],  edx           ; save the aligned stack
+
+    mov  ecx,         seh_fcontext  ; set ECX to exception-handler
+    mov  [edx+0ch],   ecx           ; save ECX as SEH handler
+    mov  ecx,         0ffffffffh    ; set ECX to -1
+    mov  [edx+08h],   ecx           ; save ECX as next SEH item
+    lea  ecx,         [edx+08h]     ; load address of next SEH item
+    mov  [eax+02ch],  ecx           ; save next SEH
+
+    stmxcsr [eax+028h]              ; save MMX control word
+    fnstcw  [eax+02ch]              ; save x87 control word
+
+    mov  ecx,         finish        ; address of finish
+    mov  [edx],       ecx
+
+    xor  eax,         eax
+    ret
+
+finish:
+    xor   eax,        eax
+    push  eax                       ; exit code is zero
+    call  _exit                     ; exit application
+    hlt
+make_fcontext ENDP
+END
Added: branches/release/libs/context/src/asm/fcontext_i386_sysv_elf_gas.S
==============================================================================
--- (empty file)
+++ branches/release/libs/context/src/asm/fcontext_i386_sysv_elf_gas.S	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,122 @@
+/*
+            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)
+*/
+
+/********************************************************************
+ *                                                                  *
+ *  --------------------------------------------------------------  *
+ *  |    0    |    1    |    2    |    3    |    4     |    5    |  *
+ *  --------------------------------------------------------------  *
+ *  |   0x0   |   0x4   |   0x8   |   0xc   |   0x10   |   0x14  |  *
+ *  --------------------------------------------------------------  *
+ *  |   EDI   |   ESI   |   EBX   |   EBP   |   ESP    |   EIP   |  *
+ *  --------------------------------------------------------------  *
+ *  --------------------------------------------------------------  *
+ *  |    6    |    7    |                                        |  *
+ *  --------------------------------------------------------------  *
+ *  |   0x18  |   0x1c  |                                        |  *
+ *  --------------------------------------------------------------  *
+ *  |  sbase  | slimit  |                                        |  *
+ *  --------------------------------------------------------------  *
+ *  --------------------------------------------------------------  *
+ *  |    8    |    9    |                                        |  *
+ *  --------------------------------------------------------------  *
+ *  |   0x20  |   0x24  |                                        |  *
+ *  --------------------------------------------------------------  *
+ *  | fc_mxcsr|fc_x87_cw|                                        |  *
+ *  --------------------------------------------------------------  *
+ *                                                                  *
+ * *****************************************************************/
+
+.text
+.globl jump_fcontext
+.align 2
+.type jump_fcontext,@function
+jump_fcontext:
+    movl    0x4(%esp), %ecx         /* load address of the first fcontext_t arg */
+    movl    %edi,       (%ecx)      /* save EDI */
+    movl    %esi,       0x4(%ecx)   /* save ESI */
+    movl    %ebx,       0x8(%ecx)   /* save EBX */
+    movl    %ebp,       0xc(%ecx)   /* save EBP */
+
+    leal    0x4(%esp),  %eax        /* exclude the return address */
+    movl    %eax,       0x10(%ecx)  /* save as stack pointer */
+    movl    (%esp),     %eax        /* load return address */
+    movl    %eax,       0x14(%ecx)  /* save return address */
+
+    movl    0x8(%esp),   %edx       /* load address of the second fcontext_t arg */
+    movl    (%edx),      %edi       /* restore EDI */
+    movl    0x4(%edx),   %esi       /* restore ESI */
+    movl    0x8(%edx),   %ebx       /* restore EBX */
+    movl    0xc(%edx),   %ebp       /* restore EBP */
+
+    movl    0x10(%esp),  %eax       /* check if fpu enve preserving was requested */
+    test    %eax,        %eax
+    je      1f
+
+    stmxcsr  0x20(%ecx)             /* save MMX control and status word */
+    fnstcw   0x24(%ecx)             /* save x87 control word */
+    ldmxcsr  0x20(%edx)             /* restore MMX control and status word */
+    fldcw    0x24(%edx)             /* restore x87 control word */
+1:
+    movl    0xc(%esp),   %eax       /* use third arg as return value after jump */
+
+    movl    0x10(%edx),  %esp       /* restore ESP */
+    movl    %eax,        0x4(%esp)  /* use third arg as first arg in context function */
+    movl    0x14(%edx),  %edx       /* fetch the address to return to */
+
+    jmp     *%edx                   /* indirect jump to context */
+.size jump_fcontext,.-jump_fcontext
+
+.text
+.globl make_fcontext
+.align 2
+.type make_fcontext,@function
+make_fcontext:
+    movl   0x4(%esp),      %eax         /* load address of the fcontext_t */
+    movl   %eax,           (%eax)       /* save the address of current context */
+    movl   0x8(%esp),      %ecx         /* load the address of the context function */
+    movl   %ecx,           0x14(%eax)   /* save the address of the context function */
+    movl   0x18(%eax),     %edx         /* load the stack base */
+
+    pushl  %eax                         /* save pointer to fcontext_t */
+    pushl  %ebx                         /* save EBX */
+    pushl  %edx                         /* stack pointer as arg for align_stack */
+    call   1f
+1:  popl   %ebx                         /* address of label 1 */
+    addl   $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx     /* compute address of GOT and store it in EBX */
+    call   align_stack_at_PLT              /* align stack */
+    movl   %eax,           %edx         /* begin of aligned stack */
+    popl   %eax                         /* remove arg for align_stack */
+    popl   %ebx                         /* restore EBX */
+    popl   %eax                         /* restore pointer to fcontext_t */
+
+    leal   -0x14(%edx),    %edx         /* reserve space for the last frame on stack, (ESP + 4) % 16 == 0 */
+    movl   %edx,           0x10(%eax)   /* save the aligned stack base */
+
+    stmxcsr  0x20(%eax)                 /* save MMX control and status word */
+    fnstcw   0x24(%eax)                 /* save x87 control word */
+
+    call    2f
+2:  popl    %ecx                        /* address of label 2 */
+    addl    $finish-2b, %ecx            /* helper code executed after context function returns */
+    movl    %ecx, (%edx)
+
+    xorl   %eax,            %eax
+    ret
+
+finish:
+    leal   -0xc(%esp),    %esp
+
+    call    3f
+3:  popl    %ebx                                    /* address of label 3 */
+    addl    $_GLOBAL_OFFSET_TABLE_+[.-3b], %ebx     /* compute address of GOT and store it in EBX */
+
+    xorl    %eax,           %eax
+    pushl   %eax                        /* exit code is zero */
+    call   _exit_at_PLT                    /* exit application */
+    hlt
+.size make_fcontext,.-make_fcontext
Added: branches/release/libs/context/src/asm/fcontext_i386_sysv_macho_gas.S
==============================================================================
--- (empty file)
+++ branches/release/libs/context/src/asm/fcontext_i386_sysv_macho_gas.S	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,118 @@
+/*
+            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)
+*/
+
+/********************************************************************
+ *                                                                  *
+ *  --------------------------------------------------------------  *
+ *  |    0    |    1    |    2    |    3    |    4     |    5    |  *
+ *  --------------------------------------------------------------  *
+ *  |   0x0   |   0x4   |   0x8   |   0xc   |   0x10   |   0x14  |  *
+ *  --------------------------------------------------------------  *
+ *  |   EDI   |   ESI   |   EBX   |   EBP   |   ESP    |   EIP   |  *
+ *  --------------------------------------------------------------  *
+ *  --------------------------------------------------------------  *
+ *  |    6    |    7    |                                        |  *
+ *  --------------------------------------------------------------  *
+ *  |   0x18  |   0x1c  |                                        |  *
+ *  --------------------------------------------------------------  *
+ *  |  sbase  | slimit  |                                        |  *
+ *  --------------------------------------------------------------  *
+ *  --------------------------------------------------------------  *
+ *  |    8    |    9    |                                        |  *
+ *  --------------------------------------------------------------  *
+ *  |   0x20  |   0x24  |                                        |  *
+ *  --------------------------------------------------------------  *
+ *  | fc_mxcsr|fc_x87_cw|                                        |  *
+ *  --------------------------------------------------------------  *
+ *                                                                  *
+ * *****************************************************************/
+
+.text
+.globl _jump_fcontext
+.align 2
+_jump_fcontext:
+    movl    0x4(%esp), %ecx         /* load address of the first fcontext_t arg */
+    movl    %edi,       (%ecx)      /* save EDI */
+    movl    %esi,       0x4(%ecx)   /* save ESI */
+    movl    %ebx,       0x8(%ecx)   /* save EBX */
+    movl    %ebp,       0xc(%ecx)   /* save EBP */
+
+    leal    0x4(%esp),  %eax        /* exclude the return address */
+    movl    %eax,       0x10(%ecx)  /* save as stack pointer */
+    movl    (%esp),     %eax        /* load return address */
+    movl    %eax,       0x14(%ecx)  /* save return address */
+
+    movl    0x8(%esp),   %edx       /* load address of the second fcontext_t arg */
+    movl    (%edx),      %edi       /* restore EDI */
+    movl    0x4(%edx),   %esi       /* restore ESI */
+    movl    0x8(%edx),   %ebx       /* restore EBX */
+    movl    0xc(%edx),   %ebp       /* restore EBP */
+
+    movl    0x10(%esp),  %eax       /* check if fpu enve preserving was requested */
+    test    %eax,        %eax
+    je      1f
+
+    stmxcsr  0x20(%ecx)             /* save MMX control and status word */
+    fnstcw   0x24(%ecx)             /* save x87 control word */
+    ldmxcsr  0x20(%edx)             /* restore MMX control and status word */
+    fldcw    0x24(%edx)             /* restore x87 control word */
+1:
+    movl    0xc(%esp),   %eax       /* use third arg as return value after jump */
+
+    movl    0x10(%edx),  %esp       /* restore ESP */
+    movl    %eax,        0x4(%esp)  /* use third arg as first arg in context function */
+    movl    0x14(%edx),  %edx       /* fetch the address to return to */
+
+    jmp     *%edx                   /* indirect jump to context */
+
+.text
+.globl _make_fcontext
+.align 2
+_make_fcontext:
+    movl   0x4(%esp),      %eax         /* load address of the fcontext_t */
+    movl   %eax,           (%eax)       /* save the address of current context */
+    movl   0x8(%esp),      %ecx         /* load the address of the context function */
+    movl   %ecx,           0x14(%eax)   /* save the address of the context function */
+    movl   0x18(%eax),     %edx         /* load the stack base */
+
+    pushl  %eax                         /* save pointer to fcontext_t */
+    pushl  %ebx                         /* save EBX */
+    pushl  %edx                         /* stack pointer as arg for align_stack */
+    call   1f
+1:  popl   %ebx                         /* address of label 1 */
+    addl   $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx     /* compute address of GOT and store it in EBX */
+    call   align_stack_at_PLT              /* align stack */
+    movl   %eax,           %edx         /* begin of aligned stack */
+    popl   %eax                         /* remove arg for align_stack */
+    popl   %ebx                         /* restore EBX */
+    popl   %eax                         /* restore pointer to fcontext_t */
+
+    leal   -0x14(%edx),    %edx         /* reserve space for the last frame on stack, (ESP + 4) % 16 == 0 */
+    movl   %edx,           0x10(%eax)   /* save the aligned stack base */
+
+    stmxcsr  0x20(%eax)                 /* save MMX control and status word */
+    fnstcw   0x24(%eax)                 /* save x87 control word */
+
+    call    2f
+2:  popl    %ecx                        /* address of label 2 */
+    addl    $finish-2b, %ecx            /* helper code executed after context function returns */
+    movl    %ecx, (%edx)
+
+    xorl   %eax,            %eax
+    ret
+
+finish:
+    leal   -0xc(%esp),    %esp
+
+    call    3f
+3:  popl    %ebx                                    /* address of label 3 */
+    addl    $_GLOBAL_OFFSET_TABLE_+[.-3b], %ebx     /* compute address of GOT and store it in EBX */
+
+    xorl    %eax,           %eax
+    pushl   %eax                        /* exit code is zero */
+    call   _exit_at_PLT                    /* exit application */
+    hlt
Added: branches/release/libs/context/src/asm/fcontext_mips32_o32_elf_gas.S
==============================================================================
--- (empty file)
+++ branches/release/libs/context/src/asm/fcontext_mips32_o32_elf_gas.S	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,144 @@
+/*
+            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)
+*/
+
+/*******************************************************************
+ *                                                                 *
+ *  -------------------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  8  |  9  |  *
+ *  -------------------------------------------------------------  *
+ *  |  0  |  8  |  16 |  24 |  32 |  40 |  48 |  56 |  64 |  72 |  *
+ *  -------------------------------------------------------------  *
+ *  |  S0 |  S1 |  S2 |  S3 |  S4 |  S5 |  S6 |  S7 |  GP |  SP |  *
+ *  -------------------------------------------------------------  *
+ *  -------------------------------------------------------------  *
+ *  |  10 |  11 |  12 |                                         |  *
+ *  -------------------------------------------------------------  *
+ *  |  80 |  88 |  96 |                                         |  *
+ *  -------------------------------------------------------------  *
+ *  |  S8 |  RA |  PC |                                         |  *
+ *  -------------------------------------------------------------  *
+ *  -------------------------------------------------------------  *
+ *  |  13 |  14 |                                               |  *
+ *  -------------------------------------------------------------  *
+ *  | 104 | 112 |                                               |  *
+ *  -------------------------------------------------------------  *
+ *  |sbase|slimt|                                               |  *
+ *  -------------------------------------------------------------  *
+ *  -------------------------------------------------------------  *
+ *  |  15 |  16 |  17 |  18 |  19 |  20 |                       |  *
+ *  -------------------------------------------------------------  *
+ *  | 120 | 128 | 136 | 144 | 152 | 160 |                       |  *
+ *  -------------------------------------------------------------  *
+ *  | F20 | F22 | F24 | F26 | F28 | F30 |                       |  *
+ *  -------------------------------------------------------------  *
+ *                                                                 *
+ * *****************************************************************/
+
+.text
+.globl jump_fcontext
+.align 2
+.type jump_fcontext,@function
+.ent jump_fcontext
+jump_fcontext:
+    sw      $s0, ($a0)      # save S0
+    sw      $s1, 8($a0)     # save S1
+    sw      $s2, 16($a0)    # save S2
+    sw      $s3, 24($a0)    # save S3
+    sw      $s4, 32($a0)    # save S4
+    sw      $s5, 40($a0)    # save S5
+    sw      $s6, 48($a0)    # save S6
+    sw      $s7, 56($a0)    # save S7
+    sw      $gp, 64($a0)    # save GP
+    sw      $sp, 72($a0)    # save SP
+    sw      $s8, 80($a0)    # save S8
+    sw      $ra, 88($a0)    # save RA
+    sw      $ra, 96($a0)    # save RA as PC
+
+#if defined(__mips_hard_float)
+    beqz    $a3,  1f        # test if fpu env should be preserved 
+    s.d     $f20, 120($a0)  # save F20
+    s.d     $f22, 128($a0)  # save F22
+    s.d     $f24, 136($a0)  # save F24
+    s.d     $f26, 144($a0)  # save F26
+    s.d     $f28, 152($a0)  # save F28
+    s.d     $f30, 160($a0)  # save F30
+
+    l.d     $f20, 120($a1)  # restore F20
+    l.d     $f22, 128($a1)  # restore F22
+    l.d     $f24, 136($a1)  # restore F24
+    l.d     $f26, 144($a1)  # restore F26
+    l.d     $f28, 152($a1)  # restore F28
+    l.d     $f30, 160($a1)  # restore F30
+1:
+#endif
+
+    lw      $s0, ($a1)      # restore S0
+    lw      $s1, 8($a1)     # restore S1
+    lw      $s2, 16($a1)    # restore S2
+    lw      $s3, 24($a1)    # restore S3
+    lw      $s4, 32($a1)    # restore S4
+    lw      $s5, 40($a1)    # restore S5
+    lw      $s6, 48($a1)    # restore S6
+    lw      $s7, 56($a1)    # restore S7
+    lw      $gp, 64($a1)    # restore GP
+    lw      $sp, 72($a1)    # restore SP
+    lw      $s8, 80($a1)    # restore S8
+    lw      $ra, 88($a1)    # restore RA
+    move    $a0, $s2        # restore void pointer as argument
+
+    move    $v0, $a2        # use third arg as return value after jump
+    move    $a0, $a2        # use third arg as first arg in context function
+
+    lw      $t9, 96($a1)    # load PC
+    jr      $t9             # jump to context
+.end jump_fcontext
+.size jump_fcontext, .-jump_fcontext
+
+.text
+.globl make_fcontext
+.align 2
+.type make_fcontext,@function
+.ent make_fcontext
+make_fcontext:
+#ifdef __PIC__
+.set    noreorder
+.cpload $t9
+.set    reorder
+#endif
+    sw      $a0, ($a0)          # save the current context
+    sw      $gp, 24($a0)        # save global pointer
+    sw      $a1, 96($a0)        # save the address of the context function
+    lw      $t0, 104($a0)       # load the stack base
+
+    sub     $sp, $sp, 28
+    sw      $ra, 24($sp)
+    sw      $a0, 20($sp)
+    move    $a0, $t0            # stack pointer as arg for align_stack
+    lw      $t9, %call16(align_stack)($gp) # align stack
+    jalr    $t9
+    nop
+    move    $t0, $v0            # begin of aligned stack 
+    lw      $ra, 24($sp)
+    lw      $a0, 20($sp)
+    addi    $sp, $sp, 28
+
+    sub     $t0, $t0, 16        # reserve 16 byte of argument space
+    sw      $t0, 72($a0)        # save the algned stack base
+
+    la      $t9, finish         # helper code executed after context function returns
+    sw      $t9, 88($a0)
+
+    move    $v0, $zero
+    jr      $ra
+
+finish:
+    move    $gp, $s3            # restore GP (global pointer)
+    move    $a0, $zero          # exit code is zero
+    lw      $t9, %call16(_exit)($gp)  # exit application
+    jalr    $t9
+.end make_fcontext
+.size make_fcontext, .-make_fcontext
Added: branches/release/libs/context/src/asm/fcontext_ppc32_sysv_elf_gas.S
==============================================================================
--- (empty file)
+++ branches/release/libs/context/src/asm/fcontext_ppc32_sysv_elf_gas.S	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,222 @@
+/*
+            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)
+*/
+
+/*******************************************************************
+ *                                                                 *
+ *  -------------------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  8  |  9  |  *
+ *  -------------------------------------------------------------  *
+ *  |  0  |  4  |  8  |  12 |  16 |  20 |  24 |  28 |  32 |  36 |  *
+ *  -------------------------------------------------------------  *
+ *  | R13 | R14 | R15 | R16 | R17 | R18 | R19 | R20 | R21 | R22 |  *
+ *  -------------------------------------------------------------  *
+ *  -------------------------------------------------------------  *
+ *  |  10 |  11 |  12 |  13 |  14 |  15 |  16 |  17 |  18 |  19 |  *
+ *  -------------------------------------------------------------  *
+ *  |  40 |  44 |  48 |  52 |  56 |  60 |  64 |  68 |  72 |  76 |  *
+ *  -------------------------------------------------------------  *
+ *  | R23 | R24 | R25 | R26 | R27 | R28 | R29 | R30 | R31 |  SP |  *
+ *  -------------------------------------------------------------  *
+ *  -------------------------------------------------------------  *
+ *  |  20 |  21 |  22 |                                         |  *
+ *  -------------------------------------------------------------  *
+ *  |  80 |  84 |  88 |                                         |  *
+ *  -------------------------------------------------------------  *
+ *  |  CR |  LR |  PC |                                         |  *
+ *  -------------------------------------------------------------  *
+ *  -------------------------------------------------------------  *
+ *  |  23 |  24 |                                               |  *
+ *  -------------------------------------------------------------  *
+ *  |  92 |  96 |                                               |  *
+ *  -------------------------------------------------------------  *
+ *  |sbase|slimt|                                               |  *
+ *  -------------------------------------------------------------  *
+ *  -------------------------------------------------------------  *
+ *  |  25 |  26 |  27 |  28 |  29 |  30 |  31 |  32 |  33 |  34 |  *
+ *  -------------------------------------------------------------  *
+ *  | 100 | 104 | 108 | 112 | 116 | 120 | 124 | 128 | 132 | 136 |  *
+ *  -------------------------------------------------------------  *
+ *  |    F14    |    F15    |    F16    |    F17    |    F18    |  *
+ *  -------------------------------------------------------------  *
+ *  -------------------------------------------------------------  *
+ *  |  35 |  36 |  37 |  38 |  39 |  40 |  41 |  42 |  43 |  44 |  *
+ *  -------------------------------------------------------------  *
+ *  | 140 | 144 | 148 | 152 | 156 | 160 | 164 | 168 | 172 | 176 |  *
+ *  -------------------------------------------------------------  *
+ *  |    F19    |    F20    |    F21    |    F22    |    F23    |  *
+ *  -------------------------------------------------------------  *
+ *  -------------------------------------------------------------  *
+ *  |  45 |  46 |  47 |  48 |  49 |  50 |  51 |  52 |  53 |  54 |  *
+ *  -------------------------------------------------------------  *
+ *  | 180 | 184 | 188 | 192 | 196 | 200 | 204 | 208 | 212 | 216 |  *
+ *  -------------------------------------------------------------  *
+ *  |    F24    |    F25    |    F26    |    F27    |    F28    |  *
+ *  -------------------------------------------------------------  *
+ *  -------------------------------------------------------------  *
+ *  |  55 |  56 |  57 |  58 |  59 |  60 |  61 |  62 |           |  *
+ *  -------------------------------------------------------------  *
+ *  | 220 | 224 | 228 | 232 | 236 | 240 | 244 | 248 |           |  *
+ *  -------------------------------------------------------------  *
+ *  |    F29    |    F30    |    F31    |   fpscr   |           |  *
+ *  -------------------------------------------------------------  *
+ *                                                                 *
+ * *****************************************************************/
+
+.text
+.globl jump_fcontext
+.align 2
+.type jump_fcontext,@function
+jump_fcontext:
+    stw     %r13,  0(%r3)       # save R13
+    stw     %r14,  4(%r3)       # save R14
+    stw     %r15,  8(%r3)       # save R15
+    stw     %r16,  12(%r3)      # save R16
+    stw     %r17,  16(%r3)      # save R17
+    stw     %r18,  20(%r3)      # save R18
+    stw     %r19,  24(%r3)      # save R19
+    stw     %r20,  28(%r3)      # save R20
+    stw     %r21,  32(%r3)      # save R21
+    stw     %r22,  36(%r3)      # save R22
+    stw     %r23,  40(%r3)      # save R23
+    stw     %r24,  44(%r3)      # save R24
+    stw     %r25,  48(%r3)      # save R25
+    stw     %r26,  52(%r3)      # save R26
+    stw     %r27,  56(%r3)      # save R27
+    stw     %r28,  60(%r3)      # save R28
+    stw     %r29,  64(%r3)      # save R29
+    stw     %r30,  68(%r3)      # save R30
+    stw     %r31,  72(%r3)      # save R31
+    stw     %r1,   76(%r3)      # save SP
+
+    mfcr    %r0                 # load CR
+    stw     %r0,   80(%r3)      # save CR
+    mflr    %r0                 # load LR
+    stw     %r0,   84(%r3)      # save LR
+    stw     %r0,   88(%r3)      # save LR as PC
+
+    cmpwi   cr7,   %r6,  0      # test if fpu env should be preserved
+    beq     cr7,   1f
+
+    stfd    %f14,  100(%r3)     # save F14
+    stfd    %f15,  108(%r3)     # save F15
+    stfd    %f16,  116(%r3)     # save F16
+    stfd    %f17,  124(%r3)     # save F17
+    stfd    %f18,  132(%r3)     # save F18
+    stfd    %f19,  140(%r3)     # save F19
+    stfd    %f20,  148(%r3)     # save F20
+    stfd    %f21,  156(%r3)     # save F21
+    stfd    %f22,  164(%r3)     # save F22
+    stfd    %f23,  172(%r3)     # save F23
+    stfd    %f24,  180(%r3)     # save F24
+    stfd    %f25,  188(%r3)     # save F25
+    stfd    %f26,  196(%r3)     # save F26
+    stfd    %f27,  204(%r3)     # save F27
+    stfd    %f28,  212(%r3)     # save F28
+    stfd    %f29,  220(%r3)     # save F29
+    stfd    %f30,  228(%r3)     # save F30
+    stfd    %f31,  236(%r3)     # save F31
+    mffs    %f0                 # load FPSCR
+    stfd    %f0,   244(%r3)     # save FPSCR
+
+    lfd     %f14,  100(%r4)     # restore F14
+    lfd     %f15,  108(%r4)     # restore F15
+    lfd     %f16,  116(%r4)     # restore F16
+    lfd     %f17,  124(%r4)     # restore F17
+    lfd     %f18,  132(%r4)     # restore F18
+    lfd     %f19,  140(%r4)     # restore F19
+    lfd     %f20,  148(%r4)     # restore F20
+    lfd     %f21,  156(%r4)     # restore F21
+    lfd     %f22,  164(%r4)     # restore F22
+    lfd     %f23,  172(%r4)     # restore F23
+    lfd     %f24,  180(%r4)     # restore F24
+    lfd     %f25,  188(%r4)     # restore F25
+    lfd     %f26,  196(%r4)     # restore F26
+    lfd     %f27,  204(%r4)     # restore F27
+    lfd     %f28,  212(%r4)     # restore F28
+    lfd     %f29,  220(%r4)     # restore F29
+    lfd     %f30,  228(%r4)     # restore F30
+    lfd     %f31,  236(%r4)     # restore F31
+    lfd     %f0,   244(%r4)     # load FPSCR
+    mtfsf   0xff,  %f0          # restore FPSCR
+1:
+
+    lwz     %r13,  0(%r4)       # restore R13
+    lwz     %r14,  4(%r4)       # restore R14
+    lwz     %r15,  8(%r4)       # restore R15
+    lwz     %r16,  12(%r4)      # restore R16
+    lwz     %r17,  16(%r4)      # restore R17
+    lwz     %r18,  20(%r4)      # restore R18
+    lwz     %r19,  24(%r4)      # restore R19
+    lwz     %r20,  28(%r4)      # restore R20
+    lwz     %r21,  32(%r4)      # restore R21
+    lwz     %r22,  36(%r4)      # restore R22
+    lwz     %r23,  40(%r4)      # restore R23
+    lwz     %r24,  44(%r4)      # restore R24
+    lwz     %r25,  48(%r4)      # restore R25
+    lwz     %r26,  52(%r4)      # restore R26
+    lwz     %r27,  56(%r4)      # restore R27
+    lwz     %r28,  60(%r4)      # restore R28
+    lwz     %r29,  64(%r4)      # restore R29
+    lwz     %r30,  68(%r4)      # restore R30
+    lwz     %r31,  72(%r4)      # restore R31
+    lwz     %r1,   76(%r4)      # restore SP
+
+    lwz     %r0,   80(%r4)      # load CR
+    mtcr    %r0                 # restore CR
+    lwz     %r0,   84(%r4)      # load LR
+    mtlr    %r0                 # restore LR
+
+    mr.     %r3,   %r5          # use third arg as return value after jump
+                                # and as first arg in context function
+
+    lwz     %r0,   88(%r4)      # load PC
+    mtctr   %r0                 # restore CTR
+
+    bctr                        # jump to context
+.size jump_fcontext, .-jump_fcontext
+
+.text
+.globl make_fcontext
+.align 2
+.type make_fcontext,@function
+make_fcontext:
+    stw     %r3, 0(%r3)         # save the current context
+    stw     %r4, 88(%r3)        # save the address of the context function
+    lwz     %r0, 92(%r3)        # load the stack base
+
+    li      %r4, 28
+    subf    %r1, %r4, %r1       # reserve space on stack
+    stw     %r3, 24(%r1)        # store pointer to fcontext_t on stack
+    mflr    %r4                 # load LR
+    stw     %r4, 20(%r1)        # store LR on stack
+    mr.     %r3, %r0            # context stack as arg to align_stack
+    bl      align_stack_at_plt     # call align_stack
+    mr.     %r0, %r3            # load result into R0
+    lwz     %r4, 20(%r1)        # pop LR from stack
+    mtlr    %r4                 # restore LR
+    lwz     %r3, 24(%r1)        # pop pointer to fcontext_t from stack
+    addi    %r1, %r1, 28        # release space on stack
+
+    li      %r4, 32
+    subf    %r0, %r4, %r0       # 32 bytes on stack for parameter area(== 8 registers)
+    stw     %r0, 76(%r3)        # save the aligned stack base
+
+    mflr    %r0                 # load LR
+    bl      1f                  # jump to label 1
+1:
+    mflr    %r4                 # load LR
+    addi    %r4, %r4, finish - 1b    # address of finish; called after context function returns
+    mtlr    %r0                 # restore LR
+    stw     %r4, 84(%r3)
+
+    li      %r3,  0
+    blr
+
+finish:
+    li      %r3,  0             # exit code is zero
+    bl      _exit_at_plt           # exit application
+.size make_fcontext, .-make_fcontext
Added: branches/release/libs/context/src/asm/fcontext_ppc64_sysv_elf_gas.S
==============================================================================
--- (empty file)
+++ branches/release/libs/context/src/asm/fcontext_ppc64_sysv_elf_gas.S	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,250 @@
+/*
+            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)
+*/
+
+/*******************************************************************
+ *                                                                 *
+ *  -------------------------------------------------------------  *
+ *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  8  |  9  |  *
+ *  -------------------------------------------------------------  *
+ *  |  0  |  4  |   8 |  12 |  16 |  20 |  24 |  28 |  32 |  36 |  *
+ *  -------------------------------------------------------------  *
+ *  |    R13    |    R14    |    R15    |    R16    |    R17    |  *
+ *  -------------------------------------------------------------  *
+ *  -------------------------------------------------------------  *
+ *  |  10 |  11 |  12 |  13 |  14 |  15 |  16 |  17 |  18 |  19 |  *
+ *  -------------------------------------------------------------  *
+ *  |  40 |  44 |  48 |  52 |  56 |  60 |  64 |  68 |  72 |  76 |  *
+ *  -------------------------------------------------------------  *
+ *  |    R18    |    R19    |    R20    |    R21    |    R22    |  *
+ *  -------------------------------------------------------------  *
+ *  -------------------------------------------------------------  *
+ *  |  20 |  21 |  22 |  23 |  24 |  25 |  26 |  27 |  28 |  29 |  *
+ *  -------------------------------------------------------------  *
+ *  |  80 |  84 |  88 |  92 |  96 | 100 | 104 | 108 | 112 | 116 |  *
+ *  -------------------------------------------------------------  *
+ *  |    R23    |    R24    |    R25    |    R26    |    R27    |  *
+ *  -------------------------------------------------------------  *
+ *  -------------------------------------------------------------  *
+ *  |  30 |  31 |  32 |  33 |  34 |  35 |  36 |  37 |  38 |  39 |  *
+ *  -------------------------------------------------------------  *
+ *  | 120 | 124 | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 |  *
+ *  -------------------------------------------------------------  *
+ *  |    R28    |    R29    |    R30    |    R31    |     SP    |  *
+ *  -------------------------------------------------------------  *
+ *  -------------------------------------------------------------  *
+ *  |  40 |  41 |  42 |  43 |  44 |  45 |                       |  *
+ *  -------------------------------------------------------------  *
+ *  | 160 | 164 | 168 | 172 | 176 | 180 |                       |  *
+ *  -------------------------------------------------------------  *
+ *  |    CR     |    LR     |     PC    |                       |  *
+ *  -------------------------------------------------------------  *
+ *  -------------------------------------------------------------  *
+ *  |  46 |  47 |  48 |  49 |                                   |  *
+ *  -------------------------------------------------------------  *
+ *  | 184 | 188 | 192 | 196 |                                   |  *
+ *  -------------------------------------------------------------  *
+ *  |   sbase   |   slimt   |                                   |  *
+ *  -------------------------------------------------------------  *
+ *  -------------------------------------------------------------  *
+ *  |  50 |  51 |  52 |  53 |  54 |  55 |  56 |  57 |  58 |  59 |  *
+ *  -------------------------------------------------------------  *
+ *  | 200 | 204 | 208 | 212 | 216 | 220 | 224 | 228 | 232 | 236 |  *
+ *  -------------------------------------------------------------  *
+ *  |    F14    |    F15    |    F16    |    F17    |    F18    |  *
+ *  -------------------------------------------------------------  *
+ *  -------------------------------------------------------------  *
+ *  |  60 |  61 |  62 |  63 |  64 |  65 |  66 |  67 |  68 |  69 |  *
+ *  -------------------------------------------------------------  *
+ *  | 240 | 244 | 248 | 252 | 256 | 260 | 264 | 268 | 272 | 276 |  *
+ *  -------------------------------------------------------------  *
+ *  |    F19    |    F20    |    F21    |    F22    |    F23    |  *
+ *  -------------------------------------------------------------  *
+ *  -------------------------------------------------------------  *
+ *  |  70 |  71 |  72 |  73 |  74 |  75 |  76 |  77 |  78 |  79 |  *
+ *  -------------------------------------------------------------  *
+ *  | 280 | 284 | 288 | 292 | 296 | 300 | 304 | 308 | 312 | 316 |  *
+ *  -------------------------------------------------------------  *
+ *  |    F24    |    F25    |    F26    |    F27    |    F28    |  *
+ *  -------------------------------------------------------------  *
+ *  -------------------------------------------------------------  *
+ *  |  80 |  81 |  82 |  83 |  84 |  85 |  86 |  87 |           |  *
+ *  -------------------------------------------------------------  *
+ *  | 320 | 324 | 328 | 332 | 336 | 340 | 344 | 348 |           |  *
+ *  -------------------------------------------------------------  *
+ *  |    F29    |    F30    |    F31    |   fpscr   |           |  *
+ *  -------------------------------------------------------------  *
+ *                                                                 *
+ * *****************************************************************/
+
+.section ".text"
+.align 2
+.globl jump_fcontext
+.section ".opd","aw"
+.align 3
+jump_fcontext:
+.quad .jump_fcontext,.TOC._at_tocbase,0
+.previous
+.size jump_fcontext,24
+.type .jump_fcontext,@function
+.globl .jump_fcontext
+.jump_fcontext:
+    std     %r13,  0(%r3)       # save R13
+    std     %r14,  8(%r3)       # save R14
+    std     %r15,  16(%r3)      # save R15
+    std     %r16,  24(%r3)      # save R16
+    std     %r17,  32(%r3)      # save R17
+    std     %r18,  40(%r3)      # save R18
+    std     %r19,  48(%r3)      # save R19
+    std     %r20,  56(%r3)      # save R20
+    std     %r21,  64(%r3)      # save R21
+    std     %r22,  72(%r3)      # save R22
+    std     %r23,  80(%r3)      # save R23
+    std     %r24,  88(%r3)      # save R24
+    std     %r25,  96(%r3)      # save R25
+    std     %r26,  104(%r3)     # save R26
+    std     %r27,  112(%r3)     # save R27
+    std     %r28,  120(%r3)     # save R28
+    std     %r29,  128(%r3)     # save R29
+    std     %r30,  136(%r3)     # save R30
+    std     %r31,  144(%r3)     # save R31
+    std     %r1,   152(%r3)     # save SP
+
+    mfcr    %r0                 # load CR
+    std     %r0,   160(%r3)     # save CR
+    mflr    %r0                 # load LR
+    std     %r0,   168(%r3)     # save LR
+    std     %r0,   176(%r3)     # save LR as PC
+
+    cmpwi   cr7,   %r6,  0      # test if fpu env should be preserved
+    beq     cr7,   1f
+
+    stfd    %f14,  200(%r3)     # save F14
+    stfd    %f15,  208(%r3)     # save F15
+    stfd    %f16,  216(%r3)     # save F16
+    stfd    %f17,  224(%r3)     # save F17
+    stfd    %f18,  232(%r3)     # save F18
+    stfd    %f19,  240(%r3)     # save F19
+    stfd    %f20,  248(%r3)     # save F20
+    stfd    %f21,  256(%r3)     # save F21
+    stfd    %f22,  264(%r3)     # save F22
+    stfd    %f23,  272(%r3)     # save F23
+    stfd    %f24,  280(%r3)     # save F24
+    stfd    %f25,  288(%r3)     # save F25
+    stfd    %f26,  296(%r3)     # save F26
+    stfd    %f27,  304(%r3)     # save F27
+    stfd    %f28,  312(%r3)     # save F28
+    stfd    %f29,  320(%r3)     # save F29
+    stfd    %f30,  328(%r3)     # save F30
+    stfd    %f31,  336(%r3)     # save F31
+    mffs    %f0                 # load FPSCR
+    stfd    %f0,   344(%r3)     # save FPSCR
+
+    lfd     %f14,  200(%r4)     # restore F14
+    lfd     %f15,  208(%r4)     # restore F15
+    lfd     %f16,  216(%r4)     # restore F16
+    lfd     %f17,  224(%r4)     # restore F17
+    lfd     %f18,  232(%r4)     # restore F18
+    lfd     %f19,  240(%r4)     # restore F19
+    lfd     %f20,  248(%r4)     # restore F20
+    lfd     %f21,  256(%r4)     # restore F21
+    lfd     %f22,  264(%r4)     # restore F22
+    lfd     %f23,  272(%r4)     # restore F23
+    lfd     %f24,  280(%r4)     # restore F24
+    lfd     %f25,  288(%r4)     # restore F25
+    lfd     %f26,  296(%r4)     # restore F26
+    lfd     %f27,  304(%r4)     # restore F27
+    lfd     %f28,  312(%r4)     # restore F28
+    lfd     %f29,  320(%r4)     # restore F29
+    lfd     %f30,  328(%r4)     # restore F30
+    lfd     %f31,  336(%r4)     # restore F31
+    lfd     %f0,   344(%r4)     # load FPSCR
+    mtfsf   0xff,  %f0          # restore FPSCR
+1:
+
+    ld      %r13,  0(%r4)       # restore R13
+    ld      %r14,  8(%r4)       # restore R14
+    ld      %r15,  16(%r4)      # restore R15
+    ld      %r16,  24(%r4)      # restore R16
+    ld      %r17,  32(%r4)      # restore R17
+    ld      %r18,  40(%r4)      # restore R18
+    ld      %r19,  48(%r4)      # restore R19
+    ld      %r20,  56(%r4)      # restore R20
+    ld      %r21,  64(%r4)      # restore R21
+    ld      %r22,  72(%r4)      # restore R22
+    ld      %r23,  80(%r4)      # restore R23
+    ld      %r24,  88(%r4)      # restore R24
+    ld      %r25,  96(%r4)      # restore R25
+    ld      %r26,  104(%r4)     # restore R26
+    ld      %r27,  112(%r4)     # restore R27
+    ld      %r28,  120(%r4)     # restore R28
+    ld      %r29,  128(%r4)     # restore R29
+    ld      %r30,  136(%r4)     # restore r30
+    ld      %r31,  144(%r4)     # restore r31
+    ld      %r1,   152(%r4)     # restore SP
+
+    ld      %r0,   160(%r4)     # load CR
+    mtcr    %r0                 # restore CR
+    ld      %r0,   168(%r4)     # load LR
+    mtlr    %r0                 # restore LR
+
+    mr.     %r3,   %r5          # use third arg as return value after jump
+                                # and as first arg in context function
+
+    ld      %r0,   176(%r4)     # load PC
+    mtctr   %r0                 # restore CTR
+
+    bctr                        # jump to context
+.size .jump_fcontext, .-.jump_fcontext
+
+.section ".text"
+.align 2
+.globl make_fcontext
+.section ".opd","aw"
+.align 3
+make_fcontext:
+.quad .make_fcontext,.TOC._at_tocbase,0
+.previous
+.size make_fcontext,24
+.type .make_fcontext,@function
+.globl .make_fcontext
+.make_fcontext:
+    std     %r3, 0(%r3)         # save the current context
+    std     %r4, 176(%r3)       # save the address of the function supposed to be run
+    ld      %r0, 184(%r3)       # load the stack base
+
+    li      %r4, 56
+    subf    %r1, %r4, %r1       # reserve space on stack
+    stw     %r3, 48(%r1)        # store pointer to fcontext_t on stack
+    mflr    %r4                 # load LR
+    stw     %r4, 40(%r1)        # store LR on stack
+    mr.     %r3, %r0            # context stack as arg to align_stack
+    bl      align_stack_at_plt     # call align_stack
+    mr.     %r0, %r3            # load result into R0
+    lwz     %r4, 40(%r1)        # pop LR from stack
+    mtlr    %r4                 # restore LR
+    lwz     %r3, 48(%r1)        # pop pointer to fcontext_t from stack
+    addi    %r1, %r1, 56        # release space on stack
+
+    li      %r4, 64
+    subf    %r0, %r4, %r0       # 64 bytes on stack for parameter area (== 8 registers)
+    std     %r0, 152(%r3)       # save the stack base
+
+    mflr    %r0                 # load LR
+    bl      1f                  # jump to label 1
+1:
+    mflr    %r4                 # load LR
+    addi    %r4, %r4, finish - 1b    # calulate absolute address of finish
+    mtlr    %r0                 # restore LR
+    std     %r4, 168(%r3)       # save address of finish
+
+    li      %r3,  0             # set return value to zero
+    blr
+
+finish:
+    li      %r3,  0             # set return value to zero
+    bl      _exit_at_plt           # exit application
+.size .make_fcontext, .-.make_fcontext
Added: branches/release/libs/context/src/asm/fcontext_x86_64_ms_pe_masm.asm
==============================================================================
--- (empty file)
+++ branches/release/libs/context/src/asm/fcontext_x86_64_ms_pe_masm.asm	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,207 @@
+
+;           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)
+
+;  ----------------------------------------------------------------------------------
+;  |    0    |    1    |    2    |    3    |    4     |    5    |    6    |    7    |
+;  ----------------------------------------------------------------------------------
+;  |   0x0   |   0x4   |   0x8   |   0xc   |   0x10   |   0x14  |   0x18  |   0x1c  |
+;  ----------------------------------------------------------------------------------
+;  |        R12        |         R13       |         R14        |        R15        |
+;  ----------------------------------------------------------------------------------
+;  ----------------------------------------------------------------------------------
+;  |    8    |    9    |   10    |   11    |    12    |    13   |    14   |    15   |
+;  ----------------------------------------------------------------------------------
+;  |   0x20  |   0x24  |   0x28  |  0x2c   |   0x30   |   0x34  |   0x38  |   0x3c  |
+;  ----------------------------------------------------------------------------------
+;  |        RDI        |        RSI        |         RBX        |        RBP        |
+;  ----------------------------------------------------------------------------------
+;  ----------------------------------------------------------------------------------
+;  |    16   |    17   |    18   |    19   |                                        |
+;  ----------------------------------------------------------------------------------
+;  |   0x40  |   0x44  |   0x48  |   0x4c  |                                        |
+;  ----------------------------------------------------------------------------------
+;  |        RSP        |       RIP         |                                        |
+;  ----------------------------------------------------------------------------------
+;  ----------------------------------------------------------------------------------
+;  |    20   |    21   |    22   |    23   |                                        |
+;  ----------------------------------------------------------------------------------
+;  |   0x50  |   0x54  |   0x58  |   0x5c  |                                        |
+;  ----------------------------------------------------------------------------------
+;  |       sbase       |       slimit      |                                        |
+;  ----------------------------------------------------------------------------------
+;  ----------------------------------------------------------------------------------
+;  |    24   |   25    |                                                            |
+;  ----------------------------------------------------------------------------------
+;  |   0x60  |   0x64  |                                                            |
+;  ----------------------------------------------------------------------------------
+;  |      fbr_strg     |                                                            |
+;  ----------------------------------------------------------------------------------
+;  ----------------------------------------------------------------------------------
+;  |    26   |   27    |    28   |    29   |                                        |
+;  ----------------------------------------------------------------------------------
+;  |   0x68  |   0x6c  |   0x70  |   0x74  |                                        |
+;  ----------------------------------------------------------------------------------
+;  | fc_mxcsr|fc_x87_cw|       fc_xmm      |                                        |
+;  ----------------------------------------------------------------------------------
+;  ----------------------------------------------------------------------------------
+;  |   30    |   31    |    32    |   33   |   34    |   35    |   36     |   37    |
+;  ----------------------------------------------------------------------------------
+;  |  0x78   |  0x7c   |   0x80   |  0x84  |  0x88   |  0x8c   |   0x90   |   0x94  |
+;  ----------------------------------------------------------------------------------
+;  |                  XMM6                 |                   XMM7                 |
+;  ----------------------------------------------------------------------------------
+;  ----------------------------------------------------------------------------------
+;  |   38    |   39    |    40    |   41   |   42    |   43    |    44    |   45    |
+;  ----------------------------------------------------------------------------------
+;  |  0x98   |  0x9c   |  0x100  |  0x104  |  0x108  |  0x10c  |   0x110  |  0x114  |
+;  ----------------------------------------------------------------------------------
+;  |                  XMM8                 |                   XMM9                 |
+;  ----------------------------------------------------------------------------------
+;  ----------------------------------------------------------------------------------
+;  |   46    |   47    |    48    |   49   |   50    |   51    |    52    |   53    |
+;  ----------------------------------------------------------------------------------
+;  |  0x118  |  0x11c  |  0x120  |  0x124  |  0x128  |  0x12c  |   0x130  |  0x134  |
+;  ----------------------------------------------------------------------------------
+;  |                 XMM10                 |                  XMM11                 |
+;  ----------------------------------------------------------------------------------
+;  ----------------------------------------------------------------------------------
+;  |   54    |   55    |    56    |   57   |   58    |   59    |    60    |   61    |
+;  ----------------------------------------------------------------------------------
+;  |  0x138  |  0x13c  |  0x140  |  0x144  |  0x148  |  0x14c  |   0x150  |  0x154  |
+;  ----------------------------------------------------------------------------------
+;  |                 XMM12                 |                  XMM13                 |
+;  ----------------------------------------------------------------------------------
+;  ----------------------------------------------------------------------------------
+;  |   62    |   63    |    64    |   65   |   66    |   67    |    68    |   69    |
+;  ----------------------------------------------------------------------------------
+;  |  0x158  |  0x15c  |  0x160  |  0x164  |  0x168  |  0x16c  |   0x170  |  0x174  |
+;  ----------------------------------------------------------------------------------
+;  |                 XMM14                 |                  XMM15                 |
+;  ----------------------------------------------------------------------------------
+
+EXTERN  _exit:PROC            ; standard C library function
+EXTERN  align_stack:PROC      ; stack alignment
+EXTERN  seh_fcontext:PROC     ; exception handler
+.code
+
+jump_fcontext PROC EXPORT FRAME:seh_fcontext
+    .endprolog
+
+    mov     [rcx],       r12        ; save R12
+    mov     [rcx+08h],   r13        ; save R13
+    mov     [rcx+010h],  r14        ; save R14
+    mov     [rcx+018h],  r15        ; save R15
+    mov     [rcx+020h],  rdi        ; save RDI
+    mov     [rcx+028h],  rsi        ; save RSI
+    mov     [rcx+030h],  rbx        ; save RBX
+    mov     [rcx+038h],  rbp        ; save RBP
+
+    mov     r10,         gs:[030h]  ; load NT_TIB
+    mov     rax,         [r10+08h]  ; load current stack base
+    mov     [rcx+050h],  rax        ; save current stack base
+    mov     rax,         [r10+010h] ; load current stack limit
+    mov     [rcx+058h],  rax        ; save current stack limit
+    mov     rax,         [r10+018h] ; load fiber local storage
+    mov     [rcx+060h],  rax        ; save fiber local storage
+
+    test    r9,          r9
+    je      nxt
+
+    stmxcsr [rcx+068h]              ; save MMX control and status word
+    fnstcw  [rcx+06ch]              ; save x87 control word
+	mov	    r10,         [rcx+070h] ; address of aligned XMM storage
+    movaps  [r10],       xmm6
+    movaps  [r10+010h],  xmm7
+    movaps  [r10+020h],  xmm8
+    movaps  [r10+030h],  xmm9
+    movaps  [r10+040h],  xmm10
+    movaps  [r10+050h],  xmm11
+    movaps  [r10+060h],  xmm12
+    movaps  [r10+070h],  xmm13
+    movaps  [r10+080h],  xmm14
+    movaps  [r10+090h],  xmm15
+
+    ldmxcsr [rdx+068h]              ; restore MMX control and status word
+    fldcw   [rdx+06ch]              ; restore x87 control word
+	mov	    r10,         [rdx+070h] ; address of aligned XMM storage
+    movaps  xmm6,        [r10]
+    movaps  xmm7,        [r10+010h]
+    movaps  xmm8,        [r10+020h]
+    movaps  xmm9,        [r10+030h]
+    movaps  xmm10,       [r10+040h]
+    movaps  xmm11,       [r10+050h]
+    movaps  xmm12,       [r10+060h]
+    movaps  xmm13,       [r10+070h]
+    movaps  xmm14,       [r10+080h]
+    movaps  xmm15,       [r10+090h]
+nxt:
+
+    lea     rax,         [rsp+08h]  ; exclude the return address
+    mov     [rcx+040h],  rax        ; save as stack pointer
+    mov     rax,         [rsp]      ; load return address
+    mov     [rcx+048h],  rax        ; save return address
+
+    mov     r12,        [rdx]       ; restore R12
+    mov     r13,        [rdx+08h]   ; restore R13
+    mov     r14,        [rdx+010h]  ; restore R14
+    mov     r15,        [rdx+018h]  ; restore R15
+    mov     rdi,        [rdx+020h]  ; restore RDI
+    mov     rsi,        [rdx+028h]  ; restore RSI
+    mov     rbx,        [rdx+030h]  ; restore RBX
+    mov     rbp,        [rdx+038h]  ; restore RBP
+
+    mov     r10,        gs:[030h]   ; load NT_TIB
+    mov     rax,        [rdx+050h]  ; load stack base
+    mov     [r10+08h],  rax         ; restore stack base
+    mov     rax,        [rdx+058h]  ; load stack limit
+    mov     [r10+010h], rax         ; restore stack limit
+    mov     rax,        [rdx+060h]  ; load fiber local storage
+    mov     [r10+018h], rax         ; restore fiber local storage
+
+    mov     rsp,        [rdx+040h]  ; restore RSP
+    mov     r10,        [rdx+048h]  ; fetch the address to returned to
+
+    mov     rax,        r8          ; use third arg as return value after jump
+    mov     rcx,        r8          ; use third arg as first arg in context function
+
+    jmp     r10                     ; indirect jump to caller
+jump_fcontext ENDP
+
+make_fcontext PROC EXPORT FRAME  ; generate function table entry in .pdata and unwind information in    E
+    .endprolog                   ; .xdata for a function's structured exception handling unwind behavior
+
+    mov  [rcx],      rcx         ; store the address of current context
+    mov  [rcx+048h], rdx         ; save the address of the function supposed to run
+    mov  rdx,        [rcx+050h]  ; load the address where the context stack beginns
+
+    push  rcx                    ; save pointer to fcontext_t
+    sub   rsp,       028h        ; reserve shadow space for align_stack
+    mov   rcx,       rdx         ; stack pointer as arg for align_stack
+    mov   [rsp+8],   rcx
+    call  align_stack   ; align stack
+    mov   rdx,       rax         ; begin of aligned stack
+    add   rsp,       028h
+    pop   rcx                    ; restore pointer to fcontext_t
+
+    lea  rdx,        [rdx-028h]  ; reserve 32byte shadow space + return address on stack, (RSP + 8) % 16 == 0
+    mov  [rcx+040h], rdx         ; save the address where the context stack beginns
+
+    stmxcsr [rcx+068h]           ; save MMX control and status word
+    fnstcw  [rcx+06ch]           ; save x87 control word
+
+    lea  rax,       finish       ; helper code executed after fn() returns
+    mov  [rdx],     rax          ; store address off the helper function as return address
+
+    xor  rax,       rax          ; set RAX to zero
+    ret
+
+finish:
+    xor   rcx,        rcx
+    mov   [rsp+08h],  rcx
+    call  _exit                  ; exit application
+    hlt
+make_fcontext ENDP
+END
Added: branches/release/libs/context/src/asm/fcontext_x86_64_sysv_elf_gas.S
==============================================================================
--- (empty file)
+++ branches/release/libs/context/src/asm/fcontext_x86_64_sysv_elf_gas.S	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,116 @@
+/*
+            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)
+*/
+
+/****************************************************************************************
+ *                                                                                      *
+ *  ----------------------------------------------------------------------------------  *
+ *  |    0    |    1    |    2    |    3    |    4     |    5    |    6    |    7    |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |   0x0   |   0x4   |   0x8   |   0xc   |   0x10   |   0x14  |   0x18  |   0x1c  |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |        RBX        |        R12        |         R13        |        R14        |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |    8    |    9    |   10    |   11    |    12    |    13   |    14   |    15   |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |   0x20  |   0x24  |   0x28  |  0x2c   |   0x30   |   0x34  |   0x38  |   0x3c  |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |        R15        |        RBP        |         RSP        |        RIP        |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |   16    |   17    |   18    |    19   |                                        |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |  0x40   |  0x44   |  0x48   |   0x4c  |                                        |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |       sbase       |        slimit     |                                        |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |    20   |    21   |                                                            |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |   0x50  |   0x54  |                                                            |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  | fc_mxcsr|fc_x87_cw|                                                            |  *
+ *  ----------------------------------------------------------------------------------  *
+ *                                                                                      *
+ * **************************************************************************************/
+
+.text
+.globl jump_fcontext
+.type jump_fcontext,@function
+.align 16
+jump_fcontext:
+    movq     %rbx,       (%rdi)         /* save RBX */
+    movq     %r12,       0x8(%rdi)      /* save R12 */
+    movq     %r13,       0x10(%rdi)     /* save R13 */
+    movq     %r14,       0x18(%rdi)     /* save R14 */
+    movq     %r15,       0x20(%rdi)     /* save R15 */
+    movq     %rbp,       0x28(%rdi)     /* save RBP */
+
+    cmp      $0,         %rcx
+    je       1f
+
+    stmxcsr  0x50(%rdi)             /* save MMX control and status word */
+    fnstcw   0x54(%rdi)             /* save x87 control word */
+
+    ldmxcsr  0x50(%rsi)             /* restore MMX control and status word */
+    fldcw    0x54(%rsi)             /* restore x87 control word */
+1:
+
+    leaq     0x8(%rsp),  %rax       /* exclude the return address and save as stack pointer */
+    movq     %rax,       0x30(%rdi) /* save as stack pointer */
+    movq     (%rsp),     %rax       /* save return address */
+    movq     %rax,       0x38(%rdi) /* save return address as RIP */
+
+    movq     (%rsi),      %rbx      /* restore RBX */
+    movq     0x8(%rsi),   %r12      /* restore R12 */
+    movq     0x10(%rsi),  %r13      /* restore R13 */
+    movq     0x18(%rsi),  %r14      /* restore R14 */
+    movq     0x20(%rsi),  %r15      /* restore R15 */
+    movq     0x28(%rsi),  %rbp      /* restore RBP */
+
+    movq     0x30(%rsi),  %rsp      /* restore RSP */
+    movq     0x38(%rsi),  %rcx      /* fetch the address to return to */
+
+    movq     %rdx,        %rax      /* use third arg as return value after jump */
+    movq     %rdx,        %rdi      /* use third arg as first arg in context function */
+
+    jmp      *%rcx                  /* indirect jump to context */
+.size jump_fcontext,.-jump_fcontext
+
+.text
+.globl make_fcontext
+.type make_fcontext,@function
+.align 16
+make_fcontext:
+    movq   %rdi,                 (%rdi)     /* save the address of passed context */
+    movq   %rsi,                 0x38(%rdi) /* save the address of the context function */
+    movq   0x40(%rdi),           %rdx       /* load the stack base */
+
+    pushq  %rdi                             /* save pointer to fcontext_t */
+    movq   %rdx,                 %rdi       /* stack pointer as arg for align_stack */
+    call   align_stack_at_PLT                  /* align stack */
+    movq   %rax,                 %rdx       /* begin of aligned stack */
+    popq   %rdi                             /* restore pointer to fcontext_t */
+
+    leaq   -0x8(%rdx),           %rdx       /* reserve space for the last frame on stack, (RSP + 8) & 15 == 0 */
+    movq   %rdx,                 0x30(%rdi) /* save the algined stack base */
+
+    stmxcsr  0x50(%rdi)                     /* save MMX control and status word */
+    fnstcw   0x54(%rdi)                     /* save x87 control word */
+
+    leaq   finish(%rip),         %rcx       /* address of finish; called after context function returns */
+    movq   %rcx,                 (%rdx)
+
+    xorq   %rax,                 %rax
+    ret
+
+finish:
+    xorq    %rdi,              %rdi         /* exit code is zero */
+    call   _exit_at_PLT                        /* exit application */
+    hlt
+.size make_fcontext,.-make_fcontext
+
Added: branches/release/libs/context/src/asm/fcontext_x86_64_sysv_macho_gas.S
==============================================================================
--- (empty file)
+++ branches/release/libs/context/src/asm/fcontext_x86_64_sysv_macho_gas.S	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,111 @@
+/*
+            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)
+*/
+
+/****************************************************************************************
+ *                                                                                      *
+ *  ----------------------------------------------------------------------------------  *
+ *  |    0    |    1    |    2    |    3    |    4     |    5    |    6    |    7    |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |   0x0   |   0x4   |   0x8   |   0xc   |   0x10   |   0x14  |   0x18  |   0x1c  |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |        RBX        |        R12        |         R13        |        R14        |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |    8    |    9    |   10    |   11    |    12    |    13   |    14   |    15   |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |   0x20  |   0x24  |   0x28  |  0x2c   |   0x30   |   0x34  |   0x38  |   0x3c  |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |        R15        |        RBP        |         RSP        |        RIP        |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |   16    |   17    |   18    |    19   |                                        |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |  0x40   |  0x44   |  0x48   |   0x4c  |                                        |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |       sbase       |        slimit     |                                        |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |    20   |    21   |                                                            |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  |   0x50  |   0x54  |                                                            |  *
+ *  ----------------------------------------------------------------------------------  *
+ *  | fc_mxcsr|fc_x87_cw|                                                            |  *
+ *  ----------------------------------------------------------------------------------  *
+ *                                                                                      *
+ * **************************************************************************************/
+
+.text
+.globl _jump_fcontext
+.align 8
+_jump_fcontext:
+    movq     %rbx,       (%rdi)         /* save RBX */
+    movq     %r12,       0x8(%rdi)      /* save R12 */
+    movq     %r13,       0x10(%rdi)     /* save R13 */
+    movq     %r14,       0x18(%rdi)     /* save R14 */
+    movq     %r15,       0x20(%rdi)     /* save R15 */
+    movq     %rbp,       0x28(%rdi)     /* save RBP */
+
+    cmp      $0,         %rcx
+    je       1f
+
+    stmxcsr  0x50(%rdi)             /* save MMX control and status word */
+    fnstcw   0x54(%rdi)             /* save x87 control word */
+
+    ldmxcsr  0x50(%rsi)             /* restore MMX control and status word */
+    fldcw    0x54(%rsi)             /* restore x87 control word */
+1:
+
+    leaq     0x8(%rsp),  %rax       /* exclude the return address and save as stack pointer */
+    movq     %rax,       0x30(%rdi) /* save as stack pointer */
+    movq     (%rsp),     %rax       /* save return address */
+    movq     %rax,       0x38(%rdi) /* save return address as RIP */
+
+    movq     (%rsi),      %rbx      /* restore RBX */
+    movq     0x8(%rsi),   %r12      /* restore R12 */
+    movq     0x10(%rsi),  %r13      /* restore R13 */
+    movq     0x18(%rsi),  %r14      /* restore R14 */
+    movq     0x20(%rsi),  %r15      /* restore R15 */
+    movq     0x28(%rsi),  %rbp      /* restore RBP */
+
+    movq     0x30(%rsi),  %rsp      /* restore RSP */
+    movq     0x38(%rsi),  %rcx      /* fetch the address to return to */
+
+    movq     %rdx,        %rax      /* use third arg as return value after jump */
+    movq     %rdx,        %rdi      /* use third arg as first arg in context function */
+
+    jmp      *%rcx                  /* indirect jump to context */
+
+.text
+.globl _make_fcontext
+.align 8
+_make_fcontext:
+    movq   %rdi,                 (%rdi)     /* save the address of current context */
+    movq   %rsi,                 0x38(%rdi) /* save the address of the function supposed to run */
+    movq   0x40(%rdi),           %rdx       /* load the stack base */
+
+    pushq  %rdi                             /* save pointer to fcontext_t */
+    movq   %rdx,                 %rdi       /* stack pointer as arg for align_stack */
+    call   _align_stack                     /* align stack */
+    movq   %rax,                 %rdx       /* begin of aligned stack */
+    popq   %rdi                             /* restore pointer to fcontext_t */
+
+    leaq   -0x8(%rdx),           %rdx       /* reserve space for the last frame on stack, (RSP + 8) % 16 == 0 */
+    movq   %rdx,                 0x30(%rdi) /* save the address */
+
+    stmxcsr  0x50(%rdi)                     /* save MMX control and status word */
+    fnstcw   0x54(%rdi)                     /* save x87 control word */
+
+    leaq   finish(%rip),         %rcx       /* helper code executed after context function returns */
+    movq   %rcx,                 (%rdx)
+
+    xorq   %rax,                 %rax       /* set RAX to zero */
+    ret
+
+finish:
+    xorq    %rdi,              %rdi         /* exit code is zero */
+    call   _exit                            /* exit application */
+    hlt
Added: branches/release/libs/context/src/fcontext.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/context/src/fcontext.cpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,36 @@
+
+//          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)
+
+#define BOOST_CONTEXT_SOURCE
+
+#include <boost/context/fcontext.hpp>
+
+#include <cstddef>
+
+#ifdef BOOST_HAS_ABI_HEADERS
+#  include BOOST_ABI_PREFIX
+#endif
+
+namespace boost {
+namespace ctx {
+namespace detail {
+
+extern "C" BOOST_CONTEXT_DECL
+void * BOOST_CONTEXT_CALLDECL align_stack( void * vp)
+{
+	void * base = vp;
+    if ( 0 != ( ( ( uintptr_t) base) & 15) )
+        base = ( char * ) ( ( ( ( uintptr_t) base) - 15) & ~0x0F);
+	return base;
+}
+
+}
+
+}}
+
+#ifdef BOOST_HAS_ABI_HEADERS
+#  include BOOST_ABI_SUFFIX
+#endif
Added: branches/release/libs/context/src/seh.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/context/src/seh.cpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,83 @@
+
+//          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)
+
+#define BOOST_CONTEXT_SOURCE
+
+extern "C" {
+
+#include <stddef.h>
+#include <stdio.h>
+
+#include <excpt.h>
+#include <windows.h>
+#include <winnt.h>
+
+#if defined(_MSC_VER)
+# define SNPRINTF _snprintf
+#else
+# define SNPRINTF snprintf
+#endif
+
+static char * exception_description(
+    _EXCEPTION_RECORD const* record, char * description, size_t len)
+{
+    const DWORD code = record->ExceptionCode;
+    const ULONG_PTR * info = record->ExceptionInformation;
+
+    switch ( code)
+    {
+    case EXCEPTION_ACCESS_VIOLATION:
+    {
+        const char * accessType = ( info[0]) ? "writing" : "reading";
+        const ULONG_PTR address = info[1];
+        SNPRINTF( description, len, "Access violation %s 0x%08lX", accessType, address);
+        return description;
+    }
+    case EXCEPTION_DATATYPE_MISALIGNMENT:    return "Datatype misalignment";
+    case EXCEPTION_BREAKPOINT:               return "Breakpoint";
+    case EXCEPTION_SINGLE_STEP:              return "Single step";
+    case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:    return "Array bounds exceeded";
+    case EXCEPTION_FLT_DENORMAL_OPERAND:     return "FPU denormal operand";
+    case EXCEPTION_FLT_DIVIDE_BY_ZERO:       return "FPU divide by zero";
+    case EXCEPTION_FLT_INEXACT_RESULT:       return "FPU inexact result";
+    case EXCEPTION_FLT_INVALID_OPERATION:    return "FPU invalid operation";
+    case EXCEPTION_FLT_OVERFLOW:             return "FPU overflow";
+    case EXCEPTION_FLT_STACK_CHECK:          return "FPU stack check";
+    case EXCEPTION_FLT_UNDERFLOW:            return "FPU underflow";
+    case EXCEPTION_INT_DIVIDE_BY_ZERO:       return "Integer divide by zero";
+    case EXCEPTION_INT_OVERFLOW:             return "Integer overflow";
+    case EXCEPTION_PRIV_INSTRUCTION:         return "Privileged instruction";
+    case EXCEPTION_IN_PAGE_ERROR:            return "In page error";
+    case EXCEPTION_ILLEGAL_INSTRUCTION:      return "Illegal instruction";
+    case EXCEPTION_NONCONTINUABLE_EXCEPTION: return "Noncontinuable exception";
+    case EXCEPTION_STACK_OVERFLOW:           return "Stack overflow";
+    case EXCEPTION_INVALID_DISPOSITION:      return "Invalid disposition";
+    case EXCEPTION_GUARD_PAGE:               return "Guard page";
+    case EXCEPTION_INVALID_HANDLE:           return "Invalid handle";
+    }
+
+    SNPRINTF( description, len, "Unknown (0x%08lX)", code);
+    return description;
+}
+
+EXCEPTION_DISPOSITION seh_fcontext(
+     struct _EXCEPTION_RECORD * record,
+     void *,
+     struct _CONTEXT *,
+     void *)
+{
+    char description[255];
+
+    fprintf( stderr, "exception: %s (%08lX)\n",
+        exception_description( record, description, sizeof( description) ),
+        record->ExceptionCode);
+
+    ExitProcess( -1);
+
+    return ExceptionContinueSearch; // never reached
+}
+
+}
Added: branches/release/libs/context/src/stack_allocator_posix.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/context/src/stack_allocator_posix.cpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,84 @@
+
+//          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)
+
+#define BOOST_CONTEXT_SOURCE
+
+#include <boost/context/stack_allocator.hpp>
+
+extern "C" {
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+}
+
+#include <stdexcept>
+
+#include <boost/config.hpp>
+#include <boost/assert.hpp>
+#include <boost/format.hpp>
+
+#include <boost/context/stack_utils.hpp>
+
+#ifdef BOOST_HAS_ABI_HEADERS
+#  include BOOST_ABI_PREFIX
+#endif
+
+namespace boost {
+namespace ctx {
+
+void *
+stack_allocator::allocate( std::size_t size) const
+{
+    if ( minimum_stacksize() > size)
+        throw std::invalid_argument(
+            boost::str( boost::format("invalid stack size: must be at least %d bytes")
+                % minimum_stacksize() ) );
+
+    if ( ! is_stack_unbound() && ( maximum_stacksize() < size) )
+        throw std::invalid_argument(
+            boost::str( boost::format("invalid stack size: must not be larger than %d bytes")
+                % maximum_stacksize() ) );
+
+    const std::size_t pages( page_count( size) + 1); // add +1 for guard page
+	std::size_t size_ = pages * pagesize();
+
+    const int fd( ::open("/dev/zero", O_RDONLY) );
+    BOOST_ASSERT( -1 != fd);
+    void * limit =
+# if defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
+        ::mmap( 0, size_, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
+# else
+        ::mmap( 0, size_, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
+# endif
+    ::close( fd);
+    if ( ! limit) throw std::bad_alloc();
+
+    const int result( ::mprotect( limit, pagesize(), PROT_NONE) );
+    BOOST_ASSERT( 0 == result);
+
+    return static_cast< char * >( limit) + size_;
+}
+
+void
+stack_allocator::deallocate( void * vp, std::size_t size) const
+{
+    if ( vp)
+    {
+		const std::size_t pages( page_count( size) + 1); // add +1 for guard page
+		std::size_t size_ = pages * pagesize();
+        BOOST_ASSERT( 0 < size && 0 < size_);
+        void * limit = static_cast< char * >( vp) - size_;
+        ::munmap( limit, size_);
+    }
+}
+
+}}
+
+#ifdef BOOST_HAS_ABI_HEADERS
+#  include BOOST_ABI_SUFFIX
+#endif
Added: branches/release/libs/context/src/stack_allocator_windows.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/context/src/stack_allocator_windows.cpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,85 @@
+
+//          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)
+
+#define BOOST_CONTEXT_SOURCE
+
+#include <boost/context/stack_allocator.hpp>
+
+extern "C" {
+#include <windows.h>
+}
+
+#include <stdexcept>
+
+#include <boost/config.hpp>
+#include <boost/assert.hpp>
+#include <boost/format.hpp>
+
+#include <boost/context/stack_utils.hpp>
+
+#ifdef BOOST_HAS_ABI_HEADERS
+#  include BOOST_ABI_PREFIX
+#endif
+
+# if defined(BOOST_MSVC)
+# pragma warning(push)
+# pragma warning(disable:4244 4267)
+# endif
+
+namespace boost {
+namespace ctx {
+
+void *
+stack_allocator::allocate( std::size_t size) const
+{
+    if ( minimum_stacksize() > size)
+        throw std::invalid_argument(
+            boost::str( boost::format("invalid stack size: must be at least %d bytes")
+                % minimum_stacksize() ) );
+
+    if ( ! is_stack_unbound() && ( maximum_stacksize() < size) )
+        throw std::invalid_argument(
+            boost::str( boost::format("invalid stack size: must not be larger than %d bytes")
+                % maximum_stacksize() ) );
+
+    const std::size_t pages( page_count( size) + 1); // add +1 for guard page
+    std::size_t size_ = pages * pagesize();
+
+#ifndef BOOST_CONTEXT_FIBER
+    void * limit = ::VirtualAlloc( 0, size_, MEM_COMMIT, PAGE_READWRITE);
+    if ( ! limit) throw std::bad_alloc();
+
+    DWORD old_options;
+    const BOOL result = ::VirtualProtect(
+        limit, pagesize(), PAGE_READWRITE | PAGE_GUARD /*PAGE_NOACCESS*/, & old_options);
+    BOOST_ASSERT( FALSE != result);
+
+    return static_cast< char * >( limit) + size_;
+#endif
+}
+
+void
+stack_allocator::deallocate( void * vp, std::size_t size) const
+{
+    if ( vp)
+    {
+        const std::size_t pages( page_count( size) + 1); // add +1 for guard page
+        std::size_t size_ = pages * pagesize();
+        BOOST_ASSERT( 0 < size && 0 < size_);
+        void * limit = static_cast< char * >( vp) - size_;
+        ::VirtualFree( limit, 0, MEM_RELEASE);
+    }
+}
+
+}}
+
+# if defined(BOOST_MSVC)
+# pragma warning(pop)
+# endif
+
+#ifdef BOOST_HAS_ABI_HEADERS
+#  include BOOST_ABI_SUFFIX
+#endif
Added: branches/release/libs/context/src/stack_utils_posix.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/context/src/stack_utils_posix.cpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,80 @@
+
+//          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)
+
+#define BOOST_CONTEXT_SOURCE
+
+#include <boost/context/stack_utils.hpp>
+
+extern "C" {
+#include <sys/resource.h>
+#include <sys/time.h>
+#include <unistd.h>
+}
+
+#include <cmath>
+#include <csignal>
+
+#include <boost/assert.hpp>
+
+namespace {
+
+static rlimit stacksize_limit_()
+{
+    rlimit limit;
+    const int result = ::getrlimit( RLIMIT_STACK, & limit);
+    BOOST_ASSERT( 0 == result);
+    return limit;
+}
+
+static rlimit stacksize_limit()
+{
+    static rlimit limit = stacksize_limit_();
+    return limit;
+}
+
+}
+
+namespace boost {
+namespace ctx {
+
+BOOST_CONTEXT_DECL
+std::size_t default_stacksize()
+{
+    static std::size_t size = 256 * 1024;
+    return size;
+}
+
+BOOST_CONTEXT_DECL
+std::size_t minimum_stacksize()
+{ return SIGSTKSZ; }
+
+BOOST_CONTEXT_DECL
+std::size_t maximum_stacksize()
+{
+    BOOST_ASSERT( ! is_stack_unbound() );
+    return static_cast< std::size_t >( stacksize_limit().rlim_max);
+}
+
+BOOST_CONTEXT_DECL
+bool is_stack_unbound()
+{ return RLIM_INFINITY == stacksize_limit().rlim_max; }
+
+BOOST_CONTEXT_DECL
+std::size_t pagesize()
+{
+    static std::size_t pagesize( ::getpagesize() );
+    return pagesize;
+}
+
+BOOST_CONTEXT_DECL
+std::size_t page_count( std::size_t stacksize)
+{
+    return static_cast< std::size_t >( 
+        std::ceil(
+            static_cast< float >( stacksize) / pagesize() ) );
+}
+
+}}
Added: branches/release/libs/context/src/stack_utils_windows.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/context/src/stack_utils_windows.cpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,84 @@
+
+//          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)
+
+#define BOOST_CONTEXT_SOURCE
+
+#include <boost/context/stack_utils.hpp>
+
+extern "C" {
+#include <windows.h>
+}
+
+#include <cmath>
+#include <csignal>
+
+#include <boost/assert.hpp>
+
+namespace {
+
+static SYSTEM_INFO system_info_()
+{
+    SYSTEM_INFO si;
+    ::GetSystemInfo( & si);
+    return si;
+}
+
+static SYSTEM_INFO system_info()
+{
+    static SYSTEM_INFO si = system_info_();
+    return si;
+}
+
+}
+
+namespace boost {
+namespace ctx {
+
+BOOST_CONTEXT_DECL
+std::size_t default_stacksize()
+{
+    static std::size_t size = 256 * 1024;
+    return size;
+}
+
+BOOST_CONTEXT_DECL
+std::size_t minimum_stacksize()
+{
+    static std::size_t stacksize(
+        static_cast< std::size_t >( system_info().dwAllocationGranularity) );
+    return stacksize;
+}
+
+BOOST_CONTEXT_DECL
+std::size_t maximum_stacksize()
+{
+    BOOST_ASSERT( ! is_stack_unbound() );
+    static std::size_t stacksize = 8 * 1024 * 1024;
+    return stacksize;
+}
+
+// Windows seams not to provide a limit for the stacksize
+BOOST_CONTEXT_DECL
+bool is_stack_unbound()
+{ return true; }
+
+BOOST_CONTEXT_DECL
+std::size_t pagesize()
+{
+    static std::size_t pagesize(
+        static_cast< std::size_t >( system_info().dwPageSize) );
+    return pagesize;
+}
+
+BOOST_CONTEXT_DECL
+std::size_t page_count( std::size_t stacksize)
+{
+    return static_cast< std::size_t >(
+        std::ceil(
+            static_cast< float >( stacksize) / pagesize() ) );
+}
+
+}}
Added: branches/release/libs/context/test/Jamfile.v2
==============================================================================
--- (empty file)
+++ branches/release/libs/context/test/Jamfile.v2	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,25 @@
+# Boost.Context Library Tests Jamfile
+
+#          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)
+
+import common ;
+import feature ;
+import indirect ;
+import modules ;
+import os ;
+import testing ;
+import toolset ;
+
+project boost/context/test
+    : requirements
+      <library>../../test/build//boost_unit_test_framework
+      <library>/boost/context//boost_context
+      <link>static
+    ;
+
+test-suite "context" :
+    [ run test_context.cpp ]
+    ;
Added: branches/release/libs/context/test/test_context.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/context/test/test_context.cpp	2012-05-22 11:16:49 EDT (Tue, 22 May 2012)
@@ -0,0 +1,190 @@
+
+//          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)
+
+#include <iostream>
+#include <sstream>
+#include <stdexcept>
+#include <string>
+#include <utility>
+
+#include <boost/assert.hpp>
+#include <boost/test/unit_test.hpp>
+#include <boost/utility.hpp>
+
+#include <boost/context/all.hpp>
+
+namespace ctx = boost::ctx;
+
+ctx::fcontext_t fcm, fc1, fc2;
+int value1 = 0;
+std::string value2;
+double value3 = 0.;
+
+void f1( intptr_t)
+{
+    ++value1;
+	ctx::jump_fcontext( & fc1, & fcm, 0);
+}
+
+void f3( intptr_t)
+{
+    ++value1;
+	ctx::jump_fcontext( & fc1, & fcm, 0);
+    ++value1;
+	ctx::jump_fcontext( & fc1, & fcm, 0);
+}
+
+void f4( intptr_t)
+{
+	ctx::jump_fcontext( & fc1, & fcm, 7);
+}
+
+void f5( intptr_t arg)
+{
+	ctx::jump_fcontext( & fc1, & fcm, arg);
+}
+
+void f6( intptr_t arg)
+{
+    std::pair< int, int > data = * ( std::pair< int, int > * ) arg;
+    int res = data.first + data.second;
+    data = * ( std::pair< int, int > *)
+        ctx::jump_fcontext( & fc1, & fcm, ( intptr_t) res);
+    res = data.first + data.second;
+    ctx::jump_fcontext( & fc1, & fcm, ( intptr_t) res);
+}
+
+void f7( intptr_t arg)
+{
+    try
+    { throw std::runtime_error( ( char *) arg); }
+    catch ( std::runtime_error const& e)
+    { value2 = e.what(); }
+	ctx::jump_fcontext( & fc1, & fcm, arg);
+}
+
+void f8( intptr_t arg)
+{
+    double d = * ( double *) arg;
+    d += 3.45;
+    value3 = d;
+	ctx::jump_fcontext( & fc1, & fcm, 0);
+}
+
+void test_start()
+{
+    value1 = 0;
+
+    ctx::stack_allocator alloc;
+
+    fc1.fc_stack.base = alloc.allocate( ctx::minimum_stacksize() );
+    fc1.fc_stack.limit = static_cast< char * >( fc1.fc_stack.base) - ctx::minimum_stacksize();
+    ctx::make_fcontext( & fc1, f1);
+
+    BOOST_CHECK_EQUAL( 0, value1);
+    ctx::jump_fcontext( & fcm, & fc1, 0);
+    BOOST_CHECK_EQUAL( 1, value1);
+}
+
+void test_jump()
+{
+    value1 = 0;
+
+    ctx::stack_allocator alloc;
+
+    fc1.fc_stack.base = alloc.allocate( ctx::minimum_stacksize() );
+    fc1.fc_stack.limit = static_cast< char * >( fc1.fc_stack.base) - ctx::minimum_stacksize();
+    ctx::make_fcontext( & fc1, f3);
+
+    BOOST_CHECK_EQUAL( 0, value1);
+    ctx::jump_fcontext( & fcm, & fc1, 0);
+    BOOST_CHECK_EQUAL( 1, value1);
+    ctx::jump_fcontext( & fcm, & fc1, 0);
+    BOOST_CHECK_EQUAL( 2, value1);
+}
+
+void test_result()
+{
+    ctx::stack_allocator alloc;
+
+    fc1.fc_stack.base = alloc.allocate( ctx::minimum_stacksize() );
+    fc1.fc_stack.limit = static_cast< char * >( fc1.fc_stack.base) - ctx::minimum_stacksize();
+    ctx::make_fcontext( & fc1, f4);
+
+    int result = ( int) ctx::jump_fcontext( & fcm, & fc1, 0);
+    BOOST_CHECK_EQUAL( 7, result);
+}
+
+void test_arg()
+{
+    ctx::stack_allocator alloc;
+
+    fc1.fc_stack.base = alloc.allocate( ctx::minimum_stacksize() );
+    fc1.fc_stack.limit = static_cast< char * >( fc1.fc_stack.base) - ctx::minimum_stacksize();
+    int i = 7;
+    ctx::make_fcontext( & fc1, f5);
+
+    int result = ( int) ctx::jump_fcontext( & fcm, & fc1, i);
+    BOOST_CHECK_EQUAL( i, result);
+}
+
+void test_transfer()
+{
+    ctx::stack_allocator alloc;
+
+    fc1.fc_stack.base = alloc.allocate( ctx::minimum_stacksize() );
+    fc1.fc_stack.limit = static_cast< char * >( fc1.fc_stack.base) - ctx::minimum_stacksize();
+    std::pair< int, int > data = std::make_pair( 3, 7);
+    ctx::make_fcontext( & fc1, f6);
+
+    int result = ( int) ctx::jump_fcontext( & fcm, & fc1, ( intptr_t) & data);
+    BOOST_CHECK_EQUAL( 10, result);
+    data = std::make_pair( 7, 7);
+    result = ( int) ctx::jump_fcontext( & fcm, & fc1, ( intptr_t) & data);
+    BOOST_CHECK_EQUAL( 14, result);
+}
+
+void test_exception()
+{
+    ctx::stack_allocator alloc;
+
+    fc1.fc_stack.base = alloc.allocate( ctx::minimum_stacksize() );
+    fc1.fc_stack.limit = static_cast< char * >( fc1.fc_stack.base) - ctx::minimum_stacksize();
+    char * what = "hello world";
+    ctx::make_fcontext( & fc1, f7);
+
+    ctx::jump_fcontext( & fcm, & fc1, ( intptr_t) what);
+    BOOST_CHECK_EQUAL( std::string( what), value2);
+}
+
+void test_fp()
+{
+    ctx::stack_allocator alloc;
+
+    fc1.fc_stack.base = alloc.allocate( ctx::minimum_stacksize() );
+    fc1.fc_stack.limit = static_cast< char * >( fc1.fc_stack.base) - ctx::minimum_stacksize();
+    double d = 7.13;
+    ctx::make_fcontext( & fc1, f8);
+
+    ctx::jump_fcontext( & fcm, & fc1, (intptr_t) & d);
+    BOOST_CHECK_EQUAL( 10.58, value3);
+}
+
+boost::unit_test::test_suite * init_unit_test_suite( int, char* [])
+{
+    boost::unit_test::test_suite * test =
+        BOOST_TEST_SUITE("Boost.Context: context test suite");
+
+    test->add( BOOST_TEST_CASE( & test_start) );
+    test->add( BOOST_TEST_CASE( & test_jump) );
+    test->add( BOOST_TEST_CASE( & test_result) );
+    test->add( BOOST_TEST_CASE( & test_arg) );
+    test->add( BOOST_TEST_CASE( & test_transfer) );
+    test->add( BOOST_TEST_CASE( & test_exception) );
+    test->add( BOOST_TEST_CASE( & test_fp) );
+
+    return test;
+}