$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r79956 - in trunk: boost/context/detail libs/context/doc libs/context/example libs/context/performance libs/context/src libs/context/src/asm libs/context/test
From: oliver.kowalke_at_[hidden]
Date: 2012-08-10 12:07:29
Author: olli
Date: 2012-08-10 12:07:25 EDT (Fri, 10 Aug 2012)
New Revision: 79956
URL: http://svn.boost.org/trac/boost/changeset/79956
Log:
context: use size instead of limit if fc_stack
Text files modified: 
   trunk/boost/context/detail/fcontext_arm.hpp                 |     6 ++-                                     
   trunk/boost/context/detail/fcontext_i386.hpp                |     4 +-                                      
   trunk/boost/context/detail/fcontext_i386_win.hpp            |     5 ++                                      
   trunk/boost/context/detail/fcontext_mips.hpp                |     6 ++-                                     
   trunk/boost/context/detail/fcontext_ppc.hpp                 |     6 ++-                                     
   trunk/boost/context/detail/fcontext_x86_64.hpp              |     6 ++-                                     
   trunk/boost/context/detail/fcontext_x86_64_win.hpp          |     6 ++-                                     
   trunk/libs/context/doc/context.qbk                          |     1                                         
   trunk/libs/context/doc/fcontext.qbk                         |    20 ++++------                              
   trunk/libs/context/example/exit.cpp                         |     6 +--                                     
   trunk/libs/context/example/jump.cpp                         |     6 +--                                     
   trunk/libs/context/example/transfer.cpp                     |     3 -                                       
   trunk/libs/context/performance/performance.cpp              |     6 +--                                     
   trunk/libs/context/src/asm/fcontext_arm_aapcs_elf_gas.S     |    13 +++---                                  
   trunk/libs/context/src/asm/fcontext_i386_ms_pe_masm.asm     |    61 +++++++++++++++++---------------        
   trunk/libs/context/src/asm/fcontext_i386_sysv_elf_gas.S     |    25 ++++++-------                           
   trunk/libs/context/src/asm/fcontext_i386_sysv_macho_gas.S   |    19 ++++-----                               
   trunk/libs/context/src/asm/fcontext_mips32_o32_elf_gas.S    |    13 +++---                                  
   trunk/libs/context/src/asm/fcontext_ppc32_sysv_elf_gas.S    |    11 ++---                                   
   trunk/libs/context/src/asm/fcontext_ppc64_sysv_elf_gas.S    |    11 ++---                                   
   trunk/libs/context/src/asm/fcontext_x86_64_ms_pe_masm.asm   |    73 ++++++++++++++++++++------------------- 
   trunk/libs/context/src/asm/fcontext_x86_64_sysv_elf_gas.S   |    15 +++----                                 
   trunk/libs/context/src/asm/fcontext_x86_64_sysv_macho_gas.S |    15 +++----                                 
   trunk/libs/context/src/seh.cpp                              |     9 ++++                                    
   trunk/libs/context/src/stack_allocator_windows.cpp          |    16 ++++----                                
   trunk/libs/context/test/test_context.cpp                    |    14 +++---                                  
   26 files changed, 192 insertions(+), 184 deletions(-)
Modified: trunk/boost/context/detail/fcontext_arm.hpp
==============================================================================
--- trunk/boost/context/detail/fcontext_arm.hpp	(original)
+++ trunk/boost/context/detail/fcontext_arm.hpp	2012-08-10 12:07:25 EDT (Fri, 10 Aug 2012)
@@ -7,6 +7,8 @@
 #ifndef BOOST_CTX_DETAIL_FCONTEXT_ARM_H
 #define BOOST_CTX_DETAIL_FCONTEXT_ARM_H
 
+#include <cstddef>
+
 #include <boost/config.hpp>
 #include <boost/cstdint.hpp>
 
@@ -26,10 +28,10 @@
 struct stack_t
 {
     void    *   base;
-    void    *   limit;
+    std::size_t size;
 
     stack_t() :
-        base( 0), limit( 0)
+        base( 0), size( 0)
     {}
 };
 
Modified: trunk/boost/context/detail/fcontext_i386.hpp
==============================================================================
--- trunk/boost/context/detail/fcontext_i386.hpp	(original)
+++ trunk/boost/context/detail/fcontext_i386.hpp	2012-08-10 12:07:25 EDT (Fri, 10 Aug 2012)
@@ -28,10 +28,10 @@
 struct stack_t
 {
     void    *   base;
-    void    *   limit;
+    std::size_t size;
 
     stack_t() :
-        base( 0), limit( 0)
+        base( 0), size( 0)
     {}
 };
 
Modified: trunk/boost/context/detail/fcontext_i386_win.hpp
==============================================================================
--- trunk/boost/context/detail/fcontext_i386_win.hpp	(original)
+++ trunk/boost/context/detail/fcontext_i386_win.hpp	2012-08-10 12:07:25 EDT (Fri, 10 Aug 2012)
@@ -11,6 +11,8 @@
 # pragma once
 #endif
 
