$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r82583 - in trunk: boost/context boost/context/detail libs/context/build libs/context/config libs/context/doc libs/context/src/asm
From: oliver.kowalke_at_[hidden]
Date: 2013-01-21 14:24:03
Author: olli
Date: 2013-01-21 14:24:01 EST (Mon, 21 Jan 2013)
New Revision: 82583
URL: http://svn.boost.org/trac/boost/changeset/82583
Log:
context: support for architecture SPARC added
Added:
   trunk/boost/context/detail/fcontext_sparc.hpp   (contents, props changed)
   trunk/libs/context/config/sparc.cpp   (contents, props changed)
   trunk/libs/context/src/asm/jump_sparc64_sysv_elf_gas.S   (contents, props changed)
   trunk/libs/context/src/asm/jump_sparc_sysv_elf_gas.S   (contents, props changed)
   trunk/libs/context/src/asm/make_sparc64_sysv_elf_gas.S   (contents, props changed)
   trunk/libs/context/src/asm/make_sparc_sysv_elf_gas.S   (contents, props changed)
Text files modified: 
   trunk/boost/context/fcontext.hpp            |     3 ++                                      
   trunk/libs/context/build/Jamfile.v2         |    47 ++++++++++++++++++++++++++++++++++----- 
   trunk/libs/context/build/architecture.jam   |    16 ++++++++-----                           
   trunk/libs/context/config/Jamfile.jam       |     7 +++--                                   
   trunk/libs/context/doc/Jamfile.v2           |     3 --                                      
   trunk/libs/context/doc/acknowledgements.qbk |     6 ++--                                    
   trunk/libs/context/doc/fcontext.qbk         |     2                                         
   7 files changed, 62 insertions(+), 22 deletions(-)
Added: trunk/boost/context/detail/fcontext_sparc.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/context/detail/fcontext_sparc.hpp	2013-01-21 14:24:01 EST (Mon, 21 Jan 2013)
@@ -0,0 +1,90 @@
+//          Copyright Martin Husemann 2012
+// Distributed under the Boost Software License, Version 1.0.
+//    (See accompanying file LICENSE_1_0.txt or copy at
+//          http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_CTX_DETAIL_FCONTEXT_SPARC_H
+#define BOOST_CTX_DETAIL_FCONTEXT_SPARC_H
+
+#include <cstddef>
+
+#include <boost/config.hpp>
+#include <boost/cstdint.hpp>
+
+#include <boost/context/detail/config.hpp>
+
+#ifdef BOOST_HAS_ABI_HEADERS
+# include BOOST_ABI_PREFIX
+#endif
+
+namespace boost {
+namespace context {
+
+extern "C" {
+
+#define BOOST_CONTEXT_CALLDECL
+
+// if defined(_LP64) we are compiling for sparc64, otherwise it is 32 bit
+// sparc.
+
+
+struct stack_t
+{
+    void    *   sp;
+    std::size_t size;
+
+    stack_t() :
+        sp( 0), size( 0)
+    {}
+};
+
+struct fp_t
+{
+#ifdef _LP64
+    boost::uint64_t     fp_freg[32];
+    boost::uint64_t	fp_fprs, fp_fsr;
+#else
+    boost::uint64_t     fp_freg[16];
+    boost::uint32_t	fp_fsr;
+#endif
+
+    fp_t() :
+        fp_freg(),
+#ifdef _LP64
+	fp_fprs(),
+#endif
+	fp_fsr()
+    {}
+}
+#ifdef _LP64
+		 __attribute__((__aligned__(64)))	// allow VIS instructions to be used
+#endif
+;
+
+struct fcontext_t
+{
+    fp_t                fc_fp;	// fpu stuff first, for easier alignement
+#ifdef _LP64
+    boost::uint64_t
+#else
+    boost::uint32_t
+#endif
+			fc_greg[8];
+    stack_t             fc_stack;
+
+    fcontext_t() :
+        fc_fp(),
+        fc_greg(),
+        fc_stack()
+    {}
+};
+
+}
+
+}}
+
+#ifdef BOOST_HAS_ABI_HEADERS
+# include BOOST_ABI_SUFFIX
+#endif
+
+#endif // BOOST_CTX_DETAIL_FCONTEXT_SPARC_H
Modified: trunk/boost/context/fcontext.hpp
==============================================================================
--- trunk/boost/context/fcontext.hpp	(original)
+++ trunk/boost/context/fcontext.hpp	2013-01-21 14:24:01 EST (Mon, 21 Jan 2013)
@@ -59,6 +59,9 @@
     || defined(__ppc__) || defined(_ARCH_PPC) || defined(__POWERPC__) \
     || defined(__PPCGECKO__) || defined(__PPCBROADWAY) || defined(_XENON)
 # include <boost/context/detail/fcontext_ppc.hpp>
