120d7907b2
OBS-URL: https://build.opensuse.org/request/show/232265 OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/boost?expand=0&rev=129
753 lines
27 KiB
Diff
753 lines
27 KiB
Diff
diff --git a/boost/context/detail/config.hpp b/boost/context/detail/config.hpp
|
|
--- a/boost/context/detail/config.hpp
|
|
+++ b/boost/context/detail/config.hpp
|
|
@@ -35,4 +35,15 @@
|
|
# include <boost/config/auto_link.hpp>
|
|
#endif
|
|
|
|
+#undef BOOST_CONTEXT_CALLDECL
|
|
+#if (defined(i386) || defined(__i386__) || defined(__i386) \
|
|
+ || defined(__i486__) || defined(__i586__) || defined(__i686__) \
|
|
+ || defined(__X86__) || defined(_X86_) || defined(__THW_INTEL__) \
|
|
+ || defined(__I86__) || defined(__INTEL__) || defined(__IA32__) \
|
|
+ || defined(_M_IX86) || defined(_I86_)) && defined(BOOST_WINDOWS)
|
|
+# define BOOST_CONTEXT_CALLDECL __cdecl
|
|
+#else
|
|
+# define BOOST_CONTEXT_CALLDECL
|
|
+#endif
|
|
+
|
|
#endif // BOOST_CONTEXT_DETAIL_CONFIG_H
|
|
diff --git a/boost/context/fcontext.hpp b/boost/context/fcontext.hpp
|
|
--- a/boost/context/fcontext.hpp
|
|
+++ b/boost/context/fcontext.hpp
|
|
@@ -24,51 +24,11 @@ typedef int intptr_t;
|
|
# include BOOST_ABI_PREFIX
|
|
#endif
|
|
|
|
-// x86_64
|
|
-// test x86_64 before i386 because icc might
|
|
-// define __i686__ for x86_64 too
|
|
-#if defined(__x86_64__) || defined(__x86_64) \
|
|
- || defined(__amd64__) || defined(__amd64) \
|
|
- || defined(_M_X64) || defined(_M_AMD64)
|
|
-# if defined(BOOST_WINDOWS)
|
|
-# include <boost/context/detail/fcontext_x86_64_win.hpp>
|
|
-# else
|
|
-# include <boost/context/detail/fcontext_x86_64.hpp>
|
|
-# endif
|
|
-// i386
|
|
-#elif defined(i386) || defined(__i386__) || defined(__i386) \
|
|
- || defined(__i486__) || defined(__i586__) || defined(__i686__) \
|
|
- || defined(__X86__) || defined(_X86_) || defined(__THW_INTEL__) \
|
|
- || defined(__I86__) || defined(__INTEL__) || defined(__IA32__) \
|
|
- || defined(_M_IX86) || defined(_I86_)
|
|
-# if defined(BOOST_WINDOWS)
|
|
-# include <boost/context/detail/fcontext_i386_win.hpp>
|
|
-# else
|
|
-# include <boost/context/detail/fcontext_i386.hpp>
|
|
-# endif
|
|
-// arm
|
|
-#elif defined(__arm__) || defined(__thumb__) || defined(__TARGET_ARCH_ARM) \
|
|
- || defined(__TARGET_ARCH_THUMB) || defined(_ARM) || defined(_M_ARM)
|
|
-# include <boost/context/detail/fcontext_arm.hpp>
|
|
-// mips
|
|
-#elif (defined(__mips) && __mips == 1) || defined(_MIPS_ISA_MIPS1) \
|
|
- || defined(_R3000)
|
|
-# include <boost/context/detail/fcontext_mips.hpp>
|
|
-// powerpc
|
|
-#elif defined(__powerpc) || defined(__powerpc__) || defined(__ppc) \
|
|
- || defined(__ppc__) || defined(_ARCH_PPC) || defined(__POWERPC__) \
|
|
- || defined(__PPCGECKO__) || defined(__PPCBROADWAY) || defined(_XENON)
|
|
-# include <boost/context/detail/fcontext_ppc.hpp>
|
|
-#elif defined(__sparc__) || defined(__sparc)
|
|
-// sparc or sparc64
|
|
-# include <boost/context/detail/fcontext_sparc.hpp>
|
|
-#else
|
|
-# error "platform not supported"
|
|
-#endif
|
|
-
|
|
namespace boost {
|
|
namespace context {
|
|
|
|
+typedef void fcontext_t;
|
|
+
|
|
extern "C" BOOST_CONTEXT_DECL
|
|
intptr_t BOOST_CONTEXT_CALLDECL jump_fcontext( fcontext_t * ofc, fcontext_t const* nfc, intptr_t vp, bool preserve_fpu = true);
|
|
extern "C" BOOST_CONTEXT_DECL
|
|
diff --git a/libs/context/build/Jamfile.v2 b/libs/context/build/Jamfile.v2
|
|
--- a/libs/context/build/Jamfile.v2
|
|
+++ b/libs/context/build/Jamfile.v2
|
|
@@ -210,6 +210,16 @@ alias asm_context_sources
|
|
;
|
|
|
|
alias asm_context_sources
|
|
+ : asm/make_ppc64_linux_elf_gas.S
|
|
+ asm/jump_ppc64_linux_elf_gas.S
|
|
+ : <address-model>64
|
|
+ <architecture>power
|
|
+ <binary-format>elf
|
|
+ <target-os>linux
|
|
+ <toolset>gcc
|
|
+ ;
|
|
+
|
|
+alias asm_context_sources
|
|
: [ 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 ]
|
|
: <address-model>64
|
|
diff --git a/libs/context/src/asm/jump_ppc64_linux_elf_gas.S b/libs/context/src/asm/jump_ppc64_linux_elf_gas.S
|
|
--- /dev/null
|
|
+++ b/libs/context/src/asm/jump_ppc64_linux_elf_gas.S
|
|
@@ -0,0 +1,267 @@
|
|
+/*
|
|
+ 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 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | F14 | F15 | F16 | F17 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | F18 | F19 | F20 | F21 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | F22 | F23 | F24 | F25 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | F26 | F27 | F28 | F29 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | F30 | F31 | fpscr | TOC | *
|
|
+ * ------------------------------------------------- *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | R14 | R15 | R16 | R17 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | R18 | R19 | R20 | R21 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 224 | 228 | 232 | 236 | 240 | 244 | 248 | 252 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | R22 | R23 | R24 | R25 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 256 | 260 | 264 | 268 | 272 | 276 | 280 | 284 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | R26 | R27 | R28 | R29 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 288 | 292 | 296 | 300 | 304 | 308 | 312 | 316 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * ------------------------------------------------- *
|
|
+ * | R30 | R31 | CR | LR | *
|
|
+ * ------------------------------------------------- *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 80 | 81 | | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 320 | 324 | | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | PC | | *
|
|
+ * ------------------------------------------------- *
|
|
+ * *
|
|
+ *******************************************************/
|
|
+
|
|
+.globl jump_fcontext
|
|
+#if _CALL_ELF == 2
|
|
+ .text
|
|
+ .align 2
|
|
+jump_fcontext:
|
|
+ addis %r2, %r12, .TOC.-jump_fcontext@ha
|
|
+ addi %r2, %r2, .TOC.-jump_fcontext@l
|
|
+ .localentry jump_fcontext, . - jump_fcontext
|
|
+#else
|
|
+ .section ".opd","aw"
|
|
+ .align 3
|
|
+jump_fcontext:
|
|
+# ifdef _CALL_LINUX
|
|
+ .quad .L.jump_fcontext,.TOC.@tocbase,0
|
|
+ .type jump_fcontext,@function
|
|
+ .text
|
|
+ .align 2
|
|
+.L.jump_fcontext:
|
|
+# else
|
|
+ .hidden .jump_fcontext
|
|
+ .globl .jump_fcontext
|
|
+ .quad .jump_fcontext,.TOC.@tocbase,0
|
|
+ .size jump_fcontext,24
|
|
+ .type .jump_fcontext,@function
|
|
+ .text
|
|
+ .align 2
|
|
+.jump_fcontext:
|
|
+# endif
|
|
+#endif
|
|
+ # reserve space on stack
|
|
+ subi %r1, %r1, 328
|
|
+
|
|
+#if _CALL_ELF != 2
|
|
+ std %r2, 152(%r1) # save TOC
|
|
+#endif
|
|
+ std %r14, 160(%r1) # save R14
|
|
+ std %r15, 168(%r1) # save R15
|
|
+ std %r16, 176(%r1) # save R16
|
|
+ std %r17, 184(%r1) # save R17
|
|
+ std %r18, 192(%r1) # save R18
|
|
+ std %r19, 200(%r1) # save R19
|
|
+ std %r20, 208(%r1) # save R20
|
|
+ std %r21, 216(%r1) # save R21
|
|
+ std %r22, 224(%r1) # save R22
|
|
+ std %r23, 232(%r1) # save R23
|
|
+ std %r24, 240(%r1) # save R24
|
|
+ std %r25, 248(%r1) # save R25
|
|
+ std %r26, 256(%r1) # save R26
|
|
+ std %r27, 264(%r1) # save R27
|
|
+ std %r28, 272(%r1) # save R28
|
|
+ std %r29, 280(%r1) # save R29
|
|
+ std %r30, 288(%r1) # save R30
|
|
+ std %r31, 296(%r1) # save R31
|
|
+
|
|
+ # save CR
|
|
+ mfcr %r0
|
|
+ std %r0, 304(%r1)
|
|
+ # save LR
|
|
+ mflr %r0
|
|
+ std %r0, 312(%r1)
|
|
+ # save LR as PC
|
|
+ std %r0, 320(%r1)
|
|
+
|
|
+ # test if fpu env should be preserved
|
|
+ cmpwi cr7, %r6, 0
|
|
+ beq cr7, 1f
|
|
+
|
|
+ stfd %f14, 0(%r1) # save F14
|
|
+ stfd %f15, 8(%r1) # save F15
|
|
+ stfd %f16, 16(%r1) # save F16
|
|
+ stfd %f17, 24(%r1) # save F17
|
|
+ stfd %f18, 32(%r1) # save F18
|
|
+ stfd %f19, 40(%r1) # save F19
|
|
+ stfd %f20, 48(%r1) # save F20
|
|
+ stfd %f21, 56(%r1) # save F21
|
|
+ stfd %f22, 64(%r1) # save F22
|
|
+ stfd %f23, 72(%r1) # save F23
|
|
+ stfd %f24, 80(%r1) # save F24
|
|
+ stfd %f25, 88(%r1) # save F25
|
|
+ stfd %f26, 96(%r1) # save F26
|
|
+ stfd %f27, 104(%r1) # save F27
|
|
+ stfd %f28, 112(%r1) # save F28
|
|
+ stfd %f29, 120(%r1) # save F29
|
|
+ stfd %f30, 128(%r1) # save F30
|
|
+ stfd %f31, 136(%r1) # save F31
|
|
+ mffs %f0 # load FPSCR
|
|
+ stfd %f0, 144(%r1) # save FPSCR
|
|
+
|
|
+1:
|
|
+ # store RSP (pointing to context-data) in R3
|
|
+ std %r1, 0(%r3)
|
|
+
|
|
+ # restore RSP (pointing to context-data) from R4
|
|
+ mr %r1, %r4
|
|
+
|
|
+ # test if fpu env should be preserved
|
|
+ cmpwi cr7, %r6, 0
|
|
+ beq cr7, 2f
|
|
+
|
|
+ lfd %f14, 0(%r1) # restore F14
|
|
+ lfd %f15, 8(%r1) # restore F15
|
|
+ lfd %f16, 16(%r1) # restore F16
|
|
+ lfd %f17, 24(%r1) # restore F17
|
|
+ lfd %f18, 32(%r1) # restore F18
|
|
+ lfd %f19, 40(%r1) # restore F19
|
|
+ lfd %f20, 48(%r1) # restore F20
|
|
+ lfd %f21, 56(%r1) # restore F21
|
|
+ lfd %f22, 64(%r1) # restore F22
|
|
+ lfd %f23, 72(%r1) # restore F23
|
|
+ lfd %f24, 80(%r1) # restore F24
|
|
+ lfd %f25, 88(%r1) # restore F25
|
|
+ lfd %f26, 96(%r1) # restore F26
|
|
+ lfd %f27, 104(%r1) # restore F27
|
|
+ lfd %f28, 112(%r1) # restore F28
|
|
+ lfd %f29, 120(%r1) # restore F29
|
|
+ lfd %f30, 128(%r1) # restore F30
|
|
+ lfd %f31, 136(%r1) # restore F31
|
|
+ lfd %f0, 144(%r1) # load FPSCR
|
|
+ mtfsf 0xff, %f0 # restore FPSCR
|
|
+
|
|
+2:
|
|
+#if _CALL_ELF != 2
|
|
+ ld %r2, 152(%r1) # restore TOC
|
|
+#endif
|
|
+ ld %r14, 160(%r1) # restore R14
|
|
+ ld %r15, 168(%r1) # restore R15
|
|
+ ld %r16, 176(%r1) # restore R16
|
|
+ ld %r17, 184(%r1) # restore R17
|
|
+ ld %r18, 192(%r1) # restore R18
|
|
+ ld %r19, 200(%r1) # restore R19
|
|
+ ld %r20, 208(%r1) # restore R20
|
|
+ ld %r21, 216(%r1) # restore R21
|
|
+ ld %r22, 224(%r1) # restore R22
|
|
+ ld %r23, 232(%r1) # restore R23
|
|
+ ld %r24, 240(%r1) # restore R24
|
|
+ ld %r25, 248(%r1) # restore R25
|
|
+ ld %r26, 256(%r1) # restore R26
|
|
+ ld %r27, 264(%r1) # restore R27
|
|
+ ld %r28, 272(%r1) # restore R28
|
|
+ ld %r29, 280(%r1) # restore R29
|
|
+ ld %r30, 288(%r1) # restore R30
|
|
+ ld %r31, 296(%r1) # restore R31
|
|
+
|
|
+ # restore CR
|
|
+ ld %r0, 304(%r1)
|
|
+ mtcr %r0
|
|
+ # restore LR
|
|
+ ld %r0, 312(%r1)
|
|
+ mtlr %r0
|
|
+
|
|
+ # load PC
|
|
+ ld %r12, 320(%r1)
|
|
+ # restore CTR
|
|
+ mtctr %r12
|
|
+
|
|
+ # adjust stack
|
|
+ addi %r1, %r1, 328
|
|
+
|
|
+ # use third arg as return value after jump
|
|
+ # use third arg as first arg in context function
|
|
+ mr %r3, %r5
|
|
+
|
|
+ # jump to context
|
|
+ bctr
|
|
+#if _CALL_ELF == 2
|
|
+ .size jump_fcontext, .-jump_fcontext
|
|
+#else
|
|
+# ifdef _CALL_LINUX
|
|
+ .size .jump_fcontext, .-.L.jump_fcontext
|
|
+# else
|
|
+ .size .jump_fcontext, .-.jump_fcontext
|
|
+# endif
|
|
+#endif
|
|
+
|
|
+
|
|
+/* Mark that we don't need executable stack. */
|
|
+.section .note.GNU-stack,"",%progbits
|
|
diff --git a/libs/context/src/asm/make_ppc64_linux_elf_gas.S b/libs/context/src/asm/make_ppc64_linux_elf_gas.S
|
|
--- /dev/null
|
|
+++ b/libs/context/src/asm/make_ppc64_linux_elf_gas.S
|
|
@@ -0,0 +1,189 @@
|
|
+/*
|
|
+ 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 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | F14 | F15 | F16 | F17 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | F18 | F19 | F20 | F21 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | F22 | F23 | F24 | F25 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | F26 | F27 | F28 | F29 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | F30 | F31 | fpscr | TOC | *
|
|
+ * ------------------------------------------------- *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | R14 | R15 | R16 | R17 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | R18 | R19 | R20 | R21 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 224 | 228 | 232 | 236 | 240 | 244 | 248 | 252 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | R22 | R23 | R24 | R25 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 256 | 260 | 264 | 268 | 272 | 276 | 280 | 284 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | R26 | R27 | R28 | R29 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 288 | 292 | 296 | 300 | 304 | 308 | 312 | 316 | *
|
|
+ * ------------------------------------------------- *
|
|
+ * ------------------------------------------------- *
|
|
+ * | R30 | R31 | CR | LR | *
|
|
+ * ------------------------------------------------- *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 80 | 81 | | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | 320 | 324 | | *
|
|
+ * ------------------------------------------------- *
|
|
+ * | PC | | *
|
|
+ * ------------------------------------------------- *
|
|
+ * *
|
|
+ *******************************************************/
|
|
+
|
|
+.globl make_fcontext
|
|
+#if _CALL_ELF == 2
|
|
+ .text
|
|
+ .align 2
|
|
+make_fcontext:
|
|
+ addis %r2, %r12, .TOC.-make_fcontext@ha
|
|
+ addi %r2, %r2, .TOC.-make_fcontext@l
|
|
+ .localentry make_fcontext, . - make_fcontext
|
|
+#else
|
|
+ .section ".opd","aw"
|
|
+ .align 3
|
|
+make_fcontext:
|
|
+# ifdef _CALL_LINUX
|
|
+ .quad .L.make_fcontext,.TOC.@tocbase,0
|
|
+ .type make_fcontext,@function
|
|
+ .text
|
|
+ .align 2
|
|
+.L.make_fcontext:
|
|
+# else
|
|
+ .hidden .make_fcontext
|
|
+ .globl .make_fcontext
|
|
+ .quad .make_fcontext,.TOC.@tocbase,0
|
|
+ .size make_fcontext,24
|
|
+ .type .make_fcontext,@function
|
|
+ .text
|
|
+ .align 2
|
|
+.make_fcontext:
|
|
+# endif
|
|
+#endif
|
|
+ # save return address into R6
|
|
+ mflr %r6
|
|
+
|
|
+ # first arg of make_fcontext() == top address of context-stack
|
|
+ # shift address in R3 to lower 16 byte boundary
|
|
+ clrrdi %r3, %r3, 4
|
|
+
|
|
+ # reserve space for context-data on context-stack
|
|
+ # including 64 byte of linkage + parameter area (R1 % 16 == 0)
|
|
+ subi %r3, %r3, 392
|
|
+
|
|
+ # third arg of make_fcontext() == address of context-function
|
|
+ # entry point (ELFv2) or descriptor (ELFv1)
|
|
+#if _CALL_ELF == 2
|
|
+ # save address of context-function entry point
|
|
+ std %r5, 320(%r3)
|
|
+#else
|
|
+ # save address of context-function entry point
|
|
+ ld %r4, 0(%r5)
|
|
+ std %r4, 320(%r3)
|
|
+ # save TOC of context-function
|
|
+ ld %r4, 8(%r5)
|
|
+ std %r4, 152(%r3)
|
|
+#endif
|
|
+
|
|
+ # load LR
|
|
+ mflr %r0
|
|
+ # jump to label 1
|
|
+ bl 1f
|
|
+1:
|
|
+ # load LR into R4
|
|
+ mflr %r4
|
|
+ # compute abs address of label finish
|
|
+ addi %r4, %r4, finish - 1b
|
|
+ # restore LR
|
|
+ mtlr %r0
|
|
+ # save address of finish as return-address for context-function
|
|
+ # will be entered after context-function returns
|
|
+ std %r4, 312(%r3)
|
|
+
|
|
+ # restore return address from R6
|
|
+ mtlr %r6
|
|
+
|
|
+ blr # return pointer to context-data
|
|
+
|
|
+finish:
|
|
+ # save return address into R0
|
|
+ mflr %r0
|
|
+ # save return address on stack, set up stack frame
|
|
+ std %r0, 8(%r1)
|
|
+ # allocate stack space, R1 % 16 == 0
|
|
+ stdu %r1, -32(%r1)
|
|
+
|
|
+ # exit code is zero
|
|
+ li %r3, 0
|
|
+ # exit application
|
|
+ bl _exit
|
|
+ nop
|
|
+#if _CALL_ELF == 2
|
|
+ .size make_fcontext, .-make_fcontext
|
|
+#else
|
|
+# ifdef _CALL_LINUX
|
|
+ .size .make_fcontext, .-.L.make_fcontext
|
|
+# else
|
|
+ .size .make_fcontext, .-.make_fcontext
|
|
+# endif
|
|
+#endif
|
|
+
|
|
+/* Mark that we don't need executable stack. */
|
|
+.section .note.GNU-stack,"",%progbits
|
|
diff --git a/libs/context/test/test_context.cpp b/libs/context/test/test_context.cpp
|
|
--- a/libs/context/test/test_context.cpp
|
|
+++ b/libs/context/test/test_context.cpp
|
|
@@ -27,8 +27,10 @@ typedef ctx::simple_stack_allocator<
|
|
8 * 1024 // 8kB
|
|
> stack_allocator;
|
|
|
|
-ctx::fcontext_t fcm;
|
|
-ctx::fcontext_t * fc = 0;
|
|
+ctx::fcontext_t *fcm = 0;
|
|
+ctx::fcontext_t *fc = 0;
|
|
+ctx::fcontext_t *fc1 = 0;
|
|
+ctx::fcontext_t *fc2 = 0;
|
|
int value1 = 0;
|
|
std::string value2;
|
|
double value3 = 0.;
|
|
@@ -36,25 +38,25 @@ double value3 = 0.;
|
|
void f1( intptr_t)
|
|
{
|
|
++value1;
|
|
- ctx::jump_fcontext( fc, & fcm, 0);
|
|
+ ctx::jump_fcontext( & fc, fcm, 0);
|
|
}
|
|
|
|
void f3( intptr_t)
|
|
{
|
|
++value1;
|
|
- ctx::jump_fcontext( fc, & fcm, 0);
|
|
+ ctx::jump_fcontext( & fc, fcm, 0);
|
|
++value1;
|
|
- ctx::jump_fcontext( fc, & fcm, 0);
|
|
+ ctx::jump_fcontext( & fc, fcm, 0);
|
|
}
|
|
|
|
void f4( intptr_t)
|
|
{
|
|
- ctx::jump_fcontext( fc, & fcm, 7);
|
|
+ ctx::jump_fcontext( & fc, fcm, 7);
|
|
}
|
|
|
|
void f5( intptr_t arg)
|
|
{
|
|
- ctx::jump_fcontext( fc, & fcm, arg);
|
|
+ ctx::jump_fcontext( & fc, fcm, arg);
|
|
}
|
|
|
|
void f6( intptr_t arg)
|
|
@@ -62,9 +64,9 @@ void f6( intptr_t arg)
|
|
std::pair< int, int > data = * ( std::pair< int, int > * ) arg;
|
|
int res = data.first + data.second;
|
|
data = * ( std::pair< int, int > *)
|
|
- ctx::jump_fcontext( fc, & fcm, ( intptr_t) res);
|
|
+ ctx::jump_fcontext( & fc, fcm, ( intptr_t) res);
|
|
res = data.first + data.second;
|
|
- ctx::jump_fcontext( fc, & fcm, ( intptr_t) res);
|
|
+ ctx::jump_fcontext( & fc, fcm, ( intptr_t) res);
|
|
}
|
|
|
|
void f7( intptr_t arg)
|
|
@@ -73,7 +75,7 @@ void f7( intptr_t arg)
|
|
{ throw std::runtime_error( ( char *) arg); }
|
|
catch ( std::runtime_error const& e)
|
|
{ value2 = e.what(); }
|
|
- ctx::jump_fcontext( fc, & fcm, arg);
|
|
+ ctx::jump_fcontext( & fc, fcm, arg);
|
|
}
|
|
|
|
void f8( intptr_t arg)
|
|
@@ -81,7 +83,24 @@ void f8( intptr_t arg)
|
|
double d = * ( double *) arg;
|
|
d += 3.45;
|
|
value3 = d;
|
|
- ctx::jump_fcontext( fc, & fcm, 0);
|
|
+ ctx::jump_fcontext( & fc, fcm, 0);
|
|
+}
|
|
+
|
|
+void f10( intptr_t)
|
|
+{
|
|
+ value1 = 3;
|
|
+ ctx::jump_fcontext( & fc2, fc1, 0);
|
|
+}
|
|
+
|
|
+void f9( intptr_t)
|
|
+{
|
|
+ std::cout << "f1: entered" << std::endl;
|
|
+
|
|
+ stack_allocator alloc;
|
|
+ void * sp = alloc.allocate( stack_allocator::default_stacksize());
|
|
+ fc2 = ctx::make_fcontext( sp, stack_allocator::default_stacksize(), f10);
|
|
+ ctx::jump_fcontext( & fc1, fc2, 0);
|
|
+ ctx::jump_fcontext( & fc1, fcm, 0);
|
|
}
|
|
|
|
void test_setup()
|
|
@@ -91,8 +110,6 @@ void test_setup()
|
|
void * sp = alloc.allocate( stack_allocator::minimum_stacksize() );
|
|
fc = ctx::make_fcontext( sp, stack_allocator::minimum_stacksize(), f1);
|
|
BOOST_CHECK( fc);
|
|
- BOOST_CHECK_EQUAL( sp, fc->fc_stack.sp);
|
|
- BOOST_CHECK_EQUAL( stack_allocator::minimum_stacksize(), fc->fc_stack.size);
|
|
}
|
|
|
|
void test_start()
|
|
@@ -104,8 +121,6 @@ void test_start()
|
|
void * sp = alloc.allocate( stack_allocator::minimum_stacksize() );
|
|
fc = ctx::make_fcontext( sp, stack_allocator::minimum_stacksize(), f1);
|
|
BOOST_CHECK( fc);
|
|
- BOOST_CHECK_EQUAL( sp, fc->fc_stack.sp);
|
|
- BOOST_CHECK_EQUAL( stack_allocator::minimum_stacksize(), fc->fc_stack.size);
|
|
|
|
BOOST_CHECK_EQUAL( 0, value1);
|
|
ctx::jump_fcontext( & fcm, fc, 0);
|
|
@@ -121,8 +136,6 @@ void test_jump()
|
|
void * sp = alloc.allocate( stack_allocator::minimum_stacksize() );
|
|
fc = ctx::make_fcontext( sp, stack_allocator::minimum_stacksize(), f3);
|
|
BOOST_CHECK( fc);
|
|
- BOOST_CHECK_EQUAL( sp, fc->fc_stack.sp);
|
|
- BOOST_CHECK_EQUAL( stack_allocator::minimum_stacksize(), fc->fc_stack.size);
|
|
|
|
BOOST_CHECK_EQUAL( 0, value1);
|
|
ctx::jump_fcontext( & fcm, fc, 0);
|
|
@@ -138,8 +151,6 @@ void test_result()
|
|
void * sp = alloc.allocate( stack_allocator::minimum_stacksize() );
|
|
fc = ctx::make_fcontext( sp, stack_allocator::minimum_stacksize(), f4);
|
|
BOOST_CHECK( fc);
|
|
- BOOST_CHECK_EQUAL( sp, fc->fc_stack.sp);
|
|
- BOOST_CHECK_EQUAL( stack_allocator::minimum_stacksize(), fc->fc_stack.size);
|
|
|
|
int result = ( int) ctx::jump_fcontext( & fcm, fc, 0);
|
|
BOOST_CHECK_EQUAL( 7, result);
|
|
@@ -153,8 +164,6 @@ void test_arg()
|
|
void * sp = alloc.allocate( stack_allocator::minimum_stacksize() );
|
|
fc = ctx::make_fcontext( sp, stack_allocator::minimum_stacksize(), f5);
|
|
BOOST_CHECK( fc);
|
|
- BOOST_CHECK_EQUAL( sp, fc->fc_stack.sp);
|
|
- BOOST_CHECK_EQUAL( stack_allocator::minimum_stacksize(), fc->fc_stack.size);
|
|
|
|
int result = ( int) ctx::jump_fcontext( & fcm, fc, i);
|
|
BOOST_CHECK_EQUAL( i, result);
|
|
@@ -168,8 +177,6 @@ void test_transfer()
|
|
void * sp = alloc.allocate( stack_allocator::minimum_stacksize() );
|
|
fc = ctx::make_fcontext( sp, stack_allocator::minimum_stacksize(), f6);
|
|
BOOST_CHECK( fc);
|
|
- BOOST_CHECK_EQUAL( sp, fc->fc_stack.sp);
|
|
- BOOST_CHECK_EQUAL( stack_allocator::minimum_stacksize(), fc->fc_stack.size);
|
|
|
|
int result = ( int) ctx::jump_fcontext( & fcm, fc, ( intptr_t) & data);
|
|
BOOST_CHECK_EQUAL( 10, result);
|
|
@@ -184,10 +191,8 @@ void test_exception()
|
|
|
|
const char * what = "hello world";
|
|
void * sp = alloc.allocate( stack_allocator::default_stacksize() );
|
|
- fc = ctx::make_fcontext( sp, stack_allocator::default_stacksize(), f7);
|
|
+ fc = ctx::make_fcontext( sp, stack_allocator::minimum_stacksize(), f7);
|
|
BOOST_CHECK( fc);
|
|
- BOOST_CHECK_EQUAL( sp, fc->fc_stack.sp);
|
|
- BOOST_CHECK_EQUAL( stack_allocator::default_stacksize(), fc->fc_stack.size);
|
|
|
|
ctx::jump_fcontext( & fcm, fc, ( intptr_t) what);
|
|
BOOST_CHECK_EQUAL( std::string( what), value2);
|
|
@@ -201,13 +206,21 @@ void test_fp()
|
|
void * sp = alloc.allocate( stack_allocator::minimum_stacksize() );
|
|
fc = ctx::make_fcontext( sp, stack_allocator::minimum_stacksize(), f8);
|
|
BOOST_CHECK( fc);
|
|
- BOOST_CHECK_EQUAL( sp, fc->fc_stack.sp);
|
|
- BOOST_CHECK_EQUAL( stack_allocator::minimum_stacksize(), fc->fc_stack.size);
|
|
|
|
ctx::jump_fcontext( & fcm, fc, (intptr_t) & d);
|
|
BOOST_CHECK_EQUAL( 10.58, value3);
|
|
}
|
|
|
|
+void test_stacked()
|
|
+{
|
|
+ value1 = 0;
|
|
+ stack_allocator alloc;
|
|
+ void * sp = alloc.allocate( stack_allocator::default_stacksize());
|
|
+ fc1 = ctx::make_fcontext( sp, stack_allocator::default_stacksize(), f9);
|
|
+ ctx::jump_fcontext( & fcm, fc1, 0);
|
|
+ BOOST_CHECK_EQUAL( 3, value1);
|
|
+}
|
|
+
|
|
boost::unit_test::test_suite * init_unit_test_suite( int, char* [])
|
|
{
|
|
boost::unit_test::test_suite * test =
|
|
@@ -221,6 +234,7 @@ boost::unit_test::test_suite * init_unit_test_suite( int, char* [])
|
|
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_stacked) );
|
|
|
|
return test;
|
|
}
|