+#include <cstddef>
+
 #include <boost/config.hpp>
 #include <boost/cstdint.hpp>
 
@@ -36,9 +38,10 @@
 {
     void    *   base;
     void    *   limit;
+    std::size_t size;
 
     stack_t() :
-        base( 0), limit( 0)
+        base( 0), limit( 0), size( 0)
     {}
 };
 
Modified: trunk/boost/context/detail/fcontext_mips.hpp
==============================================================================
--- trunk/boost/context/detail/fcontext_mips.hpp	(original)
+++ trunk/boost/context/detail/fcontext_mips.hpp	2012-08-10 12:07:25 EDT (Fri, 10 Aug 2012)
@@ -7,6 +7,8 @@
 #ifndef BOOST_CTX_DETAIL_FCONTEXT_MIPS_H
 #define BOOST_CTX_DETAIL_FCONTEXT_MIPS_H
 
+#include <cstddef>
+
 #include <boost/config.hpp>
 #include <boost/cstdint.hpp>
 
@@ -28,10 +30,10 @@
 struct stack_t
 {
     void    *   base;
-    void    *   limit;
+    std::size_t size;
 
     stack_t() :
-        base( 0), limit( 0)
+        base( 0), size( 0)
     {}
 };
 
Modified: trunk/boost/context/detail/fcontext_ppc.hpp
==============================================================================
--- trunk/boost/context/detail/fcontext_ppc.hpp	(original)
+++ trunk/boost/context/detail/fcontext_ppc.hpp	2012-08-10 12:07:25 EDT (Fri, 10 Aug 2012)
@@ -7,6 +7,8 @@
 #ifndef BOOST_CTX_DETAIL_FCONTEXT_PPC_H
 #define BOOST_CTX_DETAIL_FCONTEXT_PPC_H
 
+#include <cstddef>
+
 #include <boost/config.hpp>
 #include <boost/cstdint.hpp>
 
@@ -26,10 +28,10 @@
 struct stack_t
 {
     void    *   base;
-    void    *   limit;
+    std::size_t size;
 
     stack_t() :
-        base( 0), limit( 0)
+        base( 0), size( 0)
     {}
 };
 
Modified: trunk/boost/context/detail/fcontext_x86_64.hpp
==============================================================================
--- trunk/boost/context/detail/fcontext_x86_64.hpp	(original)
+++ trunk/boost/context/detail/fcontext_x86_64.hpp	2012-08-10 12:07:25 EDT (Fri, 10 Aug 2012)
@@ -7,6 +7,8 @@
 #ifndef BOOST_CTX_DETAIL_FCONTEXT_X86_64_H
 #define BOOST_CTX_DETAIL_FCONTEXT_X86_64_H
 
+#include <cstddef>
+
 #include <boost/config.hpp>
 #include <boost/cstdint.hpp>
 
@@ -26,10 +28,10 @@
 struct stack_t
 {
     void    *   base;
-    void    *   limit;
+    std::size_t size;
 
     stack_t() :
-        base( 0), limit( 0)
+        base( 0), size( 0)
     {}
 };
 
Modified: trunk/boost/context/detail/fcontext_x86_64_win.hpp
==============================================================================
--- trunk/boost/context/detail/fcontext_x86_64_win.hpp	(original)
+++ trunk/boost/context/detail/fcontext_x86_64_win.hpp	2012-08-10 12:07:25 EDT (Fri, 10 Aug 2012)
@@ -11,7 +11,8 @@
 # pragma once
 #endif
 
-#include <boost/assert.hpp>
+#include <cstddef>
+
 #include <boost/config.hpp>
 #include <boost/cstdint.hpp>
 
@@ -37,9 +38,10 @@
 {
     void    *   base;
     void    *   limit;
+    std::size_t size;
 
     stack_t() :
-        base( 0), limit( 0)
+        base( 0), limit( 0), size( 0)
     {}
 };
 
Modified: trunk/libs/context/doc/context.qbk
==============================================================================
--- trunk/libs/context/doc/context.qbk	(original)
+++ trunk/libs/context/doc/context.qbk	2012-08-10 12:07:25 EDT (Fri, 10 Aug 2012)
@@ -51,7 +51,6 @@
 
 [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()]]
Modified: trunk/libs/context/doc/fcontext.qbk
==============================================================================
--- trunk/libs/context/doc/fcontext.qbk	(original)
+++ trunk/libs/context/doc/fcontext.qbk	2012-08-10 12:07:25 EDT (Fri, 10 Aug 2012)
@@ -35,14 +35,13 @@
             // creates and manages a protected stack (with guard page)
             ctx::stack_allocator alloc;
             fc.fc_stack.base = alloc.allocate(ctx::minimum_stacksize());
-            fc.fc_stack.limit =
-                static_cast< char * >( fc.fc_stack.base) - ctx::minimum_stacksize();
+            fc.fc_stack.size = ctx::minimum_stacksize();
 
             // 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__).
+as the size of the stack.
 
 Calling __jump_fcontext__ invokes the __context_fn__ in a newly created context
 complete with registers, flags, stack and instruction pointers.  When control
@@ -78,13 +77,11 @@
                 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();
+                fc1.fc_stack.size = 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();
+                fc2.fc_stack.size = ctx::minimum_stacksize();
                 ctx::make_fcontext( & fc2, f2);
 
                 std::cout << "main: call jump_fcontext( & fcm, & fc1, 0)" << std::endl;
@@ -147,8 +144,7 @@
             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_stack.size = ctx::minimum_stacksize();
             fc1.fc_link = & fcm;
             pair_t p( std::make_pair( 2, 7) );
             ctx::make_fcontext( & fc1, f1);
@@ -199,7 +195,7 @@
         struct stack_t
         {
             void    *   base;
-            void    *   limit;
+            std::size_t size;
         };
 
         struct fcontext_t
@@ -217,9 +213,9 @@
 [[Member:] [Pointer to the top of the stack.]]
 ]
 
-[heading `limit`]
+[heading `size`]
 [variablelist
-[[Member:] [Pointer to the bottom of the stack.]]
+[[Member:] [Size of the stack in bytes.]]
 ]
 
 [heading `fc_stack`]
Modified: trunk/libs/context/example/exit.cpp
==============================================================================
--- trunk/libs/context/example/exit.cpp	(original)
+++ trunk/libs/context/example/exit.cpp	2012-08-10 12:07:25 EDT (Fri, 10 Aug 2012)
@@ -38,13 +38,11 @@
         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_stack.size = 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();
+        fc2.fc_stack.size = ctx::minimum_stacksize();
         ctx::make_fcontext( & fc2, f2);
 
         std::cout << "main: call start_fcontext( & fcm, & fc1, 0)" << std::endl;
Modified: trunk/libs/context/example/jump.cpp
==============================================================================
--- trunk/libs/context/example/jump.cpp	(original)
+++ trunk/libs/context/example/jump.cpp	2012-08-10 12:07:25 EDT (Fri, 10 Aug 2012)
@@ -38,13 +38,11 @@
         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();
+        fc1.fc_stack.size = 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();
+        fc2.fc_stack.size = ctx::minimum_stacksize();
         ctx::make_fcontext( & fc2, f2);
 
         std::cout << "main: call start_fcontext( & fcm, & fc1, 0)" << std::endl;
Modified: trunk/libs/context/example/transfer.cpp
==============================================================================
--- trunk/libs/context/example/transfer.cpp	(original)
+++ trunk/libs/context/example/transfer.cpp	2012-08-10 12:07:25 EDT (Fri, 10 Aug 2012)
@@ -33,8 +33,7 @@
     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_stack.size = ctx::minimum_stacksize();
     ctx::make_fcontext( & fc1, f1);
 
     pair_t p( std::make_pair( 2, 7) );
