diff options
author | martin <martin@pkgsrc.org> | 2013-01-20 09:06:58 +0000 |
---|---|---|
committer | martin <martin@pkgsrc.org> | 2013-01-20 09:06:58 +0000 |
commit | a37eed104cd41c11c7ac7d993de86ed6c0827949 (patch) | |
tree | 2a7abefc242e7492d86d6779914032a6567988f5 | |
parent | 017123ab984d37c65b9f22cfe84885a45be4d4e7 (diff) | |
download | pkgsrc-a37eed104cd41c11c7ac7d993de86ed6c0827949.tar.gz |
Add missing assembler code for the context library on sparc and sparc64
10 files changed, 496 insertions, 10 deletions
diff --git a/meta-pkgs/boost/Makefile.common b/meta-pkgs/boost/Makefile.common index 468038a442a..7b47067eef3 100644 --- a/meta-pkgs/boost/Makefile.common +++ b/meta-pkgs/boost/Makefile.common @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.common,v 1.37 2012/11/07 21:04:11 adam Exp $ +# $NetBSD: Makefile.common,v 1.38 2013/01/20 09:06:58 martin Exp $ # # used by devel/boost-build/Makefile # used by devel/boost-docs/Makefile @@ -19,6 +19,7 @@ CATEGORIES= devel PKGNAME= boost-${BOOST_VERSION} .else # ${BOOST_PACKAGE} != "meta-pkg" PKGNAME= boost-${BOOST_PACKAGE}-${BOOST_VERSION} +PKGREVISION= 1 MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=boost/} EXTRACT_SUFX= .tar.bz2 diff --git a/meta-pkgs/boost/distinfo b/meta-pkgs/boost/distinfo index 8756d76753c..27a47a3b9b1 100644 --- a/meta-pkgs/boost/distinfo +++ b/meta-pkgs/boost/distinfo @@ -1,8 +1,5 @@ -$NetBSD: distinfo,v 1.52 2013/01/17 11:58:50 jperkin Exp $ +$NetBSD: distinfo,v 1.53 2013/01/20 09:06:58 martin Exp $ -SHA1 (boost_1_52_0.tar.bz2) = cddd6b4526a09152ddc5db856463eaa1dc29c5d9 -RMD160 (boost_1_52_0.tar.bz2) = 94f72f4553a88495f2052029fb2e90cf8366e75d -Size (boost_1_52_0.tar.bz2) = 54421709 bytes SHA1 (patch-aa) = 408a63a807aaa491130db018cd89bca6a427090d SHA1 (patch-ab) = f1c95ae229465a4d2da76ce6ff88d76ace52fdd8 SHA1 (patch-ac) = 5ecd12564259e4ad9d439990e198b889762ec733 @@ -12,8 +9,15 @@ SHA1 (patch-ag) = c406e9beb9260db7861b13a6eb4c386f23346eb1 SHA1 (patch-ai) = 231db48819aa563b2082d95bb91d662b5d6cf779 SHA1 (patch-aq) = e5c7b72ffa2942ce401f3d9bf05498fd761df17a SHA1 (patch-ar) = 2fec2c51272cc4ee376e6538d8f1fd8561a7f0a3 +SHA1 (patch-boost_context_detail_fcontext__sparc.hpp) = 1f9cd1292669c13a8560817dec9632f21e6760e3 +SHA1 (patch-boost_context_fcontext.hpp) = 5b7738e335410dfb922c023313c096ae7d454953 SHA1 (patch-boost_foreach.hpp) = 7cd26c4983873bcac284ad400950e341c559f9a8 SHA1 (patch-boost_foreach_fwd.hpp) = 5accd68d559213a9677f7d1204e72dd082a42a41 -SHA1 (patch-libs_context_build_Jamfile.v2) = 93cad3cc588c84e333688318df7250d14a3c302e +SHA1 (patch-libs_context_build_Jamfile.v2) = 649ec4d3c38291d8145a1170e8cb42466fc280dd +SHA1 (patch-libs_context_build_architecture.jam) = 8daa6ffdd9e4934f9e627a4c777da716443ff31e +SHA1 (patch-libs_context_config_Jamfile.jam) = c486154e49f80f19030522075596e48d0bab400c +SHA1 (patch-libs_context_config_sparc.cpp) = 93794017c4dae28c08ab26ef0b1d43ebb7050528 +SHA1 (patch-libs_context_src_asm_jump__sparc__sysv__elf__gas.S) = 80c2dd361328a1cee1b25445da3b791cbef80a01 +SHA1 (patch-libs_context_src_asm_make__sparc__sysv__elf__gas.S) = ba1a878618cdffefde7081f807faeed18b738db6 SHA1 (patch-libs_filesystem_src_unique_path.cpp) = 3666663305bba85871f2ef291dc117158c678643 SHA1 (patch-tools_build_v2_engine_hash.c) = a4687fafa1e54a5fea543670c529399c3a09fb80 diff --git a/meta-pkgs/boost/patches/patch-boost_context_detail_fcontext__sparc.hpp b/meta-pkgs/boost/patches/patch-boost_context_detail_fcontext__sparc.hpp new file mode 100644 index 00000000000..0233e0b34ce --- /dev/null +++ b/meta-pkgs/boost/patches/patch-boost_context_detail_fcontext__sparc.hpp @@ -0,0 +1,97 @@ +$NetBSD: patch-boost_context_detail_fcontext__sparc.hpp,v 1.1 2013/01/20 09:06:59 martin Exp $ + +# Implementation details for sparc + +--- /dev/null 2013-01-19 12:02:03.000000000 +0100 ++++ boost/context/detail/fcontext_sparc.hpp 2013-01-19 19:21:19.000000000 +0100 +@@ -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 diff --git a/meta-pkgs/boost/patches/patch-boost_context_fcontext.hpp b/meta-pkgs/boost/patches/patch-boost_context_fcontext.hpp new file mode 100644 index 00000000000..ca62d7509c4 --- /dev/null +++ b/meta-pkgs/boost/patches/patch-boost_context_fcontext.hpp @@ -0,0 +1,16 @@ +$NetBSD: patch-boost_context_fcontext.hpp,v 1.1 2013/01/20 09:06:59 martin Exp $ + +# add support for SPARC + +--- boost/context/fcontext.hpp.orig 2012-10-31 11:07:06.000000000 +0100 ++++ boost/context/fcontext.hpp 2012-10-31 13:31:48.000000000 +0100 +@@ -55,6 +55,9 @@ + || defined(__ppc__) || defined(_ARCH_PPC) || defined(__POWERPC__) \ + || defined(__PPCGECKO__) || defined(__PPCBROADWAY) || defined(_XENON) + # include <boost/context/detail/fcontext_ppc.hpp> ++#elif defined(__sparc__) ++// sparc or sparc64 ++# include <boost/context/detail/fcontext_sparc.hpp> + #else + # error "platform not supported" + #endif diff --git a/meta-pkgs/boost/patches/patch-libs_context_build_Jamfile.v2 b/meta-pkgs/boost/patches/patch-libs_context_build_Jamfile.v2 index 6498b6cb205..ad6eecdc919 100644 --- a/meta-pkgs/boost/patches/patch-libs_context_build_Jamfile.v2 +++ b/meta-pkgs/boost/patches/patch-libs_context_build_Jamfile.v2 @@ -1,9 +1,9 @@ -$NetBSD: patch-libs_context_build_Jamfile.v2,v 1.1 2012/09/20 12:22:27 jperkin Exp $ +$NetBSD: patch-libs_context_build_Jamfile.v2,v 1.2 2013/01/20 09:06:59 martin Exp $ -_XOPEN_SOURCE_EXTENDED conflicts with existing _XOPEN_SOURCE definition. +# add support for SPARC architecture ---- libs/context/build/Jamfile.v2.orig 2012-09-20 10:37:02.244099518 +0000 -+++ libs/context/build/Jamfile.v2 2012-09-20 10:38:31.345922902 +0000 +--- ./libs/context/build/Jamfile.v2.orig 2012-11-24 22:52:40.000000000 +0100 ++++ ./libs/context/build/Jamfile.v2 2012-11-25 21:20:20.000000000 +0100 @@ -17,8 +17,7 @@ project boost/context : source-location ../src @@ -14,3 +14,20 @@ _XOPEN_SOURCE_EXTENDED conflicts with existing _XOPEN_SOURCE definition. : usage-requirements <link>shared:<define>BOOST_CONTEXT_DYN_LINK=1 ; +@@ -427,6 +426,16 @@ + <target-os>windows + ; + ++# SPARC ++alias asm_context_sources ++ : asm/make_sparc_sysv_elf_gas.S ++ asm/jump_sparc_sysv_elf_gas.S ++ : <abi>sysv ++ <architecture>sparc ++ <binary-format>elf ++ <toolset>gcc ++ ; ++ + explicit asm_context_sources ; + + diff --git a/meta-pkgs/boost/patches/patch-libs_context_build_architecture.jam b/meta-pkgs/boost/patches/patch-libs_context_build_architecture.jam new file mode 100644 index 00000000000..269cc0bc256 --- /dev/null +++ b/meta-pkgs/boost/patches/patch-libs_context_build_architecture.jam @@ -0,0 +1,17 @@ +$NetBSD: patch-libs_context_build_architecture.jam,v 1.1 2013/01/20 09:06:59 martin Exp $ + +# add support for SPARC architecture + +--- libs/context/build/architecture.jam.orig 2012-11-04 15:21:27.000000000 +0100 ++++ libs/context/build/architecture.jam 2012-11-04 18:53:45.000000000 +0100 +@@ -63,6 +63,10 @@ + { + return <architecture>arm ; + } ++ else if [ configure.builds /boost/architecture//sparc : $(properties) : sparc ] ++ { ++ return <architecture>sparc ; ++ } + else if [ configure.builds /boost/architecture//mips1 : $(properties) : mips1 ] + { + return <architecture>mips1 ; diff --git a/meta-pkgs/boost/patches/patch-libs_context_config_Jamfile.jam b/meta-pkgs/boost/patches/patch-libs_context_config_Jamfile.jam new file mode 100644 index 00000000000..e330858bb26 --- /dev/null +++ b/meta-pkgs/boost/patches/patch-libs_context_config_Jamfile.jam @@ -0,0 +1,11 @@ +$NetBSD: patch-libs_context_config_Jamfile.jam,v 1.1 2013/01/20 09:06:59 martin Exp $ + +# new build test for SPARC architecture + +--- libs/context/config/Jamfile.jam.orig 2012-11-04 18:56:00.000000000 +0100 ++++ libs/context/config/Jamfile.jam 2012-11-04 18:56:19.000000000 +0100 +@@ -15,3 +15,4 @@ + obj x86 : x86.cpp ; + obj mips1 : mips1.cpp ; + obj arm : arm.cpp ; ++obj sparc : sparc.cpp ; diff --git a/meta-pkgs/boost/patches/patch-libs_context_config_sparc.cpp b/meta-pkgs/boost/patches/patch-libs_context_config_sparc.cpp new file mode 100644 index 00000000000..ad08ff8db34 --- /dev/null +++ b/meta-pkgs/boost/patches/patch-libs_context_config_sparc.cpp @@ -0,0 +1,14 @@ +--- /dev/null 2012-11-04 15:17:53.000000000 +0100 ++++ libs/context/config/sparc.cpp 2012-11-04 18:56:51.000000000 +0100 +@@ -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) ++#error "Not SPARC" ++#endif diff --git a/meta-pkgs/boost/patches/patch-libs_context_src_asm_jump__sparc__sysv__elf__gas.S b/meta-pkgs/boost/patches/patch-libs_context_src_asm_jump__sparc__sysv__elf__gas.S new file mode 100644 index 00000000000..45b435fb916 --- /dev/null +++ b/meta-pkgs/boost/patches/patch-libs_context_src_asm_jump__sparc__sysv__elf__gas.S @@ -0,0 +1,194 @@ +$NetBSD: patch-libs_context_src_asm_jump__sparc__sysv__elf__gas.S,v 1.1 2013/01/20 09:06:59 martin Exp $ + +# Implementation for jump_fcontext for sparc + +--- /dev/null 2013-01-19 12:02:03.000000000 +0100 ++++ libs/context/src/asm/jump_sparc_sysv_elf_gas.S 2013-01-19 18:41:04.000000000 +0100 +@@ -0,0 +1,187 @@ ++/* ++ 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. * ++ *******************************************************************/ ++ ++#ifdef _LP64 ++#define ST stx ++#define LD ldx ++#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 ++#define FLUSHW flushw ++ ++ .register %g2,#ignore ++ .register %g3,#ignore ++ .register %g6,#ignore ++ ++#else ++#define ST st ++#define LD ld ++#define OFF(N) (4*(N)) ++#define CCFSZ 96 ++#define BIAS 0 ++#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 ++#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? ++#ifdef _LP64 ++ brz %o3, Lno_fpu ++ nop ++#else ++ cmp %o3, 0 ++ bz Lno_fpu ++ nop ++#endif ++ ++ add %o0, FC_FPU, %o5 ++#ifdef _LP64 ++ 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] ++#else ++ 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] ++#endif ++ ++ add %o1, FC_FPU, %o5 ++#ifdef _LP64 ++ 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 ++#else ++ 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 ++#endif ++ ++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 + BIAS + OFF(0)], %l0 ++ LD [%sp + BIAS + OFF(1)], %l1 ++ LD [%sp + BIAS + OFF(2)], %l2 ++ LD [%sp + BIAS + OFF(3)], %l3 ++ LD [%sp + BIAS + OFF(4)], %l4 ++ LD [%sp + BIAS + OFF(5)], %l5 ++ LD [%sp + BIAS + OFF(6)], %l6 ++ LD [%sp + BIAS + OFF(7)], %l7 ++ LD [%sp + BIAS + OFF(8)], %i0 ++ LD [%sp + BIAS + OFF(9)], %i1 ++ LD [%sp + BIAS + OFF(10)], %i2 ++ LD [%sp + BIAS + OFF(11)], %i3 ++ LD [%sp + BIAS + OFF(12)], %i4 ++ LD [%sp + BIAS + OFF(13)], %i5 ++ LD [%sp + BIAS + OFF(14)], %i6 ++ LD [%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 diff --git a/meta-pkgs/boost/patches/patch-libs_context_src_asm_make__sparc__sysv__elf__gas.S b/meta-pkgs/boost/patches/patch-libs_context_src_asm_make__sparc__sysv__elf__gas.S new file mode 100644 index 00000000000..fc93b563e7c --- /dev/null +++ b/meta-pkgs/boost/patches/patch-libs_context_src_asm_make__sparc__sysv__elf__gas.S @@ -0,0 +1,115 @@ +$NetBSD: patch-libs_context_src_asm_make__sparc__sysv__elf__gas.S,v 1.1 2013/01/20 09:06:59 martin Exp $ + +# Implementation of make_fcontext for sparc + +--- /dev/null 2013-01-19 12:02:03.000000000 +0100 ++++ libs/context/src/asm/make_sparc_sysv_elf_gas.S 2013-01-19 19:29:27.000000000 +0100 +@@ -0,0 +1,108 @@ ++/* ++ 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. * ++ *******************************************************************/ ++ ++#ifdef _LP64 ++#define ST stx ++#define LD ldx ++#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 ++#define FLUSHW flushw ++ ++ .register %g2,#ignore ++ .register %g3,#ignore ++ .register %g6,#ignore ++ ++#else ++#define ST st ++#define LD ld ++#define OFF(N) (4*(N)) ++#define CCFSZ 96 ++#define BIAS 0 ++#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 ++#endif ++ ++.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+BIAS, %o1 // leave space for one register window (and offset stack for 64bit) ++ 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 ++#ifdef _LP64 ++1: rd %pc, %i4 ++ add %i4, finish-1b-8, %i4 ++#else ++ set finish-8, %i4 ++#endif ++ 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 |