+#elif defined(__sparc__) || defined(__sparc)
+// sparc or sparc64
+# include <boost/context/detail/fcontext_sparc.hpp>
 #else
 # error "platform not supported"
 #endif
Modified: trunk/libs/context/build/Jamfile.v2
==============================================================================
--- trunk/libs/context/build/Jamfile.v2	(original)
+++ trunk/libs/context/build/Jamfile.v2	2013-01-21 14:24:01 EST (Mon, 21 Jan 2013)
@@ -17,8 +17,7 @@
 project boost/context
     : source-location ../src
     : requirements
-      <os>SOLARIS:<define>_XOPEN_SOURCE=1
-      <os>SOLARIS:<define>_XOPEN_SOURCE_EXTENDED=1
+      <os>SOLARIS:<define>_XOPEN_SOURCE=600
     : usage-requirements
       <link>shared:<define>BOOST_CONTEXT_DYN_LINK=1
     ;
@@ -138,7 +137,7 @@
      <binary-format>elf
    ;
 
-# MIPS 32bit
+# MIPS
 alias asm_context_sources
    : asm/make_mips32_o32_elf_gas.S
      asm/jump_mips32_o32_elf_gas.S
@@ -162,7 +161,7 @@
      <binary-format>elf
    ;
 
-# POWERPC 32bit
+# POWERPC
 alias asm_context_sources
    : asm/make_ppc32_sysv_elf_gas.S
      asm/jump_ppc32_sysv_elf_gas.S
@@ -189,7 +188,7 @@
      <binary-format>elf
    ;
 
-# POWERPC 64bit
+# POWERPC_64
 alias asm_context_sources
    : asm/make_ppc64_sysv_elf_gas.S
      asm/jump_ppc64_sysv_elf_gas.S
@@ -216,7 +215,43 @@
      <binary-format>elf
    ;
 
-# I386
+# SPARC
+alias asm_context_sources
+   : asm/make_sparc_sysv_elf_gas.S
+     asm/jump_sparc_sysv_elf_gas.S
+   : <address-model>32
+     <architecture>sparc
+     <binary-format>elf
+     <toolset>gcc
+   ;
+
+alias asm_context_sources
+   : [ make asm/make_sparc_sysv_elf_gas.o : asm/make_sparc_sysv_elf_gas.S : @gas ]
+     [ make asm/jump_sparc_sysv_elf_gas.o : asm/jump_sparc_sysv_elf_gas.S : @gas ]
+   : <address-model>32
+     <architecture>sparc
+     <binary-format>elf
+   ;
+
+# SPARC_64
+alias asm_context_sources
+   : asm/make_sparc64_sysv_elf_gas.S
+     asm/jump_sparc64_sysv_elf_gas.S
+   : <address-model>64
+     <architecture>sparc
+     <binary-format>elf
+     <toolset>gcc
+   ;
+
+alias asm_context_sources
+   : [ make asm/make_sparc64_sysv_elf_gas.o : asm/make_sparc64_sysv_elf_gas.S : @gas ]
+     [ make asm/jump_sparc64_sysv_elf_gas.o : asm/jump_sparc64_sysv_elf_gas.S : @gas ]
+   : <address-model>64
+     <architecture>sparc
+     <binary-format>elf
+   ;
+
+# X86
 alias asm_context_sources
    : asm/make_i386_sysv_elf_gas.S
      asm/jump_i386_sysv_elf_gas.S
