Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r80529 - in trunk: boost/context boost/context/detail libs/context/build 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-09-15 02:31:56


Author: olli
Date: 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
New Revision: 80529
URL: http://svn.boost.org/trac/boost/changeset/80529

Log:
context: namespace renamed to 'context'; spltting up asm files

Added:
   trunk/libs/context/src/asm/jump_arm_aapcs_elf_gas.S (contents, props changed)
   trunk/libs/context/src/asm/jump_i386_ms_pe_masm.asm (contents, props changed)
   trunk/libs/context/src/asm/jump_i386_sysv_elf_gas.S (contents, props changed)
   trunk/libs/context/src/asm/jump_i386_sysv_macho_gas.S (contents, props changed)
   trunk/libs/context/src/asm/jump_mips32_o32_elf_gas.S (contents, props changed)
   trunk/libs/context/src/asm/jump_ppc32_sysv_elf_gas.S (contents, props changed)
   trunk/libs/context/src/asm/jump_ppc64_sysv_elf_gas.S (contents, props changed)
   trunk/libs/context/src/asm/jump_x86_64_ms_pe_masm.asm (contents, props changed)
   trunk/libs/context/src/asm/jump_x86_64_sysv_elf_gas.S (contents, props changed)
   trunk/libs/context/src/asm/jump_x86_64_sysv_macho_gas.S (contents, props changed)
   trunk/libs/context/src/asm/make_arm_aapcs_elf_gas.S (contents, props changed)
   trunk/libs/context/src/asm/make_i386_ms_pe_masm.asm (contents, props changed)
   trunk/libs/context/src/asm/make_i386_sysv_elf_gas.S (contents, props changed)
   trunk/libs/context/src/asm/make_i386_sysv_macho_gas.S (contents, props changed)
   trunk/libs/context/src/asm/make_mips32_o32_elf_gas.S (contents, props changed)
   trunk/libs/context/src/asm/make_ppc32_sysv_elf_gas.S (contents, props changed)
   trunk/libs/context/src/asm/make_ppc64_sysv_elf_gas.S (contents, props changed)
   trunk/libs/context/src/asm/make_x86_64_ms_pe_masm.asm (contents, props changed)
   trunk/libs/context/src/asm/make_x86_64_sysv_elf_gas.S (contents, props changed)
   trunk/libs/context/src/asm/make_x86_64_sysv_macho_gas.S (contents, props changed)
Removed:
   trunk/libs/context/src/asm/fcontext_arm_aapcs_elf_gas.S
   trunk/libs/context/src/asm/fcontext_i386_ms_pe_masm.asm
   trunk/libs/context/src/asm/fcontext_i386_sysv_elf_gas.S
   trunk/libs/context/src/asm/fcontext_i386_sysv_macho_gas.S
   trunk/libs/context/src/asm/fcontext_mips32_o32_elf_gas.S
   trunk/libs/context/src/asm/fcontext_ppc32_sysv_elf_gas.S
   trunk/libs/context/src/asm/fcontext_ppc64_sysv_elf_gas.S
   trunk/libs/context/src/asm/fcontext_x86_64_ms_pe_masm.asm
   trunk/libs/context/src/asm/fcontext_x86_64_sysv_elf_gas.S
   trunk/libs/context/src/asm/fcontext_x86_64_sysv_macho_gas.S
Text files modified:
   trunk/boost/context/all.hpp | 6 +-
   trunk/boost/context/detail/config.hpp | 6 +-
   trunk/boost/context/detail/fcontext_arm.hpp | 8 +-
   trunk/boost/context/detail/fcontext_i386.hpp | 8 +-
   trunk/boost/context/detail/fcontext_i386_win.hpp | 8 +-
   trunk/boost/context/detail/fcontext_mips.hpp | 8 +-
   trunk/boost/context/detail/fcontext_ppc.hpp | 8 +-
   trunk/boost/context/detail/fcontext_x86_64.hpp | 8 +-
   trunk/boost/context/detail/fcontext_x86_64_win.hpp | 8 +-
   trunk/boost/context/fcontext.hpp | 8 +-
   trunk/boost/context/guarded_stack_allocator.hpp | 8 +-
   trunk/boost/context/simple_stack_allocator.hpp | 8 +-
   trunk/boost/context/utils.hpp | 8 +-
   trunk/libs/context/build/Jamfile.v2 | 99 ++++++++++++++++++++++++++-------------
   trunk/libs/context/doc/context.qbk | 2
   trunk/libs/context/doc/fcontext.qbk | 8 +-
   trunk/libs/context/doc/overview.qbk | 4
   trunk/libs/context/doc/performance.qbk | 2
   trunk/libs/context/doc/rationale.qbk | 10 ++-
   trunk/libs/context/doc/stack.qbk | 6 +-
   trunk/libs/context/example/exit.cpp | 2
   trunk/libs/context/example/jump.cpp | 2
   trunk/libs/context/example/transfer.cpp | 2
   trunk/libs/context/performance/performance.cpp | 2
   trunk/libs/context/src/fcontext.cpp | 2
   trunk/libs/context/src/guarded_stack_allocator_posix.cpp | 4
   trunk/libs/context/src/guarded_stack_allocator_windows.cpp | 4
   trunk/libs/context/src/utils_posix.cpp | 2
   trunk/libs/context/src/utils_windows.cpp | 2
   trunk/libs/context/test/test_context.cpp | 33 +++---------
   30 files changed, 153 insertions(+), 133 deletions(-)

Modified: trunk/boost/context/all.hpp
==============================================================================
--- trunk/boost/context/all.hpp (original)
+++ trunk/boost/context/all.hpp 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -4,12 +4,12 @@
 // (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
+#ifndef BOOST_CONTEXT_ALL_H
+#define BOOST_CONTEXT_ALL_H
 
 #include <boost/context/fcontext.hpp>
 #include <boost/context/guarded_stack_allocator.hpp>
 #include <boost/context/simple_stack_allocator.hpp>
 #include <boost/context/utils.hpp>
 
-#endif // BOOST_CTX_ALL_H
+#endif // BOOST_CONTEXT_ALL_H

Modified: trunk/boost/context/detail/config.hpp
==============================================================================
--- trunk/boost/context/detail/config.hpp (original)
+++ trunk/boost/context/detail/config.hpp 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -4,8 +4,8 @@
 // (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
+#ifndef BOOST_CONTEXT_DETAIL_CONFIG_H
+#define BOOST_CONTEXT_DETAIL_CONFIG_H
 
 #include <boost/config.hpp>
 #include <boost/detail/workaround.hpp>
@@ -39,4 +39,4 @@
 # include <boost/config/auto_link.hpp>
 #endif
 
-#endif // BOOST_CTX_DETAIL_CONFIG_H
+#endif // BOOST_CONTEXT_DETAIL_CONFIG_H

Modified: trunk/boost/context/detail/fcontext_arm.hpp
==============================================================================
--- trunk/boost/context/detail/fcontext_arm.hpp (original)
+++ trunk/boost/context/detail/fcontext_arm.hpp 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -4,8 +4,8 @@
 // (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
+#ifndef BOOST_CONTEXT_DETAIL_FCONTEXT_ARM_H
+#define BOOST_CONTEXT_DETAIL_FCONTEXT_ARM_H
 
 #include <cstddef>
 