Modified: trunk/libs/context/performance/performance.cpp
==============================================================================
--- trunk/libs/context/performance/performance.cpp	(original)
+++ trunk/libs/context/performance/performance.cpp	2012-08-10 12:07:25 EDT (Fri, 10 Aug 2012)
@@ -116,8 +116,7 @@
 {
     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();
+    fc.fc_stack.size = ctx::default_stacksize();
     ctx::make_fcontext( & fc, f1);
 
     ctx::jump_fcontext( & fcm, & fc, 7, preserve_fpu);
@@ -189,8 +188,7 @@
 {
     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();
+    fc.fc_stack.size = ctx::default_stacksize();
     ctx::make_fcontext( & fc, f1);
 
     ctx::jump_fcontext( & fcm, & fc, 7, preserve_fpu);
Modified: trunk/libs/context/src/asm/fcontext_arm_aapcs_elf_gas.S
==============================================================================
--- trunk/libs/context/src/asm/fcontext_arm_aapcs_elf_gas.S	(original)
+++ trunk/libs/context/src/asm/fcontext_arm_aapcs_elf_gas.S	2012-08-10 12:07:25 EDT (Fri, 10 Aug 2012)
@@ -77,17 +77,16 @@
 .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
+    str     a2, [a1,#40]        @ save address of context function
+    ldr     a2, [a1,#44]        @ load address of context 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
+    mov     a1, a2              @ context stack pointer as arg for align_stack
+    bl      align_stack_at_PLT     @ call align_stack
+    mov     a2, a1              @ begin of aligned context stack
     pop     {a1,lr}             @ restore pointer to fcontext_t
 
-    str     a2, [a1,#32]        @ save the aligned stack base
+    str     a2, [a1,#32]        @ save the aligned context stack base
 
     adr     a2, finish          @ address of finish; called after context function returns
     str     a2, [a1,#36]
Modified: trunk/libs/context/src/asm/fcontext_i386_ms_pe_masm.asm
==============================================================================
--- trunk/libs/context/src/asm/fcontext_i386_ms_pe_masm.asm	(original)
+++ trunk/libs/context/src/asm/fcontext_i386_ms_pe_masm.asm	2012-08-10 12:07:25 EDT (Fri, 10 Aug 2012)
@@ -12,30 +12,30 @@
 ;  |   EDI   |   ESI   |   EBX   |   EBP   |   ESP    |   EIP   |
 ;  --------------------------------------------------------------
 ;  --------------------------------------------------------------
-;  |    6    |    7    |                                        |
+;  |    6    |    7    |    8    |                              |
 ;  --------------------------------------------------------------
-;  |   018h  |   01ch  |                                        |
+;  |   018h  |   01ch  |   020h  |                              |
 ;  --------------------------------------------------------------
-;  | ss_base | ss_limit|                                        |
+;  |   base  |  limit  |   size  |                              |
 ;  --------------------------------------------------------------
 ;  --------------------------------------------------------------
-;  |    8    |                                                  |
+;  |    9    |                                                  |
 ;  --------------------------------------------------------------
-;  |  020h   |                                                  |
+;  |  024h   |                                                  |
 ;  --------------------------------------------------------------
 ;  |fc_execpt|                                                  |
 ;  --------------------------------------------------------------
 ;  --------------------------------------------------------------
-;  |    9    |                                                  |
+;  |   10    |                                                  |
 ;  --------------------------------------------------------------
-;  |  024h   |                                                  |
+;  |  028h   |                                                  |
 ;  --------------------------------------------------------------
 ;  |fc_strage|                                                  |
 ;  --------------------------------------------------------------
 ;  --------------------------------------------------------------
-;  |   10    |    11   |                                        |
+;  |   11    |    12   |                                        |
 ;  --------------------------------------------------------------
-;  |  028h   |   02ch  |                                        |
+;  |  02ch   |   030h  |                                        |
 ;  --------------------------------------------------------------
 ;  | fc_mxcsr|fc_x87_cw|                                        |
 ;  --------------------------------------------------------------
@@ -59,13 +59,13 @@
     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     [ecx+024h],  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
+    mov     [ecx+028h],  eax        ; save fiber local storage
 
     lea     eax,         [esp+04h]  ; exclude the return address
     mov     [ecx+010h],  eax        ; save as stack pointer
@@ -82,22 +82,22 @@
     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
+    stmxcsr [ecx+02ch]              ; save MMX control word
+    fnstcw  [ecx+030h]              ; save x87 control word
+    ldmxcsr [edx+02ch]              ; restore MMX control word
+    fldcw   [edx+030h]              ; 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     eax,        [ecx+024h]  ; 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     eax,        [ecx+028h]  ; load fiber local storage
     mov     [edx+010h], eax         ; restore fiber local storage
 
     mov     eax,        [esp+0ch]   ; use third arg as return value after jump
@@ -110,20 +110,23 @@
 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
+    mov  eax,         [esp+04h]     ; load address of the fcontext_t
+    mov  ecx,         [esp+08h]     ; load address of the context function
+    mov  [eax+014h],  ecx           ; save address of the context function
+    mov  edx,         [eax+018h]    ; load address of context stack base
+    mov  ecx,         [eax+020h]    ; load context stack size
+    neg  ecx                        ; negate stacksize for LEA 
+    lea  ecx,         [edx+ecx]     ; compute context stack limit
+    mov  [eax+01ch],  ecx           ; save context stack limit
 
     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
+    push  edx                       ; context stack as arg for align_stack
+    call  align_stack               ; call align_stack
+    mov   edx,        eax           ; begin of aligned context 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
+    lea  edx,         [edx-014h]    ; reserve space for last frame on context stack, (ESP + 4) & 15 == 0
     mov  [eax+010h],  edx           ; save the aligned stack
 
     mov  ecx,         seh_fcontext  ; set ECX to exception-handler
@@ -131,10 +134,10 @@
     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
+    mov  [eax+024h],  ecx           ; save next SEH
 
-    stmxcsr [eax+028h]              ; save MMX control word
-    fnstcw  [eax+02ch]              ; save x87 control word
+    stmxcsr [eax+02ch]              ; save MMX control word
+    fnstcw  [eax+030h]              ; save x87 control word
 
     mov  ecx,         finish        ; address of finish
     mov  [edx],       ecx
Modified: trunk/libs/context/src/asm/fcontext_i386_sysv_elf_gas.S
==============================================================================
--- trunk/libs/context/src/asm/fcontext_i386_sysv_elf_gas.S	(original)
+++ trunk/libs/context/src/asm/fcontext_i386_sysv_elf_gas.S	2012-08-10 12:07:25 EDT (Fri, 10 Aug 2012)
@@ -77,25 +77,24 @@
 .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 */
+    movl   0x8(%esp),      %ecx         /* load address of the context function */
+    movl   %ecx,           0x14(%eax)   /* save address of the context function */
+    movl   0x18(%eax),     %edx         /* load address of context stack base */
 
     pushl  %eax                         /* save pointer to fcontext_t */
     pushl  %ebx                         /* save EBX */
-    pushl  %edx                         /* stack pointer as arg for align_stack */
+    pushl  %edx                         /* context stack pointer as arg for align_stack */
     call   1f
-1:  popl   %ebx                         /* address of label 1 */
+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 */
+    call   align_stack_at_PLT                         /* call align_stack */
+    movl   %eax,           %edx                    /* begin of aligned context 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 */
+    leal   -0x14(%edx),    %edx         /* reserve space for the last frame on context stack, (ESP + 4) % 16 == 0 */
+    movl   %edx,           0x10(%eax)   /* save the aligned context stack base */
 
     stmxcsr  0x20(%eax)                 /* save MMX control and status word */
     fnstcw   0x24(%eax)                 /* save x87 control word */
Modified: trunk/libs/context/src/asm/fcontext_i386_sysv_macho_gas.S
==============================================================================
--- trunk/libs/context/src/asm/fcontext_i386_sysv_macho_gas.S	(original)
+++ trunk/libs/context/src/asm/fcontext_i386_sysv_macho_gas.S	2012-08-10 12:07:25 EDT (Fri, 10 Aug 2012)
@@ -74,28 +74,27 @@
 .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 */
+    movl   0x8(%esp),      %ecx         /* load address of the context function */
+    movl   %ecx,           0x14(%eax)   /* save address of the context function */
+    movl   0x18(%eax),     %edx         /* load address of context stack base */
 
     pushl  %eax                         /* save pointer to fcontext_t */
     pushl  %ebx                         /* save EBX */
-    pushl  %edx                         /* stack pointer as arg for align_stack */
-    call   _align_stack                 /* align stack */
-    movl   %eax,           %edx         /* begin of aligned stack */
+    pushl  %edx                         /* context stack pointer as arg for align_stack */
+    call   _align_stack                 /* call align_stack */
+    movl   %eax,           %edx         /* begin of aligned context 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 */
+    leal   -0x14(%edx),    %edx         /* reserve space for the last frame on context stack, (ESP + 4) % 16 == 0 */
+    movl   %edx,           0x10(%eax)   /* save the aligned context stack base */
 
     stmxcsr  0x20(%eax)                 /* save MMX control and status word */
     fnstcw   0x24(%eax)                 /* save x87 control word */
 
     call   1f
-1:  popl   %ecx
+1:  popl   %ecx                         /* address of lable 1 */
     addl   $finish-1b,     %ecx         /* helper code executed after context function returns */
     movl   %ecx, (%edx)
 
Modified: trunk/libs/context/src/asm/fcontext_mips32_o32_elf_gas.S
==============================================================================
--- trunk/libs/context/src/asm/fcontext_mips32_o32_elf_gas.S	(original)
+++ trunk/libs/context/src/asm/fcontext_mips32_o32_elf_gas.S	2012-08-10 12:07:25 EDT (Fri, 10 Aug 2012)
@@ -109,19 +109,18 @@
 .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
+    sw      $a1, 96($a0)        # save address of context function
+    lw      $t0, 104($a0)       # load address of context 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
+    move    $a0, $t0                       # context stack pointer as arg for align_stack
+    lw      $t9, %call16(align_stack)($gp) # address of align_stack
+    jalr    $t9                            # call align_stack
     nop
-    move    $t0, $v0            # begin of aligned stack 
+    move    $t0, $v0            # begin of aligned context stack
     lw      $ra, 24($sp)
     lw      $a0, 20($sp)
     addi    $sp, $sp, 28
Modified: trunk/libs/context/src/asm/fcontext_ppc32_sysv_elf_gas.S
==============================================================================
--- trunk/libs/context/src/asm/fcontext_ppc32_sysv_elf_gas.S	(original)
+++ trunk/libs/context/src/asm/fcontext_ppc32_sysv_elf_gas.S	2012-08-10 12:07:25 EDT (Fri, 10 Aug 2012)
@@ -184,9 +184,8 @@
 .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
+    stw     %r4, 88(%r3)        # save address of context function
+    lwz     %r0, 92(%r3)        # load address of context stack base
 
     li      %r4, 28
     subf    %r1, %r4, %r1       # reserve space on stack
@@ -208,10 +207,10 @@
     mflr    %r0                 # load LR
     bl      1f                  # jump to label 1
 1:
-    mflr    %r4                 # load LR
+    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)
+    mtlr    %r0                      # restore LR
+    stw     %r4, 84(%r3)             # save address of finish
 
     li      %r3,  0
     blr
Modified: trunk/libs/context/src/asm/fcontext_ppc64_sysv_elf_gas.S
==============================================================================
--- trunk/libs/context/src/asm/fcontext_ppc64_sysv_elf_gas.S	(original)
+++ trunk/libs/context/src/asm/fcontext_ppc64_sysv_elf_gas.S	2012-08-10 12:07:25 EDT (Fri, 10 Aug 2012)
@@ -212,9 +212,8 @@
 .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
+    std     %r4, 176(%r3)       # save address of context function
+    ld      %r0, 184(%r3)       # load address of context stack base
 
     li      %r4, 56
     subf    %r1, %r4, %r1       # reserve space on stack
@@ -236,10 +235,10 @@
     mflr    %r0                 # load LR
     bl      1f                  # jump to label 1
 1:
-    mflr    %r4                 # load LR
+    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
+    mtlr    %r0                      # restore LR
+    std     %r4, 168(%r3)            # save address of finish
 
     li      %r3,  0             # set return value to zero
     blr
Modified: trunk/libs/context/src/asm/fcontext_x86_64_ms_pe_masm.asm
==============================================================================
--- trunk/libs/context/src/asm/fcontext_x86_64_ms_pe_masm.asm	(original)
+++ trunk/libs/context/src/asm/fcontext_x86_64_ms_pe_masm.asm	2012-08-10 12:07:25 EDT (Fri, 10 Aug 2012)
@@ -23,61 +23,61 @@
 ;  ----------------------------------------------------------------------------------
 ;  |   0x40  |   0x44  |   0x48  |   0x4c  |                                        |
 ;  ----------------------------------------------------------------------------------
-;  |        RSP        |       RIP         |                                        |
+;  |        RSP        |        RIP        |                                        |
 ;  ----------------------------------------------------------------------------------
 ;  ----------------------------------------------------------------------------------
-;  |    20   |    21   |    22   |    23   |                                        |
+;  |    20   |    21   |    22   |    23   |    24    |    25   |                   |
 ;  ----------------------------------------------------------------------------------
-;  |   0x50  |   0x54  |   0x58  |   0x5c  |                                        |
+;  |   0x50  |   0x54  |   0x58  |   0x5c  |   0x60   |   0x64  |                   |
 ;  ----------------------------------------------------------------------------------
-;  |       sbase       |       slimit      |                                        |
+;  |       base        |       limit       |        size        |                   |
 ;  ----------------------------------------------------------------------------------
 ;  ----------------------------------------------------------------------------------
-;  |    24   |   25    |                                                            |
+;  |    26   |   27    |                                                            |
 ;  ----------------------------------------------------------------------------------
-;  |   0x60  |   0x64  |                                                            |
+;  |   0x68  |   0x6c  |                                                            |
 ;  ----------------------------------------------------------------------------------
 ;  |      fbr_strg     |                                                            |
 ;  ----------------------------------------------------------------------------------
 ;  ----------------------------------------------------------------------------------
-;  |    26   |   27    |    28   |    29   |                                        |
+;  |    28   |   29    |    30   |    31   |                                        |
 ;  ----------------------------------------------------------------------------------
-;  |   0x68  |   0x6c  |   0x70  |   0x74  |                                        |
+;  |   0x70  |   0x74  |   0x78  |   0x7c  |                                        |
 ;  ----------------------------------------------------------------------------------
 ;  | fc_mxcsr|fc_x87_cw|       fc_xmm      |                                        |
 ;  ----------------------------------------------------------------------------------
 ;  ----------------------------------------------------------------------------------
-;  |   30    |   31    |    32    |   33   |   34    |   35    |   36     |   37    |
+;  |    32    |   33   |   34    |   35    |   36     |   37    |    38   |    39   |
 ;  ----------------------------------------------------------------------------------
-;  |  0x78   |  0x7c   |   0x80   |  0x84  |  0x88   |  0x8c   |   0x90   |   0x94  |
+;  |   0x80   |  0x84  |  0x88   |  0x8c   |   0x90   |   0x94  |   0x98  |   0x9c  |
 ;  ----------------------------------------------------------------------------------
 ;  |                  XMM6                 |                   XMM7                 |
 ;  ----------------------------------------------------------------------------------
 ;  ----------------------------------------------------------------------------------
-;  |   38    |   39    |    40    |   41   |   42    |   43    |    44    |   45    |
+;  |    40    |   41   |   42    |   43    |    44    |   45    |    46   |    47   | 
 ;  ----------------------------------------------------------------------------------
-;  |  0x98   |  0x9c   |  0x100  |  0x104  |  0x108  |  0x10c  |   0x110  |  0x114  |
+;  |   0x100  |  0x104  |  0x108  |  0x10c |   0x110  |  0x114  |  0x118  |  0x11c  |
 ;  ----------------------------------------------------------------------------------
 ;  |                  XMM8                 |                   XMM9                 |
 ;  ----------------------------------------------------------------------------------
 ;  ----------------------------------------------------------------------------------
-;  |   46    |   47    |    48    |   49   |   50    |   51    |    52    |   53    |
+;  |    48    |   49   |   50    |   51    |    52    |   53    |    54   |    55   |
 ;  ----------------------------------------------------------------------------------
-;  |  0x118  |  0x11c  |  0x120  |  0x124  |  0x128  |  0x12c  |   0x130  |  0x134  |
+;  |   0x120  |  0x124 |  0x128  |  0x12c  |   0x130  |  0x134  |   0x138 |   0x13c |
 ;  ----------------------------------------------------------------------------------
 ;  |                 XMM10                 |                  XMM11                 |
 ;  ----------------------------------------------------------------------------------
 ;  ----------------------------------------------------------------------------------
-;  |   54    |   55    |    56    |   57   |   58    |   59    |    60    |   61    |
+;  |    56    |   57   |   58    |   59    |    60   |    61   |    62    |    63   |
 ;  ----------------------------------------------------------------------------------
-;  |  0x138  |  0x13c  |  0x140  |  0x144  |  0x148  |  0x14c  |   0x150  |  0x154  |
+;  |  0x140  |  0x144  |  0x148  |  0x14c  |   0x150  |  0x154 |   0x158  |   0x15c |
 ;  ----------------------------------------------------------------------------------
 ;  |                 XMM12                 |                  XMM13                 |
 ;  ----------------------------------------------------------------------------------
 ;  ----------------------------------------------------------------------------------
-;  |   62    |   63    |    64    |   65   |   66    |   67    |    68    |   69    |
+;  |    64    |   65   |   66    |   67    |    68    |   69    |    70   |    71   |
 ;  ----------------------------------------------------------------------------------
-;  |  0x158  |  0x15c  |  0x160  |  0x164  |  0x168  |  0x16c  |   0x170  |  0x174  |
+;  |  0x160  |  0x164  |  0x168  |  0x16c  |   0x170  |  0x174  |  0x178  |   0x17c |
 ;  ----------------------------------------------------------------------------------
 ;  |                 XMM14                 |                  XMM15                 |
 ;  ----------------------------------------------------------------------------------
@@ -105,14 +105,14 @@
     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
+    mov     [rcx+068h],  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
+    stmxcsr [rcx+070h]              ; save MMX control and status word
+    fnstcw  [rcx+074h]              ; save x87 control word
+	mov	    r10,         [rcx+078h] ; address of aligned XMM storage
     movaps  [r10],       xmm6
     movaps  [r10+010h],  xmm7
     movaps  [r10+020h],  xmm8
@@ -124,9 +124,9 @@
     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
+    ldmxcsr [rdx+070h]              ; restore MMX control and status word
+    fldcw   [rdx+074h]              ; restore x87 control word
+	mov	    r10,         [rdx+078h] ; address of aligned XMM storage
     movaps  xmm6,        [r10]
     movaps  xmm7,        [r10+010h]
     movaps  xmm8,        [r10+020h]
@@ -158,7 +158,7 @@
     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     rax,        [rdx+068h]  ; load fiber local storage
     mov     [r10+018h], rax         ; restore fiber local storage
 
     mov     rsp,        [rdx+040h]  ; restore RSP
@@ -173,24 +173,27 @@
 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
+    mov  [rcx+048h], rdx         ; save address of context function
+    mov  rdx,        [rcx+050h]  ; load address of context stack base
+    mov  r8,         [rcx+060h]  ; load context stack size
+    neg  r8                      ; negate r8 for LEA 
+    lea  r8,         [rdx+r8]    ; compute the address of context stack limit
+    mov  [rcx+058h], r8          ; save the address of context stack limit
 
     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   rcx,       rdx         ; context stack pointer as arg for align_stack
     mov   [rsp+8],   rcx
-    call  align_stack   ; align stack
-    mov   rdx,       rax         ; begin of aligned stack
+    call  align_stack            ; call align_stack
+    mov   rdx,       rax         ; begin of aligned context 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
+    mov  [rcx+040h], rdx         ; save the address where the context stack begins
 
-    stmxcsr [rcx+068h]           ; save MMX control and status word
-    fnstcw  [rcx+06ch]           ; save x87 control word
+    stmxcsr [rcx+070h]           ; save MMX control and status word
+    fnstcw  [rcx+074h]           ; 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
Modified: trunk/libs/context/src/asm/fcontext_x86_64_sysv_elf_gas.S
==============================================================================
--- trunk/libs/context/src/asm/fcontext_x86_64_sysv_elf_gas.S	(original)
+++ trunk/libs/context/src/asm/fcontext_x86_64_sysv_elf_gas.S	2012-08-10 12:07:25 EDT (Fri, 10 Aug 2012)
@@ -86,18 +86,17 @@
 .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 */
+    movq   %rsi,                 0x38(%rdi) /* save address of context function */
+    movq   0x40(%rdi),           %rdx       /* load address of context 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 */
+    movq   %rdx,                 %rdi       /* context stack pointer as arg for align_stack */
+    call   align_stack_at_PLT                  /* align context stack */
+    movq   %rax,                 %rdx       /* begin of aligned context 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 */
+    leaq   -0x8(%rdx),           %rdx       /* reserve space for the last frame on context stack, (RSP + 8) & 15 == 0 */
+    movq   %rdx,                 0x30(%rdi) /* save the algined context stack base */
 
     stmxcsr  0x50(%rdi)                     /* save MMX control and status word */
     fnstcw   0x54(%rdi)                     /* save x87 control word */
Modified: trunk/libs/context/src/asm/fcontext_x86_64_sysv_macho_gas.S
==============================================================================
--- trunk/libs/context/src/asm/fcontext_x86_64_sysv_macho_gas.S	(original)
+++ trunk/libs/context/src/asm/fcontext_x86_64_sysv_macho_gas.S	2012-08-10 12:07:25 EDT (Fri, 10 Aug 2012)
@@ -83,18 +83,17 @@
 .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 */
+    movq   %rsi,                 0x38(%rdi) /* save address of context function */
+    movq   0x40(%rdi),           %rdx       /* load address of context 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 */
+    movq   %rdx,                 %rdi       /* context stack pointer as arg for align_stack */
+    call   _align_stack                     /* call align_stack */
+    movq   %rax,                 %rdx       /* begin of aligned context 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 */
+    leaq   -0x8(%rdx),           %rdx       /* reserve space for the last frame on context stack, (RSP + 8) % 16 == 0 */
+    movq   %rdx,                 0x30(%rdi) /* save the algined context stack base */
 
     stmxcsr  0x50(%rdi)                     /* save MMX control and status word */
     fnstcw   0x54(%rdi)                     /* save x87 control word */
Modified: trunk/libs/context/src/seh.cpp
==============================================================================
--- trunk/libs/context/src/seh.cpp	(original)
+++ trunk/libs/context/src/seh.cpp	2012-08-10 12:07:25 EDT (Fri, 10 Aug 2012)
@@ -6,6 +6,11 @@
 
 #define BOOST_CONTEXT_SOURCE
 
+# if defined(BOOST_MSVC)
+# pragma warning(push)
+# pragma warning(disable:4996)
+# endif
+
 extern "C" {
 
 #include <stddef.h>
@@ -80,4 +85,8 @@
     return ExceptionContinueSearch; // never reached
 }
 
+# if defined(BOOST_MSVC)
+# pragma warning(pop)
+# endif
+
 }
Modified: trunk/libs/context/src/stack_allocator_windows.cpp
==============================================================================
--- trunk/libs/context/src/stack_allocator_windows.cpp	(original)
+++ trunk/libs/context/src/stack_allocator_windows.cpp	2012-08-10 12:07:25 EDT (Fri, 10 Aug 2012)
@@ -21,15 +21,15 @@
 
 #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
 
+#ifdef BOOST_HAS_ABI_HEADERS
+#  include BOOST_ABI_PREFIX
+#endif
+
 namespace boost {
 namespace ctx {
 
@@ -77,10 +77,10 @@
 
 }}
 
-# if defined(BOOST_MSVC)
-# pragma warning(pop)
-# endif
-
 #ifdef BOOST_HAS_ABI_HEADERS
 #  include BOOST_ABI_SUFFIX
 #endif
+
+# if defined(BOOST_MSVC)
+# pragma warning(pop)
+# endif
Modified: trunk/libs/context/test/test_context.cpp
==============================================================================
--- trunk/libs/context/test/test_context.cpp	(original)
+++ trunk/libs/context/test/test_context.cpp	2012-08-10 12:07:25 EDT (Fri, 10 Aug 2012)
@@ -81,7 +81,7 @@
     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_stack.size = ctx::minimum_stacksize();
     ctx::make_fcontext( & fc1, f1);
 
     BOOST_CHECK_EQUAL( 0, value1);
@@ -96,7 +96,7 @@
     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_stack.size = ctx::minimum_stacksize();
     ctx::make_fcontext( & fc1, f3);
 
     BOOST_CHECK_EQUAL( 0, value1);
@@ -111,7 +111,7 @@
     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_stack.size = ctx::minimum_stacksize();
     ctx::make_fcontext( & fc1, f4);
 
     int result = ( int) ctx::jump_fcontext( & fcm, & fc1, 0);
@@ -123,7 +123,7 @@
     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_stack.size = ctx::minimum_stacksize();
     int i = 7;
     ctx::make_fcontext( & fc1, f5);
 
@@ -136,7 +136,7 @@
     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_stack.size = ctx::minimum_stacksize();
     std::pair< int, int > data = std::make_pair( 3, 7);
     ctx::make_fcontext( & fc1, f6);
 
@@ -152,7 +152,7 @@
     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_stack.size = ctx::minimum_stacksize();
     const char * what = "hello world";
     ctx::make_fcontext( & fc1, f7);
 
@@ -165,7 +165,7 @@
     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_stack.size = ctx::minimum_stacksize();
     double d = 7.13;
     ctx::make_fcontext( & fc1, f8);