Modified: trunk/libs/context/build/architecture.jam
==============================================================================
--- trunk/libs/context/build/architecture.jam	(original)
+++ trunk/libs/context/build/architecture.jam	2013-01-21 14:24:01 EST (Mon, 21 Jan 2013)
@@ -51,21 +51,25 @@
     }
     else
     {
-        if [ configure.builds /boost/architecture//x86 : $(properties) : x86 ]
+        if [ configure.builds /boost/architecture//arm : $(properties) : arm ]
         {
-            return <architecture>x86 ;
+            return <architecture>arm ;
+        }
+        else if [ configure.builds /boost/architecture//mips1 : $(properties) : mips1 ]
+        {
+            return <architecture>mips1 ;
         }
         else if [ configure.builds /boost/architecture//power : $(properties) : power ]
         {
             return <architecture>power ;
         }
-        else if [ configure.builds /boost/architecture//arm : $(properties) : arm ]
+        else if [ configure.builds /boost/architecture//sparc : $(properties) : sparc ]
         {
-            return <architecture>arm ;
+            return <architecture>sparc ;
         }
-        else if [ configure.builds /boost/architecture//mips1 : $(properties) : mips1 ]
+        else if [ configure.builds /boost/architecture//x86 : $(properties) : x86 ]
         {
-            return <architecture>mips1 ;
+            return <architecture>x86 ;
         }
     }
 }
Modified: trunk/libs/context/config/Jamfile.jam
==============================================================================
--- trunk/libs/context/config/Jamfile.jam	(original)
+++ trunk/libs/context/config/Jamfile.jam	2013-01-21 14:24:01 EST (Mon, 21 Jan 2013)
@@ -11,7 +11,8 @@
 obj 32 : 32.cpp ;
 obj 64 : 64.cpp ;
 
-obj power : power.cpp ;
-obj x86 : x86.cpp ;
+obj arm   : arm.cpp ;
 obj mips1 : mips1.cpp ;
-obj arm : arm.cpp ;
+obj power : power.cpp ;
+obj sparc : sparc.cpp ;
+obj x86   : x86.cpp ;
Added: trunk/libs/context/config/sparc.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/context/config/sparc.cpp	2013-01-21 14:24:01 EST (Mon, 21 Jan 2013)
@@ -0,0 +1,11 @@
+// power.cpp
+//
+// Copyright (c) 2012 Steven Watanabe
+//
+// Distributed under the Boost Software License Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#if !defined(__sparc__) && !defined(__sparc)
+#error "Not SPARC"
+#endif
Modified: trunk/libs/context/doc/Jamfile.v2
==============================================================================
--- trunk/libs/context/doc/Jamfile.v2	(original)
+++ trunk/libs/context/doc/Jamfile.v2	2013-01-21 14:24:01 EST (Mon, 21 Jan 2013)
@@ -3,9 +3,6 @@
 # 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)
 
-using boostbook ;
-using quickbook ;
-
 xml context : context.qbk ;
 
 boostbook standalone
Modified: trunk/libs/context/doc/acknowledgements.qbk
==============================================================================
--- trunk/libs/context/doc/acknowledgements.qbk	(original)
+++ trunk/libs/context/doc/acknowledgements.qbk	2013-01-21 14:24:01 EST (Mon, 21 Jan 2013)
@@ -9,8 +9,8 @@
 
 I'd like to thank Adreas Fett, Artyom Beilis, Daniel Larimer, David Deakins,
 Fernando Pelliccioni, Giovanni Piero Deretta, Gordon Woodhull, Helge Bahmann,
-Holger Grund, Jeffrey Lee Hellrung (Jr.), Keith Jeffery, Phil Endecott,
-Robert Stewart, Sergey Cheban, Steven Watanabe, Vicente J. Botet Escriba,
-Wayne Piekarski.
+Holger Grund, Jeffrey Lee Hellrung (Jr.), Keith Jeffery, Martin Husemann,
+Phil Endecott, Robert Stewart, Sergey Cheban, Steven Watanabe,
+Vicente J. Botet Escriba, Wayne Piekarski.
 
 [endsect]
Modified: trunk/libs/context/doc/fcontext.qbk
==============================================================================
--- trunk/libs/context/doc/fcontext.qbk	(original)
+++ trunk/libs/context/doc/fcontext.qbk	2013-01-21 14:24:01 EST (Mon, 21 Jan 2013)
@@ -177,7 +177,7 @@
 
 Preserving the floating point registers increases the cycle count for a context
 switch (see performance tests).
-The fourth argument of __jump_fcontext__ controls if fpu registers should be 
+The fourth argument of __jump_fcontext__ controls if fpu registers should be
 preserved by the context jump.
 
 [important The use of the fpu controlling argument of __jump_fcontext__ must
Added: trunk/libs/context/src/asm/jump_sparc64_sysv_elf_gas.S
==============================================================================
--- (empty file)
+++ trunk/libs/context/src/asm/jump_sparc64_sysv_elf_gas.S	2013-01-21 14:24:01 EST (Mon, 21 Jan 2013)
@@ -0,0 +1,136 @@
+/*
+            Copyright Martin Husemann 2013.
+   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)
+*/
+
+/*******************************************************************
+ *                                                                 *
+ *  -------------------------------------------------------------  *
+ *  |  Offset (in 4 or 8 byte units) | Content                  |  *
+ *  -------------------------------------------------------------  *
+ *  | 0                              | %sp                      |  *
+ *  -------------------------------------------------------------  *
+ *  | 1                              | %pc                      |  *
+ *  -------------------------------------------------------------  *
+ *  | 2                              | %i7 (return address)     |  *
+ *  -------------------------------------------------------------  *
+ *  | 3                              | %g1                      |  *
+ *  -------------------------------------------------------------  *
+ *  | 4                              | %g2                      |  *
+ *  -------------------------------------------------------------  *
+ *  | 5                              | %g3                      |  *
+ *  -------------------------------------------------------------  *
+ *  | 6                              | %g6                      |  *
+ *  -------------------------------------------------------------  *
+ *  | 7                              | %g7                      |  *
+ *  -------------------------------------------------------------  *
+ *    The local and in registers are stored on the stack.          *
+ *******************************************************************/
+
+#define OFF(N)	(8*(N))
+#define CCFSZ   176		// C Compiler Frame Size
+#define BIAS    (2048-1)	// Stack offset for 64 bit programs
+#define FC_SZ   448		// sizeof(fcontext_t)
+#define FC_STK  384		// offsetof(fcontext_t, fc_stack)
+#define FC_FPU  0		// offsetof(fcontext_t, fc_fp)
+#define FC_FSR  264		// offsetof(fcontext_t, fc_fp.fp_fsr)
+#define FC_FPRS 256		// offsetof(fcontext_t, fc_fp.fp_fprs)
+#define FC_GREG 320		// offsetof(fcontext_t, fc_greg)
+#define BLOCK_SIZE  64
+
+    .register %g2,#ignore
+    .register %g3,#ignore
+    .register %g6,#ignore
+
+.text
+.globl jump_fcontext
+.align 4
+.type jump_fcontext,@function
+// intptr_t
+// jump_fcontext( fcontext_t * ofc, fcontext_t const* nfc, intptr_t vp,
+//                bool preserve_fpu = true);
+jump_fcontext:
+    // %o0 = pointer to old fcontext, save current state here
+    // %o1 = new context to jump to
+    // %o2 = new return value in context %o0
+    // %o3 = preserve fpu registers
+    // Save current state in %o0 fcontext, then activate %o1.
+    // If %o3, include fpu registers.
+
+    flushw // make sure all shadow registers are up to date in the current stack
+
+    // save current state to fcontext_t at %o0
+    stx %sp, [%o0 + FC_GREG + OFF(0)]    // current stack pointer
+    add %o7, 8, %o4         // calculate next instruction past call
+    stx %o4, [%o0 + FC_GREG + OFF(1)]    // and store it as %pc in save context
+    stx %o7, [%o0 + FC_GREG + OFF(2)]
+    stx %g1, [%o0 + FC_GREG + OFF(3)]
+    stx %g2, [%o0 + FC_GREG + OFF(4)]
+    stx %g3, [%o0 + FC_GREG + OFF(5)]
+    stx %g6, [%o0 + FC_GREG + OFF(6)]
+    stx %g7, [%o0 + FC_GREG + OFF(7)]
+
+    // do we need to handle fpu?
+    brz %o3, Lno_fpu
+    nop
+
+    add %o0, FC_FPU, %o5
+    stda %f0, [%o5] 0xf0 /* ASI_BLOCK_PRIMARY */
+    add %o5, BLOCK_SIZE, %o5
+    stda %f16, [%o5] 0xf0
+    add %o5, BLOCK_SIZE, %o5
+    stda %f32, [%o5] 0xf0
+    add %o5, BLOCK_SIZE, %o5
+    stda %f48, [%o5] 0xf0
+    stx %fsr, [%o0+FC_FSR]
+    rd %fprs, %o4
+    stx %o4, [%o0+FC_FPRS]
+
+    add %o1, FC_FPU, %o5
+    ldda [%o5] 0xf0 /* ASI_BLOCK_PRIMARY */, %f0
+    add %o5, BLOCK_SIZE, %o5
+    ldda [%o5] 0xf0, %f16
+    add %o5, BLOCK_SIZE, %o5
+    ldda [%o5] 0xf0, %f32
+    add %o5, BLOCK_SIZE, %o5
+    ldda [%o5] 0xf0, %f48
+    ldx [%o1+FC_FSR], %fsr
+    ldx [%o1+FC_FPRS], %o4
+    wr %o4,0,%fprs
+
+Lno_fpu:
+    // load new state from %o1
+    ldx [%o1 + FC_GREG + OFF(1)], %o4
+    ldx [%o1 + FC_GREG + OFF(2)], %o7
+    ldx [%o1 + FC_GREG + OFF(3)], %g1
+    ldx [%o1 + FC_GREG + OFF(4)], %g2
+    ldx [%o1 + FC_GREG + OFF(5)], %g3
+    ldx [%o1 + FC_GREG + OFF(6)], %g6
+    ldx [%o1 + FC_GREG + OFF(7)], %g7
+    // switch to new stack
+    ldx [%o1 + FC_GREG + OFF(0)], %sp
+    // and now reload from this stack the shadow regist bank contents
+    ldx [%sp + BIAS + OFF(0)], %l0
+    ldx [%sp + BIAS + OFF(1)], %l1
+    ldx [%sp + BIAS + OFF(2)], %l2
+    ldx [%sp + BIAS + OFF(3)], %l3
+    ldx [%sp + BIAS + OFF(4)], %l4
+    ldx [%sp + BIAS + OFF(5)], %l5
+    ldx [%sp + BIAS + OFF(6)], %l6
+    ldx [%sp + BIAS + OFF(7)], %l7
+    ldx [%sp + BIAS + OFF(8)], %i0
+    ldx [%sp + BIAS + OFF(9)], %i1
+    ldx [%sp + BIAS + OFF(10)], %i2
+    ldx [%sp + BIAS + OFF(11)], %i3
+    ldx [%sp + BIAS + OFF(12)], %i4
+    ldx [%sp + BIAS + OFF(13)], %i5
+    ldx [%sp + BIAS + OFF(14)], %i6
+    ldx [%sp + BIAS + OFF(15)], %i7
+
+    // finally continue execution in new context
+    jmp %o4
+    mov %o2, %o0    // return arg as result
+
+.size jump_fcontext,.-jump_fcontext
Added: trunk/libs/context/src/asm/jump_sparc_sysv_elf_gas.S
==============================================================================
--- (empty file)
+++ trunk/libs/context/src/asm/jump_sparc_sysv_elf_gas.S	2013-01-21 14:24:01 EST (Mon, 21 Jan 2013)
@@ -0,0 +1,132 @@
+/*
+            Copyright Martin Husemann 2013.
+   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)
+*/
+
+/*******************************************************************
+ *                                                                 *
+ *  -------------------------------------------------------------  *
+ *  |  Offset (in 4 or 8 byte units) | Content                  |  *
+ *  -------------------------------------------------------------  *
+ *  | 0                              | %sp                      |  *
+ *  -------------------------------------------------------------  *
+ *  | 1                              | %pc                      |  *
+ *  -------------------------------------------------------------  *
+ *  | 2                              | %i7 (return address)     |  *
+ *  -------------------------------------------------------------  *
+ *  | 3                              | %g1                      |  *
+ *  -------------------------------------------------------------  *
+ *  | 4                              | %g2                      |  *
+ *  -------------------------------------------------------------  *
+ *  | 5                              | %g3                      |  *
+ *  -------------------------------------------------------------  *
+ *  | 6                              | %g6                      |  *
+ *  -------------------------------------------------------------  *
+ *  | 7                              | %g7                      |  *
+ *  -------------------------------------------------------------  *
+ *    The local and in registers are stored on the stack.          *
+ *******************************************************************/
+
+#define OFF(N)  (4*(N))
+#define CCFSZ   96
+#define FC_SZ   176
+#define FC_stK  168     // offsetof(fcontext_t, fc_stack)
+#define FC_FPU  0       // offsetof(fcontext_t, fc_fp)
+#define FC_FSR  128     // offsetof(fcontext_t, fc_fp.fp_fsr)
+#define FC_GREG 136     // offsetof(fcontext_t, fc_greg)
+#define BLOCK_SIZE 8
+#ifdef __NetBSD__
+#define FLUSHW  t 0x83; nop // T_FLUSHWIN
+#endif
+
+.text
+.globl jump_fcontext
+.align 4
+.type jump_fcontext,@function
+// intptr_t
+// jump_fcontext( fcontext_t * ofc, fcontext_t const* nfc, intptr_t vp,
+//                bool preserve_fpu = true);
+jump_fcontext:
+    // %o0 = pointer to old fcontext, save current state here
+    // %o1 = new context to jump to
+    // %o2 = new return value in context %o0
+    // %o3 = preserve fpu registers
+    // Save current state in %o0 fcontext, then activate %o1.
+    // If %o3, include fpu registers.
+
+    FLUSHW // make sure all shadow registers are up to date in the current stack
+
+    // save current state to fcontext_t at %o0
+    st %sp, [%o0 + FC_GREG + OFF(0)]    // current stack pointer
+    add %o7, 8, %o4         // calculate next instruction past call
+    st %o4, [%o0 + FC_GREG + OFF(1)]    // and store it as %pc in save context
+    st %o7, [%o0 + FC_GREG + OFF(2)]
+    st %g1, [%o0 + FC_GREG + OFF(3)]
+    st %g2, [%o0 + FC_GREG + OFF(4)]
+    st %g3, [%o0 + FC_GREG + OFF(5)]
+    st %g6, [%o0 + FC_GREG + OFF(6)]
+    st %g7, [%o0 + FC_GREG + OFF(7)]
+
+    // do we need to handle fpu?
+    cmp %o3, 0
+    bz Lno_fpu
+    nop
+
+    add %o0, FC_FPU, %o5
+    std %f0, [%o5]
+    std %f2, [%o5+0x08]
+    std %f4, [%o5+0x10]
+    std %f6, [%o5+0x18]
+    std %f8, [%o5+0x20]
+    std %f10, [%o5+0x28]
+    std %f12, [%o5+0x30]
+    std %f14, [%o5+0x38]
+    st %fsr, [%o0+FC_FSR]
+
+    add %o1, FC_FPU, %o5
+    ldd [%o5], %f0
+    ldd [%o5+0x08], %f2
+    ldd [%o5+0x10], %f4
+    ldd [%o5+0x18], %f6
+    ldd [%o5+0x20], %f8
+    ldd [%o5+0x28], %f10
+    ldd [%o5+0x30], %f12
+    ldd [%o5+0x38], %f14
+    ld [%o1+FC_FSR], %fsr
+
+Lno_fpu:
+    // load new state from %o1
+    ld [%o1 + FC_GREG + OFF(1)], %o4
+    ld [%o1 + FC_GREG + OFF(2)], %o7
+    ld [%o1 + FC_GREG + OFF(3)], %g1
+    ld [%o1 + FC_GREG + OFF(4)], %g2
+    ld [%o1 + FC_GREG + OFF(5)], %g3
+    ld [%o1 + FC_GREG + OFF(6)], %g6
+    ld [%o1 + FC_GREG + OFF(7)], %g7
+    // switch to new stack
+    ld [%o1 + FC_GREG + OFF(0)], %sp
+    // and now reload from this stack the shadow regist bank contents
+    ld [%sp + OFF(0)], %l0
+    ld [%sp + OFF(1)], %l1
+    ld [%sp + OFF(2)], %l2
+    ld [%sp + OFF(3)], %l3
+    ld [%sp + OFF(4)], %l4
+    ld [%sp + OFF(5)], %l5
+    ld [%sp + OFF(6)], %l6
+    ld [%sp + OFF(7)], %l7
+    ld [%sp + OFF(8)], %i0
+    ld [%sp + OFF(9)], %i1
+    ld [%sp + OFF(10)], %i2
+    ld [%sp + OFF(11)], %i3
+    ld [%sp + OFF(12)], %i4
+    ld [%sp + OFF(13)], %i5
+    ld [%sp + OFF(14)], %i6
+    ld [%sp + OFF(15)], %i7
+
+    // finally continue execution in new context
+    jmp %o4
+    mov %o2, %o0    // return arg as result
+
+.size jump_fcontext,.-jump_fcontext
Added: trunk/libs/context/src/asm/make_sparc64_sysv_elf_gas.S
==============================================================================
--- (empty file)
+++ trunk/libs/context/src/asm/make_sparc64_sysv_elf_gas.S	2013-01-21 14:24:01 EST (Mon, 21 Jan 2013)
@@ -0,0 +1,86 @@
+/*
+            Copyright Martin Husemann 2013.
+   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)
+*/
+
+/*******************************************************************
+ *                                                                 *
+ *  -------------------------------------------------------------  *
+ *  |  Offset (in 4 or 8 byte units) | Content                  |  *
+ *  -------------------------------------------------------------  *
+ *  | 0                              | %sp                      |  *
+ *  -------------------------------------------------------------  *
+ *  | 1                              | %pc                      |  *
+ *  -------------------------------------------------------------  *
+ *  | 2                              | %i7 (return address)     |  *
+ *  -------------------------------------------------------------  *
+ *  | 3                              | %g1                      |  *
+ *  -------------------------------------------------------------  *
+ *  | 4                              | %g2                      |  *
+ *  -------------------------------------------------------------  *
+ *  | 5                              | %g3                      |  *
+ *  -------------------------------------------------------------  *
+ *  | 6                              | %g6                      |  *
+ *  -------------------------------------------------------------  *
+ *  | 7                              | %g7                      |  *
+ *  -------------------------------------------------------------  *
+ *    The local and in registers are stored on the stack.          *
+ *******************************************************************/
+
+#define	OFF(N)	(8*(N))
+#define	CCFSZ	176		// C Compiler Frame Size
+#define	BIAS	(2048-1)	// Stack offset for 64 bit programs
+#define	FC_SZ	448		// sizeof(fcontext_t)
+#define	FC_STK	384		// offsetof(fcontext_t, fc_stack)
+#define	FC_FPU	0		// offsetof(fcontext_t, fc_fp)
+#define	FC_FSR	264		// offsetof(fcontext_t, fc_fp.fp_fsr)
+#define	FC_FPRS	256		// offsetof(fcontext_t, fc_fp.fp_fprs)
+#define	FC_GREG	320		// offsetof(fcontext_t, fc_greg)
+#define	BLOCK_SIZE	64
+
+	.register %g2,#ignore
+	.register %g3,#ignore
+	.register %g6,#ignore
+
+.text
+.globl make_fcontext
+.align 4
+.type make_fcontext,@function
+// fcontext_t *
+// make_fcontext( void * sp, std::size_t size, void (* fn)( intptr_t) )
+make_fcontext:
+    save %sp, -CCFSZ, %sp
+    // %i0 initial stack pointer
+    // %i1 stack size limit
+    // %i2 function pointer for context start function
+
+    sub %i0, FC_SZ, %i4		// allocate fcontext_t at on the new stack and keep pointer as return value
+    andn %i4, BLOCK_SIZE-1, %i5	// force block ops usable alignement and keep pointer to fcontext in %i5
+
+    stx %i0, [%i5+FC_STK+OFF(0)]	// save fs_stack.sp
+    stx %i1, [%i5+FC_STK+OFF(1)]	// save fs_stack.size
+    sub %i5, CCFSZ+BIAS, %o1	   	// leave space for one register window (and offset stack for 64bit)
+    stx %o1, [%i5+FC_GREG+OFF(0)]	// save new stack pointer
+    stx %i2, [%i5+FC_GREG+OFF(1)]	// save new %pc (function pointer)
+    stx %g1, [%i5+FC_GREG+OFF(3)]
+    stx %g2, [%i5+FC_GREG+OFF(4)]
+    stx %g3, [%i5+FC_GREG+OFF(5)]
+    stx %g6, [%i5+FC_GREG+OFF(6)]
+    stx %g7, [%i5+FC_GREG+OFF(7)]
+
+    // synthesize "return address": jump to finish
+1:  rd %pc, %i4
+    add %i4, finish-1b-8, %i4
+    stx %i4, [%i5+FC_GREG+OFF(2)]
+
+    ret
+    restore %g0, %i5, %o0	// return fcontext_t
+
+finish:
+    mov %g0, %o0
+    call _exit
+     nop
+
+.size make_fcontext,.-make_fcontext
Added: trunk/libs/context/src/asm/make_sparc_sysv_elf_gas.S
==============================================================================
--- (empty file)
+++ trunk/libs/context/src/asm/make_sparc_sysv_elf_gas.S	2013-01-21 14:24:01 EST (Mon, 21 Jan 2013)
@@ -0,0 +1,82 @@
+/*
+            Copyright Martin Husemann 2013.
+   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)
+*/
+
+/*******************************************************************
+ *                                                                 *
+ *  -------------------------------------------------------------  *
+ *  |  Offset (in 4 or 8 byte units) | Content                  |  *
+ *  -------------------------------------------------------------  *
+ *  | 0                              | %sp                      |  *
+ *  -------------------------------------------------------------  *
+ *  | 1                              | %pc                      |  *
+ *  -------------------------------------------------------------  *
+ *  | 2                              | %i7 (return address)     |  *
+ *  -------------------------------------------------------------  *
+ *  | 3                              | %g1                      |  *
+ *  -------------------------------------------------------------  *
+ *  | 4                              | %g2                      |  *
+ *  -------------------------------------------------------------  *
+ *  | 5                              | %g3                      |  *
+ *  -------------------------------------------------------------  *
+ *  | 6                              | %g6                      |  *
+ *  -------------------------------------------------------------  *
+ *  | 7                              | %g7                      |  *
+ *  -------------------------------------------------------------  *
+ *    The local and in registers are stored on the stack.          *
+ *******************************************************************/
+
+#define	OFF(N)	(4*(N))
+#define	CCFSZ	96
+#define	FC_SZ	176
+#define	FC_stK	168		// offsetof(fcontext_t, fc_stack)
+#define	FC_FPU	0		// offsetof(fcontext_t, fc_fp)
+#define	FC_FSR	128		// offsetof(fcontext_t, fc_fp.fp_fsr)
+#define	FC_GREG	136		// offsetof(fcontext_t, fc_greg)
+#define	BLOCK_SIZE 8
+
+.text
+.globl make_fcontext
+.align 4
+.type make_fcontext,@function
+// fcontext_t *
+// make_fcontext( void * sp, std::size_t size, void (* fn)( intptr_t) )
+make_fcontext:
+    save %sp, -CCFSZ, %sp
+    // %i0 initial stack pointer
+    // %i1 stack size limit
+    // %i2 function pointer for context start function
+
+    sub %i0, FC_SZ, %i4			// allocate fcontext_t at on the new stack and keep pointer as return value
+    andn %i4, BLOCK_SIZE-1, %i5		// force block ops usable alignement and keep pointer to fcontext in %i5
+
+    st %i0, [%i5+FC_stK+OFF(0)]		// save fs_stack.sp
+    st %i1, [%i5+FC_stK+OFF(1)]		// save fs_stack.size
+    sub %i5, CCFSZ, %o1   		// leave space for one register window
+    st %o1, [%i5+FC_GREG+OFF(0)]	// save new stack pointer
+    st %i2, [%i5+FC_GREG+OFF(1)]	// save new %pc (function pointer)
+    st %g1, [%i5+FC_GREG+OFF(3)]
+    st %g2, [%i5+FC_GREG+OFF(4)]
+    st %g3, [%i5+FC_GREG+OFF(5)]
+    st %g6, [%i5+FC_GREG+OFF(6)]
+    st %g7, [%i5+FC_GREG+OFF(7)]
+
+    // synthesize "return address": jump to finish
+    mov %i7, %l0
+2:  call 3f
+     nop
+3:  add finish-2b-8, %o7, %i4
+    st %i4, [%i5+FC_GREG+OFF(2)]
+
+    ret
+    restore %g0, %i5, %o0	// return fcontext_t
+
+finish:
+    mov %g0, %o0
+    call _exit
+     nop
+
+.size make_fcontext,.-make_fcontext