@@ -19,7 +19,7 @@
 #endif
 
 namespace boost {
-namespace ctx {
+namespace context {
 
 extern "C" {
 
@@ -65,4 +65,4 @@
 # include BOOST_ABI_SUFFIX
 #endif
 
-#endif // BOOST_CTX_DETAIL_FCONTEXT_ARM_H
+#endif // BOOST_CONTEXT_DETAIL_FCONTEXT_ARM_H

Modified: trunk/boost/context/detail/fcontext_i386.hpp
==============================================================================
--- trunk/boost/context/detail/fcontext_i386.hpp (original)
+++ trunk/boost/context/detail/fcontext_i386.hpp 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -4,8 +4,8 @@
 // (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
+#ifndef BOOST_CONTEXT_DETAIL_FCONTEXT_I386H
+#define BOOST_CONTEXT_DETAIL_FCONTEXT_I386H
 
 #include <cstddef>
 
@@ -19,7 +19,7 @@
 #endif
 
 namespace boost {
-namespace ctx {
+namespace context {
 
 extern "C" {
 
@@ -56,4 +56,4 @@
 # include BOOST_ABI_SUFFIX
 #endif
 
-#endif // BOOST_CTX_DETAIL_FCONTEXT_I386_H
+#endif // BOOST_CONTEXT_DETAIL_FCONTEXT_I386_H

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-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -4,8 +4,8 @@
 // (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
+#ifndef BOOST_CONTEXT_DETAIL_FCONTEXT_I386H
+#define BOOST_CONTEXT_DETAIL_FCONTEXT_I386H
 
 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
 # pragma once
@@ -28,7 +28,7 @@
 #endif
 
 namespace boost {
-namespace ctx {
+namespace context {
 
 extern "C" {
 
@@ -83,4 +83,4 @@
 #pragma warning(pop)
 #endif
 
-#endif // BOOST_CTX_DETAIL_FCONTEXT_I386_H
+#endif // BOOST_CONTEXT_DETAIL_FCONTEXT_I386_H

Modified: trunk/boost/context/detail/fcontext_mips.hpp
==============================================================================
--- trunk/boost/context/detail/fcontext_mips.hpp (original)
+++ trunk/boost/context/detail/fcontext_mips.hpp 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -4,8 +4,8 @@
 // (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
+#ifndef BOOST_CONTEXT_DETAIL_FCONTEXT_MIPS_H
+#define BOOST_CONTEXT_DETAIL_FCONTEXT_MIPS_H
 
 #include <cstddef>
 
@@ -19,7 +19,7 @@
 #endif
 
 namespace boost {
-namespace ctx {
+namespace context {
 
 extern "C" {
 
@@ -67,4 +67,4 @@
 # include BOOST_ABI_SUFFIX
 #endif
 
-#endif // BOOST_CTX_DETAIL_FCONTEXT_MIPS_H
+#endif // BOOST_CONTEXT_DETAIL_FCONTEXT_MIPS_H

Modified: trunk/boost/context/detail/fcontext_ppc.hpp
==============================================================================
--- trunk/boost/context/detail/fcontext_ppc.hpp (original)
+++ trunk/boost/context/detail/fcontext_ppc.hpp 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -4,8 +4,8 @@
 // (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
+#ifndef BOOST_CONTEXT_DETAIL_FCONTEXT_PPC_H
+#define BOOST_CONTEXT_DETAIL_FCONTEXT_PPC_H
 
 #include <cstddef>
 
@@ -19,7 +19,7 @@
 #endif
 
 namespace boost {
-namespace ctx {
+namespace context {
 
 extern "C" {
 
@@ -69,4 +69,4 @@
 # include BOOST_ABI_SUFFIX
 #endif
 
-#endif // BOOST_CTX_DETAIL_FCONTEXT_PPC_H
+#endif // BOOST_CONTEXT_DETAIL_FCONTEXT_PPC_H

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-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -4,8 +4,8 @@
 // (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
+#ifndef BOOST_CONTEXT_DETAIL_FCONTEXT_X86_64_H
+#define BOOST_CONTEXT_DETAIL_FCONTEXT_X86_64_H
 
 #include <cstddef>
 
@@ -19,7 +19,7 @@
 #endif
 
 namespace boost {
-namespace ctx {
+namespace context {
 
 extern "C" {
 
@@ -65,4 +65,4 @@
 # include BOOST_ABI_SUFFIX
 #endif
 
-#endif // BOOST_CTX_DETAIL_FCONTEXT_X86_64_H
+#endif // BOOST_CONTEXT_DETAIL_FCONTEXT_X86_64_H

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-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -4,8 +4,8 @@
 // (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
+#ifndef BOOST_CONTEXT_DETAIL_FCONTEXT_X86_64_H
+#define BOOST_CONTEXT_DETAIL_FCONTEXT_X86_64_H
 
 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
 # pragma once
@@ -28,7 +28,7 @@
 #endif
 
 namespace boost {
-namespace ctx {
+namespace context {
 
 extern "C" {
 
@@ -89,4 +89,4 @@
 #pragma warning(pop)
 #endif
 
-#endif // BOOST_CTX_DETAIL_FCONTEXT_X86_64_H
+#endif // BOOST_CONTEXT_DETAIL_FCONTEXT_X86_64_H

Modified: trunk/boost/context/fcontext.hpp
==============================================================================
--- trunk/boost/context/fcontext.hpp (original)
+++ trunk/boost/context/fcontext.hpp 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -4,8 +4,8 @@
 // (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
+#ifndef BOOST_CONTEXT_FCONTEXT_H
+#define BOOST_CONTEXT_FCONTEXT_H
 
 #if defined(__PGI)
 #include <stdint.h>
@@ -60,7 +60,7 @@
 #endif
 
 namespace boost {
-namespace ctx {
+namespace context {
 namespace detail {
 
 extern "C" BOOST_CONTEXT_DECL void * BOOST_CONTEXT_CALLDECL align_stack( void * vp);
@@ -78,5 +78,5 @@
 # include BOOST_ABI_SUFFIX
 #endif
 
-#endif // BOOST_CTX_FCONTEXT_H
+#endif // BOOST_CONTEXT_FCONTEXT_H
 

Modified: trunk/boost/context/guarded_stack_allocator.hpp
==============================================================================
--- trunk/boost/context/guarded_stack_allocator.hpp (original)
+++ trunk/boost/context/guarded_stack_allocator.hpp 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -4,8 +4,8 @@
 // (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#ifndef BOOST_CTX_GUARDED_STACK_ALLOCATOR_H
-#define BOOST_CTX_GUARDED_STACK_ALLOCATOR_H
+#ifndef BOOST_CONTEXT_GUARDED_STACK_ALLOCATOR_H
+#define BOOST_CONTEXT_GUARDED_STACK_ALLOCATOR_H
 
 #include <boost/config.hpp>
 
@@ -26,7 +26,7 @@
 #endif
 
 namespace boost {
-namespace ctx {
+namespace context {
 
 class BOOST_CONTEXT_DECL guarded_stack_allocator
 {
@@ -52,4 +52,4 @@
 
 //#endif
 
-#endif // BOOST_CTX_GUARDED_STACK_ALLOCATOR_H
+#endif // BOOST_CONTEXT_GUARDED_STACK_ALLOCATOR_H

Modified: trunk/boost/context/simple_stack_allocator.hpp
==============================================================================
--- trunk/boost/context/simple_stack_allocator.hpp (original)
+++ trunk/boost/context/simple_stack_allocator.hpp 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -4,8 +4,8 @@
 // (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#ifndef BOOST_CTX_SIMPLE_STACK_ALLOCATOR_H
-#define BOOST_CTX_SIMPLE_STACK_ALLOCATOR_H
+#ifndef BOOST_CONTEXT_SIMPLE_STACK_ALLOCATOR_H
+#define BOOST_CONTEXT_SIMPLE_STACK_ALLOCATOR_H
 
 #include <cstddef>
 #include <cstdlib>
@@ -21,7 +21,7 @@
 #endif
 
 namespace boost {
-namespace ctx {
+namespace context {
 
 template< std::size_t Max, std::size_t Default, std::size_t Min >
 class simple_stack_allocator
@@ -64,4 +64,4 @@
 # include BOOST_ABI_SUFFIX
 #endif
 
-#endif // BOOST_CTX_SIMPLE_STACK_ALLOCATOR_H
+#endif // BOOST_CONTEXT_SIMPLE_STACK_ALLOCATOR_H

Modified: trunk/boost/context/utils.hpp
==============================================================================
--- trunk/boost/context/utils.hpp (original)
+++ trunk/boost/context/utils.hpp 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -4,8 +4,8 @@
 // (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#ifndef BOOST_CTX_UTILS_H
-#define BOOST_CTX_UTILS_H
+#ifndef BOOST_CONTEXT_UTILS_H
+#define BOOST_CONTEXT_UTILS_H
 
 #include <boost/config.hpp>
 
@@ -26,7 +26,7 @@
 #endif
 
 namespace boost {
-namespace ctx {
+namespace context {
 
 BOOST_CONTEXT_DECL std::size_t pagesize();
 
@@ -38,4 +38,4 @@
 
 //#endif
 
-#endif // BOOST_CTX_UTILS_H
+#endif // BOOST_CONTEXT_UTILS_H

Modified: trunk/libs/context/build/Jamfile.v2
==============================================================================
--- trunk/libs/context/build/Jamfile.v2 (original)
+++ trunk/libs/context/build/Jamfile.v2 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -96,7 +96,8 @@
 
 # ARM
 alias asm_context_sources
- : asm/fcontext_arm_aapcs_elf_gas.S
+ : asm/make_arm_aapcs_elf_gas.S
+ asm/jump_arm_aapcs_elf_gas.S
    : <abi>aapcs
      <architecture>arm
      <binary-format>elf
@@ -104,7 +105,8 @@
    ;
 
 alias asm_context_sources
- : asm/fcontext_arm_aapcs_elf_gas.S
+ : asm/make_arm_aapcs_elf_gas.S
+ asm/jump_arm_aapcs_elf_gas.S
    : <abi>aapcs
      <architecture>arm
      <binary-format>elf
@@ -112,7 +114,8 @@
    ;
 
 alias asm_context_sources
- : [ make asm/fcontext_arm_aapcs_elf_gas.o : asm/fcontext_arm_aapcs_elf_gas.S : @gas ]
+ : [ make asm/make_arm_aapcs_elf_gas.o : asm/make_arm_aapcs_elf_gas.S : @gas ]
+ [ make asm/jump_arm_aapcs_elf_gas.o : asm/jump_arm_aapcs_elf_gas.S : @gas ]
    : <abi>aapcs
      <architecture>arm
      <binary-format>elf
@@ -120,7 +123,8 @@
 
 # MIPS 32bit
 alias asm_context_sources
- : asm/fcontext_mips32_o32_elf_gas.S
+ : asm/make_mips32_o32_elf_gas.S
+ asm/jump_mips32_o32_elf_gas.S
    : <abi>o32
      <architecture>mips1
      <binary-format>elf
@@ -128,7 +132,8 @@
    ;
 
 alias asm_context_sources
- : asm/fcontext_mips32_o32_elf_gas.S
+ : asm/make_mips32_o32_elf_gas.S
+ asm/jump_mips32_o32_elf_gas.S
    : <abi>o32
      <architecture>mips1
      <binary-format>elf
@@ -136,7 +141,8 @@
    ;
 
 alias asm_context_sources
- : [ make asm/fcontext_mips32_o32_elf_gas.o : asm/fcontext_mips32_o32_elf_gas.S : @gas ]
+ : [ make asm/make_mips32_o32_elf_gas.o : asm/make_mips32_o32_elf_gas.S : @gas ]
+ [ make asm/jump_mips32_o32_elf_gas.o : asm/jump_mips32_o32_elf_gas.S : @gas ]
    : <abi>o32
      <architecture>mips1
      <binary-format>elf
@@ -144,7 +150,8 @@
 
 # POWERPC 32bit
 alias asm_context_sources
- : asm/fcontext_ppc32_sysv_elf_gas.S
+ : asm/make_ppc32_sysv_elf_gas.S
+ asm/jump_ppc32_sysv_elf_gas.S
    : <abi>sysv
      <address-model>32
      <architecture>power
@@ -153,7 +160,8 @@
    ;
 
 alias asm_context_sources
- : asm/fcontext_ppc32_sysv_elf_gas.S
+ : asm/make_ppc32_sysv_elf_gas.S
+ asm/jump_ppc32_sysv_elf_gas.S
    : <abi>sysv
      <address-model>32
      <architecture>power
@@ -162,7 +170,8 @@
    ;
 
 alias asm_context_sources
- : [ make asm/fcontext_ppc32_sysv_elf_gas.o : asm/fcontext_ppc32_sysv_elf_gas.S : @gas ]
+ : [ make asm/make_ppc32_sysv_elf_gas.o : asm/make_ppc32_sysv_elf_gas.S : @gas ]
+ [ make asm/jump_ppc32_sysv_elf_gas.o : asm/jump_ppc32_sysv_elf_gas.S : @gas ]
    : <abi>sysv
      <address-model>32
      <architecture>power
@@ -171,7 +180,8 @@
 
 # POWERPC 64bit
 alias asm_context_sources
- : asm/fcontext_ppc64_sysv_elf_gas.S
+ : asm/make_ppc64_sysv_elf_gas.S
+ asm/jump_ppc64_sysv_elf_gas.S
    : <abi>sysv
      <address-model>64
      <architecture>power
@@ -180,7 +190,8 @@
    ;
 
 alias asm_context_sources
- : asm/fcontext_ppc64_sysv_elf_gas.S
+ : asm/make_ppc64_sysv_elf_gas.S
+ asm/jump_ppc64_sysv_elf_gas.S
    : <abi>sysv
      <address-model>64
      <architecture>power
@@ -189,7 +200,8 @@
    ;
 
 alias asm_context_sources
- : [ make asm/fcontext_ppc64_sysv_elf_gas.o : asm/fcontext_ppc64_sysv_elf_gas.S : @gas ]
+ : [ make asm/make_ppc64_sysv_elf_gas.o : asm/make_ppc64_sysv_elf_gas.S : @gas ]
+ [ make asm/jump_ppc64_sysv_elf_gas.o : asm/jump_ppc64_sysv_elf_gas.S : @gas ]
    : <abi>sysv
      <address-model>64
      <architecture>power
@@ -198,7 +210,8 @@
 
 # I386
 alias asm_context_sources
- : asm/fcontext_i386_sysv_elf_gas.S
+ : asm/make_i386_sysv_elf_gas.S
+ asm/jump_i386_sysv_elf_gas.S
    : <abi>sysv
      <address-model>32
      <architecture>x86
@@ -207,7 +220,8 @@
    ;
 
 alias asm_context_sources
- : asm/fcontext_i386_sysv_elf_gas.S
+ : asm/make_i386_sysv_elf_gas.S
+ asm/jump_i386_sysv_elf_gas.S
    : <abi>sysv
      <address-model>32
      <architecture>x86
@@ -216,7 +230,8 @@
    ;
 
 alias asm_context_sources
- : asm/fcontext_i386_sysv_elf_gas.S
+ : asm/make_i386_sysv_elf_gas.S
+ asm/jump_i386_sysv_elf_gas.S
    : <abi>sysv
      <address-model>32
      <architecture>x86
@@ -225,7 +240,8 @@
    ;
 
 alias asm_context_sources
- : [ make asm/fcontext_i386_sysv_elf_gas.o : asm/fcontext_i386_sysv_elf_gas.S : @gas ]
+ : [ make asm/make_i386_sysv_elf_gas.o : asm/make_i386_sysv_elf_gas.S : @gas ]
+ [ make asm/jump_i386_sysv_elf_gas.o : asm/jump_i386_sysv_elf_gas.S : @gas ]
    : <abi>sysv
      <address-model>32
      <architecture>x86
@@ -233,7 +249,8 @@
    ;
 
 alias asm_context_sources
- : asm/fcontext_i386_sysv_macho_gas.S
+ : asm/make_i386_sysv_macho_gas.S
+ asm/jump_i386_sysv_macho_gas.S
    : <abi>sysv
      <address-model>32
      <architecture>x86
@@ -243,7 +260,8 @@
    ;
 
 alias asm_context_sources
- : asm/fcontext_i386_sysv_macho_gas.S
+ : asm/make_i386_sysv_macho_gas.S
+ asm/jump_i386_sysv_macho_gas.S
    : <abi>sysv
      <address-model>32
      <architecture>x86
@@ -253,7 +271,8 @@
    ;
 
 alias asm_context_sources
- : asm/fcontext_i386_sysv_macho_gas.S
+ : asm/make_i386_sysv_macho_gas.S
+ asm/jumjumpysv_macho_gas.S
    : <abi>sysv
      <address-model>32
      <architecture>x86
@@ -263,7 +282,8 @@
    ;
 
 alias asm_context_sources
- : [ make asm/fcontext_i386_sysv_macho_gas.o : asm/fcontext_i386_sysv_macho_gas.S : @gas ]
+ : [ make asm/make_i386_sysv_macho_gas.o : asm/make_i386_sysv_macho_gas.S : @gas ]
+ [ make asm/jump_i386_sysv_macho_gas.o : asm/jump_i386_sysv_macho_gas.S : @gas ]
    : <abi>sysv
      <address-model>32
      <architecture>x86
@@ -272,7 +292,8 @@
    ;
 
 alias asm_context_sources
- : asm/fcontext_i386_ms_pe_masm.asm
+ : asm/make_i386_ms_pe_masm.asm
+ asm/jump_i386_ms_pe_masm.asm
    : <abi>ms
      <address-model>32
      <architecture>x86
@@ -282,7 +303,8 @@
    ;
 
 alias asm_context_sources
- : asm/fcontext_i386_ms_pe_masm.asm
+ : asm/make_i386_ms_pe_masm.asm
+ asm/jump_i386_ms_pe_masm.asm
    : <abi>ms
      <address-model>32
      <architecture>x86
@@ -292,7 +314,8 @@
    ;
 
 alias asm_context_sources
- : [ make asm/fcontext_i386_ms_pe_masm.o : asm/fcontext_i386_ms_pe_masm.asm : @masm ]
+ : [ make asm/make_i386_ms_pe_masm.o : asm/make_i386_ms_pe_masm.asm : @masm ]
+ [ make asm/jump_i386_ms_pe_masm.o : asm/jump_i386_ms_pe_masm.asm : @masm ]
    : <abi>ms
      <address-model>32
      <architecture>x86
@@ -302,7 +325,8 @@
 
 # X86_64
 alias asm_context_sources
- : asm/fcontext_x86_64_sysv_elf_gas.S
+ : asm/make_x86_64_sysv_elf_gas.S
+ asm/jump_x86_64_sysv_elf_gas.S
    : <abi>sysv
      <address-model>64
      <architecture>x86
@@ -311,7 +335,8 @@
    ;
 
 alias asm_context_sources
- : asm/fcontext_x86_64_sysv_elf_gas.S
+ : asm/make_x86_64_sysv_elf_gas.S
+ asm/jump_x86_64_sysv_elf_gas.S
    : <abi>sysv
      <address-model>64
      <architecture>x86
@@ -320,7 +345,8 @@
    ;
 
 alias asm_context_sources
- : asm/fcontext_x86_64_sysv_elf_gas.S
+ : asm/make_x86_64_sysv_elf_gas.S
+ asm/jump_x86_64_sysv_elf_gas.S
    : <abi>sysv
      <address-model>64
      <architecture>x86
@@ -329,7 +355,8 @@
    ;
 
 alias asm_context_sources
- : [ make asm/fcontext_x86_64_sysv_elf_gas.o : asm/fcontext_x86_64_sysv_elf_gas.S : @gas ]
+ : [ make asm/make_x86_64_sysv_elf_gas.o : asm/make_x86_64_sysv_elf_gas.S : @gas ]
+ [ make asm/jump_x86_64_sysv_elf_gas.o : asm/jump_x86_64_sysv_elf_gas.S : @gas ]
    : <abi>sysv
      <address-model>64
      <architecture>x86
@@ -337,7 +364,8 @@
    ;
 
 alias asm_context_sources
- : asm/fcontext_x86_64_sysv_macho_gas.S
+ : asm/make_x86_64_sysv_macho_gas.S
+ asm/jump_x86_64_sysv_macho_gas.S
    : <abi>sysv
      <address-model>64
      <architecture>x86
@@ -347,7 +375,8 @@
    ;
 
 alias asm_context_sources
- : asm/fcontext_x86_64_sysv_macho_gas.S
+ : asm/make_x86_64_sysv_macho_gas.S
+ asm/jump_x86_64_sysv_macho_gas.S
    : <abi>sysv
      <address-model>64
      <architecture>x86
@@ -357,7 +386,8 @@
    ;
 
 alias asm_context_sources
- : [ make asm/fcontext_x86_64_sysv_macho_gas.o : asm/fcontext_x86_64_sysv_macho_gas.S : @gas ]
+ : [ make asm/make_x86_64_sysv_macho_gas.o : asm/make_x86_64_sysv_macho_gas.S : @gas ]
+ [ make asm/jump_x86_64_sysv_macho_gas.o : asm/jump_x86_64_sysv_macho_gas.S : @gas ]
    : <abi>sysv
      <address-model>64
      <architecture>x86
@@ -366,7 +396,8 @@
    ;
 
 alias asm_context_sources
- : asm/fcontext_x86_64_ms_pe_masm.asm
+ : asm/make_x86_64_ms_pe_masm.asm
+ asm/jump_x86_64_ms_pe_masm.asm
    : <abi>ms
      <address-model>64
      <architecture>x86
@@ -376,7 +407,8 @@
    ;
 
 alias asm_context_sources
- : asm/fcontext_x86_64_ms_pe_masm.asm
+ : asm/make_x86_64_ms_pe_masm.asm
+ asm/jump_x86_64_ms_pe_masm.asm
    : <abi>ms
      <address-model>64
      <architecture>x86
@@ -386,7 +418,8 @@
    ;
 
 alias asm_context_sources
- : [ make asm/fcontext_x86_64_ms_pe_masm.o : asm/fcontext_x86_64_ms_pe_masm.asm : @masm64 ]
+ : [ make asm/make_x86_64_ms_pe_masm.o : asm/make_x86_64_ms_pe_masm.asm : @masm64 ]
+ [ make asm/jump_x86_64_ms_pe_masm.o : asm/jump_x86_64_ms_pe_masm.asm : @masm64 ]
    : <abi>ms
      <address-model>64
      <architecture>x86

Modified: trunk/libs/context/doc/context.qbk
==============================================================================
--- trunk/libs/context/doc/context.qbk (original)
+++ trunk/libs/context/doc/context.qbk 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -60,7 +60,7 @@
 [def __stack_helper__ ['stack_helper]]
 [def __yield__ ['yield]]
 
-[def __context_ns__ ['boost::ctx]]
+[def __context_ns__ ['boost::context]]
 
 [include overview.qbk]
 [include requirements.qbk]

Modified: trunk/libs/context/doc/fcontext.qbk
==============================================================================
--- trunk/libs/context/doc/fcontext.qbk (original)
+++ trunk/libs/context/doc/fcontext.qbk 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -16,7 +16,7 @@
 __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
+[warning If __fcontext__ is used in a multi threaded application, it can migrated
 between threads, but must not reference __tls__.]
 
 [important The low level API is the part to port to new platforms.]
@@ -52,7 +52,7 @@
 __jump_fcontext__ again resumes execution in the second context after saving the
 new state of the original context.
 
- namespace ctx = boost::ctx;
+ namespace ctx = boost::context;
 
         ctx::fcontext_t fcm, * fc1, * fc2;
 
@@ -124,7 +124,7 @@
 __jump_fcontext__, in one context, is returned by __jump_fcontext__ in the
 other context.
 
- namespace ctx = boost::ctx;
+ namespace ctx = boost::context;
 
         ctx::fcontext_t fcm, * fc;
 
@@ -178,7 +178,7 @@
 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
+[important The use of the fpu controlling argument of __jump_fcontext__ must
 be consistent in the application. Otherwise the behaviour is undefined.]
 
 

Modified: trunk/libs/context/doc/overview.qbk
==============================================================================
--- trunk/libs/context/doc/overview.qbk (original)
+++ trunk/libs/context/doc/overview.qbk 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -13,13 +13,13 @@
 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
+__coroutines__, __coop_threads__ or an equivalent 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
+current thread. This state full 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.

Modified: trunk/libs/context/doc/performance.qbk
==============================================================================
--- trunk/libs/context/doc/performance.qbk (original)
+++ trunk/libs/context/doc/performance.qbk 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -20,7 +20,7 @@
 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
+[table Performance of context switch
     [[Platform] [ucontext_t] [fcontext_t with fpu] [fcontext_t without fpu] [boost::function]]
     [
         [AMD Athlon 64 DualCore 4400+ (32bit Linux)]

Modified: trunk/libs/context/doc/rationale.qbk
==============================================================================
--- trunk/libs/context/doc/rationale.qbk (original)
+++ trunk/libs/context/doc/rationale.qbk 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -13,6 +13,8 @@
 support inline assembler.
 [footnote [@http://msdn.microsoft.com/en-us/library/4ks26t93.aspx MSDN article
 'Inline Assembler']].
+Inlined assembler generates code bloating which his not welcome on embedded
+systems.
 
 
 [heading fcontext_t]
@@ -26,7 +28,7 @@
 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.
+virtual methods and all members and base classes are PODs too.
 
 
 [heading Protecting the stack]
@@ -64,10 +66,10 @@
 [footnote 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
+in var-arg list is not guaranteed 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
+`ucontext_t` preserves signal mask between context switches which involves system
 calls consuming a lot of CPU cycles (ucontext_t is slower by
 perfomance_link[factor 13x] relative to `fcontext_t`).
 
@@ -110,7 +112,7 @@
 
 [heading Windows]
 
-MxCsr - "A callee that modifies any of the nonvolatile fields within MxCsr must restore
+MxCsr - "A callee that modifies any of the non-volatile 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

Modified: trunk/libs/context/doc/stack.qbk
==============================================================================
--- trunk/libs/context/doc/stack.qbk (original)
+++ trunk/libs/context/doc/stack.qbk 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -55,7 +55,7 @@
 the stack. If the guard page is accessed (read or write operation) a
 segmentation fault/access violation is generated by the operating system.
 
-[note The appended `guard page` is [*not] mapped to pyhsical memory, only
+[note The appended `guard page` is [*not] mapped to physical memory, only
 virtual addresses are used.]
 
         class guarded_stack_allocator
@@ -124,7 +124,7 @@
 the __stack_allocator_concept__ concept. The template arguments define the
 limits for the stack size.
 The class simply allocates memory on the heap via `calloc()` - in contrast to
-`guarde_stack_allocator` no guard page is appended.
+`guarded_stack_allocator` no guard page is appended.
 
 [important The user is responsible for valid stack limits (e.g. maximum, minimum
 and default stacksize.]
@@ -181,7 +181,7 @@
 [endsect]
 
 
-[section:pagesize Frre function `pagesize()`]
+[section:pagesize Free function `pagesize()`]
 
         std::size_t pagesize();
 

Modified: trunk/libs/context/example/exit.cpp
==============================================================================
--- trunk/libs/context/example/exit.cpp (original)
+++ trunk/libs/context/example/exit.cpp 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -12,7 +12,7 @@
 #include <boost/assert.hpp>
 #include <boost/context/all.hpp>
 
-namespace ctx = boost::ctx;
+namespace ctx = boost::context;
 
 ctx::fcontext_t * fc1;
 ctx::fcontext_t * fc2;

Modified: trunk/libs/context/example/jump.cpp
==============================================================================
--- trunk/libs/context/example/jump.cpp (original)
+++ trunk/libs/context/example/jump.cpp 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -12,7 +12,7 @@
 #include <boost/assert.hpp>
 #include <boost/context/all.hpp>
 
-namespace ctx = boost::ctx;
+namespace ctx = boost::context;
 
 ctx::fcontext_t fcm;
 ctx::fcontext_t * fc1 = 0;

Modified: trunk/libs/context/example/transfer.cpp
==============================================================================
--- trunk/libs/context/example/transfer.cpp (original)
+++ trunk/libs/context/example/transfer.cpp 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -13,7 +13,7 @@
 #include <boost/assert.hpp>
 #include <boost/context/all.hpp>
 
-namespace ctx = boost::ctx;
+namespace ctx = boost::context;
 
 ctx::fcontext_t fcm;
 ctx::fcontext_t * fc1;

Modified: trunk/libs/context/performance/performance.cpp
==============================================================================
--- trunk/libs/context/performance/performance.cpp (original)
+++ trunk/libs/context/performance/performance.cpp 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -30,7 +30,7 @@
 #include "zeit.hpp"
 #endif
 
-namespace ctx = boost::ctx;
+namespace ctx = boost::context;
 
 bool pres_fpu = false;
 

Deleted: trunk/libs/context/src/asm/fcontext_arm_aapcs_elf_gas.S
==============================================================================
--- trunk/libs/context/src/asm/fcontext_arm_aapcs_elf_gas.S 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
+++ (empty file)
@@ -1,102 +0,0 @@
-/*
- 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| | *
- * ------------------------------------------------------------- *
- * | sp | size| | *
- * ------------------------------------------------------------- *
- * ------------------------------------------------------------- *
- * | 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
- beq 1f
-
- mov a4, a1
- add a4, #52
- fstmiax a4, {d8-d15} @ save S16-S31
-
- mov a4, a2
- add a4, #52
- fldmiax a4, {d8-d15} @ 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:
- stmfd sp!, {a1-a3,lr} @ save arguments of make_fcontext and return address on stack, SP % 8 == 0
- sub a1, #116 @ reserve space for fcontext_t at top of context stack
- bl align_stack_at_PLT @ call align_stack, A1 contains address at 16 byte boundary after return
- @ == pointer to fcontext_t and address of context stack
-
- ldmfd sp!, {a2-a4,lr} @ restore arguments of make_fcontext and return address from stack
- str a2, [a1,#44] @ save address of context stack (base) in fcontext_t
- str a3, [a1,#48] @ save context stack size in fcontext_t
- str a4, [a1,#40] @ save address of context function in fcontext_t
-
- str a1, [a1,#32] @ save address in A1 as stack pointer for context function
-
- adr a2, finish @ compute abs address of label finish
- str a2, [a1,#36] @ save address of finish as return address for context function
- @ entered after context function returns
-
- bx lr
-
-finish:
- @ SP points to same address as SP on entry of context function
- mov a1, #0 @ exit code is zero
- bl _exit_at_PLT @ exit application
-.size make_fcontext,.-make_fcontext

Deleted: trunk/libs/context/src/asm/fcontext_i386_ms_pe_masm.asm
==============================================================================
--- trunk/libs/context/src/asm/fcontext_i386_ms_pe_masm.asm 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
+++ (empty file)
@@ -1,162 +0,0 @@
-
-; 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 | 8 | |
-; --------------------------------------------------------------
-; | 018h | 01ch | 020h | |
-; --------------------------------------------------------------
-; | sp | size | limit | |
-; --------------------------------------------------------------
-; --------------------------------------------------------------
-; | 9 | |
-; --------------------------------------------------------------
-; | 024h | |
-; --------------------------------------------------------------
-; |fc_execpt| |
-; --------------------------------------------------------------
-; --------------------------------------------------------------
-; | 10 | |
-; --------------------------------------------------------------
-; | 028h | |
-; --------------------------------------------------------------
-; |fc_strage| |
-; --------------------------------------------------------------
-; --------------------------------------------------------------
-; | 11 | 12 | |
-; --------------------------------------------------------------
-; | 02ch | 030h | |
-; --------------------------------------------------------------
-; | 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+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+020h], eax ; save current stack limit
- mov eax, [edx+010h] ; load 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
- 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+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+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+020h] ; load stack limit
- mov [edx+08h], eax ; restore stack limit
- 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
-
- 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
- push ebp ; save previous frame pointer; get the stack 16 byte aligned
- mov ebp, esp ; set EBP to ESP
- sub esp, 010h ; allocate stack space
-
- mov eax, [ebp+08h] ; load 1. arg of make_fcontext, pointer to context stack (base)
- lea eax, [eax-034h] ; reserve space for fcontext_t at top of context stack
- mov [esp], eax ; address in EAX becomes 1.arg of align_stack
- call align_stack ; call align_stack, EAX contains address at 16 byte boundary after return
- ; == pointer to fcontext_t and address of context stack
-
- mov ecx, [ebp+08h] ; load 1. arg of make_fcontext, pointer to context stack (base)
- mov [eax+018h], ecx ; save address of context stack (base) in fcontext_t
- mov edx, [ebp+0ch] ; load 2. arg of make_fcontext, context stack size
- mov [eax+01ch], edx ; save context stack size in fcontext_t
- neg edx ; negate stack size for LEA instruction (== substraction)
- lea ecx, [ecx+edx] ; compute bottom address of context stack (limit)
- mov [eax+020h], ecx ; save address of context stack (limit) in fcontext_t
- mov ecx, [ebp+010h] ; load 3. arg of make_fcontext, pointer to context function
- mov [eax+014h], ecx ; save address of context function in fcontext_t
-
- stmxcsr [eax+02ch] ; save MMX control word
- fnstcw [eax+030h] ; save x87 control word
-
- lea edx, [eax-01ch] ; reserve space for last frame and seh on context stack, (ESP - 0x4) % 16 == 0
- mov [eax+010h], edx ; save address in EDX as stack pointer for context function
-
- mov ecx, seh_fcontext ; set ECX to exception-handler
- mov [edx+018h], ecx ; save ECX as SEH handler
- mov ecx, 0ffffffffh ; set ECX to -1
- mov [edx+014h], ecx ; save ECX as next SEH item
- lea ecx, [edx+014h] ; load address of next SEH item
- mov [eax+024h], ecx ; save next SEH
-
- mov ecx, finish ; abs address of finish
- mov [edx], ecx ; save address of finish as return address for context function
- ; entered after context function returns
-
- add esp, 010h ; deallocate stack space
- pop ebp
-
- ret
-
-finish:
- ; ESP points to same address as ESP on entry of context function + 0x4
- xor eax, eax
- mov [esp], eax ; exit code is zero
- call _exit ; exit application
- hlt
-make_fcontext ENDP
-END

Deleted: trunk/libs/context/src/asm/fcontext_i386_sysv_elf_gas.S
==============================================================================
--- trunk/libs/context/src/asm/fcontext_i386_sysv_elf_gas.S 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
+++ (empty file)
@@ -1,129 +0,0 @@
-/*
- 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 | | *
- * -------------------------------------------------------------- *
- * | sp | size | | *
- * -------------------------------------------------------------- *
- * -------------------------------------------------------------- *
- * | 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:
- pushl %ebp /* save previous frame pointer; get the stack 16 byte aligned */
- movl %esp, %ebp /* set EBP to ESP */
- subl $0x10, %esp /* allocate stack space */
-
- movl %ebx, 0x4(%esp) /* save EBX */
- movl 0x8(%ebp), %eax /* load 1. arg of make_fcontext, pointer to context stack (base) */
- leal -0x28(%eax), %eax /* reserve space for fcontext_t at top of context stack */
- movl %eax, (%esp) /* address in EAX becomes 1. arg of 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 /* call align_stack, EAX contains address at 16 byte boundary after return */
- /* == pointer to fcontext_t and address of context stack */
- movl 0x4(%esp), %ebx /* restore EBX */
-
- movl 0x8(%ebp), %edx /* load 1. arg of make_fcontext, pointer to context stack (base) */
- movl %edx, 0x18(%eax) /* save address of context stack (base) in fcontext_t */
- movl 0xc(%ebp), %edx /* load 2. arg of make_fcontext, context stack size */
- movl %edx, 0x1c(%eax) /* save stack size in fcontext_t */
- movl 0x10(%ebp), %edx /* load 3. arg of make_fcontext, pointer to context function */
- movl %edx, 0x14(%eax) /* save address of context function in fcontext_t */
-
- stmxcsr 0x20(%eax) /* save MMX control and status word */
- fnstcw 0x24(%eax) /* save x87 control word */
-
- leal -0xc(%eax), %edx /* reserve space for the last frame on context stack; (ESP - 0x4) % 16 == 0 */
- movl %edx, 0x10(%eax) /* save address in EDX as stack pointer for context function */
-
- call 2f
-2: popl %ecx /* address of label 2 */
- addl $finish-2b, %ecx /* compute abs address of label finish */
- movl %ecx, (%edx) /* save address of finish as return address for context functions */
- /* entered after context function returns */
-
- addl $0x10, %esp /* deallocate stack space */
- pop %ebp
-
- ret
-
-finish:
- /* ESP points to same address as ESP on entry of context function + 0x4 */
- 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
- movl %eax, (%esp) /* exit code is zero */
- call _exit_at_PLT /* exit application */
- hlt
-.size make_fcontext,.-make_fcontext

Deleted: trunk/libs/context/src/asm/fcontext_i386_sysv_macho_gas.S
==============================================================================
--- trunk/libs/context/src/asm/fcontext_i386_sysv_macho_gas.S 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
+++ (empty file)
@@ -1,115 +0,0 @@
-/*
- 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 | | *
- * -------------------------------------------------------------- *
- * | sp | size | | *
- * -------------------------------------------------------------- *
- * -------------------------------------------------------------- *
- * | 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:
- pushl %ebp /* save previous frame pointer; get the stack 16 byte aligned */
- movl %esp, %ebp /* set EBP to ESP */
- subl $0x10, %esp /* allocate stack space */
-
- movl 0x8(%ebp), %eax /* load 1. arg of make_fcontext, pointer to context stack (base) */
- leal -0x28(%eax), %eax /* reserve space for fcontext_t at top of context stack */
- movl %eax, (%esp) /* address in EAX becomes 1. arg of align_stack */
- call _align_stack /* call align_stack, EAX contains address at 16 byte boundary after return */
- /* ==pointer to fcontext_t and address of context stack */
-
- movl 0x8(%ebp), %edx /* load 1. arg of make_fcontext, pointer to context stack (base) */
- movl %edx, 0x18(%eax) /* save address of stack pointer (base) in fcontext_t */
- movl 0xc(%ebp), %edx /* load 2. arg of make_fcontext, context stack size */
- movl %edx, 0x1c(%eax) /* save stack size in fcontext_t */
- movl 0x10(%ebp), %edx /* load 3. arg of make_fcontext, pointer to context function */
- movl %edx, 0x14(%eax) /* save address of context fcuntion in fcontext_t */
-
- stmxcsr 0x20(%eax) /* save MMX control and status word */
- fnstcw 0x24(%eax) /* save x87 control word */
-
- leal -0xc(%eax), %edx /* reserve space for the last frame on context stack, (ESP - 0x4) % 16 == 0 */
- movl %edx, 0x10(%eax) /* save address in EDX as stack pointer for context function */
-
- call 1f
-1: popl %ecx /* address of label 1 */
- addl $finish-1b, %ecx /* compute abs address of label finish */
- movl %ecx, (%edx) /* save address of finish as return address for context function */
- /* entered after context function returns */
-
- addl $0x10, %esp /* deallocate stack space */
- pop %ebp
-
- ret
-
-finish:
- /* ESP points to same address as ESP on entry of context function + 0x4 */
- xorl %eax, %eax
- movl %eax, (%esp) /* exit code is zero */
- call _exit /* exit application */
- hlt

Deleted: trunk/libs/context/src/asm/fcontext_mips32_o32_elf_gas.S
==============================================================================
--- trunk/libs/context/src/asm/fcontext_mips32_o32_elf_gas.S 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
+++ (empty file)
@@ -1,152 +0,0 @@
-/*
- 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 | *
- * ------------------------------------------------------------- *
- * | S0 | S1 | S2 | S3 | S4 | S5 | S6 | S7 | FP | SP | *
- * ------------------------------------------------------------- *
- * ------------------------------------------------------------- *
- * | 10 | 11 | | *
- * ------------------------------------------------------------- *
- * | 40 | 44 | | *
- * ------------------------------------------------------------- *
- * | RA | PC | | *
- * ------------------------------------------------------------- *
- * ------------------------------------------------------------- *
- * | 12 | 13 | | *
- * ------------------------------------------------------------- *
- * | 48 | 52 | | *
- * ------------------------------------------------------------- *
- * | sp | size| | *
- * ------------------------------------------------------------- *
- * ------------------------------------------------------------- *
- * | 14 | 15 | 16 | 17 | 18 | 19 | | *
- * ------------------------------------------------------------- *
- * | 56 | 64 | 72 | 80 | 88 | 96 | | *
- * ------------------------------------------------------------- *
- * | 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, 4($a0) # save S1
- sw $s2, 8($a0) # save S2
- sw $s3, 12($a0) # save S3
- sw $s4, 16($a0) # save S4
- sw $s5, 20($a0) # save S5
- sw $s6, 24($a0) # save S6
- sw $s7, 28($a0) # save S7
- sw $fp, 32($a0) # save FP
- sw $sp, 36($a0) # save SP
- sw $ra, 40($a0) # save RA
- sw $ra, 44($a0) # save RA as PC
-
-#if defined(__mips_hard_float)
- beqz $a3, 1f # test if fpu env should be preserved
- s.d $f20, 56($a0) # save F20
- s.d $f22, 64($a0) # save F22
- s.d $f24, 72($a0) # save F24
- s.d $f26, 80($a0) # save F26
- s.d $f28, 88($a0) # save F28
- s.d $f30, 96($a0) # save F30
-
- l.d $f20, 56($a1) # restore F20
- l.d $f22, 64($a1) # restore F22
- l.d $f24, 72($a1) # restore F24
- l.d $f26, 80($a1) # restore F26
- l.d $f28, 88($a1) # restore F28
- l.d $f30, 96($a1) # restore F30
-1:
-#endif
-
- lw $s0, ($a1) # restore S0
- lw $s1, 4($a1) # restore S1
- lw $s2, 8($a1) # restore S2
- lw $s3, 12($a1) # restore S3
- lw $s4, 16($a1) # restore S4
- lw $s5, 20($a1) # restore S5
- lw $s6, 24($a1) # restore S6
- lw $s7, 28($a1) # restore S7
- lw $fp, 32($a1) # restore FP
- lw $sp, 36($a1) # restore SP
- lw $ra, 40($a1) # restore RA
-
- 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, 44($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
- addiu $sp, $sp, -48 # allocate stack space (contains shadow space for subroutines)
- sw $ra, 44($sp) # save return address
- sw $fp, 40($sp) # save frame pointer
-
- sw $a2, 48($sp) # save 3. arg of make_fcontnext, pointer to context function
- sw $a1, 52($sp) # save 2. arg of make_fcontext, context stack size
- sw $a0, 56($sp) # save 1. arg of make_fcontext, pointer to context stack (base)
- addiu $a0, $a0, -104 # reserve space for fcontext_t at top of context stack
- lw $t9, %call16(align_stack)($gp) # compute adddress of align_stack via global pointer
- jalr $t9 # call align_stack, V0 contains address at 16 byte boundary after return
- # == pointer to fcontext_t and address of context stack
- lw $a0, 56($sp) # restore pointer to context stack (base)
- lw $a1, 52($sp) # restore context stack size
- lw $a2, 48($sp) # restore pointer to context function
-
- sw $a0, 48($v0) # save address of context stack (base) in fcontext_t
- sw $a1, 52($v0) # save context stack size in fcontext_t
- sw $a2, 44($v0) # save address of context function in fcontext_t
- sw $gp, ($v0) # save global pointer in fcontext_t, S0 will contain address of global pointer
-
- addiu $t0, $v0, -48 # reserve 48 bytes (includes 4 byte shadow space), T0 % 16 == 0
- sw $t0, 36($v0) # save address in T0 as stack pointer for context function, SP % 16 == 0
-
- la $t9, finish # compute abs address of label finish
- sw $t9, 40($v0) # save address of finish as return address for context function
- # entered after context function returns
-
- lw $fp, 40($sp) # restore frame pointer
- lw $ra, 44($sp) # restore return address
- addiu $sp, $sp, 48 # deallocate stack space
-
- jr $ra
-
-finish:
- # SP points to same adddress as SP on entry of context function
- addiu $sp, $sp, -32 # allocate stack space (contains shadow space for subroutines)
- sw $ra, 28($sp) # save return address
-
- move $gp, $s0 # restore GP (global pointer)
- move $a0, $zero # exit code is zero
- lw $t9, %call16(_exit)($gp) # address of exit
- jalr $t9 # exit application
-.end make_fcontext
-.size make_fcontext, .-make_fcontext

Deleted: trunk/libs/context/src/asm/fcontext_ppc32_sysv_elf_gas.S
==============================================================================
--- trunk/libs/context/src/asm/fcontext_ppc32_sysv_elf_gas.S 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
+++ (empty file)
@@ -1,232 +0,0 @@
-/*
- 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 | | *
- * ------------------------------------------------------------- *
- * | sp | size| | *
- * ------------------------------------------------------------- *
- * ------------------------------------------------------------- *
- * | 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:
- mflr %r0 # save return address into R0
- stw %r0, 4(%r1) # save return address on stack, set up stack frame
- stwu %r1, -48(%r1) # allocate stack space, SP % 16 == 0
-
- stw %r5, 32(%r1) # save 3. arg of make_fcontext, pointer to context function
- stw %r4, 28(%r1) # save 2. arg of make_fcontext, context stack size
- stw %r3, 24(%r1) # save 1. arg of make_fcontext, pointer to context stack (base)
-
- subi %r3, %r3, 252 # reserve space for fcontext_t at top of context stack
- bl align_stack_at_plt # call align_stack, R3 contains address at 16 byte boundary after return
- # == pointer to fcontext_t and address of context stack
- lwz %r4, 24(%r1) # restore pointer to context stack (base)
- lwz %r5, 28(%r1) # restore context stack size
- lwz %r6, 32(%r1) # restore pointer to context function
-
- stw %r4, 92(%r3) # save address of context stack (base) in fcontext_t
- stw %r5, 96(%r3) # save context stack size in fcontext_t
- stw %r6, 88(%r3) # save address of context function in fcontext_t
-
- subi %r0, %r3, 64 # reserve 64 bytes (linkage + parameter area), R0 % 16 == 0
- stw %r0, 76(%r3) # save address in R0 as stack pointer for context function
-
- mflr %r0 # load LR
- bl 1f # jump to label 1
-1:
- mflr %r4 # load LR into R4
- addi %r4, %r4, finish - 1b # compute abs address of label finish
- mtlr %r0 # restore LR
- stw %r4, 84(%r3) # save address of finish as return address for context function
- # entered after context function returns
-
- addi %r1, %r1, 48 # deallocate stack space
- lwz %r0, 4(%r1) # load return address from stack, destroy stack frame
- mtlr %r0 # restore return address
-
- blr
-
-finish:
- # SP points to same address as SP on entry of context function
- mflr %r0 # save return address into R0
- stw %r0, 4(%r1) # save return address on stack, set up stack frame
- stwu %r1, -16(%r1) # allocate stack space, SP % 16 == 0
-
- li %r3, 0 # exit code is zero
- bl _exit_at_plt # exit application
-.size make_fcontext, .-make_fcontext

Deleted: trunk/libs/context/src/asm/fcontext_ppc64_sysv_elf_gas.S
==============================================================================
--- trunk/libs/context/src/asm/fcontext_ppc64_sysv_elf_gas.S 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
+++ (empty file)
@@ -1,260 +0,0 @@
-/*
- 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 | | *
- * ------------------------------------------------------------- *
- * | sp | size | | *
- * ------------------------------------------------------------- *
- * ------------------------------------------------------------- *
- * | 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:
- mflr %r0 # save return address into R0
- std %r0, 8(%r1) # save return address on stack, set up stack frame
- stdu %r1, -96(%r1) # allocate stack space, SP % 16 == 0
-
- std %r5, 64(%r1) # save 3. arg of make_fcontext, pointer to context function
- std %r4, 56(%r1) # save 2. arg of make_fcontext, context stack size
- std %r3, 48(%r1) # save 1. arg of make_fcontext, pointer to context stack (base)
-
- subi %r3, %r3, 352 # reserve space for fcontext_t at top of context stack
- bl align_stack_at_plt # call align_stack, R3 contains address at 16 byte boundary after return
- # == pointer to fcontext_t and address of context stack
- ld %r4, 48(%r1) # restore pointer to context stack (base)
- ld %r5, 56(%r1) # restore context stack size
- ld %r6, 64(%r1) # restore pointer to context function
-
- std %r4, 184(%r3) # save address of context stack (base) in fcontext_t
- std %r5, 192(%r3) # save context stack size in fcontext_t
- std %r6, 176(%r3) # save address of context function in fcontext_t
-
- subf %r0, %r3, 64 # 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 into R4
- addi %r4, %r4, finish - 1b # compute abs address of label finish
- mtlr %r0 # restore LR
- std %r4, 168(%r3) # save address of finish as return address for context function
- # entered after context function returns
-
- addi %r1, %r1, 64 # deallocate stack space
- lwz %r0, 8(%r1) # load return address from stack, destroy stack frame
- mtlr %r0 # restore return address
-
- blr
-
-finish:
- # SP points to same address as SP on entry of context function
- mflr %r0 # save return address into R0
- stw %r0, 8(%r1) # save return address on stack, set up stack frame
- stwu %r1, -32(%r1) # allocate stack space, SP % 16 == 0
-
- li %r3, 0 # set return value to zero
- bl _exit_at_plt # exit application
-.size .make_fcontext, .-.make_fcontext

Deleted: trunk/libs/context/src/asm/fcontext_x86_64_ms_pe_masm.asm
==============================================================================
--- trunk/libs/context/src/asm/fcontext_x86_64_ms_pe_masm.asm 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
+++ (empty file)
@@ -1,220 +0,0 @@
-
-; 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 | 24 | 25 | |
-; ----------------------------------------------------------------------------------
-; | 0x50 | 0x54 | 0x58 | 0x5c | 0x60 | 0x64 | |
-; ----------------------------------------------------------------------------------
-; | sp | size | limit | |
-; ----------------------------------------------------------------------------------
-; ----------------------------------------------------------------------------------
-; | 26 | 27 | |
-; ----------------------------------------------------------------------------------
-; | 0x68 | 0x6c | |
-; ----------------------------------------------------------------------------------
-; | fbr_strg | |
-; ----------------------------------------------------------------------------------
-; ----------------------------------------------------------------------------------
-; | 28 | 29 | 30 | 31 | |
-; ----------------------------------------------------------------------------------
-; | 0x70 | 0x74 | 0x78 | 0x7c | |
-; ----------------------------------------------------------------------------------
-; | fc_mxcsr|fc_x87_cw| <padding> | |
-; ----------------------------------------------------------------------------------
-; ----------------------------------------------------------------------------------
-; | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
-; ----------------------------------------------------------------------------------
-; | 0x80 | 0x84 | 0x88 | 0x8c | 0x90 | 0x94 | 0x98 | 0x9c |
-; ----------------------------------------------------------------------------------
-; | XMM6 | XMM7 |
-; ----------------------------------------------------------------------------------
-; ----------------------------------------------------------------------------------
-; | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |
-; ----------------------------------------------------------------------------------
-; | 0x100 | 0x104 | 0x108 | 0x10c | 0x110 | 0x114 | 0x118 | 0x11c |
-; ----------------------------------------------------------------------------------
-; | XMM8 | XMM9 |
-; ----------------------------------------------------------------------------------
-; ----------------------------------------------------------------------------------
-; | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 |
-; ----------------------------------------------------------------------------------
-; | 0x120 | 0x124 | 0x128 | 0x12c | 0x130 | 0x134 | 0x138 | 0x13c |
-; ----------------------------------------------------------------------------------
-; | XMM10 | XMM11 |
-; ----------------------------------------------------------------------------------
-; ----------------------------------------------------------------------------------
-; | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
-; ----------------------------------------------------------------------------------
-; | 0x140 | 0x144 | 0x148 | 0x14c | 0x150 | 0x154 | 0x158 | 0x15c |
-; ----------------------------------------------------------------------------------
-; | XMM12 | XMM13 |
-; ----------------------------------------------------------------------------------
-; ----------------------------------------------------------------------------------
-; | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 |
-; ----------------------------------------------------------------------------------
-; | 0x160 | 0x164 | 0x168 | 0x16c | 0x170 | 0x174 | 0x178 | 0x17c |
-; ----------------------------------------------------------------------------------
-; | 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+060h], rax ; save current stack limit
- mov rax, [r10+018h] ; load fiber local storage
- mov [rcx+068h], rax ; save fiber local storage
-
- test r9, r9
- je nxt
-
- stmxcsr [rcx+070h] ; save MMX control and status word
- fnstcw [rcx+074h] ; save x87 control word
- ; save XMM storage
- movaps [rcx+080h], xmm6
- movaps [rcx+090h], xmm7
- movaps [rcx+0100h], xmm8
- movaps [rcx+0110h], xmm9
- movaps [rcx+0120h], xmm10
- movaps [rcx+0130h], xmm11
- movaps [rcx+0140h], xmm12
- movaps [rcx+0150h], xmm13
- movaps [rcx+0160h], xmm14
- movaps [rcx+0170h], xmm15
-
- ldmxcsr [rdx+070h] ; restore MMX control and status word
- fldcw [rdx+074h] ; restore x87 control word
- ; restore XMM storage
- movaps xmm6, [rdx+080h]
- movaps xmm7, [rdx+090h]
- movaps xmm8, [rdx+0100h]
- movaps xmm9, [rdx+0110h]
- movaps xmm10, [rdx+0120h]
- movaps xmm11, [rdx+0130h]
- movaps xmm12, [rdx+0140h]
- movaps xmm13, [rdx+0150h]
- movaps xmm14, [rdx+0160h]
- movaps xmm15, [rdx+0170h]
-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+060h] ; load stack limit
- mov [r10+010h], rax ; restore stack limit
- mov rax, [rdx+068h] ; 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
- .endprolog ; .xdata for a function's structured exception handling unwind behavior
-
- push rbp ; save previous frame pointer; get the stack 16 byte aligned
- mov rbp, rsp ; set RBP to RSP
- sub rsp, 040h ; allocate stack space (contains shadow space for subroutines)
-
- mov [rbp-08h], r8 ; save 3. arg of make_fcontext, pointer to context function
- mov [rbp-010h], rdx ; save 2. arg of make_fcontext, context stack size
- mov [rbp-018h], rcx ; save 1. arg of make_fcontext, pointer to context stack (base)
- lea rcx, [rcx-0180h] ; reserve space for fcontext_t at top of context stack
- call align_stack ; align context stack, RAX contains address at 16 byte boundary
- ; == pointer to fcontext_t and address of context stack
-
- mov r8, [rbp-08h] ; restore pointer to context function
- mov rdx, [rbp-010h] ; restore context stack size
- mov rcx, [rbp-018h] ; restore pointer to context stack (base)
-
- mov [rax+048h], r8 ; save address of context function in fcontext_t
- mov [rax+058h], rdx ; save context stack size in fcontext_t
- mov [rax+050h], rcx ; save address of context stack pointer (base) in fcontext_t
-
- neg rdx ; negate stack size for LEA instruction (== substraction)
- lea rcx, [rcx+rdx] ; compute bottom address of context stack (limit)
- mov [rax+060h], rcx ; save bottom address of context stack (limit) in fcontext_t
-
- stmxcsr [rax+070h] ; save MMX control and status word
- fnstcw [rax+074h] ; save x87 control word
-
- lea rdx, [rax-028h] ; reserve 32byte shadow space + return address on stack, (RSP - 0x8) % 16 == 0
- mov [rax+040h], rdx ; save address in RDX as stack pointer for context function
-
- lea rcx, finish ; compute abs address of label finish
- mov [rdx], rcx ; save address of finish as return address for context function
- ; entered after context function returns
-
- add rsp, 040h ; deallocate shadow space
- pop rbp ; restore previous frame pointer
-
- ret
-
-finish:
- ; RSP points to same address as RSP on entry of context function + 0x8
- xor rcx, rcx ; exit code is zero
- call _exit ; exit application
- hlt
-make_fcontext ENDP
-END

Deleted: trunk/libs/context/src/asm/fcontext_x86_64_sysv_elf_gas.S
==============================================================================
--- trunk/libs/context/src/asm/fcontext_x86_64_sysv_elf_gas.S 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
+++ (empty file)
@@ -1,128 +0,0 @@
-/*
- 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 | | *
- * ---------------------------------------------------------------------------------- *
- * | sp | size | | *
- * ---------------------------------------------------------------------------------- *
- * ---------------------------------------------------------------------------------- *
- * | 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:
- pushq %rbp /* save previous frame pointer; get the stack 16 byte aligned */
- movq %rsp, %rbp /* set RBP to RSP */
- subq $0x20, %rsp /* allocate stack space */
-
- movq %rdx, 0x10(%rsp) /* save 3. arg of make_fcontext, pointer to context function */
- movq %rsi, 0x8(%rsp) /* save 2. arg of make_fcontext, context stack size */
- movq %rdi, (%rsp) /* save 1. arg of make_fcontext, pointer to context stack (base) */
- leaq -0x58(%rdi), %rdi /* reserve space for fcontext_t at top of context stack */
- call align_stack_at_PLT /* align context stack, RAX contains address at 16 byte boundary afte return */
- /* == pointer to fcontext_t and address of context stack */
- movq (%rsp), %rdi /* restore pointer to context stack (base) */
- movq 0x8(%rsp), %rsi /* restore context stack size */
- movq 0x10(%rsp), %rdx /* restore pointer to context function */
-
- movq %rdi, 0x40(%rax) /* save address of context stack pointer (base) in fcontext_t */
- movq %rsi, 0x48(%rax) /* save context stack size in fcontext_t */
- movq %rdx, 0x38(%rax) /* save address of context function in fcontext_t */
-
- stmxcsr 0x50(%rax) /* save MMX control and status word */
- fnstcw 0x54(%rax) /* save x87 control word */
-
- leaq -0x8(%rax), %rdx /* reserve space for the return address on context stack, (RSP - 0x8) % 16 == 0 */
- movq %rdx, 0x30(%rax) /* save address in RDX as stack pointer for context function */
-
- leaq finish(%rip), %rcx /* compute abs address of label finish */
- movq %rcx, (%rdx) /* save address of finish as return address for context function */
- /* entered after context function returns */
-
- addq $0x20, %rsp /* deallocate shadow space */
- popq %rbp /* restore previous frame pointer */
-
- ret /* return pointer to fcontext_t placed on context stack */
-
-finish:
- /* RSP points to same address as RSP on entry of context function + 0x8 */
- xorq %rdi, %rdi /* exit code is zero */
- call _exit_at_PLT /* exit application */
- hlt
-.size make_fcontext,.-make_fcontext
-

Deleted: trunk/libs/context/src/asm/fcontext_x86_64_sysv_macho_gas.S
==============================================================================
--- trunk/libs/context/src/asm/fcontext_x86_64_sysv_macho_gas.S 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
+++ (empty file)
@@ -1,123 +0,0 @@
-/*
- 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 | | *
- * ---------------------------------------------------------------------------------- *
- * | sp | size | | *
- * ---------------------------------------------------------------------------------- *
- * ---------------------------------------------------------------------------------- *
- * | 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:
- pushq %rbp /* save previous frame pointer; get the stack 16 byte aligned */
- movq %rsp, %rbp /* set RBP to RSP */
- subq $0x20, %rsp /* allocate stack space */
-
- movq %rdx, 0x10(%rsp) /* save 3. arg of make_fcontext, pointer to context function */
- movq %rsi, 0x8(%rsp) /* save 2. arg of make_fcontext, context stack size */
- movq %rdi, (%rsp) /* save 1. arg of make_fcontext, pointer to context stack (base) */
- leaq -0x58(%rdi), %rdi /* reserve space for fcontext_t at top of context stack */
- call _align_stack /* align context stack, RAX contains address at 16 byte boundary */
- /* == pointer to fcontext_t and address of context stack */
- movq (%rsp), %rdi /* restore pointer to context stack (base) */
- movq 0x8(%rsp), %rsi /* restore context stack size */
- movq 0x10(%rsp), %rdx /* restore pointer to context function */
-
- movq %rdi, 0x40(%rax) /* save address of stack pointer (base) in fcontext_t */
- movq %rsi, 0x48(%rax) /* save stack size in fcontext_t */
- movq %rdx, 0x38(%rax) /* save address of context function in fcontext_t */
-
- stmxcsr 0x50(%rax) /* save MMX control and status word */
- fnstcw 0x54(%rax) /* save x87 control word */
-
- leaq -0x8(%rax), %rdx /* reserve space for the return address on context stack, (RSP - 0x8) % 16 == 0 */
- movq %rdx, 0x30(%rax) /* save address in RDX as stack pointer for context function */
-
- leaq finish(%rip), %rcx /* compute abs address of label finish */
- movq %rcx, (%rdx) /* save address of finish as return address for context function */
- /* entered after context function returns */
-
- addq $0x20, %rsp /* deallocate shadow space */
- popq %rbp /* restore previous frame pointer */
-
- ret /* return pointer to fcontext_t placed on context stack */
-
-finish:
- /* RSP points to same address as RSP on entry of context function + 0x8 */
- xorq %rdi, %rdi /* exit code is zero */
- call _exit /* exit application */
- hlt

Added: trunk/libs/context/src/asm/jump_arm_aapcs_elf_gas.S
==============================================================================
--- (empty file)
+++ trunk/libs/context/src/asm/jump_arm_aapcs_elf_gas.S 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -0,0 +1,73 @@
+/*
+ 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| | *
+ * ------------------------------------------------------------- *
+ * | sp | size| | *
+ * ------------------------------------------------------------- *
+ * ------------------------------------------------------------- *
+ * | 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
+ beq 1f
+
+ mov a4, a1
+ add a4, #52
+ fstmiax a4, {d8-d15} @ save S16-S31
+
+ mov a4, a2
+ add a4, #52
+ fldmiax a4, {d8-d15} @ 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

Added: trunk/libs/context/src/asm/jump_i386_ms_pe_masm.asm
==============================================================================
--- (empty file)
+++ trunk/libs/context/src/asm/jump_i386_ms_pe_masm.asm 2012-09-15 02:31:49 EDT (Sat, 15 Sep 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 |
+; --------------------------------------------------------------
+; | 0h | 04h | 08h | 0ch | 010h | 014h |
+; --------------------------------------------------------------
+; | EDI | ESI | EBX | EBP | ESP | EIP |
+; --------------------------------------------------------------
+; --------------------------------------------------------------
+; | 6 | 7 | 8 | |
+; --------------------------------------------------------------
+; | 018h | 01ch | 020h | |
+; --------------------------------------------------------------
+; | sp | size | limit | |
+; --------------------------------------------------------------
+; --------------------------------------------------------------
+; | 9 | |
+; --------------------------------------------------------------
+; | 024h | |
+; --------------------------------------------------------------
+; |fc_execpt| |
+; --------------------------------------------------------------
+; --------------------------------------------------------------
+; | 10 | |
+; --------------------------------------------------------------
+; | 028h | |
+; --------------------------------------------------------------
+; |fc_strage| |
+; --------------------------------------------------------------
+; --------------------------------------------------------------
+; | 11 | 12 | |
+; --------------------------------------------------------------
+; | 02ch | 030h | |
+; --------------------------------------------------------------
+; | 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+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+020h], eax ; save current stack limit
+ mov eax, [edx+010h] ; load 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
+ 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+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+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+020h] ; load stack limit
+ mov [edx+08h], eax ; restore stack limit
+ 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
+
+ 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
+END

Added: trunk/libs/context/src/asm/jump_i386_sysv_elf_gas.S
==============================================================================
--- (empty file)
+++ trunk/libs/context/src/asm/jump_i386_sysv_elf_gas.S 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -0,0 +1,72 @@
+/*
+ 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 | | *
+ * -------------------------------------------------------------- *
+ * | sp | size | | *
+ * -------------------------------------------------------------- *
+ * -------------------------------------------------------------- *
+ * | 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

Added: trunk/libs/context/src/asm/jump_i386_sysv_macho_gas.S
==============================================================================
--- (empty file)
+++ trunk/libs/context/src/asm/jump_i386_sysv_macho_gas.S 2012-09-15 02:31:49 EDT (Sat, 15 Sep 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)
+*/
+
+/********************************************************************
+ * *
+ * -------------------------------------------------------------- *
+ * | 0 | 1 | 2 | 3 | 4 | 5 | *
+ * -------------------------------------------------------------- *
+ * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | *
+ * -------------------------------------------------------------- *
+ * | EDI | ESI | EBX | EBP | ESP | EIP | *
+ * -------------------------------------------------------------- *
+ * -------------------------------------------------------------- *
+ * | 6 | 7 | | *
+ * -------------------------------------------------------------- *
+ * | 0x18 | 0x1c | | *
+ * -------------------------------------------------------------- *
+ * | sp | size | | *
+ * -------------------------------------------------------------- *
+ * -------------------------------------------------------------- *
+ * | 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 */

Added: trunk/libs/context/src/asm/jump_mips32_o32_elf_gas.S
==============================================================================
--- (empty file)
+++ trunk/libs/context/src/asm/jump_mips32_o32_elf_gas.S 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -0,0 +1,96 @@
+/*
+ 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 | *
+ * ------------------------------------------------------------- *
+ * | S0 | S1 | S2 | S3 | S4 | S5 | S6 | S7 | FP | SP | *
+ * ------------------------------------------------------------- *
+ * ------------------------------------------------------------- *
+ * | 10 | 11 | | *
+ * ------------------------------------------------------------- *
+ * | 40 | 44 | | *
+ * ------------------------------------------------------------- *
+ * | RA | PC | | *
+ * ------------------------------------------------------------- *
+ * ------------------------------------------------------------- *
+ * | 12 | 13 | | *
+ * ------------------------------------------------------------- *
+ * | 48 | 52 | | *
+ * ------------------------------------------------------------- *
+ * | sp | size| | *
+ * ------------------------------------------------------------- *
+ * ------------------------------------------------------------- *
+ * | 14 | 15 | 16 | 17 | 18 | 19 | | *
+ * ------------------------------------------------------------- *
+ * | 56 | 64 | 72 | 80 | 88 | 96 | | *
+ * ------------------------------------------------------------- *
+ * | 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, 4($a0) # save S1
+ sw $s2, 8($a0) # save S2
+ sw $s3, 12($a0) # save S3
+ sw $s4, 16($a0) # save S4
+ sw $s5, 20($a0) # save S5
+ sw $s6, 24($a0) # save S6
+ sw $s7, 28($a0) # save S7
+ sw $fp, 32($a0) # save FP
+ sw $sp, 36($a0) # save SP
+ sw $ra, 40($a0) # save RA
+ sw $ra, 44($a0) # save RA as PC
+
+#if defined(__mips_hard_float)
+ beqz $a3, 1f # test if fpu env should be preserved
+ s.d $f20, 56($a0) # save F20
+ s.d $f22, 64($a0) # save F22
+ s.d $f24, 72($a0) # save F24
+ s.d $f26, 80($a0) # save F26
+ s.d $f28, 88($a0) # save F28
+ s.d $f30, 96($a0) # save F30
+
+ l.d $f20, 56($a1) # restore F20
+ l.d $f22, 64($a1) # restore F22
+ l.d $f24, 72($a1) # restore F24
+ l.d $f26, 80($a1) # restore F26
+ l.d $f28, 88($a1) # restore F28
+ l.d $f30, 96($a1) # restore F30
+1:
+#endif
+
+ lw $s0, ($a1) # restore S0
+ lw $s1, 4($a1) # restore S1
+ lw $s2, 8($a1) # restore S2
+ lw $s3, 12($a1) # restore S3
+ lw $s4, 16($a1) # restore S4
+ lw $s5, 20($a1) # restore S5
+ lw $s6, 24($a1) # restore S6
+ lw $s7, 28($a1) # restore S7
+ lw $fp, 32($a1) # restore FP
+ lw $sp, 36($a1) # restore SP
+ lw $ra, 40($a1) # restore RA
+
+ 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, 44($a1) # load PC
+ jr $t9 # jump to context
+.end jump_fcontext
+.size jump_fcontext, .-jump_fcontext

Added: trunk/libs/context/src/asm/jump_ppc32_sysv_elf_gas.S
==============================================================================
--- (empty file)
+++ trunk/libs/context/src/asm/jump_ppc32_sysv_elf_gas.S 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -0,0 +1,180 @@
+/*
+ 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 | | *
+ * ------------------------------------------------------------- *
+ * | sp | size| | *
+ * ------------------------------------------------------------- *
+ * ------------------------------------------------------------- *
+ * | 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

Added: trunk/libs/context/src/asm/jump_ppc64_sysv_elf_gas.S
==============================================================================
--- (empty file)
+++ trunk/libs/context/src/asm/jump_ppc64_sysv_elf_gas.S 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -0,0 +1,201 @@
+/*
+ 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 | | *
+ * ------------------------------------------------------------- *
+ * | sp | size | | *
+ * ------------------------------------------------------------- *
+ * ------------------------------------------------------------- *
+ * | 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

Added: trunk/libs/context/src/asm/jump_x86_64_ms_pe_masm.asm
==============================================================================
--- (empty file)
+++ trunk/libs/context/src/asm/jump_x86_64_ms_pe_masm.asm 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -0,0 +1,172 @@
+
+; 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 | 24 | 25 | |
+; ----------------------------------------------------------------------------------
+; | 0x50 | 0x54 | 0x58 | 0x5c | 0x60 | 0x64 | |
+; ----------------------------------------------------------------------------------
+; | sp | size | limit | |
+; ----------------------------------------------------------------------------------
+; ----------------------------------------------------------------------------------
+; | 26 | 27 | |
+; ----------------------------------------------------------------------------------
+; | 0x68 | 0x6c | |
+; ----------------------------------------------------------------------------------
+; | fbr_strg | |
+; ----------------------------------------------------------------------------------
+; ----------------------------------------------------------------------------------
+; | 28 | 29 | 30 | 31 | |
+; ----------------------------------------------------------------------------------
+; | 0x70 | 0x74 | 0x78 | 0x7c | |
+; ----------------------------------------------------------------------------------
+; | fc_mxcsr|fc_x87_cw| <padding> | |
+; ----------------------------------------------------------------------------------
+; ----------------------------------------------------------------------------------
+; | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
+; ----------------------------------------------------------------------------------
+; | 0x80 | 0x84 | 0x88 | 0x8c | 0x90 | 0x94 | 0x98 | 0x9c |
+; ----------------------------------------------------------------------------------
+; | XMM6 | XMM7 |
+; ----------------------------------------------------------------------------------
+; ----------------------------------------------------------------------------------
+; | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |
+; ----------------------------------------------------------------------------------
+; | 0x100 | 0x104 | 0x108 | 0x10c | 0x110 | 0x114 | 0x118 | 0x11c |
+; ----------------------------------------------------------------------------------
+; | XMM8 | XMM9 |
+; ----------------------------------------------------------------------------------
+; ----------------------------------------------------------------------------------
+; | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 |
+; ----------------------------------------------------------------------------------
+; | 0x120 | 0x124 | 0x128 | 0x12c | 0x130 | 0x134 | 0x138 | 0x13c |
+; ----------------------------------------------------------------------------------
+; | XMM10 | XMM11 |
+; ----------------------------------------------------------------------------------
+; ----------------------------------------------------------------------------------
+; | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
+; ----------------------------------------------------------------------------------
+; | 0x140 | 0x144 | 0x148 | 0x14c | 0x150 | 0x154 | 0x158 | 0x15c |
+; ----------------------------------------------------------------------------------
+; | XMM12 | XMM13 |
+; ----------------------------------------------------------------------------------
+; ----------------------------------------------------------------------------------
+; | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 |
+; ----------------------------------------------------------------------------------
+; | 0x160 | 0x164 | 0x168 | 0x16c | 0x170 | 0x174 | 0x178 | 0x17c |
+; ----------------------------------------------------------------------------------
+; | 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+060h], rax ; save current stack limit
+ mov rax, [r10+018h] ; load fiber local storage
+ mov [rcx+068h], rax ; save fiber local storage
+
+ test r9, r9
+ je nxt
+
+ stmxcsr [rcx+070h] ; save MMX control and status word
+ fnstcw [rcx+074h] ; save x87 control word
+ ; save XMM storage
+ movaps [rcx+080h], xmm6
+ movaps [rcx+090h], xmm7
+ movaps [rcx+0100h], xmm8
+ movaps [rcx+0110h], xmm9
+ movaps [rcx+0120h], xmm10
+ movaps [rcx+0130h], xmm11
+ movaps [rcx+0140h], xmm12
+ movaps [rcx+0150h], xmm13
+ movaps [rcx+0160h], xmm14
+ movaps [rcx+0170h], xmm15
+
+ ldmxcsr [rdx+070h] ; restore MMX control and status word
+ fldcw [rdx+074h] ; restore x87 control word
+ ; restore XMM storage
+ movaps xmm6, [rdx+080h]
+ movaps xmm7, [rdx+090h]
+ movaps xmm8, [rdx+0100h]
+ movaps xmm9, [rdx+0110h]
+ movaps xmm10, [rdx+0120h]
+ movaps xmm11, [rdx+0130h]
+ movaps xmm12, [rdx+0140h]
+ movaps xmm13, [rdx+0150h]
+ movaps xmm14, [rdx+0160h]
+ movaps xmm15, [rdx+0170h]
+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+060h] ; load stack limit
+ mov [r10+010h], rax ; restore stack limit
+ mov rax, [rdx+068h] ; 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
+END

Added: trunk/libs/context/src/asm/jump_x86_64_sysv_elf_gas.S
==============================================================================
--- (empty file)
+++ trunk/libs/context/src/asm/jump_x86_64_sysv_elf_gas.S 2012-09-15 02:31:49 EDT (Sat, 15 Sep 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)
+*/
+
+/****************************************************************************************
+ * *
+ * ---------------------------------------------------------------------------------- *
+ * | 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 | | *
+ * ---------------------------------------------------------------------------------- *
+ * | sp | size | | *
+ * ---------------------------------------------------------------------------------- *
+ * ---------------------------------------------------------------------------------- *
+ * | 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

Added: trunk/libs/context/src/asm/jump_x86_64_sysv_macho_gas.S
==============================================================================
--- (empty file)
+++ trunk/libs/context/src/asm/jump_x86_64_sysv_macho_gas.S 2012-09-15 02:31:49 EDT (Sat, 15 Sep 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)
+*/
+
+/****************************************************************************************
+ * *
+ * ---------------------------------------------------------------------------------- *
+ * | 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 | | *
+ * ---------------------------------------------------------------------------------- *
+ * | sp | size | | *
+ * ---------------------------------------------------------------------------------- *
+ * ---------------------------------------------------------------------------------- *
+ * | 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 */

Added: trunk/libs/context/src/asm/make_arm_aapcs_elf_gas.S
==============================================================================
--- (empty file)
+++ trunk/libs/context/src/asm/make_arm_aapcs_elf_gas.S 2012-09-15 02:31:49 EDT (Sat, 15 Sep 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)
+*/
+
+/*******************************************************************
+ * *
+ * ------------------------------------------------------------- *
+ * | 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| | *
+ * ------------------------------------------------------------- *
+ * | sp | size| | *
+ * ------------------------------------------------------------- *
+ * ------------------------------------------------------------- *
+ * | 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 make_fcontext
+.align 2
+.type make_fcontext,%function
+make_fcontext:
+ stmfd sp!, {a1-a3,lr} @ save arguments of make_fcontext and return address on stack, SP % 8 == 0
+ sub a1, #116 @ reserve space for fcontext_t at top of context stack
+ bl align_stack_at_PLT @ call align_stack, A1 contains address at 16 byte boundary after return
+ @ == pointer to fcontext_t and address of context stack
+
+ ldmfd sp!, {a2-a4,lr} @ restore arguments of make_fcontext and return address from stack
+ str a2, [a1,#44] @ save address of context stack (base) in fcontext_t
+ str a3, [a1,#48] @ save context stack size in fcontext_t
+ str a4, [a1,#40] @ save address of context function in fcontext_t
+
+ str a1, [a1,#32] @ save address in A1 as stack pointer for context function
+
+ adr a2, finish @ compute abs address of label finish
+ str a2, [a1,#36] @ save address of finish as return address for context function
+ @ entered after context function returns
+
+ bx lr
+
+finish:
+ @ SP points to same address as SP on entry of context function
+ mov a1, #0 @ exit code is zero
+ bl _exit_at_PLT @ exit application
+.size make_fcontext,.-make_fcontext

Added: trunk/libs/context/src/asm/make_i386_ms_pe_masm.asm
==============================================================================
--- (empty file)
+++ trunk/libs/context/src/asm/make_i386_ms_pe_masm.asm 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -0,0 +1,101 @@
+
+; 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 | 8 | |
+; --------------------------------------------------------------
+; | 018h | 01ch | 020h | |
+; --------------------------------------------------------------
+; | sp | size | limit | |
+; --------------------------------------------------------------
+; --------------------------------------------------------------
+; | 9 | |
+; --------------------------------------------------------------
+; | 024h | |
+; --------------------------------------------------------------
+; |fc_execpt| |
+; --------------------------------------------------------------
+; --------------------------------------------------------------
+; | 10 | |
+; --------------------------------------------------------------
+; | 028h | |
+; --------------------------------------------------------------
+; |fc_strage| |
+; --------------------------------------------------------------
+; --------------------------------------------------------------
+; | 11 | 12 | |
+; --------------------------------------------------------------
+; | 02ch | 030h | |
+; --------------------------------------------------------------
+; | 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
+
+make_fcontext PROC EXPORT
+ push ebp ; save previous frame pointer; get the stack 16 byte aligned
+ mov ebp, esp ; set EBP to ESP
+ sub esp, 010h ; allocate stack space
+
+ mov eax, [ebp+08h] ; load 1. arg of make_fcontext, pointer to context stack (base)
+ lea eax, [eax-034h] ; reserve space for fcontext_t at top of context stack
+ mov [esp], eax ; address in EAX becomes 1.arg of align_stack
+ call align_stack ; call align_stack, EAX contains address at 16 byte boundary after return
+ ; == pointer to fcontext_t and address of context stack
+
+ mov ecx, [ebp+08h] ; load 1. arg of make_fcontext, pointer to context stack (base)
+ mov [eax+018h], ecx ; save address of context stack (base) in fcontext_t
+ mov edx, [ebp+0ch] ; load 2. arg of make_fcontext, context stack size
+ mov [eax+01ch], edx ; save context stack size in fcontext_t
+ neg edx ; negate stack size for LEA instruction (== substraction)
+ lea ecx, [ecx+edx] ; compute bottom address of context stack (limit)
+ mov [eax+020h], ecx ; save address of context stack (limit) in fcontext_t
+ mov ecx, [ebp+010h] ; load 3. arg of make_fcontext, pointer to context function
+ mov [eax+014h], ecx ; save address of context function in fcontext_t
+
+ stmxcsr [eax+02ch] ; save MMX control word
+ fnstcw [eax+030h] ; save x87 control word
+
+ lea edx, [eax-01ch] ; reserve space for last frame and seh on context stack, (ESP - 0x4) % 16 == 0
+ mov [eax+010h], edx ; save address in EDX as stack pointer for context function
+
+ mov ecx, seh_fcontext ; set ECX to exception-handler
+ mov [edx+018h], ecx ; save ECX as SEH handler
+ mov ecx, 0ffffffffh ; set ECX to -1
+ mov [edx+014h], ecx ; save ECX as next SEH item
+ lea ecx, [edx+014h] ; load address of next SEH item
+ mov [eax+024h], ecx ; save next SEH
+
+ mov ecx, finish ; abs address of finish
+ mov [edx], ecx ; save address of finish as return address for context function
+ ; entered after context function returns
+
+ add esp, 010h ; deallocate stack space
+ pop ebp
+
+ ret
+
+finish:
+ ; ESP points to same address as ESP on entry of context function + 0x4
+ xor eax, eax
+ mov [esp], eax ; exit code is zero
+ call _exit ; exit application
+ hlt
+make_fcontext ENDP
+END

Added: trunk/libs/context/src/asm/make_i386_sysv_elf_gas.S
==============================================================================
--- (empty file)
+++ trunk/libs/context/src/asm/make_i386_sysv_elf_gas.S 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -0,0 +1,89 @@
+/*
+ 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 | | *
+ * -------------------------------------------------------------- *
+ * | sp | size | | *
+ * -------------------------------------------------------------- *
+ * -------------------------------------------------------------- *
+ * | 8 | 9 | | *
+ * -------------------------------------------------------------- *
+ * | 0x20 | 0x24 | | *
+ * -------------------------------------------------------------- *
+ * | fc_mxcsr|fc_x87_cw| | *
+ * -------------------------------------------------------------- *
+ * *
+ * *****************************************************************/
+
+.text
+.globl make_fcontext
+.align 2
+.type make_fcontext,@function
+make_fcontext:
+ pushl %ebp /* save previous frame pointer; get the stack 16 byte aligned */
+ movl %esp, %ebp /* set EBP to ESP */
+ subl $0x10, %esp /* allocate stack space */
+
+ movl %ebx, 0x4(%esp) /* save EBX */
+ movl 0x8(%ebp), %eax /* load 1. arg of make_fcontext, pointer to context stack (base) */
+ leal -0x28(%eax), %eax /* reserve space for fcontext_t at top of context stack */
+ movl %eax, (%esp) /* address in EAX becomes 1. arg of 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 /* call align_stack, EAX contains address at 16 byte boundary after return */
+ /* == pointer to fcontext_t and address of context stack */
+ movl 0x4(%esp), %ebx /* restore EBX */
+
+ movl 0x8(%ebp), %edx /* load 1. arg of make_fcontext, pointer to context stack (base) */
+ movl %edx, 0x18(%eax) /* save address of context stack (base) in fcontext_t */
+ movl 0xc(%ebp), %edx /* load 2. arg of make_fcontext, context stack size */
+ movl %edx, 0x1c(%eax) /* save stack size in fcontext_t */
+ movl 0x10(%ebp), %edx /* load 3. arg of make_fcontext, pointer to context function */
+ movl %edx, 0x14(%eax) /* save address of context function in fcontext_t */
+
+ stmxcsr 0x20(%eax) /* save MMX control and status word */
+ fnstcw 0x24(%eax) /* save x87 control word */
+
+ leal -0xc(%eax), %edx /* reserve space for the last frame on context stack; (ESP - 0x4) % 16 == 0 */
+ movl %edx, 0x10(%eax) /* save address in EDX as stack pointer for context function */
+
+ call 2f
+2: popl %ecx /* address of label 2 */
+ addl $finish-2b, %ecx /* compute abs address of label finish */
+ movl %ecx, (%edx) /* save address of finish as return address for context functions */
+ /* entered after context function returns */
+
+ addl $0x10, %esp /* deallocate stack space */
+ pop %ebp
+
+ ret
+
+finish:
+ /* ESP points to same address as ESP on entry of context function + 0x4 */
+ 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
+ movl %eax, (%esp) /* exit code is zero */
+ call _exit_at_PLT /* exit application */
+ hlt
+.size make_fcontext,.-make_fcontext

Added: trunk/libs/context/src/asm/make_i386_sysv_macho_gas.S
==============================================================================
--- (empty file)
+++ trunk/libs/context/src/asm/make_i386_sysv_macho_gas.S 2012-09-15 02:31:49 EDT (Sat, 15 Sep 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)
+*/
+
+/********************************************************************
+ * *
+ * -------------------------------------------------------------- *
+ * | 0 | 1 | 2 | 3 | 4 | 5 | *
+ * -------------------------------------------------------------- *
+ * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | *
+ * -------------------------------------------------------------- *
+ * | EDI | ESI | EBX | EBP | ESP | EIP | *
+ * -------------------------------------------------------------- *
+ * -------------------------------------------------------------- *
+ * | 6 | 7 | | *
+ * -------------------------------------------------------------- *
+ * | 0x18 | 0x1c | | *
+ * -------------------------------------------------------------- *
+ * | sp | size | | *
+ * -------------------------------------------------------------- *
+ * -------------------------------------------------------------- *
+ * | 8 | 9 | | *
+ * -------------------------------------------------------------- *
+ * | 0x20 | 0x24 | | *
+ * -------------------------------------------------------------- *
+ * | fc_mxcsr|fc_x87_cw| | *
+ * -------------------------------------------------------------- *
+ * *
+ * *****************************************************************/
+
+.text
+.globl _make_fcontext
+.align 2
+_make_fcontext:
+ pushl %ebp /* save previous frame pointer; get the stack 16 byte aligned */
+ movl %esp, %ebp /* set EBP to ESP */
+ subl $0x10, %esp /* allocate stack space */
+
+ movl 0x8(%ebp), %eax /* load 1. arg of make_fcontext, pointer to context stack (base) */
+ leal -0x28(%eax), %eax /* reserve space for fcontext_t at top of context stack */
+ movl %eax, (%esp) /* address in EAX becomes 1. arg of align_stack */
+ call _align_stack /* call align_stack, EAX contains address at 16 byte boundary after return */
+ /* ==pointer to fcontext_t and address of context stack */
+
+ movl 0x8(%ebp), %edx /* load 1. arg of make_fcontext, pointer to context stack (base) */
+ movl %edx, 0x18(%eax) /* save address of stack pointer (base) in fcontext_t */
+ movl 0xc(%ebp), %edx /* load 2. arg of make_fcontext, context stack size */
+ movl %edx, 0x1c(%eax) /* save stack size in fcontext_t */
+ movl 0x10(%ebp), %edx /* load 3. arg of make_fcontext, pointer to context function */
+ movl %edx, 0x14(%eax) /* save address of context fcuntion in fcontext_t */
+
+ stmxcsr 0x20(%eax) /* save MMX control and status word */
+ fnstcw 0x24(%eax) /* save x87 control word */
+
+ leal -0xc(%eax), %edx /* reserve space for the last frame on context stack, (ESP - 0x4) % 16 == 0 */
+ movl %edx, 0x10(%eax) /* save address in EDX as stack pointer for context function */
+
+ call 1f
+1: popl %ecx /* address of label 1 */
+ addl $finish-1b, %ecx /* compute abs address of label finish */
+ movl %ecx, (%edx) /* save address of finish as return address for context function */
+ /* entered after context function returns */
+
+ addl $0x10, %esp /* deallocate stack space */
+ pop %ebp
+
+ ret
+
+finish:
+ /* ESP points to same address as ESP on entry of context function + 0x4 */
+ xorl %eax, %eax
+ movl %eax, (%esp) /* exit code is zero */
+ call _exit /* exit application */
+ hlt

Added: trunk/libs/context/src/asm/make_mips32_o32_elf_gas.S
==============================================================================
--- (empty file)
+++ trunk/libs/context/src/asm/make_mips32_o32_elf_gas.S 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -0,0 +1,95 @@
+/*
+ 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 | *
+ * ------------------------------------------------------------- *
+ * | S0 | S1 | S2 | S3 | S4 | S5 | S6 | S7 | FP | SP | *
+ * ------------------------------------------------------------- *
+ * ------------------------------------------------------------- *
+ * | 10 | 11 | | *
+ * ------------------------------------------------------------- *
+ * | 40 | 44 | | *
+ * ------------------------------------------------------------- *
+ * | RA | PC | | *
+ * ------------------------------------------------------------- *
+ * ------------------------------------------------------------- *
+ * | 12 | 13 | | *
+ * ------------------------------------------------------------- *
+ * | 48 | 52 | | *
+ * ------------------------------------------------------------- *
+ * | sp | size| | *
+ * ------------------------------------------------------------- *
+ * ------------------------------------------------------------- *
+ * | 14 | 15 | 16 | 17 | 18 | 19 | | *
+ * ------------------------------------------------------------- *
+ * | 56 | 64 | 72 | 80 | 88 | 96 | | *
+ * ------------------------------------------------------------- *
+ * | F20 | F22 | F24 | F26 | F28 | F30 | | *
+ * ------------------------------------------------------------- *
+ * *
+ * *****************************************************************/
+
+.text
+.globl make_fcontext
+.align 2
+.type make_fcontext,@function
+.ent make_fcontext
+make_fcontext:
+#ifdef __PIC__
+.set noreorder
+.cpload $t9
+.set reorder
+#endif
+ addiu $sp, $sp, -48 # allocate stack space (contains shadow space for subroutines)
+ sw $ra, 44($sp) # save return address
+ sw $fp, 40($sp) # save frame pointer
+
+ sw $a2, 48($sp) # save 3. arg of make_fcontnext, pointer to context function
+ sw $a1, 52($sp) # save 2. arg of make_fcontext, context stack size
+ sw $a0, 56($sp) # save 1. arg of make_fcontext, pointer to context stack (base)
+ addiu $a0, $a0, -104 # reserve space for fcontext_t at top of context stack
+ lw $t9, %call16(align_stack)($gp) # compute adddress of align_stack via global pointer
+ jalr $t9 # call align_stack, V0 contains address at 16 byte boundary after return
+ # == pointer to fcontext_t and address of context stack
+ lw $a0, 56($sp) # restore pointer to context stack (base)
+ lw $a1, 52($sp) # restore context stack size
+ lw $a2, 48($sp) # restore pointer to context function
+
+ sw $a0, 48($v0) # save address of context stack (base) in fcontext_t
+ sw $a1, 52($v0) # save context stack size in fcontext_t
+ sw $a2, 44($v0) # save address of context function in fcontext_t
+ sw $gp, ($v0) # save global pointer in fcontext_t, S0 will contain address of global pointer
+
+ addiu $t0, $v0, -48 # reserve 48 bytes (includes 4 byte shadow space), T0 % 16 == 0
+ sw $t0, 36($v0) # save address in T0 as stack pointer for context function, SP % 16 == 0
+
+ la $t9, finish # compute abs address of label finish
+ sw $t9, 40($v0) # save address of finish as return address for context function
+ # entered after context function returns
+
+ lw $fp, 40($sp) # restore frame pointer
+ lw $ra, 44($sp) # restore return address
+ addiu $sp, $sp, 48 # deallocate stack space
+
+ jr $ra
+
+finish:
+ # SP points to same adddress as SP on entry of context function
+ addiu $sp, $sp, -32 # allocate stack space (contains shadow space for subroutines)
+ sw $ra, 28($sp) # save return address
+
+ move $gp, $s0 # restore GP (global pointer)
+ move $a0, $zero # exit code is zero
+ lw $t9, %call16(_exit)($gp) # address of exit
+ jalr $t9 # exit application
+.end make_fcontext
+.size make_fcontext, .-make_fcontext

Added: trunk/libs/context/src/asm/make_ppc32_sysv_elf_gas.S
==============================================================================
--- (empty file)
+++ trunk/libs/context/src/asm/make_ppc32_sysv_elf_gas.S 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -0,0 +1,119 @@
+/*
+ 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 | | *
+ * ------------------------------------------------------------- *
+ * | sp | size| | *
+ * ------------------------------------------------------------- *
+ * ------------------------------------------------------------- *
+ * | 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 make_fcontext
+.align 2
+.type make_fcontext,@function
+make_fcontext:
+ mflr %r0 # save return address into R0
+ stw %r0, 4(%r1) # save return address on stack, set up stack frame
+ stwu %r1, -48(%r1) # allocate stack space, SP % 16 == 0
+
+ stw %r5, 32(%r1) # save 3. arg of make_fcontext, pointer to context function
+ stw %r4, 28(%r1) # save 2. arg of make_fcontext, context stack size
+ stw %r3, 24(%r1) # save 1. arg of make_fcontext, pointer to context stack (base)
+
+ subi %r3, %r3, 252 # reserve space for fcontext_t at top of context stack
+ bl align_stack_at_plt # call align_stack, R3 contains address at 16 byte boundary after return
+ # == pointer to fcontext_t and address of context stack
+ lwz %r4, 24(%r1) # restore pointer to context stack (base)
+ lwz %r5, 28(%r1) # restore context stack size
+ lwz %r6, 32(%r1) # restore pointer to context function
+
+ stw %r4, 92(%r3) # save address of context stack (base) in fcontext_t
+ stw %r5, 96(%r3) # save context stack size in fcontext_t
+ stw %r6, 88(%r3) # save address of context function in fcontext_t
+
+ subi %r0, %r3, 64 # reserve 64 bytes (linkage + parameter area), R0 % 16 == 0
+ stw %r0, 76(%r3) # save address in R0 as stack pointer for context function
+
+ mflr %r0 # load LR
+ bl 1f # jump to label 1
+1:
+ mflr %r4 # load LR into R4
+ addi %r4, %r4, finish - 1b # compute abs address of label finish
+ mtlr %r0 # restore LR
+ stw %r4, 84(%r3) # save address of finish as return address for context function
+ # entered after context function returns
+
+ addi %r1, %r1, 48 # deallocate stack space
+ lwz %r0, 4(%r1) # load return address from stack, destroy stack frame
+ mtlr %r0 # restore return address
+
+ blr
+
+finish:
+ # SP points to same address as SP on entry of context function
+ mflr %r0 # save return address into R0
+ stw %r0, 4(%r1) # save return address on stack, set up stack frame
+ stwu %r1, -16(%r1) # allocate stack space, SP % 16 == 0
+
+ li %r3, 0 # exit code is zero
+ bl _exit_at_plt # exit application
+.size make_fcontext, .-make_fcontext

Added: trunk/libs/context/src/asm/make_ppc64_sysv_elf_gas.S
==============================================================================
--- (empty file)
+++ trunk/libs/context/src/asm/make_ppc64_sysv_elf_gas.S 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -0,0 +1,140 @@
+/*
+ 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 | | *
+ * ------------------------------------------------------------- *
+ * | sp | size | | *
+ * ------------------------------------------------------------- *
+ * ------------------------------------------------------------- *
+ * | 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 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:
+ mflr %r0 # save return address into R0
+ std %r0, 8(%r1) # save return address on stack, set up stack frame
+ stdu %r1, -96(%r1) # allocate stack space, SP % 16 == 0
+
+ std %r5, 64(%r1) # save 3. arg of make_fcontext, pointer to context function
+ std %r4, 56(%r1) # save 2. arg of make_fcontext, context stack size
+ std %r3, 48(%r1) # save 1. arg of make_fcontext, pointer to context stack (base)
+
+ subi %r3, %r3, 352 # reserve space for fcontext_t at top of context stack
+ bl align_stack_at_plt # call align_stack, R3 contains address at 16 byte boundary after return
+ # == pointer to fcontext_t and address of context stack
+ ld %r4, 48(%r1) # restore pointer to context stack (base)
+ ld %r5, 56(%r1) # restore context stack size
+ ld %r6, 64(%r1) # restore pointer to context function
+
+ std %r4, 184(%r3) # save address of context stack (base) in fcontext_t
+ std %r5, 192(%r3) # save context stack size in fcontext_t
+ std %r6, 176(%r3) # save address of context function in fcontext_t
+
+ subf %r0, %r3, 64 # 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 into R4
+ addi %r4, %r4, finish - 1b # compute abs address of label finish
+ mtlr %r0 # restore LR
+ std %r4, 168(%r3) # save address of finish as return address for context function
+ # entered after context function returns
+
+ addi %r1, %r1, 64 # deallocate stack space
+ lwz %r0, 8(%r1) # load return address from stack, destroy stack frame
+ mtlr %r0 # restore return address
+
+ blr
+
+finish:
+ # SP points to same address as SP on entry of context function
+ mflr %r0 # save return address into R0
+ stw %r0, 8(%r1) # save return address on stack, set up stack frame
+ stwu %r1, -32(%r1) # allocate stack space, SP % 16 == 0
+
+ li %r3, 0 # set return value to zero
+ bl _exit_at_plt # exit application
+.size .make_fcontext, .-.make_fcontext

Added: trunk/libs/context/src/asm/make_x86_64_ms_pe_masm.asm
==============================================================================
--- (empty file)
+++ trunk/libs/context/src/asm/make_x86_64_ms_pe_masm.asm 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -0,0 +1,137 @@
+
+; 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 | 24 | 25 | |
+; ----------------------------------------------------------------------------------
+; | 0x50 | 0x54 | 0x58 | 0x5c | 0x60 | 0x64 | |
+; ----------------------------------------------------------------------------------
+; | sp | size | limit | |
+; ----------------------------------------------------------------------------------
+; ----------------------------------------------------------------------------------
+; | 26 | 27 | |
+; ----------------------------------------------------------------------------------
+; | 0x68 | 0x6c | |
+; ----------------------------------------------------------------------------------
+; | fbr_strg | |
+; ----------------------------------------------------------------------------------
+; ----------------------------------------------------------------------------------
+; | 28 | 29 | 30 | 31 | |
+; ----------------------------------------------------------------------------------
+; | 0x70 | 0x74 | 0x78 | 0x7c | |
+; ----------------------------------------------------------------------------------
+; | fc_mxcsr|fc_x87_cw| <padding> | |
+; ----------------------------------------------------------------------------------
+; ----------------------------------------------------------------------------------
+; | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
+; ----------------------------------------------------------------------------------
+; | 0x80 | 0x84 | 0x88 | 0x8c | 0x90 | 0x94 | 0x98 | 0x9c |
+; ----------------------------------------------------------------------------------
+; | XMM6 | XMM7 |
+; ----------------------------------------------------------------------------------
+; ----------------------------------------------------------------------------------
+; | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |
+; ----------------------------------------------------------------------------------
+; | 0x100 | 0x104 | 0x108 | 0x10c | 0x110 | 0x114 | 0x118 | 0x11c |
+; ----------------------------------------------------------------------------------
+; | XMM8 | XMM9 |
+; ----------------------------------------------------------------------------------
+; ----------------------------------------------------------------------------------
+; | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 |
+; ----------------------------------------------------------------------------------
+; | 0x120 | 0x124 | 0x128 | 0x12c | 0x130 | 0x134 | 0x138 | 0x13c |
+; ----------------------------------------------------------------------------------
+; | XMM10 | XMM11 |
+; ----------------------------------------------------------------------------------
+; ----------------------------------------------------------------------------------
+; | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
+; ----------------------------------------------------------------------------------
+; | 0x140 | 0x144 | 0x148 | 0x14c | 0x150 | 0x154 | 0x158 | 0x15c |
+; ----------------------------------------------------------------------------------
+; | XMM12 | XMM13 |
+; ----------------------------------------------------------------------------------
+; ----------------------------------------------------------------------------------
+; | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 |
+; ----------------------------------------------------------------------------------
+; | 0x160 | 0x164 | 0x168 | 0x16c | 0x170 | 0x174 | 0x178 | 0x17c |
+; ----------------------------------------------------------------------------------
+; | XMM14 | XMM15 |
+; ----------------------------------------------------------------------------------
+
+EXTERN _exit:PROC ; standard C library function
+EXTERN align_stack:PROC ; stack alignment
+EXTERN seh_fcontext:PROC ; exception handler
+.code
+
+make_fcontext PROC EXPORT FRAME ; generate function table entry in .pdata and unwind information in
+ .endprolog ; .xdata for a function's structured exception handling unwind behavior
+
+ push rbp ; save previous frame pointer; get the stack 16 byte aligned
+ mov rbp, rsp ; set RBP to RSP
+ sub rsp, 040h ; allocate stack space (contains shadow space for subroutines)
+
+ mov [rbp-08h], r8 ; save 3. arg of make_fcontext, pointer to context function
+ mov [rbp-010h], rdx ; save 2. arg of make_fcontext, context stack size
+ mov [rbp-018h], rcx ; save 1. arg of make_fcontext, pointer to context stack (base)
+ lea rcx, [rcx-0180h] ; reserve space for fcontext_t at top of context stack
+ call align_stack ; align context stack, RAX contains address at 16 byte boundary
+ ; == pointer to fcontext_t and address of context stack
+
+ mov r8, [rbp-08h] ; restore pointer to context function
+ mov rdx, [rbp-010h] ; restore context stack size
+ mov rcx, [rbp-018h] ; restore pointer to context stack (base)
+
+ mov [rax+048h], r8 ; save address of context function in fcontext_t
+ mov [rax+058h], rdx ; save context stack size in fcontext_t
+ mov [rax+050h], rcx ; save address of context stack pointer (base) in fcontext_t
+
+ neg rdx ; negate stack size for LEA instruction (== substraction)
+ lea rcx, [rcx+rdx] ; compute bottom address of context stack (limit)
+ mov [rax+060h], rcx ; save bottom address of context stack (limit) in fcontext_t
+
+ stmxcsr [rax+070h] ; save MMX control and status word
+ fnstcw [rax+074h] ; save x87 control word
+
+ lea rdx, [rax-028h] ; reserve 32byte shadow space + return address on stack, (RSP - 0x8) % 16 == 0
+ mov [rax+040h], rdx ; save address in RDX as stack pointer for context function
+
+ lea rcx, finish ; compute abs address of label finish
+ mov [rdx], rcx ; save address of finish as return address for context function
+ ; entered after context function returns
+
+ add rsp, 040h ; deallocate shadow space
+ pop rbp ; restore previous frame pointer
+
+ ret
+
+finish:
+ ; RSP points to same address as RSP on entry of context function + 0x8
+ xor rcx, rcx ; exit code is zero
+ call _exit ; exit application
+ hlt
+make_fcontext ENDP
+END

Added: trunk/libs/context/src/asm/make_x86_64_sysv_elf_gas.S
==============================================================================
--- (empty file)
+++ trunk/libs/context/src/asm/make_x86_64_sysv_elf_gas.S 2012-09-15 02:31:49 EDT (Sat, 15 Sep 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)
+*/
+
+/****************************************************************************************
+ * *
+ * ---------------------------------------------------------------------------------- *
+ * | 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 | | *
+ * ---------------------------------------------------------------------------------- *
+ * | sp | size | | *
+ * ---------------------------------------------------------------------------------- *
+ * ---------------------------------------------------------------------------------- *
+ * | 20 | 21 | | *
+ * ---------------------------------------------------------------------------------- *
+ * | 0x50 | 0x54 | | *
+ * ---------------------------------------------------------------------------------- *
+ * | fc_mxcsr|fc_x87_cw| | *
+ * ---------------------------------------------------------------------------------- *
+ * *
+ * **************************************************************************************/
+
+.text
+.globl make_fcontext
+.type make_fcontext,@function
+.align 16
+make_fcontext:
+ pushq %rbp /* save previous frame pointer; get the stack 16 byte aligned */
+ movq %rsp, %rbp /* set RBP to RSP */
+ subq $0x20, %rsp /* allocate stack space */
+
+ movq %rdx, 0x10(%rsp) /* save 3. arg of make_fcontext, pointer to context function */
+ movq %rsi, 0x8(%rsp) /* save 2. arg of make_fcontext, context stack size */
+ movq %rdi, (%rsp) /* save 1. arg of make_fcontext, pointer to context stack (base) */
+ leaq -0x58(%rdi), %rdi /* reserve space for fcontext_t at top of context stack */
+ call align_stack_at_PLT /* align context stack, RAX contains address at 16 byte boundary afte return */
+ /* == pointer to fcontext_t and address of context stack */
+ movq (%rsp), %rdi /* restore pointer to context stack (base) */
+ movq 0x8(%rsp), %rsi /* restore context stack size */
+ movq 0x10(%rsp), %rdx /* restore pointer to context function */
+
+ movq %rdi, 0x40(%rax) /* save address of context stack pointer (base) in fcontext_t */
+ movq %rsi, 0x48(%rax) /* save context stack size in fcontext_t */
+ movq %rdx, 0x38(%rax) /* save address of context function in fcontext_t */
+
+ stmxcsr 0x50(%rax) /* save MMX control and status word */
+ fnstcw 0x54(%rax) /* save x87 control word */
+
+ leaq -0x8(%rax), %rdx /* reserve space for the return address on context stack, (RSP - 0x8) % 16 == 0 */
+ movq %rdx, 0x30(%rax) /* save address in RDX as stack pointer for context function */
+
+ leaq finish(%rip), %rcx /* compute abs address of label finish */
+ movq %rcx, (%rdx) /* save address of finish as return address for context function */
+ /* entered after context function returns */
+
+ addq $0x20, %rsp /* deallocate shadow space */
+ popq %rbp /* restore previous frame pointer */
+
+ ret /* return pointer to fcontext_t placed on context stack */
+
+finish:
+ /* RSP points to same address as RSP on entry of context function + 0x8 */
+ xorq %rdi, %rdi /* exit code is zero */
+ call _exit_at_PLT /* exit application */
+ hlt
+.size make_fcontext,.-make_fcontext
+

Added: trunk/libs/context/src/asm/make_x86_64_sysv_macho_gas.S
==============================================================================
--- (empty file)
+++ trunk/libs/context/src/asm/make_x86_64_sysv_macho_gas.S 2012-09-15 02:31:49 EDT (Sat, 15 Sep 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)
+*/
+
+/****************************************************************************************
+ * *
+ * ---------------------------------------------------------------------------------- *
+ * | 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 | | *
+ * ---------------------------------------------------------------------------------- *
+ * | sp | size | | *
+ * ---------------------------------------------------------------------------------- *
+ * ---------------------------------------------------------------------------------- *
+ * | 20 | 21 | | *
+ * ---------------------------------------------------------------------------------- *
+ * | 0x50 | 0x54 | | *
+ * ---------------------------------------------------------------------------------- *
+ * | fc_mxcsr|fc_x87_cw| | *
+ * ---------------------------------------------------------------------------------- *
+ * *
+ * **************************************************************************************/
+
+.text
+.globl _make_fcontext
+.align 8
+_make_fcontext:
+ pushq %rbp /* save previous frame pointer; get the stack 16 byte aligned */
+ movq %rsp, %rbp /* set RBP to RSP */
+ subq $0x20, %rsp /* allocate stack space */
+
+ movq %rdx, 0x10(%rsp) /* save 3. arg of make_fcontext, pointer to context function */
+ movq %rsi, 0x8(%rsp) /* save 2. arg of make_fcontext, context stack size */
+ movq %rdi, (%rsp) /* save 1. arg of make_fcontext, pointer to context stack (base) */
+ leaq -0x58(%rdi), %rdi /* reserve space for fcontext_t at top of context stack */
+ call _align_stack /* align context stack, RAX contains address at 16 byte boundary */
+ /* == pointer to fcontext_t and address of context stack */
+ movq (%rsp), %rdi /* restore pointer to context stack (base) */
+ movq 0x8(%rsp), %rsi /* restore context stack size */
+ movq 0x10(%rsp), %rdx /* restore pointer to context function */
+
+ movq %rdi, 0x40(%rax) /* save address of stack pointer (base) in fcontext_t */
+ movq %rsi, 0x48(%rax) /* save stack size in fcontext_t */
+ movq %rdx, 0x38(%rax) /* save address of context function in fcontext_t */
+
+ stmxcsr 0x50(%rax) /* save MMX control and status word */
+ fnstcw 0x54(%rax) /* save x87 control word */
+
+ leaq -0x8(%rax), %rdx /* reserve space for the return address on context stack, (RSP - 0x8) % 16 == 0 */
+ movq %rdx, 0x30(%rax) /* save address in RDX as stack pointer for context function */
+
+ leaq finish(%rip), %rcx /* compute abs address of label finish */
+ movq %rcx, (%rdx) /* save address of finish as return address for context function */
+ /* entered after context function returns */
+
+ addq $0x20, %rsp /* deallocate shadow space */
+ popq %rbp /* restore previous frame pointer */
+
+ ret /* return pointer to fcontext_t placed on context stack */
+
+finish:
+ /* RSP points to same address as RSP on entry of context function + 0x8 */
+ xorq %rdi, %rdi /* exit code is zero */
+ call _exit /* exit application */
+ hlt

Modified: trunk/libs/context/src/fcontext.cpp
==============================================================================
--- trunk/libs/context/src/fcontext.cpp (original)
+++ trunk/libs/context/src/fcontext.cpp 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -15,7 +15,7 @@
 #endif
 
 namespace boost {
-namespace ctx {
+namespace context {
 namespace detail {
 
 extern "C" BOOST_CONTEXT_DECL

Modified: trunk/libs/context/src/guarded_stack_allocator_posix.cpp
==============================================================================
--- trunk/libs/context/src/guarded_stack_allocator_posix.cpp (original)
+++ trunk/libs/context/src/guarded_stack_allocator_posix.cpp 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -61,13 +61,13 @@
 {
     return static_cast< std::size_t >(
         std::ceil(
- static_cast< float >( stacksize) / boost::ctx::pagesize() ) );
+ static_cast< float >( stacksize) / boost::context::pagesize() ) );
 }
 
 }
 
 namespace boost {
-namespace ctx {
+namespace context {
 
 bool
 guarded_stack_allocator::is_stack_unbound()

Modified: trunk/libs/context/src/guarded_stack_allocator_windows.cpp
==============================================================================
--- trunk/libs/context/src/guarded_stack_allocator_windows.cpp (original)
+++ trunk/libs/context/src/guarded_stack_allocator_windows.cpp 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -67,13 +67,13 @@
 {
     return static_cast< std::size_t >(
         std::ceil(
- static_cast< float >( stacksize) / boost::ctx::pagesize() ) );
+ static_cast< float >( stacksize) / boost::context::pagesize() ) );
 }
 
 }
 
 namespace boost {
-namespace ctx {
+namespace context {
 
 // Windows seams not to provide a limit for the stacksize
 bool

Modified: trunk/libs/context/src/utils_posix.cpp
==============================================================================
--- trunk/libs/context/src/utils_posix.cpp (original)
+++ trunk/libs/context/src/utils_posix.cpp 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -21,7 +21,7 @@
 #endif
 
 namespace boost {
-namespace ctx {
+namespace context {
 
 std::size_t pagesize()
 {

Modified: trunk/libs/context/src/utils_windows.cpp
==============================================================================
--- trunk/libs/context/src/utils_windows.cpp (original)
+++ trunk/libs/context/src/utils_windows.cpp 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -36,7 +36,7 @@
 }
 
 namespace boost {
-namespace ctx {
+namespace context {
 
 std::size_t pagesize()
 { return static_cast< std::size_t >( system_info().dwPageSize); }

Modified: trunk/libs/context/test/test_context.cpp
==============================================================================
--- trunk/libs/context/test/test_context.cpp (original)
+++ trunk/libs/context/test/test_context.cpp 2012-09-15 02:31:49 EDT (Sat, 15 Sep 2012)
@@ -17,7 +17,7 @@
 
 #include <boost/context/all.hpp>
 
-namespace ctx = boost::ctx;
+namespace ctx = boost::context;
 
 ctx::fcontext_t fcm;
 ctx::fcontext_t * fc = 0;
@@ -76,20 +76,6 @@
     ctx::jump_fcontext( fc, & fcm, 0);
 }
 
-void test_stack()
-{
- std::size_t def = ctx::guarded_stack_allocator::default_stacksize();
- std::size_t min = ctx::guarded_stack_allocator::minimum_stacksize();
- bool unbound = ctx::guarded_stack_allocator::is_stack_unbound();
- if ( ! unbound)
- {
- std::size_t max = ctx::guarded_stack_allocator::maximum_stacksize();
- BOOST_CHECK( unbound || ( max >= def) );
- }
-
- BOOST_CHECK( min <= def);
-}
-
 void test_setup()
 {
     ctx::guarded_stack_allocator alloc;
@@ -219,15 +205,14 @@
     boost::unit_test::test_suite * test =
         BOOST_TEST_SUITE("Boost.Context: context test suite");
 
- test->add( BOOST_TEST_CASE( & test_stack) );
- test->add( BOOST_TEST_CASE( & test_setup) );
- 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) );
+ test->add( BOOST_TEST_CASE( & test_setup) );
+ 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;
 }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk