├── .github └── workflows │ └── ng-build.yml ├── .gitignore ├── .gitmodules ├── README.md ├── _clang-format ├── boost_context ├── jump_arm64_aapcs_elf_gas.S ├── jump_arm64_aapcs_macho_gas.S ├── jump_arm_aapcs_elf_gas.S ├── jump_arm_aapcs_macho_gas.S ├── jump_arm_aapcs_pe_armasm.asm ├── jump_combined_sysv_macho_gas.S ├── jump_i386_ms_pe_gas.asm ├── jump_i386_ms_pe_masm.asm ├── jump_i386_sysv_elf_gas.S ├── jump_i386_sysv_macho_gas.S ├── jump_i386_x86_64_sysv_macho_gas.S ├── jump_mips32_o32_elf_gas.S ├── jump_ppc32_ppc64_sysv_macho_gas.S ├── jump_ppc32_sysv_elf_gas.S ├── jump_ppc32_sysv_macho_gas.S ├── jump_ppc32_sysv_xcoff_gas.S ├── jump_ppc64_sysv_elf_gas.S ├── jump_ppc64_sysv_macho_gas.S ├── jump_ppc64_sysv_xcoff_gas.S ├── jump_x86_64_ms_pe_gas.asm ├── jump_x86_64_ms_pe_masm.asm ├── jump_x86_64_sysv_elf_gas.S ├── jump_x86_64_sysv_macho_gas.S ├── make_arm64_aapcs_elf_gas.S ├── make_arm64_aapcs_macho_gas.S ├── make_arm_aapcs_elf_gas.S ├── make_arm_aapcs_macho_gas.S ├── make_arm_aapcs_pe_armasm.asm ├── make_combined_sysv_macho_gas.S ├── make_i386_ms_pe_gas.asm ├── make_i386_ms_pe_masm.asm ├── make_i386_sysv_elf_gas.S ├── make_i386_sysv_macho_gas.S ├── make_i386_x86_64_sysv_macho_gas.S ├── make_mips32_o32_elf_gas.S ├── make_ppc32_ppc64_sysv_macho_gas.S ├── make_ppc32_sysv_elf_gas.S ├── make_ppc32_sysv_macho_gas.S ├── make_ppc32_sysv_xcoff_gas.S ├── make_ppc64_sysv_elf_gas.S ├── make_ppc64_sysv_macho_gas.S ├── make_ppc64_sysv_xcoff_gas.S ├── make_x86_64_ms_pe_gas.asm ├── make_x86_64_ms_pe_masm.asm ├── make_x86_64_sysv_elf_gas.S └── make_x86_64_sysv_macho_gas.S ├── demo ├── Makefile ├── demo_full.cpp ├── demo_profile.cpp ├── demo_simple.cpp ├── ng ├── ng.bat ├── ngen.cfg ├── ngen.linux ├── ngen.osx ├── ngen.win32 └── sln │ ├── demo_full.vcxproj │ ├── demo_full.vcxproj.filters │ ├── demo_profile.vcxproj │ ├── demo_profile.vcxproj.filters │ ├── demo_simple.vcxproj │ ├── demo_simple.vcxproj.filters │ └── jq_demo.sln ├── jq.h ├── jq.sublime-project ├── jq.sublime-workspace ├── jq2.cpp ├── jqfcontext.h ├── jqinternal.cpp └── jqinternal.h /.github/workflows/ng-build.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | push: 4 | branches: [ "main" ] 5 | pull_request: 6 | branches: [ "main" ] 7 | workflow_dispatch: 8 | 9 | jobs: 10 | build-linux: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v3 14 | - uses: seanmiddleditch/gha-setup-ninja@master 15 | 16 | - name: Checkout submodules 17 | run: | 18 | git submodule update --init --recursive 19 | - name: build all 20 | run: | 21 | pushd demo 22 | ./ng all 23 | popd 24 | - name: test simple debug 25 | run: demo/_out/linux/demo_simple_debug 26 | - name: test simple release 27 | run: demo/_out/linux/demo_simple_release 28 | - name: test simple nomicroprofile 29 | run: demo/_out/linux/demo_simple_nomicroprofile 30 | - name: test simple lto 31 | run: demo/_out/linux/demo_simple_lto 32 | - name: test simple asan 33 | run: demo/_out/linux/demo_simple_asan 34 | - name: test simple ubsan 35 | run: demo/_out/linux/demo_simple_ubsan 36 | - name: test simple tsan 37 | run: demo/_out/linux/demo_simple_tsan 38 | - name: test simple msan 39 | run: demo/_out/linux/demo_simple_msan 40 | 41 | build-macos: 42 | runs-on: macos-latest 43 | steps: 44 | - uses: actions/checkout@v3 45 | - uses: seanmiddleditch/gha-setup-ninja@master 46 | 47 | - name: Checkout submodules 48 | run: | 49 | git submodule update --init --recursive 50 | - name: build all 51 | run: | 52 | pushd demo 53 | ./ng all 54 | popd 55 | - name: test simple debug 56 | run: demo/_out/osx/demo_simple_debug 57 | - name: test simple release 58 | run: demo/_out/osx/demo_simple_release 59 | - name: test simple nomicroprofile 60 | run: demo/_out/osx/demo_simple_nomicroprofile 61 | - name: test simple lto 62 | run: demo/_out/osx/demo_simple_lto 63 | - name: test simple asan 64 | run: demo/_out/osx/demo_simple_asan 65 | - name: test simple ubsan 66 | run: demo/_out/osx/demo_simple_ubsan 67 | - name: test simple tsan 68 | run: demo/_out/osx/demo_simple_tsan 69 | 70 | 71 | build-windows: 72 | runs-on: windows-latest 73 | steps: 74 | - uses: actions/checkout@v3 75 | - uses: seanmiddleditch/gha-setup-ninja@master 76 | - uses: ilammy/msvc-dev-cmd@v1 77 | with: 78 | arch: amd64 79 | 80 | - name: Checkout submodules 81 | run: | 82 | git submodule update --init --recursive 83 | - name: build all 84 | run: | 85 | pushd demo 86 | ./ng all 87 | popd 88 | - name: test simple debug 89 | run: demo/_out/win32/demo_simple_debug 90 | - name: test simple release 91 | run: demo/_out/win32/demo_simple_release 92 | - name: test simple nomicroprofile 93 | run: demo/_out/win32/demo_simple_nomicroprofile 94 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | demo/_out 2 | demo/_temp 3 | build.ninja 4 | .ninja_deps 5 | .ninja_log 6 | *.o 7 | *.obj 8 | *.log 9 | *.pdb 10 | *.tlog 11 | *.suo 12 | *.user 13 | *.exe 14 | *.iobj 15 | *.ipdb 16 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "microprofile"] 2 | path = microprofile 3 | url = https://github.com/jonasmr/microprofile.git 4 | [submodule "demo/ngen"] 5 | path = demo/ngen 6 | url = https://github.com/jonasmr/ngen.git 7 | -------------------------------------------------------------------------------- /_clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | # BasedOnStyle: LLVM 3 | AccessModifierOffset: -2 4 | ConstructorInitializerIndentWidth: 4 5 | AlignEscapedNewlinesLeft: false 6 | AlignTrailingComments: true 7 | AlignConsecutiveDeclarations : true 8 | AlignConsecutiveAssignments : true 9 | AllowAllParametersOfDeclarationOnNextLine: false 10 | AllowAllArgumentsOnNextLine : false 11 | AllowShortIfStatementsOnASingleLine: false 12 | AllowShortLoopsOnASingleLine: false 13 | AlwaysBreakTemplateDeclarations: true 14 | AlwaysBreakBeforeMultilineStrings: false 15 | BreakBeforeBinaryOperators: false 16 | AllowShortBlocksOnASingleLine : false 17 | AllowShortFunctionsOnASingleLine : false 18 | BreakConstructorInitializersBeforeComma: true 19 | ColumnLimit: 200 20 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 21 | DerivePointerBinding: false 22 | ExperimentalAutoDetectBinPacking: false 23 | IndentCaseLabels: false 24 | MaxEmptyLinesToKeep: 1 25 | NamespaceIndentation: None 26 | ObjCSpaceBeforeProtocolList: true 27 | PenaltyBreakComment: 60 28 | PenaltyBreakString: 1000 29 | PenaltyBreakFirstLessLess: 120 30 | PenaltyExcessCharacter: 1000000 31 | PenaltyReturnTypeOnItsOwnLine: 60 32 | PointerBindsToType: true 33 | SpacesBeforeTrailingComments: 1 34 | Cpp11BracedListStyle: false 35 | Standard: Cpp03 36 | IndentWidth: 4 37 | TabWidth: 4 38 | UseTab: true 39 | BreakBeforeBraces: Allman 40 | IndentFunctionDeclarationAfterType: false 41 | SpacesInParentheses: false 42 | SpaceInEmptyParentheses: false 43 | SpacesInCStyleCastParentheses: false 44 | SpaceAfterControlStatementKeyword: false 45 | BinPackArguments: true 46 | BinPackParameters: true 47 | AllowShortLambdasOnASingleLine : None 48 | ... 49 | -------------------------------------------------------------------------------- /boost_context/jump_arm64_aapcs_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Edward Nevill + Oliver Kowalke 2015 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | /******************************************************* 8 | * * 9 | * ------------------------------------------------- * 10 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 11 | * ------------------------------------------------- * 12 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 13 | * ------------------------------------------------- * 14 | * | d8 | d9 | d10 | d11 | * 15 | * ------------------------------------------------- * 16 | * ------------------------------------------------- * 17 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 18 | * ------------------------------------------------- * 19 | * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 20 | * ------------------------------------------------- * 21 | * | d12 | d13 | d14 | d15 | * 22 | * ------------------------------------------------- * 23 | * ------------------------------------------------- * 24 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 25 | * ------------------------------------------------- * 26 | * | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| * 27 | * ------------------------------------------------- * 28 | * | x19 | x20 | x21 | x22 | * 29 | * ------------------------------------------------- * 30 | * ------------------------------------------------- * 31 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 32 | * ------------------------------------------------- * 33 | * | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| * 34 | * ------------------------------------------------- * 35 | * | x23 | x24 | x25 | x26 | * 36 | * ------------------------------------------------- * 37 | * ------------------------------------------------- * 38 | * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * 39 | * ------------------------------------------------- * 40 | * | 0x80| 0x84| 0x88| 0x8c| 0x90| 0x94| 0x98| 0x9c| * 41 | * ------------------------------------------------- * 42 | * | x27 | x28 | FP | LR | * 43 | * ------------------------------------------------- * 44 | * ------------------------------------------------- * 45 | * | 40 | 41 | 42 | 43 | | | * 46 | * ------------------------------------------------- * 47 | * | 0xa0| 0xa4| 0xa8| 0xac| | | * 48 | * ------------------------------------------------- * 49 | * | PC | align | | | * 50 | * ------------------------------------------------- * 51 | * * 52 | *******************************************************/ 53 | 54 | .text 55 | .align 2 56 | .global jq_jump_fcontext 57 | .type jq_jump_fcontext, %function 58 | jq_jump_fcontext: 59 | # prepare stack for GP + FPU 60 | sub sp, sp, #0xb0 61 | 62 | # save d8 - d15 63 | stp d8, d9, [sp, #0x00] 64 | stp d10, d11, [sp, #0x10] 65 | stp d12, d13, [sp, #0x20] 66 | stp d14, d15, [sp, #0x30] 67 | 68 | # save x19-x30 69 | stp x19, x20, [sp, #0x40] 70 | stp x21, x22, [sp, #0x50] 71 | stp x23, x24, [sp, #0x60] 72 | stp x25, x26, [sp, #0x70] 73 | stp x27, x28, [sp, #0x80] 74 | stp x29, x30, [sp, #0x90] 75 | 76 | # save LR as PC 77 | str x30, [sp, #0xa0] 78 | 79 | # store RSP (pointing to context-data) in X0 80 | mov x4, sp 81 | 82 | # restore RSP (pointing to context-data) from X1 83 | mov sp, x0 84 | 85 | # load d8 - d15 86 | ldp d8, d9, [sp, #0x00] 87 | ldp d10, d11, [sp, #0x10] 88 | ldp d12, d13, [sp, #0x20] 89 | ldp d14, d15, [sp, #0x30] 90 | 91 | # load x19-x30 92 | ldp x19, x20, [sp, #0x40] 93 | ldp x21, x22, [sp, #0x50] 94 | ldp x23, x24, [sp, #0x60] 95 | ldp x25, x26, [sp, #0x70] 96 | ldp x27, x28, [sp, #0x80] 97 | ldp x29, x30, [sp, #0x90] 98 | 99 | # return transfer_t from jump 100 | # pass transfer_t as first arg in context function 101 | # X0 == FCTX, X1 == DATA 102 | mov x0, x4 103 | 104 | # load pc 105 | ldr x4, [sp, #0xa0] 106 | 107 | # restore stack from GP + FPU 108 | add sp, sp, #0xb0 109 | 110 | ret x4 111 | .size jq_jump_fcontext,.-jq_jump_fcontext 112 | # Mark that we don't need executable stack. 113 | .section .note.GNU-stack,"",%progbits 114 | -------------------------------------------------------------------------------- /boost_context/jump_arm64_aapcs_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Edward Nevill + Oliver Kowalke 2015 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | /******************************************************* 8 | * * 9 | * ------------------------------------------------- * 10 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 11 | * ------------------------------------------------- * 12 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 13 | * ------------------------------------------------- * 14 | * | d8 | d9 | d10 | d11 | * 15 | * ------------------------------------------------- * 16 | * ------------------------------------------------- * 17 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 18 | * ------------------------------------------------- * 19 | * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 20 | * ------------------------------------------------- * 21 | * | d12 | d13 | d14 | d15 | * 22 | * ------------------------------------------------- * 23 | * ------------------------------------------------- * 24 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 25 | * ------------------------------------------------- * 26 | * | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| * 27 | * ------------------------------------------------- * 28 | * | x19 | x20 | x21 | x22 | * 29 | * ------------------------------------------------- * 30 | * ------------------------------------------------- * 31 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 32 | * ------------------------------------------------- * 33 | * | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| * 34 | * ------------------------------------------------- * 35 | * | x23 | x24 | x25 | x26 | * 36 | * ------------------------------------------------- * 37 | * ------------------------------------------------- * 38 | * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * 39 | * ------------------------------------------------- * 40 | * | 0x80| 0x84| 0x88| 0x8c| 0x90| 0x94| 0x98| 0x9c| * 41 | * ------------------------------------------------- * 42 | * | x27 | x28 | FP | LR | * 43 | * ------------------------------------------------- * 44 | * ------------------------------------------------- * 45 | * | 40 | 41 | 42 | 43 | | | * 46 | * ------------------------------------------------- * 47 | * | 0xa0| 0xa4| 0xa8| 0xac| | | * 48 | * ------------------------------------------------- * 49 | * | PC | align | | | * 50 | * ------------------------------------------------- * 51 | * * 52 | *******************************************************/ 53 | 54 | .text 55 | .globl _jq_jump_fcontext 56 | .balign 16 57 | _jq_jump_fcontext: 58 | ; prepare stack for GP + FPU 59 | sub sp, sp, #0xb0 60 | 61 | ; save d8 - d15 62 | stp d8, d9, [sp, #0x00] 63 | stp d10, d11, [sp, #0x10] 64 | stp d12, d13, [sp, #0x20] 65 | stp d14, d15, [sp, #0x30] 66 | 67 | ; save x19-x30 68 | stp x19, x20, [sp, #0x40] 69 | stp x21, x22, [sp, #0x50] 70 | stp x23, x24, [sp, #0x60] 71 | stp x25, x26, [sp, #0x70] 72 | stp x27, x28, [sp, #0x80] 73 | stp fp, lr, [sp, #0x90] 74 | 75 | ; save LR as PC 76 | str lr, [sp, #0xa0] 77 | 78 | ; store RSP (pointing to context-data) in X0 79 | mov x4, sp 80 | 81 | ; restore RSP (pointing to context-data) from X1 82 | mov sp, x0 83 | 84 | ; load d8 - d15 85 | ldp d8, d9, [sp, #0x00] 86 | ldp d10, d11, [sp, #0x10] 87 | ldp d12, d13, [sp, #0x20] 88 | ldp d14, d15, [sp, #0x30] 89 | 90 | ; load x19-x30 91 | ldp x19, x20, [sp, #0x40] 92 | ldp x21, x22, [sp, #0x50] 93 | ldp x23, x24, [sp, #0x60] 94 | ldp x25, x26, [sp, #0x70] 95 | ldp x27, x28, [sp, #0x80] 96 | ldp fp, lr, [sp, #0x90] 97 | 98 | ; return transfer_t from jump 99 | ; pass transfer_t as first arg in context function 100 | ; X0 == FCTX, X1 == DATA 101 | mov x0, x4 102 | 103 | ; load pc 104 | ldr x4, [sp, #0xa0] 105 | 106 | ; restore stack from GP + FPU 107 | add sp, sp, #0xb0 108 | 109 | ret x4 110 | -------------------------------------------------------------------------------- /boost_context/jump_arm_aapcs_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /******************************************************* 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 14 | * ------------------------------------------------- * 15 | * | s16 | s17 | s18 | s19 | s20 | s21 | s22 | s23 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 21 | * ------------------------------------------------- * 22 | * | s24 | s25 | s26 | s27 | s28 | s29 | s30 | s31 | * 23 | * ------------------------------------------------- * 24 | * ------------------------------------------------- * 25 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 26 | * ------------------------------------------------- * 27 | * | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| * 28 | * ------------------------------------------------- * 29 | * |hiddn| v1 | v2 | v3 | v4 | v5 | v6 | v7 | * 30 | * ------------------------------------------------- * 31 | * ------------------------------------------------- * 32 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 33 | * ------------------------------------------------- * 34 | * | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| * 35 | * ------------------------------------------------- * 36 | * | v8 | lr | pc | FCTX| DATA| | * 37 | * ------------------------------------------------- * 38 | * * 39 | *******************************************************/ 40 | 41 | .text 42 | .globl jq_jump_fcontext 43 | .align 2 44 | .type jq_jump_fcontext,%function 45 | jq_jump_fcontext: 46 | @ save LR as PC 47 | push {lr} 48 | @ save hidden,V1-V8,LR 49 | push {a1,v1-v8,lr} 50 | 51 | @ prepare stack for FPU 52 | sub sp, sp, #64 53 | #if (defined(__VFP_FP__) && !defined(__SOFTFP__)) 54 | @ save S16-S31 55 | vstmia sp, {d8-d15} 56 | #endif 57 | 58 | @ store RSP (pointing to context-data) in A1 59 | mov a1, sp 60 | 61 | @ restore RSP (pointing to context-data) from A2 62 | mov sp, a2 63 | 64 | #if (defined(__VFP_FP__) && !defined(__SOFTFP__)) 65 | @ restore S16-S31 66 | vldmia sp, {d8-d15} 67 | #endif 68 | @ prepare stack for FPU 69 | add sp, sp, #64 70 | 71 | @ restore hidden,V1-V8,LR 72 | pop {a4,v1-v8,lr} 73 | 74 | @ return transfer_t from jump 75 | str a1, [a4, #0] 76 | str a3, [a4, #4] 77 | @ pass transfer_t as first arg in context function 78 | @ A1 == FCTX, A2 == DATA 79 | mov a2, a3 80 | 81 | @ restore PC 82 | pop {pc} 83 | .size jq_jump_fcontext,.-jq_jump_fcontext 84 | 85 | @ Mark that we don't need executable stack. 86 | .section .note.GNU-stack,"",%progbits 87 | -------------------------------------------------------------------------------- /boost_context/jump_arm_aapcs_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /******************************************************* 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 14 | * ------------------------------------------------- * 15 | * | s16 | s17 | s18 | s19 | s20 | s21 | s22 | s23 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 21 | * ------------------------------------------------- * 22 | * | s24 | s25 | s26 | s27 | s28 | s29 | s30 | s31 | * 23 | * ------------------------------------------------- * 24 | * ------------------------------------------------- * 25 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 26 | * ------------------------------------------------- * 27 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 28 | * ------------------------------------------------- * 29 | * | sjlj|hiddn| v1 | v2 | v3 | v4 | v5 | v6 | * 30 | * ------------------------------------------------- * 31 | * ------------------------------------------------- * 32 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 33 | * ------------------------------------------------- * 34 | * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 35 | * ------------------------------------------------- * 36 | * | v7 | v8 | lr | pc | FCTX| DATA| | * 37 | * ------------------------------------------------- * 38 | * * 39 | *******************************************************/ 40 | 41 | .text 42 | .globl _jq_jump_fcontext 43 | .align 2 44 | _jq_jump_fcontext: 45 | @ save LR as PC 46 | push {lr} 47 | @ save hidden,V1-V8,LR 48 | push {a1,v1-v8,lr} 49 | 50 | @ locate TLS to save/restore SjLj handler 51 | mrc p15, 0, v2, c13, c0, #3 52 | bic v2, v2, #3 53 | 54 | @ load TLS[__PTK_LIBC_DYLD_Unwind_SjLj_Key] 55 | ldr v1, [v2, #8] 56 | @ save SjLj handler 57 | push {v1} 58 | 59 | @ prepare stack for FPU 60 | sub sp, sp, #64 61 | #if (defined(__VFP_FP__) && !defined(__SOFTFP__)) 62 | @ save S16-S31 63 | vstmia sp, {d8-d15} 64 | #endif 65 | 66 | @ store RSP (pointing to context-data) in A1 67 | mov a1, sp 68 | 69 | @ restore RSP (pointing to context-data) from A2 70 | mov sp, a2 71 | 72 | #if (defined(__VFP_FP__) && !defined(__SOFTFP__)) 73 | @ restore S16-S31 74 | vldmia sp, {d8-d15} 75 | #endif 76 | @ prepare stack for FPU 77 | add sp, sp, #64 78 | 79 | @ r#estore SjLj handler 80 | pop {v1} 81 | @ store SjLj handler in TLS 82 | str v1, [v2, #8] 83 | 84 | @ restore hidden,V1-V8,LR 85 | pop {a4,v1-v8,lr} 86 | 87 | @ return transfer_t from jump 88 | str a1, [a4, #0] 89 | str a3, [a4, #4] 90 | @ pass transfer_t as first arg in context function 91 | @ A1 == FCTX, A2 == DATA 92 | mov a2, a3 93 | 94 | @ restore PC 95 | pop {pc} 96 | -------------------------------------------------------------------------------- /boost_context/jump_arm_aapcs_pe_armasm.asm: -------------------------------------------------------------------------------- 1 | ;/* 2 | ; Copyright Oliver Kowalke 2009. 3 | ; Distributed under the Boost Software License, Version 1.0. 4 | ; (See accompanying file LICENSE_1_0.txt or copy at 5 | ; http://www.boost.org/LICENSE_1_0.txt) 6 | ;*/ 7 | 8 | ; ******************************************************* 9 | ; * * 10 | ; * ------------------------------------------------- * 11 | ; * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | ; * ------------------------------------------------- * 13 | ; * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 14 | ; * ------------------------------------------------- * 15 | ; * |deall|limit| base|hiddn| v1 | v2 | v3 | v4 | * 16 | ; * ------------------------------------------------- * 17 | ; * ------------------------------------------------- * 18 | ; * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | ; * ------------------------------------------------- * 20 | ; * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 21 | ; * ------------------------------------------------- * 22 | ; * | v5 | v6 | v7 | v8 | lr | pc | FCTX| DATA| * 23 | ; * ------------------------------------------------- * 24 | ; * * 25 | ; ******************************************************* 26 | 27 | AREA |.text|, CODE 28 | ALIGN 4 29 | EXPORT jq_jump_fcontext 30 | 31 | jq_jump_fcontext PROC 32 | ; save LR as PC 33 | push {lr} 34 | ; save hidden,V1-V8,LR 35 | push {a1,v1-v8,lr} 36 | 37 | ; load TIB to save/restore thread size and limit. 38 | ; we do not need preserve CPU flag and can use it's arg register 39 | mrc p15, #0, v1, c13, c0, #2 40 | 41 | ; save current stack base 42 | ldr a5, [v1, #0x04] 43 | push {a5} 44 | ; save current stack limit 45 | ldr a5, [v1, #0x08] 46 | push {a5} 47 | ; save current deallocation stack 48 | ldr a5, [v1, #0xe0c] 49 | push {a5} 50 | 51 | ; store RSP (pointing to context-data) in A1 52 | mov a1, sp 53 | 54 | ; restore RSP (pointing to context-data) from A2 55 | mov sp, a2 56 | 57 | ; restore deallocation stack 58 | pop {a5} 59 | str a5, [v1, #0xe0c] 60 | ; restore stack limit 61 | pop {a5} 62 | str a5, [v1, #0x08] 63 | ; restore stack base 64 | pop {a5} 65 | str a5, [v1, #0x04] 66 | 67 | ; restore hidden,V1-V8,LR 68 | pop {a4,v1-v8,lr} 69 | 70 | ; return transfer_t from jump 71 | str a1, [a4, #0] 72 | str a3, [a4, #4] 73 | ; pass transfer_t as first arg in context function 74 | ; A1 == FCTX, A2 == DATA 75 | mov a2, a3 76 | 77 | ; restore PC 78 | pop {pc} 79 | 80 | ENDP 81 | END 82 | -------------------------------------------------------------------------------- /boost_context/jump_combined_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Sergue E. Leontiev 2013. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Stub file for universal binary 9 | 10 | #if defined(__i386__) 11 | #include "jump_i386_sysv_macho_gas.S" 12 | #elif defined(__x86_64__) 13 | #include "jump_x86_64_sysv_macho_gas.S" 14 | #elif defined(__ppc__) 15 | #include "jump_ppc32_sysv_macho_gas.S" 16 | #elif defined(__ppc64__) 17 | #include "jump_ppc64_sysv_macho_gas.S" 18 | #else 19 | #error "No arch's" 20 | #endif 21 | -------------------------------------------------------------------------------- /boost_context/jump_i386_ms_pe_gas.asm: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Copyright Thomas Sailer 2013. 4 | Distributed under the Boost Software License, Version 1.0. 5 | (See accompanying file LICENSE_1_0.txt or copy at 6 | http://www.boost.org/LICENSE_1_0.txt) 7 | */ 8 | 9 | /************************************************************************************* 10 | * --------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * --------------------------------------------------------------------------------- * 13 | * | 0h | 04h | 08h | 0ch | 010h | 014h | 018h | 01ch | * 14 | * --------------------------------------------------------------------------------- * 15 | * | fc_mxcsr|fc_x87_cw| fc_strg |fc_deallo| limit | base | fc_seh | EDI | * 16 | * --------------------------------------------------------------------------------- * 17 | * --------------------------------------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * --------------------------------------------------------------------------------- * 20 | * | 020h | 024h | 028h | 02ch | 030h | 034h | 038h | 03ch | * 21 | * --------------------------------------------------------------------------------- * 22 | * | ESI | EBX | EBP | EIP | to | data | EH NXT |SEH HNDLR| * 23 | * --------------------------------------------------------------------------------- * 24 | **************************************************************************************/ 25 | 26 | .file "jump_i386_ms_pe_gas.asm" 27 | .text 28 | .p2align 4,,15 29 | .globl _jq_jump_fcontext 30 | .def _jq_jump_fcontext; .scl 2; .type 32; .endef 31 | _jq_jump_fcontext: 32 | /* prepare stack */ 33 | leal -0x2c(%esp), %esp 34 | 35 | /* save MMX control- and status-word */ 36 | stmxcsr (%esp) 37 | /* save x87 control-word */ 38 | fnstcw 0x4(%esp) 39 | 40 | /* load NT_TIB */ 41 | movl %fs:(0x18), %edx 42 | /* load fiber local storage */ 43 | movl 0x10(%edx), %eax 44 | movl %eax, 0x8(%esp) 45 | /* load current dealloction stack */ 46 | movl 0xe0c(%edx), %eax 47 | movl %eax, 0xc(%esp) 48 | /* load current stack limit */ 49 | movl 0x8(%edx), %eax 50 | movl %eax, 0x10(%esp) 51 | /* load current stack base */ 52 | movl 0x4(%edx), %eax 53 | movl %eax, 0x14(%esp) 54 | /* load current SEH exception list */ 55 | movl (%edx), %eax 56 | movl %eax, 0x18(%esp) 57 | 58 | movl %edi, 0x1c(%esp) /* save EDI */ 59 | movl %esi, 0x20(%esp) /* save ESI */ 60 | movl %ebx, 0x24(%esp) /* save EBX */ 61 | movl %ebp, 0x28(%esp) /* save EBP */ 62 | 63 | /* store ESP (pointing to context-data) in EAX */ 64 | movl %esp, %eax 65 | 66 | /* firstarg of jq_jump_fcontext() == fcontext to jump to */ 67 | movl 0x30(%esp), %ecx 68 | 69 | /* restore ESP (pointing to context-data) from ECX */ 70 | movl %ecx, %esp 71 | 72 | /* restore MMX control- and status-word */ 73 | ldmxcsr (%esp) 74 | /* restore x87 control-word */ 75 | fldcw 0x4(%esp) 76 | 77 | /* restore NT_TIB into EDX */ 78 | movl %fs:(0x18), %edx 79 | /* restore fiber local storage */ 80 | movl 0x8(%esp), %ecx 81 | movl %ecx, 0x10(%edx) 82 | /* restore current deallocation stack */ 83 | movl 0xc(%esp), %ecx 84 | movl %ecx, 0xe0c(%edx) 85 | /* restore current stack limit */ 86 | movl 0x10(%esp), %ecx 87 | movl %ecx, 0x8(%edx) 88 | /* restore current stack base */ 89 | movl 0x14(%esp), %ecx 90 | movl %ecx, 0x4(%edx) 91 | /* restore current SEH exception list */ 92 | movl 0x18(%esp), %ecx 93 | movl %ecx, (%edx) 94 | 95 | movl 0x2c(%esp), %ecx /* restore EIP */ 96 | 97 | movl 0x1c(%esp), %edi /* restore EDI */ 98 | movl 0x20(%esp), %esi /* restore ESI */ 99 | movl 0x24(%esp), %ebx /* restore EBX */ 100 | movl 0x28(%esp), %ebp /* restore EBP */ 101 | 102 | /* prepare stack */ 103 | leal 0x30(%esp), %esp 104 | 105 | /* return transfer_t */ 106 | /* FCTX == EAX, DATA == EDX */ 107 | movl 0x34(%eax), %edx 108 | 109 | /* jump to context */ 110 | jmp *%ecx 111 | 112 | .section .drectve 113 | .ascii " -export:\"jq_jump_fcontext\"" 114 | -------------------------------------------------------------------------------- /boost_context/jump_i386_ms_pe_masm.asm: -------------------------------------------------------------------------------- 1 | 2 | ; Copyright Oliver Kowalke 2009. 3 | ; Distributed under the Boost Software License, Version 1.0. 4 | ; (See accompanying file LICENSE_1_0.txt or copy at 5 | ; http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | ; --------------------------------------------------------------------------------- 8 | ; | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | ; --------------------------------------------------------------------------------- 10 | ; | 0h | 04h | 08h | 0ch | 010h | 014h | 018h | 01ch | 11 | ; --------------------------------------------------------------------------------- 12 | ; | fc_mxcsr|fc_x87_cw| fc_strg |fc_deallo| limit | base | fc_seh | EDI | 13 | ; --------------------------------------------------------------------------------- 14 | ; --------------------------------------------------------------------------------- 15 | ; | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | ; --------------------------------------------------------------------------------- 17 | ; | 020h | 024h | 028h | 02ch | 030h | 034h | 038h | 03ch | 18 | ; --------------------------------------------------------------------------------- 19 | ; | ESI | EBX | EBP | EIP | to | data | EH NXT |SEH HNDLR| 20 | ; --------------------------------------------------------------------------------- 21 | 22 | .386 23 | .XMM 24 | .model flat, c 25 | .code 26 | 27 | jq_jump_fcontext PROC BOOST_CONTEXT_EXPORT 28 | ; prepare stack 29 | lea esp, [esp-02ch] 30 | 31 | ; save MMX control- and status-word 32 | stmxcsr [esp] 33 | ; save x87 control-word 34 | fnstcw [esp+04h] 35 | 36 | assume fs:nothing 37 | ; load NT_TIB into ECX 38 | mov edx, fs:[018h] 39 | assume fs:error 40 | ; load fiber local storage 41 | mov eax, [edx+010h] 42 | mov [esp+08h], eax 43 | ; load current deallocation stack 44 | mov eax, [edx+0e0ch] 45 | mov [esp+0ch], eax 46 | ; load current stack limit 47 | mov eax, [edx+08h] 48 | mov [esp+010h], eax 49 | ; load current stack base 50 | mov eax, [edx+04h] 51 | mov [esp+014h], eax 52 | ; load current SEH exception list 53 | mov eax, [edx] 54 | mov [esp+018h], eax 55 | 56 | mov [esp+01ch], edi ; save EDI 57 | mov [esp+020h], esi ; save ESI 58 | mov [esp+024h], ebx ; save EBX 59 | mov [esp+028h], ebp ; save EBP 60 | 61 | ; store ESP (pointing to context-data) in EAX 62 | mov eax, esp 63 | 64 | ; firstarg of jq_jump_fcontext() == fcontext to jump to 65 | mov ecx, [esp+030h] 66 | 67 | ; restore ESP (pointing to context-data) from ECX 68 | mov esp, ecx 69 | 70 | ; restore MMX control- and status-word 71 | ldmxcsr [esp] 72 | ; restore x87 control-word 73 | fldcw [esp+04h] 74 | 75 | assume fs:nothing 76 | ; load NT_TIB into EDX 77 | mov edx, fs:[018h] 78 | assume fs:error 79 | ; restore fiber local storage 80 | mov ecx, [esp+08h] 81 | mov [edx+010h], ecx 82 | ; restore current deallocation stack 83 | mov ecx, [esp+0ch] 84 | mov [edx+0e0ch], ecx 85 | ; restore current stack limit 86 | mov ecx, [esp+010h] 87 | mov [edx+08h], ecx 88 | ; restore current stack base 89 | mov ecx, [esp+014h] 90 | mov [edx+04h], ecx 91 | ; restore current SEH exception list 92 | mov ecx, [esp+018h] 93 | mov [edx], ecx 94 | 95 | mov ecx, [esp+02ch] ; restore EIP 96 | 97 | mov edi, [esp+01ch] ; restore EDI 98 | mov esi, [esp+020h] ; restore ESI 99 | mov ebx, [esp+024h] ; restore EBX 100 | mov ebp, [esp+028h] ; restore EBP 101 | 102 | ; prepare stack 103 | lea esp, [esp+030h] 104 | 105 | ; return transfer_t 106 | ; FCTX == EAX, DATA == EDX 107 | mov edx, [eax+034h] 108 | 109 | ; jump to context 110 | jmp ecx 111 | jq_jump_fcontext ENDP 112 | END 113 | -------------------------------------------------------------------------------- /boost_context/jump_i386_sysv_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /**************************************************************************************** 9 | * * 10 | * ---------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ---------------------------------------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | * 14 | * ---------------------------------------------------------------------------------- * 15 | * | fc_mxcsr|fc_x87_cw| EDI | ESI | EBX | EBP | EIP | hidden | * 16 | * ---------------------------------------------------------------------------------- * 17 | * ---------------------------------------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ---------------------------------------------------------------------------------- * 20 | * | 0x20 | 0x24 | | * 21 | * ---------------------------------------------------------------------------------- * 22 | * | to | data | | * 23 | * ---------------------------------------------------------------------------------- * 24 | * * 25 | ****************************************************************************************/ 26 | 27 | .text 28 | .globl jq_jump_fcontext 29 | .align 2 30 | .type jq_jump_fcontext,@function 31 | jq_jump_fcontext: 32 | leal -0x18(%esp), %esp /* prepare stack */ 33 | 34 | stmxcsr (%esp) /* save MMX control- and status-word */ 35 | fnstcw 0x4(%esp) /* save x87 control-word */ 36 | 37 | movl %edi, 0x8(%esp) /* save EDI */ 38 | movl %esi, 0xc(%esp) /* save ESI */ 39 | movl %ebx, 0x10(%esp) /* save EBX */ 40 | movl %ebp, 0x14(%esp) /* save EBP */ 41 | 42 | /* store ESP (pointing to context-data) in ECX */ 43 | movl %esp, %ecx 44 | 45 | /* first arg of jq_jump_fcontext() == fcontext to jump to */ 46 | movl 0x20(%esp), %eax 47 | 48 | /* second arg of jq_jump_fcontext() == data to be transferred */ 49 | movl 0x24(%esp), %edx 50 | 51 | /* restore ESP (pointing to context-data) from EAX */ 52 | movl %eax, %esp 53 | 54 | /* address of returned transport_t */ 55 | movl 0x1c(%esp), %eax 56 | /* return parent fcontext_t */ 57 | movl %ecx, (%eax) 58 | /* return data */ 59 | movl %edx, 0x4(%eax) 60 | 61 | movl 0x18(%esp), %ecx /* restore EIP */ 62 | 63 | ldmxcsr (%esp) /* restore MMX control- and status-word */ 64 | fldcw 0x4(%esp) /* restore x87 control-word */ 65 | 66 | movl 0x8(%esp), %edi /* restore EDI */ 67 | movl 0xc(%esp), %esi /* restore ESI */ 68 | movl 0x10(%esp), %ebx /* restore EBX */ 69 | movl 0x14(%esp), %ebp /* restore EBP */ 70 | 71 | leal 0x20(%esp), %esp /* prepare stack */ 72 | 73 | /* jump to context */ 74 | jmp *%ecx 75 | .size jq_jump_fcontext,.-jq_jump_fcontext 76 | 77 | /* Mark that we don't need executable stack. */ 78 | .section .note.GNU-stack,"",%progbits 79 | -------------------------------------------------------------------------------- /boost_context/jump_i386_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /**************************************************************************************** 9 | * * 10 | * ---------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ---------------------------------------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | * 14 | * ---------------------------------------------------------------------------------- * 15 | * | fc_mxcsr|fc_x87_cw| EDI | ESI | EBX | EBP | EIP | hidden | * 16 | * ---------------------------------------------------------------------------------- * 17 | * ---------------------------------------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ---------------------------------------------------------------------------------- * 20 | * | 0x20 | 0x24 | | * 21 | * ---------------------------------------------------------------------------------- * 22 | * | to | data | | * 23 | * ---------------------------------------------------------------------------------- * 24 | * * 25 | ****************************************************************************************/ 26 | 27 | .text 28 | .globl _jq_jump_fcontext 29 | .align 2 30 | _jq_jump_fcontext: 31 | leal -0x18(%esp), %esp /* prepare stack */ 32 | 33 | stmxcsr (%esp) /* save MMX control- and status-word */ 34 | fnstcw 0x4(%esp) /* save x87 control-word */ 35 | 36 | movl %edi, 0x8(%esp) /* save EDI */ 37 | movl %esi, 0xc(%esp) /* save ESI */ 38 | movl %ebx, 0x10(%esp) /* save EBX */ 39 | movl %ebp, 0x14(%esp) /* save EBP */ 40 | 41 | /* store ESP (pointing to context-data) in ECX */ 42 | movl %esp, %ecx 43 | 44 | /* first arg of jump_fcontext() == fcontext to jump to */ 45 | movl 0x20(%esp), %eax 46 | 47 | /* second arg of jump_fcontext() == data to be transferred */ 48 | movl 0x24(%esp), %edx 49 | 50 | /* restore ESP (pointing to context-data) from EAX */ 51 | movl %eax, %esp 52 | 53 | /* address of returned transport_t */ 54 | movl 0x1c(%esp), %eax 55 | /* return parent fcontext_t */ 56 | movl %ecx, (%eax) 57 | /* return data */ 58 | movl %edx, 0x4(%eax) 59 | 60 | movl 0x18(%esp), %ecx /* restore EIP */ 61 | 62 | ldmxcsr (%esp) /* restore MMX control- and status-word */ 63 | fldcw 0x4(%esp) /* restore x87 control-word */ 64 | 65 | movl 0x8(%esp), %edi /* restore EDI */ 66 | movl 0xc(%esp), %esi /* restore ESI */ 67 | movl 0x10(%esp), %ebx /* restore EBX */ 68 | movl 0x14(%esp), %ebp /* restore EBP */ 69 | 70 | leal 0x20(%esp), %esp /* prepare stack */ 71 | 72 | /* jump to context */ 73 | jmp *%ecx 74 | -------------------------------------------------------------------------------- /boost_context/jump_i386_x86_64_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Sergue E. Leontiev 2013. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Stub file for universal binary 9 | 10 | #if defined(__i386__) 11 | #include "jump_i386_sysv_macho_gas.S" 12 | #elif defined(__x86_64__) 13 | #include "jump_x86_64_sysv_macho_gas.S" 14 | #else 15 | #error "No arch's" 16 | #endif 17 | -------------------------------------------------------------------------------- /boost_context/jump_mips32_o32_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /******************************************************* 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | * 14 | * ------------------------------------------------- * 15 | * | F20 | F22 | F24 | F26 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | * 21 | * ------------------------------------------------- * 22 | * | F28 | F30 | S0 | S1 | S2 | S3 | * 23 | * ------------------------------------------------- * 24 | * ------------------------------------------------- * 25 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 26 | * ------------------------------------------------- * 27 | * | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | * 28 | * ------------------------------------------------- * 29 | * | S4 | S5 | S6 | S7 | FP |hiddn| RA | PC | * 30 | * ------------------------------------------------- * 31 | * ------------------------------------------------- * 32 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 33 | * ------------------------------------------------- * 34 | * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | * 35 | * ------------------------------------------------- * 36 | * | GP | FCTX| DATA| | | | | | * 37 | * ------------------------------------------------- * 38 | * * 39 | * *****************************************************/ 40 | 41 | .text 42 | .globl jq_jump_fcontext 43 | .align 2 44 | .type jq_jump_fcontext,@function 45 | .ent jq_jump_fcontext 46 | jq_jump_fcontext: 47 | # reserve space on stack 48 | addiu $sp, $sp, -112 49 | 50 | sw $s0, 48($sp) # save S0 51 | sw $s1, 52($sp) # save S1 52 | sw $s2, 56($sp) # save S2 53 | sw $s3, 60($sp) # save S3 54 | sw $s4, 64($sp) # save S4 55 | sw $s5, 68($sp) # save S5 56 | sw $s6, 72($sp) # save S6 57 | sw $s7, 76($sp) # save S7 58 | sw $fp, 80($sp) # save FP 59 | sw $a0, 84($sp) # save hidden, address of returned transfer_t 60 | sw $ra, 88($sp) # save RA 61 | sw $ra, 92($sp) # save RA as PC 62 | 63 | #if defined(__mips_hard_float) 64 | s.d $f20, ($sp) # save F20 65 | s.d $f22, 8($sp) # save F22 66 | s.d $f24, 16($sp) # save F24 67 | s.d $f26, 24($sp) # save F26 68 | s.d $f28, 32($sp) # save F28 69 | s.d $f30, 40($sp) # save F30 70 | #endif 71 | 72 | # store SP (pointing to context-data) in A0 73 | move $a0, $sp 74 | 75 | # restore SP (pointing to context-data) from A1 76 | move $sp, $a1 77 | 78 | #if defined(__mips_hard_float) 79 | l.d $f20, ($sp) # restore F20 80 | l.d $f22, 8($sp) # restore F22 81 | l.d $f24, 16($sp) # restore F24 82 | l.d $f26, 24($sp) # restore F26 83 | l.d $f28, 32($sp) # restore F28 84 | l.d $f30, 40($sp) # restore F30 85 | #endif 86 | 87 | lw $s0, 48($sp) # restore S0 88 | lw $s1, 52($sp) # restore S1 89 | lw $s2, 56($sp) # restore S2 90 | lw $s3, 60($sp) # restore S3 91 | lw $s4, 64($sp) # restore S4 92 | lw $s5, 68($sp) # restore S5 93 | lw $s6, 72($sp) # restore S6 94 | lw $s7, 76($sp) # restore S7 95 | lw $fp, 80($sp) # restore FP 96 | lw $t0, 84($sp) # restore hidden, address of returned transfer_t 97 | lw $ra, 88($sp) # restore RA 98 | 99 | # load PC 100 | lw $t9, 92($sp) 101 | 102 | # adjust stack 103 | addiu $sp, $sp, 112 104 | 105 | # return transfer_t from jump 106 | sw $a0, ($t0) # fctx of transfer_t 107 | sw $a2, 4($t0) # data of transfer_t 108 | # pass transfer_t as first arg in context function 109 | # A0 == fctx, A1 == data 110 | move $a1, $a2 111 | 112 | # jump to context 113 | jr $t9 114 | .end jq_jump_fcontext 115 | .size jq_jump_fcontext, .-jq_jump_fcontext 116 | 117 | /* Mark that we don't need executable stack. */ 118 | .section .note.GNU-stack,"",%progbits 119 | -------------------------------------------------------------------------------- /boost_context/jump_ppc32_ppc64_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Sergue E. Leontiev 2013. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Stub file for universal binary 9 | 10 | #if defined(__ppc__) 11 | #include "jump_ppc32_sysv_macho_gas.S" 12 | #elif defined(__ppc64__) 13 | #include "jump_ppc64_sysv_macho_gas.S" 14 | #else 15 | #error "No arch's" 16 | #endif 17 | -------------------------------------------------------------------------------- /boost_context/jump_ppc32_sysv_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /****************************************************** 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | * 14 | * ------------------------------------------------- * 15 | * | F14 | F15 | F16 | F17 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | * 21 | * ------------------------------------------------- * 22 | * | F18 | F19 | F20 | F21 | * 23 | * ------------------------------------------------- * 24 | * ------------------------------------------------- * 25 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 26 | * ------------------------------------------------- * 27 | * | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | * 28 | * ------------------------------------------------- * 29 | * | F22 | F23 | F24 | F25 | * 30 | * ------------------------------------------------- * 31 | * ------------------------------------------------- * 32 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 33 | * ------------------------------------------------- * 34 | * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | * 35 | * ------------------------------------------------- * 36 | * | F26 | F27 | F28 | F29 | * 37 | * ------------------------------------------------- * 38 | * ------------------------------------------------- * 39 | * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * 40 | * ------------------------------------------------- * 41 | * | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | * 42 | * ------------------------------------------------- * 43 | * | F30 | F31 | fpscr | R13 | R14 | * 44 | * ------------------------------------------------- * 45 | * ------------------------------------------------- * 46 | * | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | * 47 | * ------------------------------------------------- * 48 | * | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | * 49 | * ------------------------------------------------- * 50 | * | R15 | R16 | R17 | R18 | R19 | R20 | R21 | R22 | * 51 | * ------------------------------------------------- * 52 | * ------------------------------------------------- * 53 | * | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | * 54 | * ------------------------------------------------- * 55 | * | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | * 56 | * ------------------------------------------------- * 57 | * | R23 | R24 | R25 | R26 | R27 | R28 | R29 | R30 | * 58 | * ------------------------------------------------- * 59 | * ------------------------------------------------- * 60 | * | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | * 61 | * ------------------------------------------------- * 62 | * | 224 | 228 | 232 | 236 | 240 | 244 | 248 | 252 | * 63 | * ------------------------------------------------- * 64 | * | R31 |hiddn| CR | LR | PC |bchai|linkr| FCTX| * 65 | * ------------------------------------------------- * 66 | * ------------------------------------------------- * 67 | * | 64 | | * 68 | * ------------------------------------------------- * 69 | * | 256 | | * 70 | * ------------------------------------------------- * 71 | * | DATA| | * 72 | * ------------------------------------------------- * 73 | * * 74 | *******************************************************/ 75 | 76 | .text 77 | .globl jq_jump_fcontext 78 | .align 2 79 | .type jq_jump_fcontext,@function 80 | jq_jump_fcontext: 81 | # reserve space on stack 82 | subi %r1, %r1, 244 83 | 84 | stfd %f14, 0(%r1) # save F14 85 | stfd %f15, 8(%r1) # save F15 86 | stfd %f16, 16(%r1) # save F16 87 | stfd %f17, 24(%r1) # save F17 88 | stfd %f18, 32(%r1) # save F18 89 | stfd %f19, 40(%r1) # save F19 90 | stfd %f20, 48(%r1) # save F20 91 | stfd %f21, 56(%r1) # save F21 92 | stfd %f22, 64(%r1) # save F22 93 | stfd %f23, 72(%r1) # save F23 94 | stfd %f24, 80(%r1) # save F24 95 | stfd %f25, 88(%r1) # save F25 96 | stfd %f26, 96(%r1) # save F26 97 | stfd %f27, 104(%r1) # save F27 98 | stfd %f28, 112(%r1) # save F28 99 | stfd %f29, 120(%r1) # save F29 100 | stfd %f30, 128(%r1) # save F30 101 | stfd %f31, 136(%r1) # save F31 102 | mffs %f0 # load FPSCR 103 | stfd %f0, 144(%r1) # save FPSCR 104 | 105 | stw %r13, 152(%r1) # save R13 106 | stw %r14, 156(%r1) # save R14 107 | stw %r15, 160(%r1) # save R15 108 | stw %r16, 164(%r1) # save R16 109 | stw %r17, 168(%r1) # save R17 110 | stw %r18, 172(%r1) # save R18 111 | stw %r19, 176(%r1) # save R19 112 | stw %r20, 180(%r1) # save R20 113 | stw %r21, 184(%r1) # save R21 114 | stw %r22, 188(%r1) # save R22 115 | stw %r23, 192(%r1) # save R23 116 | stw %r24, 196(%r1) # save R24 117 | stw %r25, 200(%r1) # save R25 118 | stw %r26, 204(%r1) # save R26 119 | stw %r27, 208(%r1) # save R27 120 | stw %r28, 212(%r1) # save R28 121 | stw %r29, 216(%r1) # save R29 122 | stw %r30, 220(%r1) # save R30 123 | stw %r31, 224(%r1) # save R31 124 | stw %r3, 228(%r1) # save hidden 125 | 126 | # save CR 127 | mfcr %r0 128 | stw %r0, 232(%r1) 129 | # save LR 130 | mflr %r0 131 | stw %r0, 236(%r1) 132 | # save LR as PC 133 | stw %r0, 240(%r1) 134 | 135 | # store RSP (pointing to context-data) in R6 136 | mr %r6, %r1 137 | 138 | # restore RSP (pointing to context-data) from R4 139 | mr %r1, %r4 140 | 141 | lfd %f14, 0(%r1) # restore F14 142 | lfd %f15, 8(%r1) # restore F15 143 | lfd %f16, 16(%r1) # restore F16 144 | lfd %f17, 24(%r1) # restore F17 145 | lfd %f18, 32(%r1) # restore F18 146 | lfd %f19, 40(%r1) # restore F19 147 | lfd %f20, 48(%r1) # restore F20 148 | lfd %f21, 56(%r1) # restore F21 149 | lfd %f22, 64(%r1) # restore F22 150 | lfd %f23, 72(%r1) # restore F23 151 | lfd %f24, 80(%r1) # restore F24 152 | lfd %f25, 88(%r1) # restore F25 153 | lfd %f26, 96(%r1) # restore F26 154 | lfd %f27, 104(%r1) # restore F27 155 | lfd %f28, 112(%r1) # restore F28 156 | lfd %f29, 120(%r1) # restore F29 157 | lfd %f30, 128(%r1) # restore F30 158 | lfd %f31, 136(%r1) # restore F31 159 | lfd %f0, 144(%r1) # load FPSCR 160 | mtfsf 0xff, %f0 # restore FPSCR 161 | 162 | lwz %r13, 152(%r1) # restore R13 163 | lwz %r14, 156(%r1) # restore R14 164 | lwz %r15, 160(%r1) # restore R15 165 | lwz %r16, 164(%r1) # restore R16 166 | lwz %r17, 168(%r1) # restore R17 167 | lwz %r18, 172(%r1) # restore R18 168 | lwz %r19, 176(%r1) # restore R19 169 | lwz %r20, 180(%r1) # restore R20 170 | lwz %r21, 184(%r1) # restore R21 171 | lwz %r22, 188(%r1) # restore R22 172 | lwz %r23, 192(%r1) # restore R23 173 | lwz %r24, 196(%r1) # restore R24 174 | lwz %r25, 200(%r1) # restore R25 175 | lwz %r26, 204(%r1) # restore R26 176 | lwz %r27, 208(%r1) # restore R27 177 | lwz %r28, 212(%r1) # restore R28 178 | lwz %r29, 216(%r1) # restore R29 179 | lwz %r30, 220(%r1) # restore R30 180 | lwz %r31, 224(%r1) # restore R31 181 | lwz %r3, 228(%r1) # restore hidden 182 | 183 | # restore CR 184 | lwz %r0, 232(%r1) 185 | mtcr %r0 186 | # restore LR 187 | lwz %r0, 236(%r1) 188 | mtlr %r0 189 | # load PC 190 | lwz %r0, 240(%r1) 191 | # restore CTR 192 | mtctr %r0 193 | 194 | # adjust stack 195 | addi %r1, %r1, 244 196 | 197 | # return transfer_t 198 | stw %r6, 0(%r3) 199 | stw %r5, 4(%r3) 200 | 201 | # jump to context 202 | bctr 203 | .size jq_jump_fcontext, .-jq_jump_fcontext 204 | 205 | /* Mark that we don't need executable stack. */ 206 | .section .note.GNU-stack,"",%progbits 207 | -------------------------------------------------------------------------------- /boost_context/jump_ppc32_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /****************************************************** 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | * 14 | * ------------------------------------------------- * 15 | * | F14 | F15 | F16 | F17 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | * 21 | * ------------------------------------------------- * 22 | * | F18 | F19 | F20 | F21 | * 23 | * ------------------------------------------------- * 24 | * ------------------------------------------------- * 25 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 26 | * ------------------------------------------------- * 27 | * | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | * 28 | * ------------------------------------------------- * 29 | * | F22 | F23 | F24 | F25 | * 30 | * ------------------------------------------------- * 31 | * ------------------------------------------------- * 32 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 33 | * ------------------------------------------------- * 34 | * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | * 35 | * ------------------------------------------------- * 36 | * | F26 | F27 | F28 | F29 | * 37 | * ------------------------------------------------- * 38 | * ------------------------------------------------- * 39 | * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * 40 | * ------------------------------------------------- * 41 | * | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | * 42 | * ------------------------------------------------- * 43 | * | F30 | F31 | fpscr | R13 | R14 | * 44 | * ------------------------------------------------- * 45 | * ------------------------------------------------- * 46 | * | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | * 47 | * ------------------------------------------------- * 48 | * | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | * 49 | * ------------------------------------------------- * 50 | * | R15 | R16 | R17 | R18 | R19 | R20 | R21 | R22 | * 51 | * ------------------------------------------------- * 52 | * ------------------------------------------------- * 53 | * | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | * 54 | * ------------------------------------------------- * 55 | * | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | * 56 | * ------------------------------------------------- * 57 | * | R23 | R24 | R25 | R26 | R27 | R28 | R29 | R30 | * 58 | * ------------------------------------------------- * 59 | * ------------------------------------------------- * 60 | * | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | * 61 | * ------------------------------------------------- * 62 | * | 224 | 228 | 232 | 236 | 240 | 244 | 248 | 252 | * 63 | * ------------------------------------------------- * 64 | * | R31 |hiddn| CR | LR | PC |bchai|linkr| FCTX| * 65 | * ------------------------------------------------- * 66 | * ------------------------------------------------- * 67 | * | 64 | | * 68 | * ------------------------------------------------- * 69 | * | 256 | | * 70 | * ------------------------------------------------- * 71 | * | DATA| | * 72 | * ------------------------------------------------- * 73 | * * 74 | *******************************************************/ 75 | 76 | .text 77 | .globl _jq_jump_fcontext 78 | .align 2 79 | _jq_jump_fcontext: 80 | ; reserve space on stack 81 | subi r1, r1, 244 82 | 83 | stfd f14, 0(r1) # save F14 84 | stfd f15, 8(r1) # save F15 85 | stfd f16, 16(r1) # save F16 86 | stfd f17, 24(r1) # save F17 87 | stfd f18, 32(r1) # save F18 88 | stfd f19, 40(r1) # save F19 89 | stfd f20, 48(r1) # save F20 90 | stfd f21, 56(r1) # save F21 91 | stfd f22, 64(r1) # save F22 92 | stfd f23, 72(r1) # save F23 93 | stfd f24, 80(r1) # save F24 94 | stfd f25, 88(r1) # save F25 95 | stfd f26, 96(r1) # save F26 96 | stfd f27, 104(r1) # save F27 97 | stfd f28, 112(r1) # save F28 98 | stfd f29, 120(r1) # save F29 99 | stfd f30, 128(r1) # save F30 100 | stfd f31, 136(r1) # save F31 101 | mffs f0 # load FPSCR 102 | stfd f0, 144(r1) # save FPSCR 103 | 104 | stw r13, 152(r1) # save R13 105 | stw r14, 156(r1) # save R14 106 | stw r15, 160(r1) # save R15 107 | stw r16, 164(r1) # save R16 108 | stw r17, 168(r1) # save R17 109 | stw r18, 172(r1) # save R18 110 | stw r19, 176(r1) # save R19 111 | stw r20, 180(r1) # save R20 112 | stw r21, 184(r1) # save R21 113 | stw r22, 188(r1) # save R22 114 | stw r23, 192(r1) # save R23 115 | stw r24, 196(r1) # save R24 116 | stw r25, 200(r1) # save R25 117 | stw r26, 204(r1) # save R26 118 | stw r27, 208(r1) # save R27 119 | stw r28, 212(r1) # save R28 120 | stw r29, 216(r1) # save R29 121 | stw r30, 220(r1) # save R30 122 | stw r31, 224(r1) # save R31 123 | stw r3, 228(r1) # save hidden 124 | 125 | # save CR 126 | mfcr r0 127 | stw r0, 232(r1) 128 | # save LR 129 | mflr r0 130 | stw r0, 236(r1) 131 | # save LR as PC 132 | stw r0, 240(r1) 133 | 134 | # store RSP (pointing to context-data) in R6 135 | mr r6, r1 136 | 137 | # restore RSP (pointing to context-data) from R4 138 | mr r1, r4 139 | 140 | lfd f14, 0(r1) # restore F14 141 | lfd f15, 8(r1) # restore F15 142 | lfd f16, 16(r1) # restore F16 143 | lfd f17, 24(r1) # restore F17 144 | lfd f18, 32(r1) # restore F18 145 | lfd f19, 40(r1) # restore F19 146 | lfd f20, 48(r1) # restore F20 147 | lfd f21, 56(r1) # restore F21 148 | lfd f22, 64(r1) # restore F22 149 | lfd f23, 72(r1) # restore F23 150 | lfd f24, 80(r1) # restore F24 151 | lfd f25, 88(r1) # restore F25 152 | lfd f26, 96(r1) # restore F26 153 | lfd f27, 104(r1) # restore F27 154 | lfd f28, 112(r1) # restore F28 155 | lfd f29, 120(r1) # restore F29 156 | lfd f30, 128(r1) # restore F30 157 | lfd f31, 136(r1) # restore F31 158 | lfd f0, 144(r1) # load FPSCR 159 | mtfsf 0xff, f0 # restore FPSCR 160 | 161 | lwz r13, 152(r1) # restore R13 162 | lwz r14, 156(r1) # restore R14 163 | lwz r15, 160(r1) # restore R15 164 | lwz r16, 164(r1) # restore R16 165 | lwz r17, 168(r1) # restore R17 166 | lwz r18, 172(r1) # restore R18 167 | lwz r19, 176(r1) # restore R19 168 | lwz r20, 180(r1) # restore R20 169 | lwz r21, 184(r1) # restore R21 170 | lwz r22, 188(r1) # restore R22 171 | lwz r23, 192(r1) # restore R23 172 | lwz r24, 196(r1) # restore R24 173 | lwz r25, 200(r1) # restore R25 174 | lwz r26, 204(r1) # restore R26 175 | lwz r27, 208(r1) # restore R27 176 | lwz r28, 212(r1) # restore R28 177 | lwz r29, 216(r1) # restore R29 178 | lwz r30, 220(r1) # restore R30 179 | lwz r31, 224(r1) # restore R31 180 | lwz r3, 228(r1) # restore hidden 181 | 182 | # restore CR 183 | lwz r0, 232(r1) 184 | mtcr r0 185 | # restore LR 186 | lwz r0, 236(r1) 187 | mtlr r0 188 | # load PC 189 | lwz r0, 240(r1) 190 | # restore CTR 191 | mtctr r0 192 | 193 | # adjust stack 194 | addi r1, r1, 244 195 | 196 | # return transfer_t 197 | stw r6, 0(r3) 198 | stw r5, 4(r3) 199 | 200 | # jump to context 201 | bctr 202 | -------------------------------------------------------------------------------- /boost_context/jump_ppc32_sysv_xcoff_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /****************************************************** 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | * 14 | * ------------------------------------------------- * 15 | * | F14 | F15 | F16 | F17 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | * 21 | * ------------------------------------------------- * 22 | * | F18 | F19 | F20 | F21 | * 23 | * ------------------------------------------------- * 24 | * ------------------------------------------------- * 25 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 26 | * ------------------------------------------------- * 27 | * | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | * 28 | * ------------------------------------------------- * 29 | * | F22 | F23 | F24 | F25 | * 30 | * ------------------------------------------------- * 31 | * ------------------------------------------------- * 32 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 33 | * ------------------------------------------------- * 34 | * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | * 35 | * ------------------------------------------------- * 36 | * | F26 | F27 | F28 | F29 | * 37 | * ------------------------------------------------- * 38 | * ------------------------------------------------- * 39 | * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * 40 | * ------------------------------------------------- * 41 | * | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | * 42 | * ------------------------------------------------- * 43 | * | F30 | F31 | fpscr | R13 | R14 | * 44 | * ------------------------------------------------- * 45 | * ------------------------------------------------- * 46 | * | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | * 47 | * ------------------------------------------------- * 48 | * | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | * 49 | * ------------------------------------------------- * 50 | * | R15 | R16 | R17 | R18 | R19 | R20 | R21 | R22 | * 51 | * ------------------------------------------------- * 52 | * ------------------------------------------------- * 53 | * | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | * 54 | * ------------------------------------------------- * 55 | * | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | * 56 | * ------------------------------------------------- * 57 | * | R23 | R24 | R25 | R26 | R27 | R28 | R29 | R30 | * 58 | * ------------------------------------------------- * 59 | * ------------------------------------------------- * 60 | * | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | * 61 | * ------------------------------------------------- * 62 | * | 224 | 228 | 232 | 236 | 240 | 244 | 248 | 252 | * 63 | * ------------------------------------------------- * 64 | * | R31 |hiddn| CR | LR | PC |bchai|linkr| FCTX| * 65 | * ------------------------------------------------- * 66 | * ------------------------------------------------- * 67 | * | 64 | | * 68 | * ------------------------------------------------- * 69 | * | 256 | | * 70 | * ------------------------------------------------- * 71 | * | DATA| | * 72 | * ------------------------------------------------- * 73 | * * 74 | *******************************************************/ 75 | .globl .jq_jump_fcontext 76 | .globl jq_jump_fcontext[DS] 77 | .align 2 78 | .csect jq_jump_fcontext[DS] 79 | jq_jump_fcontext: 80 | .long .jq_jump_fcontext 81 | .jq_jump_fcontext: 82 | # reserve space on stack 83 | subi r1, r1, 244 84 | 85 | stfd f14, 0(r1) # save F14 86 | stfd f15, 8(r1) # save F15 87 | stfd f16, 16(r1) # save F16 88 | stfd f17, 24(r1) # save F17 89 | stfd f18, 32(r1) # save F18 90 | stfd f19, 40(r1) # save F19 91 | stfd f20, 48(r1) # save F20 92 | stfd f21, 56(r1) # save F21 93 | stfd f22, 64(r1) # save F22 94 | stfd f23, 72(r1) # save F23 95 | stfd f24, 80(r1) # save F24 96 | stfd f25, 88(r1) # save F25 97 | stfd f26, 96(r1) # save F26 98 | stfd f27, 104(r1) # save F27 99 | stfd f28, 112(r1) # save F28 100 | stfd f29, 120(r1) # save F29 101 | stfd f30, 128(r1) # save F30 102 | stfd f31, 136(r1) # save F31 103 | mffs f0 # load FPSCR 104 | stfd f0, 144(r1) # save FPSCR 105 | 106 | stw r13, 152(r1) # save R13 107 | stw r14, 156(r1) # save R14 108 | stw r15, 160(r1) # save R15 109 | stw r16, 164(r1) # save R16 110 | stw r17, 168(r1) # save R17 111 | stw r18, 172(r1) # save R18 112 | stw r19, 176(r1) # save R19 113 | stw r20, 180(r1) # save R20 114 | stw r21, 184(r1) # save R21 115 | stw r22, 188(r1) # save R22 116 | stw r23, 192(r1) # save R23 117 | stw r24, 196(r1) # save R24 118 | stw r25, 200(r1) # save R25 119 | stw r26, 204(r1) # save R26 120 | stw r27, 208(r1) # save R27 121 | stw r28, 212(r1) # save R28 122 | stw r29, 216(r1) # save R29 123 | stw r30, 220(r1) # save R30 124 | stw r31, 224(r1) # save R31 125 | stw r3, 228(r1) # save hidden 126 | 127 | # save CR 128 | mfcr r0 129 | stw r0, 232(r1) 130 | # save LR 131 | mflr r0 132 | stw r0, 236(r1) 133 | # save LR as PC 134 | stw r0, 240(r1) 135 | 136 | # store RSP (pointing to context-data) in R6 137 | mr r6, r1 138 | 139 | # restore RSP (pointing to context-data) from R4 140 | mr r1, r4 141 | 142 | lfd f14, 0(r1) # restore F14 143 | lfd f15, 8(r1) # restore F15 144 | lfd f16, 16(r1) # restore F16 145 | lfd f17, 24(r1) # restore F17 146 | lfd f18, 32(r1) # restore F18 147 | lfd f19, 40(r1) # restore F19 148 | lfd f20, 48(r1) # restore F20 149 | lfd f21, 56(r1) # restore F21 150 | lfd f22, 64(r1) # restore F22 151 | lfd f23, 72(r1) # restore F23 152 | lfd f24, 80(r1) # restore F24 153 | lfd f25, 88(r1) # restore F25 154 | lfd f26, 96(r1) # restore F26 155 | lfd f27, 104(r1) # restore F27 156 | lfd f28, 112(r1) # restore F28 157 | lfd f29, 120(r1) # restore F29 158 | lfd f30, 128(r1) # restore F30 159 | lfd f31, 136(r1) # restore F31 160 | lfd f0, 144(r1) # load FPSCR 161 | mtfsf 0xff, f0 # restore FPSCR 162 | 163 | lwz r13, 152(r1) # restore R13 164 | lwz r14, 156(r1) # restore R14 165 | lwz r15, 160(r1) # restore R15 166 | lwz r16, 164(r1) # restore R16 167 | lwz r17, 168(r1) # restore R17 168 | lwz r18, 172(r1) # restore R18 169 | lwz r19, 176(r1) # restore R19 170 | lwz r20, 180(r1) # restore R20 171 | lwz r21, 184(r1) # restore R21 172 | lwz r22, 188(r1) # restore R22 173 | lwz r23, 192(r1) # restore R23 174 | lwz r24, 196(r1) # restore R24 175 | lwz r25, 200(r1) # restore R25 176 | lwz r26, 204(r1) # restore R26 177 | lwz r27, 208(r1) # restore R27 178 | lwz r28, 212(r1) # restore R28 179 | lwz r29, 216(r1) # restore R29 180 | lwz r30, 220(r1) # restore R30 181 | lwz r31, 224(r1) # restore R31 182 | lwz r3, 228(r1) # restore hidden 183 | 184 | # restore CR 185 | lwz r0, 232(r1) 186 | mtcr r0 187 | # restore LR 188 | lwz r0, 236(r1) 189 | mtlr r0 190 | # load PC 191 | lwz r0, 240(r1) 192 | # restore CTR 193 | mtctr r0 194 | 195 | # adjust stack 196 | addi r1, r1, 244 197 | 198 | # return transfer_t 199 | stw r6, 0(r3) 200 | stw r5, 4(r3) 201 | 202 | # jump to context 203 | bctr 204 | -------------------------------------------------------------------------------- /boost_context/jump_ppc64_sysv_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /******************************************************* 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | * 14 | * ------------------------------------------------- * 15 | * | TOC | R14 | R15 | R16 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | * 21 | * ------------------------------------------------- * 22 | * | R17 | R18 | R19 | R20 | * 23 | * ------------------------------------------------- * 24 | * ------------------------------------------------- * 25 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 26 | * ------------------------------------------------- * 27 | * | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | * 28 | * ------------------------------------------------- * 29 | * | R21 | R22 | R23 | R24 | * 30 | * ------------------------------------------------- * 31 | * ------------------------------------------------- * 32 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 33 | * ------------------------------------------------- * 34 | * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | * 35 | * ------------------------------------------------- * 36 | * | R25 | R26 | R27 | R28 | * 37 | * ------------------------------------------------- * 38 | * ------------------------------------------------- * 39 | * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * 40 | * ------------------------------------------------- * 41 | * | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | * 42 | * ------------------------------------------------- * 43 | * | R29 | R30 | R31 | hidden | * 44 | * ------------------------------------------------- * 45 | * ------------------------------------------------- * 46 | * | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | * 47 | * ------------------------------------------------- * 48 | * | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | * 49 | * ------------------------------------------------- * 50 | * | CR | LR | PC | back-chain| * 51 | * ------------------------------------------------- * 52 | * ------------------------------------------------- * 53 | * | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | * 54 | * ------------------------------------------------- * 55 | * | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | * 56 | * ------------------------------------------------- * 57 | * | cr saved | lr saved | compiler | linker | * 58 | * ------------------------------------------------- * 59 | * ------------------------------------------------- * 60 | * | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | * 61 | * ------------------------------------------------- * 62 | * | 224 | 228 | 232 | 236 | 240 | 244 | 248 | 252 | * 63 | * ------------------------------------------------- * 64 | * | TOC saved | FCTX | DATA | | * 65 | * ------------------------------------------------- * 66 | * * 67 | *******************************************************/ 68 | 69 | .globl jq_jump_fcontext 70 | #if _CALL_ELF == 2 71 | .text 72 | .align 2 73 | jq_jump_fcontext: 74 | addis %r2, %r12, .TOC.-jq_jump_fcontext@ha 75 | addi %r2, %r2, .TOC.-jq_jump_fcontext@l 76 | .localentry jq_jump_fcontext, . - jq_jump_fcontext 77 | #else 78 | .section ".opd","aw" 79 | .align 3 80 | jq_jump_fcontext: 81 | # ifdef _CALL_LINUX 82 | .quad .L.jq_jump_fcontext,.TOC.@tocbase,0 83 | .type jq_jump_fcontext,@function 84 | .text 85 | .align 2 86 | .L.jq_jump_fcontext: 87 | # else 88 | .hidden .jq_jump_fcontext 89 | .globl .jq_jump_fcontext 90 | .quad .jq_jump_fcontext,.TOC.@tocbase,0 91 | .size jq_jump_fcontext,24 92 | .type .jq_jump_fcontext,@function 93 | .text 94 | .align 2 95 | .jq_jump_fcontext: 96 | # endif 97 | #endif 98 | # reserve space on stack 99 | subi %r1, %r1, 184 100 | 101 | #if _CALL_ELF != 2 102 | std %r2, 0(%r1) # save TOC 103 | #endif 104 | std %r14, 8(%r1) # save R14 105 | std %r15, 16(%r1) # save R15 106 | std %r16, 24(%r1) # save R16 107 | std %r17, 32(%r1) # save R17 108 | std %r18, 40(%r1) # save R18 109 | std %r19, 48(%r1) # save R19 110 | std %r20, 56(%r1) # save R20 111 | std %r21, 64(%r1) # save R21 112 | std %r22, 72(%r1) # save R22 113 | std %r23, 80(%r1) # save R23 114 | std %r24, 88(%r1) # save R24 115 | std %r25, 96(%r1) # save R25 116 | std %r26, 104(%r1) # save R26 117 | std %r27, 112(%r1) # save R27 118 | std %r29, 120(%r1) # save R28 119 | std %r29, 128(%r1) # save R29 120 | std %r30, 136(%r1) # save R30 121 | std %r31, 144(%r1) # save R31 122 | std %r3, 152(%r1) # save hidden 123 | 124 | # save CR 125 | mfcr %r0 126 | std %r0, 160(%r1) 127 | # save LR 128 | mflr %r0 129 | std %r0, 168(%r1) 130 | # save LR as PC 131 | std %r0, 176(%r1) 132 | 133 | # store RSP (pointing to context-data) in R6 134 | mr %r6, %r1 135 | 136 | # restore RSP (pointing to context-data) from R4 137 | mr %r1, %r4 138 | 139 | #if _CALL_ELF != 2 140 | ld %r2, 0(%r1) # restore TOC 141 | #endif 142 | ld %r14, 8(%r1) # restore R14 143 | ld %r15, 16(%r1) # restore R15 144 | ld %r16, 24(%r1) # restore R16 145 | ld %r17, 32(%r1) # restore R17 146 | ld %r18, 40(%r1) # restore R18 147 | ld %r19, 48(%r1) # restore R19 148 | ld %r20, 56(%r1) # restore R20 149 | ld %r21, 64(%r1) # restore R21 150 | ld %r22, 72(%r1) # restore R22 151 | ld %r23, 80(%r1) # restore R23 152 | ld %r24, 88(%r1) # restore R24 153 | ld %r25, 96(%r1) # restore R25 154 | ld %r26, 104(%r1) # restore R26 155 | ld %r27, 112(%r1) # restore R27 156 | ld %r28, 120(%r1) # restore R28 157 | ld %r29, 128(%r1) # restore R29 158 | ld %r30, 136(%r1) # restore R30 159 | ld %r31, 144(%r1) # restore R31 160 | ld %r3, 152(%r1) # restore hidden 161 | 162 | # restore CR 163 | ld %r0, 160(%r1) 164 | mtcr %r0 165 | # restore LR 166 | ld %r0, 168(%r1) 167 | mtlr %r0 168 | 169 | # load PC 170 | ld %r12, 176(%r1) 171 | # restore CTR 172 | mtctr %r12 173 | 174 | # adjust stack 175 | addi %r1, %r1, 184 176 | 177 | # return transfer_t 178 | std %r6, 0(%r3) 179 | std %r5, 8(%r3) 180 | 181 | # jump to context 182 | bctr 183 | #if _CALL_ELF == 2 184 | .size jq_jump_fcontext, .-jq_jump_fcontext 185 | #else 186 | # ifdef _CALL_LINUX 187 | .size .jq_jump_fcontext, .-.L.jq_jump_fcontext 188 | # else 189 | .size .jq_jump_fcontext, .-.jq_jump_fcontext 190 | # endif 191 | #endif 192 | 193 | 194 | /* Mark that we don't need executable stack. */ 195 | .section .note.GNU-stack,"",%progbits 196 | -------------------------------------------------------------------------------- /boost_context/jump_ppc64_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /******************************************************* 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | * 14 | * ------------------------------------------------- * 15 | * | TOC | R14 | R15 | R16 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | * 21 | * ------------------------------------------------- * 22 | * | R17 | R18 | R19 | R20 | * 23 | * ------------------------------------------------- * 24 | * ------------------------------------------------- * 25 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 26 | * ------------------------------------------------- * 27 | * | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | * 28 | * ------------------------------------------------- * 29 | * | R21 | R22 | R23 | R24 | * 30 | * ------------------------------------------------- * 31 | * ------------------------------------------------- * 32 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 33 | * ------------------------------------------------- * 34 | * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | * 35 | * ------------------------------------------------- * 36 | * | R25 | R26 | R27 | R28 | * 37 | * ------------------------------------------------- * 38 | * ------------------------------------------------- * 39 | * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * 40 | * ------------------------------------------------- * 41 | * | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | * 42 | * ------------------------------------------------- * 43 | * | R29 | R30 | R31 | hidden | * 44 | * ------------------------------------------------- * 45 | * ------------------------------------------------- * 46 | * | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | * 47 | * ------------------------------------------------- * 48 | * | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | * 49 | * ------------------------------------------------- * 50 | * | CR | LR | PC | back-chain| * 51 | * ------------------------------------------------- * 52 | * ------------------------------------------------- * 53 | * | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | * 54 | * ------------------------------------------------- * 55 | * | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | * 56 | * ------------------------------------------------- * 57 | * | cr saved | lr saved | compiler | linker | * 58 | * ------------------------------------------------- * 59 | * ------------------------------------------------- * 60 | * | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | * 61 | * ------------------------------------------------- * 62 | * | 224 | 228 | 232 | 236 | 240 | 244 | 248 | 252 | * 63 | * ------------------------------------------------- * 64 | * | TOC saved | FCTX | DATA | | * 65 | * ------------------------------------------------- * 66 | * * 67 | *******************************************************/ 68 | 69 | .text 70 | .align 2 71 | .globl jq_jump_fcontext 72 | 73 | _jq_jump_fcontext: 74 | ; reserve space on stack 75 | subi r1, r1, 184 76 | 77 | std %r14, 8(%r1) ; save R14 78 | std %r15, 16(%r1) ; save R15 79 | std %r16, 24(%r1) ; save R16 80 | std %r17, 32(%r1) ; save R17 81 | std %r18, 40(%r1) ; save R18 82 | std %r19, 48(%r1) ; save R19 83 | std %r20, 56(%r1) ; save R20 84 | std %r21, 64(%r1) ; save R21 85 | std %r22, 72(%r1) ; save R22 86 | std %r23, 80(%r1) ; save R23 87 | std %r24, 88(%r1) ; save R24 88 | std %r25, 96(%r1) ; save R25 89 | std %r26, 104(%r1) ; save R26 90 | std %r27, 112(%r1) ; save R27 91 | std %r29, 120(%r1) ; save R28 92 | std %r29, 128(%r1) ; save R29 93 | std %r30, 136(%r1) ; save R30 94 | std %r31, 144(%r1) ; save R31 95 | std %r3, 152(%r1) ; save hidden 96 | 97 | ; save CR 98 | mfcr r0 99 | std r0, 160(r1) 100 | ; save LR 101 | mflr r0 102 | std r0, 168(r1) 103 | ; save LR as PC 104 | std r0, 176(r1) 105 | 106 | ; store RSP (pointing to context-data) in R6 107 | mr %r6, %r1 108 | 109 | ; restore RSP (pointing to context-data) from R4 110 | mr r1, r4 111 | 112 | ld %r14, 8(%r1) ; restore R14 113 | ld %r15, 16(%r1) ; restore R15 114 | ld %r16, 24(%r1) ; restore R16 115 | ld %r17, 32(%r1) ; restore R17 116 | ld %r18, 40(%r1) ; restore R18 117 | ld %r19, 48(%r1) ; restore R19 118 | ld %r20, 56(%r1) ; restore R20 119 | ld %r21, 64(%r1) ; restore R21 120 | ld %r22, 72(%r1) ; restore R22 121 | ld %r23, 80(%r1) ; restore R23 122 | ld %r24, 88(%r1) ; restore R24 123 | ld %r25, 96(%r1) ; restore R25 124 | ld %r26, 104(%r1) ; restore R26 125 | ld %r27, 112(%r1) ; restore R27 126 | ld %r28, 120(%r1) ; restore R28 127 | ld %r29, 128(%r1) ; restore R29 128 | ld %r30, 136(%r1) ; restore R30 129 | ld %r31, 144(%r1) ; restore R31 130 | ld %r3, 152(%r1) ; restore hidden 131 | 132 | ; restore CR 133 | ld r0, 160(r1) 134 | mtcr r0 135 | ; restore LR 136 | ld r0, 168(r1) 137 | mtlr r0 138 | 139 | ; load PC 140 | ld r0, 176(r1) 141 | ; restore CTR 142 | mtctr r0 143 | 144 | ; adjust stack 145 | addi r1, r1, 184 146 | 147 | ; return transfer_t 148 | std %r6, 0(%r3) 149 | std %r5, 8(%r3) 150 | 151 | ; jump to context 152 | bctr 153 | -------------------------------------------------------------------------------- /boost_context/jump_ppc64_sysv_xcoff_gas.S: -------------------------------------------------------------------------------- 1 | .align 2 2 | .globl .jq_jump_fcontext 3 | .jq_jump_fcontext: 4 | # reserve space on stack 5 | subi 1, 1, 184 6 | 7 | std 13, 0(1) # save R13 8 | std 14, 8(1) # save R14 9 | std 15, 16(1) # save R15 10 | std 16, 24(1) # save R16 11 | std 17, 32(1) # save R17 12 | std 18, 40(1) # save R18 13 | std 19, 48(1) # save R19 14 | std 20, 56(1) # save R20 15 | std 21, 64(1) # save R21 16 | std 22, 72(1) # save R22 17 | std 23, 80(1) # save R23 18 | std 24, 88(1) # save R24 19 | std 25, 96(1) # save R25 20 | std 26, 104(1) # save R26 21 | std 27, 112(1) # save R27 22 | std 29, 120(1) # save R28 23 | std 29, 128(1) # save R29 24 | std 30, 136(1) # save R30 25 | std 31, 144(1) # save R31 26 | std 3, 152(1) # save hidden 27 | 28 | # save CR 29 | mfcr 0 30 | std 0, 160(1) 31 | # save LR 32 | mflr 0 33 | std 0, 168(1) 34 | # save LR as PC 35 | std 0, 176(1) 36 | 37 | # store RSP (pointing to context-data) in R6 38 | mr 6, 1 39 | 40 | # restore RSP (pointing to context-data) from R4 41 | mr 1, 4 42 | 43 | ld 13, 0(1) # restore R13 44 | ld 14, 8(1) # restore R14 45 | ld 15, 16(1) # restore R15 46 | ld 16, 24(1) # restore R16 47 | ld 17, 32(1) # restore R17 48 | ld 18, 40(1) # restore R18 49 | ld 19, 48(1) # restore R19 50 | ld 20, 56(1) # restore R20 51 | ld 21, 64(1) # restore R21 52 | ld 22, 72(1) # restore R22 53 | ld 23, 80(1) # restore R23 54 | ld 24, 88(1) # restore R24 55 | ld 25, 96(1) # restore R25 56 | ld 26, 104(1) # restore R26 57 | ld 27, 112(1) # restore R27 58 | ld 28, 120(1) # restore R28 59 | ld 29, 128(1) # restore R29 60 | ld 30, 136(1) # restore R30 61 | ld 31, 144(1) # restore R31 62 | ld 3, 152(1) # restore hidden 63 | 64 | # restore CR 65 | ld 0, 160(1) 66 | mtcr 0 67 | # restore LR 68 | ld 0, 168(1) 69 | mtlr 0 70 | 71 | # load PC 72 | ld 0, 176(1) 73 | # restore CTR 74 | mtctr 0 75 | 76 | # adjust stack 77 | addi 1, 1, 184 78 | 79 | # return transfer_t 80 | std 6, 0(3) 81 | std 5, 8(3) 82 | 83 | # jump to context 84 | bctr 85 | -------------------------------------------------------------------------------- /boost_context/jump_x86_64_sysv_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /**************************************************************************************** 9 | * * 10 | * ---------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ---------------------------------------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | * 14 | * ---------------------------------------------------------------------------------- * 15 | * | fc_mxcsr|fc_x87_cw| R12 | R13 | R14 | * 16 | * ---------------------------------------------------------------------------------- * 17 | * ---------------------------------------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ---------------------------------------------------------------------------------- * 20 | * | 0x20 | 0x24 | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c | * 21 | * ---------------------------------------------------------------------------------- * 22 | * | R15 | RBX | RBP | RIP | * 23 | * ---------------------------------------------------------------------------------- * 24 | * * 25 | ****************************************************************************************/ 26 | 27 | .text 28 | .globl jq_jump_fcontext 29 | .type jq_jump_fcontext,@function 30 | .align 16 31 | jq_jump_fcontext: 32 | leaq -0x38(%rsp), %rsp /* prepare stack */ 33 | 34 | stmxcsr (%rsp) /* save MMX control- and status-word */ 35 | fnstcw 0x4(%rsp) /* save x87 control-word */ 36 | 37 | movq %r12, 0x8(%rsp) /* save R12 */ 38 | movq %r13, 0x10(%rsp) /* save R13 */ 39 | movq %r14, 0x18(%rsp) /* save R14 */ 40 | movq %r15, 0x20(%rsp) /* save R15 */ 41 | movq %rbx, 0x28(%rsp) /* save RBX */ 42 | movq %rbp, 0x30(%rsp) /* save RBP */ 43 | 44 | /* store RSP (pointing to context-data) in RAX */ 45 | movq %rsp, %rax 46 | 47 | /* restore RSP (pointing to context-data) from RDI */ 48 | movq %rdi, %rsp 49 | 50 | movq 0x38(%rsp), %r8 /* restore return-address */ 51 | 52 | ldmxcsr (%rsp) /* restore MMX control- and status-word */ 53 | fldcw 0x4(%rsp) /* restore x87 control-word */ 54 | 55 | movq 0x8(%rsp), %r12 /* restore R12 */ 56 | movq 0x10(%rsp), %r13 /* restore R13 */ 57 | movq 0x18(%rsp), %r14 /* restore R14 */ 58 | movq 0x20(%rsp), %r15 /* restore R15 */ 59 | movq 0x28(%rsp), %rbx /* restore RBX */ 60 | movq 0x30(%rsp), %rbp /* restore RBP */ 61 | 62 | leaq 0x40(%rsp), %rsp /* prepare stack */ 63 | 64 | /* return transfer_t from jump */ 65 | /* RAX == fctx, RDX == data */ 66 | movq %rsi, %rdx 67 | /* pass transfer_t as first arg in context function */ 68 | /* RDI == fctx, RSI == data */ 69 | movq %rax, %rdi 70 | 71 | /* indirect jump to context */ 72 | jmp *%r8 73 | .size jq_jump_fcontext,.-jq_jump_fcontext 74 | 75 | /* Mark that we don't need executable stack. */ 76 | .section .note.GNU-stack,"",%progbits 77 | -------------------------------------------------------------------------------- /boost_context/jump_x86_64_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /**************************************************************************************** 9 | * * 10 | * ---------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ---------------------------------------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | * 14 | * ---------------------------------------------------------------------------------- * 15 | * | fc_mxcsr|fc_x87_cw| R12 | R13 | R14 | * 16 | * ---------------------------------------------------------------------------------- * 17 | * ---------------------------------------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ---------------------------------------------------------------------------------- * 20 | * | 0x20 | 0x24 | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c | * 21 | * ---------------------------------------------------------------------------------- * 22 | * | R15 | RBX | RBP | RIP | * 23 | * ---------------------------------------------------------------------------------- * 24 | * * 25 | ****************************************************************************************/ 26 | 27 | .text 28 | .globl _jq_jump_fcontext 29 | .align 8 30 | _jq_jump_fcontext: 31 | leaq -0x38(%rsp), %rsp /* prepare stack */ 32 | 33 | stmxcsr (%rsp) /* save MMX control- and status-word */ 34 | fnstcw 0x4(%rsp) /* save x87 control-word */ 35 | 36 | movq %r12, 0x8(%rsp) /* save R12 */ 37 | movq %r13, 0x10(%rsp) /* save R13 */ 38 | movq %r14, 0x18(%rsp) /* save R14 */ 39 | movq %r15, 0x20(%rsp) /* save R15 */ 40 | movq %rbx, 0x28(%rsp) /* save RBX */ 41 | movq %rbp, 0x30(%rsp) /* save RBP */ 42 | 43 | /* store RSP (pointing to context-data) in RAX */ 44 | movq %rsp, %rax 45 | 46 | /* restore RSP (pointing to context-data) from RDI */ 47 | movq %rdi, %rsp 48 | 49 | movq 0x38(%rsp), %r8 /* restore return-address */ 50 | 51 | ldmxcsr (%rsp) /* restore MMX control- and status-word */ 52 | fldcw 0x4(%rsp) /* restore x87 control-word */ 53 | 54 | movq 0x8(%rsp), %r12 /* restore R12 */ 55 | movq 0x10(%rsp), %r13 /* restore R13 */ 56 | movq 0x18(%rsp), %r14 /* restore R14 */ 57 | movq 0x20(%rsp), %r15 /* restore R15 */ 58 | movq 0x28(%rsp), %rbx /* restore RBX */ 59 | movq 0x30(%rsp), %rbp /* restore RBP */ 60 | 61 | leaq 0x40(%rsp), %rsp /* prepare stack */ 62 | 63 | /* return transfer_t from jump */ 64 | /* RAX == fctx, RDX == data */ 65 | movq %rsi, %rdx 66 | /* pass transfer_t as first arg in context function */ 67 | /* RDI == fctx, RSI == data */ 68 | movq %rax, %rdi 69 | 70 | /* indirect jump to context */ 71 | jmp *%r8 72 | -------------------------------------------------------------------------------- /boost_context/make_arm64_aapcs_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Edward Nevill + Oliver Kowalke 2015 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | /******************************************************* 8 | * * 9 | * ------------------------------------------------- * 10 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 11 | * ------------------------------------------------- * 12 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 13 | * ------------------------------------------------- * 14 | * | d8 | d9 | d10 | d11 | * 15 | * ------------------------------------------------- * 16 | * ------------------------------------------------- * 17 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 18 | * ------------------------------------------------- * 19 | * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 20 | * ------------------------------------------------- * 21 | * | d12 | d13 | d14 | d15 | * 22 | * ------------------------------------------------- * 23 | * ------------------------------------------------- * 24 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 25 | * ------------------------------------------------- * 26 | * | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| * 27 | * ------------------------------------------------- * 28 | * | x19 | x20 | x21 | x22 | * 29 | * ------------------------------------------------- * 30 | * ------------------------------------------------- * 31 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 32 | * ------------------------------------------------- * 33 | * | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| * 34 | * ------------------------------------------------- * 35 | * | x23 | x24 | x25 | x26 | * 36 | * ------------------------------------------------- * 37 | * ------------------------------------------------- * 38 | * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * 39 | * ------------------------------------------------- * 40 | * | 0x80| 0x84| 0x88| 0x8c| 0x90| 0x94| 0x98| 0x9c| * 41 | * ------------------------------------------------- * 42 | * | x27 | x28 | FP | LR | * 43 | * ------------------------------------------------- * 44 | * ------------------------------------------------- * 45 | * | 40 | 41 | 42 | 43 | | | * 46 | * ------------------------------------------------- * 47 | * | 0xa0| 0xa4| 0xa8| 0xac| | | * 48 | * ------------------------------------------------- * 49 | * | PC | align | | | * 50 | * ------------------------------------------------- * 51 | * * 52 | *******************************************************/ 53 | 54 | .text 55 | .align 2 56 | .global jq_make_fcontext 57 | .type jq_make_fcontext, %function 58 | jq_make_fcontext: 59 | # shift address in x0 (allocated stack) to lower 16 byte boundary 60 | and x0, x0, ~0xF 61 | 62 | # reserve space for context-data on context-stack 63 | sub x0, x0, #0xb0 64 | 65 | # third arg of jq_make_fcontext() == address of context-function 66 | # store address as a PC to jump in 67 | str x2, [x0, #0xa0] 68 | 69 | # save address of finish as return-address for context-function 70 | # will be entered after context-function returns (LR register) 71 | adr x1, finish 72 | str x1, [x0, #0x98] 73 | 74 | ret x30 // return pointer to context-data (x0) 75 | 76 | finish: 77 | # exit code is zero 78 | mov x0, #0 79 | # exit application 80 | bl _exit 81 | 82 | .size jq_make_fcontext,.-jq_make_fcontext 83 | # Mark that we don't need executable stack. 84 | .section .note.GNU-stack,"",%progbits 85 | -------------------------------------------------------------------------------- /boost_context/make_arm64_aapcs_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Edward Nevill + Oliver Kowalke 2015 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | /******************************************************* 8 | * * 9 | * ------------------------------------------------- * 10 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 11 | * ------------------------------------------------- * 12 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 13 | * ------------------------------------------------- * 14 | * | d8 | d9 | d10 | d11 | * 15 | * ------------------------------------------------- * 16 | * ------------------------------------------------- * 17 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 18 | * ------------------------------------------------- * 19 | * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 20 | * ------------------------------------------------- * 21 | * | d12 | d13 | d14 | d15 | * 22 | * ------------------------------------------------- * 23 | * ------------------------------------------------- * 24 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 25 | * ------------------------------------------------- * 26 | * | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| * 27 | * ------------------------------------------------- * 28 | * | x19 | x20 | x21 | x22 | * 29 | * ------------------------------------------------- * 30 | * ------------------------------------------------- * 31 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 32 | * ------------------------------------------------- * 33 | * | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| * 34 | * ------------------------------------------------- * 35 | * | x23 | x24 | x25 | x26 | * 36 | * ------------------------------------------------- * 37 | * ------------------------------------------------- * 38 | * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * 39 | * ------------------------------------------------- * 40 | * | 0x80| 0x84| 0x88| 0x8c| 0x90| 0x94| 0x98| 0x9c| * 41 | * ------------------------------------------------- * 42 | * | x27 | x28 | FP | LR | * 43 | * ------------------------------------------------- * 44 | * ------------------------------------------------- * 45 | * | 40 | 41 | 42 | 43 | | | * 46 | * ------------------------------------------------- * 47 | * | 0xa0| 0xa4| 0xa8| 0xac| | | * 48 | * ------------------------------------------------- * 49 | * | PC | align | | | * 50 | * ------------------------------------------------- * 51 | * * 52 | *******************************************************/ 53 | 54 | .text 55 | .globl _jq_make_fcontext 56 | .balign 16 57 | 58 | _jq_make_fcontext: 59 | ; shift address in x0 (allocated stack) to lower 16 byte boundary 60 | and x0, x0, ~0xF 61 | 62 | ; reserve space for context-data on context-stack 63 | sub x0, x0, #0xb0 64 | 65 | ; third arg of make_fcontext() == address of context-function 66 | ; store address as a PC to jump in 67 | str x2, [x0, #0xa0] 68 | 69 | ; compute abs address of label finish 70 | ; 0x0c = 3 instructions * size (4) before label 'finish' 71 | 72 | ; TODO: Numeric offset since llvm still does not support labels in ADR. Fix: 73 | ; http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140407/212336.html 74 | adr x1, 0x0c 75 | 76 | ; save address of finish as return-address for context-function 77 | ; will be entered after context-function returns (LR register) 78 | str x1, [x0, #0x98] 79 | 80 | ret lr ; return pointer to context-data (x0) 81 | 82 | finish: 83 | ; exit code is zero 84 | mov x0, #0 85 | ; exit application 86 | bl __exit 87 | 88 | 89 | -------------------------------------------------------------------------------- /boost_context/make_arm_aapcs_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /******************************************************* 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 14 | * ------------------------------------------------- * 15 | * | s16 | s17 | s18 | s19 | s20 | s21 | s22 | s23 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 21 | * ------------------------------------------------- * 22 | * | s24 | s25 | s26 | s27 | s28 | s29 | s30 | s31 | * 23 | * ------------------------------------------------- * 24 | * ------------------------------------------------- * 25 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 26 | * ------------------------------------------------- * 27 | * | 0x40| 0x44| 0x48| 0x4c| 0x50| 0x54| 0x58| 0x5c| * 28 | * ------------------------------------------------- * 29 | * |hiddn| v1 | v2 | v3 | v4 | v5 | v6 | v7 | * 30 | * ------------------------------------------------- * 31 | * ------------------------------------------------- * 32 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 33 | * ------------------------------------------------- * 34 | * | 0x60| 0x64| 0x68| 0x6c| 0x70| 0x74| 0x78| 0x7c| * 35 | * ------------------------------------------------- * 36 | * | v8 | lr | pc | FCTX| DATA| | * 37 | * ------------------------------------------------- * 38 | * * 39 | *******************************************************/ 40 | 41 | .text 42 | .globl jq_make_fcontext 43 | .align 2 44 | .type jq_make_fcontext,%function 45 | jq_make_fcontext: 46 | @ shift address in A1 to lower 16 byte boundary 47 | bic a1, a1, #15 48 | 49 | @ reserve space for context-data on context-stack 50 | sub a1, a1, #128 51 | 52 | @ third arg of jq_make_fcontext() == address of context-function 53 | str a3, [a1, #104] 54 | 55 | @ compute address of returned transfer_t 56 | add a2, a1, #108 57 | mov a3, a2 58 | str a3, [a1, #64] 59 | 60 | @ compute abs address of label finish 61 | adr a2, finish 62 | @ save address of finish as return-address for context-function 63 | @ will be entered after context-function returns 64 | str a2, [a1, #100] 65 | 66 | #if (defined(__VFP_FP__) && !defined(__SOFTFP__)) 67 | #endif 68 | 69 | bx lr @ return pointer to context-data 70 | 71 | finish: 72 | @ exit code is zero 73 | mov a1, #0 74 | @ exit application 75 | bl _exit@PLT 76 | .size jq_make_fcontext,.-jq_make_fcontext 77 | 78 | @ Mark that we don't need executable stack. 79 | .section .note.GNU-stack,"",%progbits 80 | -------------------------------------------------------------------------------- /boost_context/make_arm_aapcs_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /******************************************************* 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 14 | * ------------------------------------------------- * 15 | * | s16 | s17 | s18 | s19 | s20 | s21 | s22 | s23 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 21 | * ------------------------------------------------- * 22 | * | s24 | s25 | s26 | s27 | s28 | s29 | s30 | s31 | * 23 | * ------------------------------------------------- * 24 | * ------------------------------------------------- * 25 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 26 | * ------------------------------------------------- * 27 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 28 | * ------------------------------------------------- * 29 | * | sjlj|hiddn| v1 | v2 | v3 | v4 | v5 | v6 | * 30 | * ------------------------------------------------- * 31 | * ------------------------------------------------- * 32 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 33 | * ------------------------------------------------- * 34 | * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 35 | * ------------------------------------------------- * 36 | * | v7 | v8 | lr | pc | FCTX| DATA| | * 37 | * ------------------------------------------------- * 38 | * * 39 | *******************************************************/ 40 | 41 | .text 42 | .globl _jq_make_fcontext 43 | .align 2 44 | _jq_make_fcontext: 45 | @ shift address in A1 to lower 16 byte boundary 46 | bic a1, a1, #15 47 | 48 | @ reserve space for context-data on context-stack 49 | sub a1, a1, #128 50 | 51 | @ third arg of make_fcontext() == address of context-function 52 | str a3, [a1, #108] 53 | 54 | @ compute address of returned transfer_t 55 | add a2, a1, #112 56 | mov a3, a2 57 | str a3, [a1, #68] 58 | 59 | @ compute abs address of label finish 60 | adr a2, finish 61 | @ save address of finish as return-address for context-function 62 | @ will be entered after context-function returns 63 | str a2, [a1, #104] 64 | 65 | bx lr @ return pointer to context-data 66 | 67 | finish: 68 | @ exit code is zero 69 | mov a1, #0 70 | @ exit application 71 | bl __exit 72 | -------------------------------------------------------------------------------- /boost_context/make_arm_aapcs_pe_armasm.asm: -------------------------------------------------------------------------------- 1 | ;/* 2 | ; Copyright Oliver Kowalke 2009. 3 | ; Distributed under the Boost Software License, Version 1.0. 4 | ; (See accompanying file LICENSE_1_0.txt or copy at 5 | ; http://www.boost.org/LICENSE_1_0.txt) 6 | ;*/ 7 | 8 | ; ******************************************************* 9 | ; * * 10 | ; * ------------------------------------------------- * 11 | ; * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | ; * ------------------------------------------------- * 13 | ; * | 0x0 | 0x4 | 0x8 | 0xc | 0x10| 0x14| 0x18| 0x1c| * 14 | ; * ------------------------------------------------- * 15 | ; * |deall|limit| base|hiddn| v1 | v2 | v3 | v4 | * 16 | ; * ------------------------------------------------- * 17 | ; * ------------------------------------------------- * 18 | ; * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | ; * ------------------------------------------------- * 20 | ; * | 0x20| 0x24| 0x28| 0x2c| 0x30| 0x34| 0x38| 0x3c| * 21 | ; * ------------------------------------------------- * 22 | ; * | v5 | v6 | v7 | v8 | lr | pc | FCTX| DATA| * 23 | ; * ------------------------------------------------- * 24 | ; * * 25 | ; ******************************************************* 26 | 27 | 28 | AREA |.text|, CODE 29 | ALIGN 4 30 | EXPORT jq_make_fcontext 31 | IMPORT _exit 32 | 33 | jq_make_fcontext PROC 34 | ; first arg of jq_make_fcontext() == top of context-stack 35 | ; save top of context-stack (base) A4 36 | mov a4, a1 37 | 38 | ; shift address in A1 to lower 16 byte boundary 39 | bic a1, a1, #0x0f 40 | 41 | ; reserve space for context-data on context-stack 42 | sub a1, a1, #0x48 43 | 44 | ; save top address of context_stack as 'base' 45 | str a4, [a1, #0x8] 46 | ; second arg of jq_make_fcontext() == size of context-stack 47 | ; compute bottom address of context-stack (limit) 48 | sub a4, a4, a2 49 | ; save bottom address of context-stack as 'limit' 50 | str a4, [a1, #0x4] 51 | ; save bottom address of context-stack as 'dealloction stack' 52 | str a4, [a1, #0x0] 53 | 54 | ; third arg of jq_make_fcontext() == address of context-function 55 | str a3, [a1, #0x34] 56 | 57 | ; compute address of returned transfer_t 58 | add a2, a1, #0x38 59 | mov a3, a2 60 | str a3, [a1, #0xc] 61 | 62 | ; compute abs address of label finish 63 | adr a2, finish 64 | ; save address of finish as return-address for context-function 65 | ; will be entered after context-function returns 66 | str a2, [a1, #0x30] 67 | 68 | bx lr ; return pointer to context-data 69 | 70 | finish 71 | ; exit code is zero 72 | mov a1, #0 73 | ; exit application 74 | bl _exit 75 | 76 | ENDP 77 | END 78 | -------------------------------------------------------------------------------- /boost_context/make_combined_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Sergue E. Leontiev 2013. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Stub file for universal binary 9 | 10 | #if defined(__i386__) 11 | #include "make_i386_sysv_macho_gas.S" 12 | #elif defined(__x86_64__) 13 | #include "make_x86_64_sysv_macho_gas.S" 14 | #elif defined(__ppc__) 15 | #include "make_ppc32_sysv_macho_gas.S" 16 | #elif defined(__ppc64__) 17 | #include "make_ppc64_sysv_macho_gas.S" 18 | #else 19 | #error "No arch's" 20 | #endif 21 | -------------------------------------------------------------------------------- /boost_context/make_i386_ms_pe_gas.asm: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Copyright Thomas Sailer 2013. 4 | Distributed under the Boost Software License, Version 1.0. 5 | (See accompanying file LICENSE_1_0.txt or copy at 6 | http://www.boost.org/LICENSE_1_0.txt) 7 | */ 8 | 9 | /************************************************************************************* 10 | * --------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * --------------------------------------------------------------------------------- * 13 | * | 0h | 04h | 08h | 0ch | 010h | 014h | 018h | 01ch | * 14 | * --------------------------------------------------------------------------------- * 15 | * | fc_mxcsr|fc_x87_cw| fc_strg |fc_deallo| limit | base | fc_seh | EDI | * 16 | * --------------------------------------------------------------------------------- * 17 | * --------------------------------------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * --------------------------------------------------------------------------------- * 20 | * | 020h | 024h | 028h | 02ch | 030h | 034h | 038h | 03ch | * 21 | * --------------------------------------------------------------------------------- * 22 | * | ESI | EBX | EBP | EIP | to | data | EH NXT |SEH HNDLR| * 23 | * --------------------------------------------------------------------------------- * 24 | **************************************************************************************/ 25 | 26 | .file "make_i386_ms_pe_gas.asm" 27 | .text 28 | .p2align 4,,15 29 | .globl _jq_make_fcontext 30 | .def _jq_make_fcontext; .scl 2; .type 32; .endef 31 | _jq_make_fcontext: 32 | /* first arg of jq_make_fcontext() == top of context-stack */ 33 | movl 0x04(%esp), %eax 34 | 35 | /* reserve space for first argument of context-function */ 36 | /* EAX might already point to a 16byte border */ 37 | leal -0x8(%eax), %eax 38 | 39 | /* shift address in EAX to lower 16 byte boundary */ 40 | andl $-16, %eax 41 | 42 | /* reserve space for context-data on context-stack */ 43 | /* size for fc_mxcsr .. EIP + return-address for context-function */ 44 | /* on context-function entry: (ESP -0x4) % 8 == 0 */ 45 | /* additional space is required for SEH */ 46 | leal -0x40(%eax), %eax 47 | 48 | /* save MMX control- and status-word */ 49 | stmxcsr (%eax) 50 | /* save x87 control-word */ 51 | fnstcw 0x4(%eax) 52 | 53 | /* first arg of jq_make_fcontext() == top of context-stack */ 54 | movl 0x4(%esp), %ecx 55 | /* save top address of context stack as 'base' */ 56 | movl %ecx, 0x14(%eax) 57 | /* second arg of jq_make_fcontext() == size of context-stack */ 58 | movl 0x8(%esp), %edx 59 | /* negate stack size for LEA instruction (== substraction) */ 60 | negl %edx 61 | /* compute bottom address of context stack (limit) */ 62 | leal (%ecx,%edx), %ecx 63 | /* save bottom address of context-stack as 'limit' */ 64 | movl %ecx, 0x10(%eax) 65 | /* save bottom address of context-stack as 'dealloction stack' */ 66 | movl %ecx, 0xc(%eax) 67 | /* set fiber-storage to zero */ 68 | xorl %ecx, %ecx 69 | movl %ecx, 0x8(%eax) 70 | 71 | /* third arg of jq_make_fcontext() == address of context-function */ 72 | /* stored in EBX */ 73 | movl 0xc(%esp), %ecx 74 | movl %ecx, 0x24(%eax) 75 | 76 | /* compute abs address of label trampoline */ 77 | movl $trampoline, %ecx 78 | /* save address of trampoline as return-address for context-function */ 79 | /* will be entered after calling jq_jump_fcontext() first time */ 80 | movl %ecx, 0x2c(%eax) 81 | 82 | /* compute abs address of label finish */ 83 | movl $finish, %ecx 84 | /* save address of finish as return-address for context-function */ 85 | /* will be entered after context-function returns */ 86 | movl %ecx, 0x28(%eax) 87 | 88 | /* traverse current seh chain to get the last exception handler installed by Windows */ 89 | /* note that on Windows Server 2008 and 2008 R2, SEHOP is activated by default */ 90 | /* the exception handler chain is tested for the presence of ntdll.dll!FinalExceptionHandler */ 91 | /* at its end by RaiseException all seh andlers are disregarded if not present and the */ 92 | /* program is aborted */ 93 | /* load NT_TIB into ECX */ 94 | movl %fs:(0x0), %ecx 95 | 96 | walk: 97 | /* load 'next' member of current SEH into EDX */ 98 | movl (%ecx), %edx 99 | /* test if 'next' of current SEH is last (== 0xffffffff) */ 100 | incl %edx 101 | jz found 102 | decl %edx 103 | /* exchange content; ECX contains address of next SEH */ 104 | xchgl %ecx, %edx 105 | /* inspect next SEH */ 106 | jmp walk 107 | 108 | found: 109 | /* load 'handler' member of SEH == address of last SEH handler installed by Windows */ 110 | movl 0x04(%ecx), %ecx 111 | /* save address in ECX as SEH handler for context */ 112 | movl %ecx, 0x3c(%eax) 113 | /* set ECX to -1 */ 114 | movl $0xffffffff, %ecx 115 | /* save ECX as next SEH item */ 116 | movl %ecx, 0x38(%eax) 117 | /* load address of next SEH item */ 118 | leal 0x38(%eax), %ecx 119 | /* save next SEH */ 120 | movl %ecx, 0x18(%eax) 121 | 122 | /* return pointer to context-data */ 123 | ret 124 | 125 | trampoline: 126 | /* move transport_t for entering context-function */ 127 | /* FCTX == EAX, DATA == EDX */ 128 | movl %eax, (%esp) 129 | movl %edx, 0x4(%esp) 130 | /* label finish as return-address */ 131 | pushl %ebp 132 | /* jump to context-function */ 133 | jmp *%ebx 134 | 135 | finish: 136 | /* ESP points to same address as ESP on entry of context function + 0x4 */ 137 | xorl %eax, %eax 138 | /* exit code is zero */ 139 | movl %eax, (%esp) 140 | /* exit application */ 141 | call __exit 142 | hlt 143 | 144 | .def __exit; .scl 2; .type 32; .endef /* standard C library function */ 145 | 146 | .section .drectve 147 | .ascii " -export:\"jq_make_fcontext\"" 148 | -------------------------------------------------------------------------------- /boost_context/make_i386_ms_pe_masm.asm: -------------------------------------------------------------------------------- 1 | 2 | ; Copyright Oliver Kowalke 2009. 3 | ; Distributed under the Boost Software License, Version 1.0. 4 | ; (See accompanying file LICENSE_1_0.txt or copy at 5 | ; http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | ; --------------------------------------------------------------------------------- 8 | ; | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | ; --------------------------------------------------------------------------------- 10 | ; | 0h | 04h | 08h | 0ch | 010h | 014h | 018h | 01ch | 11 | ; --------------------------------------------------------------------------------- 12 | ; | fc_mxcsr|fc_x87_cw| fc_strg |fc_deallo| limit | base | fc_seh | EDI | 13 | ; --------------------------------------------------------------------------------- 14 | ; --------------------------------------------------------------------------------- 15 | ; | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | ; --------------------------------------------------------------------------------- 17 | ; | 020h | 024h | 028h | 02ch | 030h | 034h | 038h | 03ch | 18 | ; --------------------------------------------------------------------------------- 19 | ; | ESI | EBX | EBP | EIP | to | data | EH NXT |SEH HNDLR| 20 | ; --------------------------------------------------------------------------------- 21 | 22 | .386 23 | .XMM 24 | .model flat, c 25 | ; standard C library function 26 | _exit PROTO, value:SDWORD 27 | .code 28 | 29 | jq_make_fcontext PROC BOOST_CONTEXT_EXPORT 30 | ; first arg of jq_make_fcontext() == top of context-stack 31 | mov eax, [esp+04h] 32 | 33 | ; reserve space for first argument of context-function 34 | ; EAX might already point to a 16byte border 35 | lea eax, [eax-08h] 36 | 37 | ; shift address in EAX to lower 16 byte boundary 38 | and eax, -16 39 | 40 | ; reserve space for context-data on context-stack 41 | ; on context-function entry: (ESP -0x4) % 8 == 0 42 | ; additional space is required for SEH 43 | lea eax, [eax-040h] 44 | 45 | ; save MMX control- and status-word 46 | stmxcsr [eax] 47 | ; save x87 control-word 48 | fnstcw [eax+04h] 49 | 50 | ; first arg of jq_make_fcontext() == top of context-stack 51 | mov ecx, [esp+04h] 52 | ; save top address of context stack as 'base' 53 | mov [eax+014h], ecx 54 | ; second arg of jq_make_fcontext() == size of context-stack 55 | mov edx, [esp+08h] 56 | ; negate stack size for LEA instruction (== substraction) 57 | neg edx 58 | ; compute bottom address of context stack (limit) 59 | lea ecx, [ecx+edx] 60 | ; save bottom address of context-stack as 'limit' 61 | mov [eax+010h], ecx 62 | ; save bottom address of context-stack as 'dealloction stack' 63 | mov [eax+0ch], ecx 64 | ; set fiber-storage to zero 65 | xor ecx, ecx 66 | mov [eax+08h], ecx 67 | 68 | ; third arg of jq_make_fcontext() == address of context-function 69 | ; stored in EBX 70 | mov ecx, [esp+0ch] 71 | mov [eax+024h], ecx 72 | 73 | ; compute abs address of label trampoline 74 | mov ecx, trampoline 75 | ; save address of trampoline as return-address for context-function 76 | ; will be entered after calling jq_jump_fcontext() first time 77 | mov [eax+02ch], ecx 78 | 79 | ; compute abs address of label finish 80 | mov ecx, finish 81 | ; save address of finish as return-address for context-function in EBP 82 | ; will be entered after context-function returns 83 | mov [eax+028h], ecx 84 | 85 | ; traverse current seh chain to get the last exception handler installed by Windows 86 | ; note that on Windows Server 2008 and 2008 R2, SEHOP is activated by default 87 | ; the exception handler chain is tested for the presence of ntdll.dll!FinalExceptionHandler 88 | ; at its end by RaiseException all seh-handlers are disregarded if not present and the 89 | ; program is aborted 90 | assume fs:nothing 91 | ; load NT_TIB into ECX 92 | mov ecx, fs:[0h] 93 | assume fs:error 94 | 95 | walk: 96 | ; load 'next' member of current SEH into EDX 97 | mov edx, [ecx] 98 | ; test if 'next' of current SEH is last (== 0xffffffff) 99 | inc edx 100 | jz found 101 | dec edx 102 | ; exchange content; ECX contains address of next SEH 103 | xchg edx, ecx 104 | ; inspect next SEH 105 | jmp walk 106 | 107 | found: 108 | ; load 'handler' member of SEH == address of last SEH handler installed by Windows 109 | mov ecx, [ecx+04h] 110 | ; save address in ECX as SEH handler for context 111 | mov [eax+03ch], ecx 112 | ; set ECX to -1 113 | mov ecx, 0ffffffffh 114 | ; save ECX as next SEH item 115 | mov [eax+038h], ecx 116 | ; load address of next SEH item 117 | lea ecx, [eax+038h] 118 | ; save next SEH 119 | mov [eax+018h], ecx 120 | 121 | ret ; return pointer to context-data 122 | 123 | trampoline: 124 | ; move transport_t for entering context-function 125 | ; FCTX == EAX, DATA == EDX 126 | mov [esp], eax 127 | mov [esp+04h], edx 128 | push ebp 129 | ; jump to context-function 130 | jmp ebx 131 | 132 | finish: 133 | ; exit code is zero 134 | xor eax, eax 135 | mov [esp], eax 136 | ; exit application 137 | call _exit 138 | hlt 139 | jq_make_fcontext ENDP 140 | END 141 | -------------------------------------------------------------------------------- /boost_context/make_i386_sysv_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /**************************************************************************************** 9 | * * 10 | * ---------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ---------------------------------------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | * 14 | * ---------------------------------------------------------------------------------- * 15 | * | fc_mxcsr|fc_x87_cw| EDI | ESI | EBX | EBP | EIP | hidden | * 16 | * ---------------------------------------------------------------------------------- * 17 | * ---------------------------------------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ---------------------------------------------------------------------------------- * 20 | * | 0x20 | 0x24 | | * 21 | * ---------------------------------------------------------------------------------- * 22 | * | to | data | | * 23 | * ---------------------------------------------------------------------------------- * 24 | * * 25 | ****************************************************************************************/ 26 | 27 | .text 28 | .globl jq_make_fcontext 29 | .align 2 30 | .type jq_make_fcontext,@function 31 | jq_make_fcontext: 32 | /* first arg of jq_make_fcontext() == top of context-stack */ 33 | movl 0x4(%esp), %eax 34 | 35 | /* reserve space for first argument of context-function 36 | eax might already point to a 16byte border */ 37 | leal -0x8(%eax), %eax 38 | 39 | /* shift address in EAX to lower 16 byte boundary */ 40 | andl $-16, %eax 41 | 42 | /* reserve space for context-data on context-stack */ 43 | leal -0x28(%eax), %eax 44 | 45 | /* third arg of jq_make_fcontext() == address of context-function */ 46 | /* stored in EBX */ 47 | movl 0xc(%esp), %ecx 48 | movl %ecx, 0x10(%eax) 49 | 50 | /* save MMX control- and status-word */ 51 | stmxcsr (%eax) 52 | /* save x87 control-word */ 53 | fnstcw 0x4(%eax) 54 | 55 | /* return transport_t */ 56 | /* FCTX == EDI, DATA == ESI */ 57 | leal 0x8(%eax), %ecx 58 | movl %ecx, 0x1c(%eax) 59 | 60 | /* compute abs address of label trampoline */ 61 | call 1f 62 | /* address of trampoline 1 */ 63 | 1: popl %ecx 64 | /* compute abs address of label trampoline */ 65 | addl $trampoline-1b, %ecx 66 | /* save address of trampoline as return address */ 67 | /* will be entered after calling jump_fcontext() first time */ 68 | movl %ecx, 0x18(%eax) 69 | 70 | /* compute abs address of label finish */ 71 | call 2f 72 | /* address of label 2 */ 73 | 2: popl %ecx 74 | /* compute abs address of label finish */ 75 | addl $finish-2b, %ecx 76 | /* save address of finish as return-address for context-function */ 77 | /* will be entered after context-function returns */ 78 | movl %ecx, 0x14(%eax) 79 | 80 | ret /* return pointer to context-data */ 81 | 82 | trampoline: 83 | /* move transport_t for entering context-function */ 84 | movl %edi, (%esp) 85 | movl %esi, 0x4(%esp) 86 | pushl %ebp 87 | /* jump to context-function */ 88 | jmp *%ebx 89 | 90 | finish: 91 | call 3f 92 | /* address of label 3 */ 93 | 3: popl %ebx 94 | /* compute address of GOT and store it in EBX */ 95 | addl $_GLOBAL_OFFSET_TABLE_+[.-3b], %ebx 96 | 97 | /* exit code is zero */ 98 | xorl %eax, %eax 99 | movl %eax, (%esp) 100 | /* exit application */ 101 | call _exit@PLT 102 | hlt 103 | .size jq_make_fcontext,.-jq_make_fcontext 104 | 105 | /* Mark that we don't need executable stack. */ 106 | .section .note.GNU-stack,"",%progbits 107 | -------------------------------------------------------------------------------- /boost_context/make_i386_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /**************************************************************************************** 9 | * * 10 | * ---------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ---------------------------------------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | * 14 | * ---------------------------------------------------------------------------------- * 15 | * | fc_mxcsr|fc_x87_cw| EDI | ESI | EBX | EBP | EIP | hidden | * 16 | * ---------------------------------------------------------------------------------- * 17 | * ---------------------------------------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ---------------------------------------------------------------------------------- * 20 | * | 0x20 | 0x24 | | * 21 | * ---------------------------------------------------------------------------------- * 22 | * | to | data | | * 23 | * ---------------------------------------------------------------------------------- * 24 | * * 25 | ****************************************************************************************/ 26 | 27 | .text 28 | .globl _jq_make_fcontext 29 | .align 2 30 | _jq_make_fcontext: 31 | /* first arg of make_fcontext() == top of context-stack */ 32 | movl 0x4(%esp), %eax 33 | 34 | /* reserve space for first argument of context-function 35 | eax might already point to a 16byte border */ 36 | leal -0x8(%eax), %eax 37 | 38 | /* shift address in EAX to lower 16 byte boundary */ 39 | andl $-16, %eax 40 | 41 | /* reserve space for context-data on context-stack */ 42 | leal -0x28(%eax), %eax 43 | 44 | /* third arg of make_fcontext() == address of context-function */ 45 | /* stored in EBX */ 46 | movl 0xc(%esp), %ecx 47 | movl %ecx, 0x10(%eax) 48 | 49 | /* save MMX control- and status-word */ 50 | stmxcsr (%eax) 51 | /* save x87 control-word */ 52 | fnstcw 0x4(%eax) 53 | 54 | /* return transport_t */ 55 | /* FCTX == EDI, DATA == ESI */ 56 | leal 0x8(%eax), %ecx 57 | movl %ecx, 0x1c(%eax) 58 | 59 | /* compute abs address of label trampoline */ 60 | call 1f 61 | /* address of trampoline 1 */ 62 | 1: popl %ecx 63 | /* compute abs address of label trampoline */ 64 | addl $trampoline-1b, %ecx 65 | /* save address of trampoline as return address */ 66 | /* will be entered after calling jump_fcontext() first time */ 67 | movl %ecx, 0x18(%eax) 68 | 69 | /* compute abs address of label finish */ 70 | call 2f 71 | /* address of label 2 */ 72 | 2: popl %ecx 73 | /* compute abs address of label finish */ 74 | addl $finish-2b, %ecx 75 | /* save address of finish as return-address for context-function */ 76 | /* will be entered after context-function returns */ 77 | movl %ecx, 0x14(%eax) 78 | 79 | ret /* return pointer to context-data */ 80 | 81 | trampoline: 82 | /* move transport_t for entering context-function */ 83 | movl %edi, (%esp) 84 | movl %esi, 0x4(%esp) 85 | pushl %ebp 86 | /* jump to context-function */ 87 | jmp *%ebx 88 | 89 | finish: 90 | /* exit code is zero */ 91 | xorl %eax, %eax 92 | movl %eax, (%esp) 93 | /* exit application */ 94 | call __exit 95 | hlt 96 | -------------------------------------------------------------------------------- /boost_context/make_i386_x86_64_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Sergue E. Leontiev 2013. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Stub file for universal binary 9 | 10 | #if defined(__i386__) 11 | #include "make_i386_sysv_macho_gas.S" 12 | #elif defined(__x86_64__) 13 | #include "make_x86_64_sysv_macho_gas.S" 14 | #else 15 | #error "No arch's" 16 | #endif 17 | -------------------------------------------------------------------------------- /boost_context/make_mips32_o32_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /******************************************************* 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | * 14 | * ------------------------------------------------- * 15 | * | S0 | S1 | S2 | S3 | S4 | S5 | S6 | S7 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | * 21 | * ------------------------------------------------- * 22 | * | FP |hiddn| RA | PC | GP | FCTX| DATA| | * 23 | * ------------------------------------------------- * 24 | * * 25 | * *****************************************************/ 26 | /******************************************************* 27 | * * 28 | * ------------------------------------------------- * 29 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 30 | * ------------------------------------------------- * 31 | * | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | * 32 | * ------------------------------------------------- * 33 | * | F20 | F22 | F24 | F26 | * 34 | * ------------------------------------------------- * 35 | * ------------------------------------------------- * 36 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 37 | * ------------------------------------------------- * 38 | * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | * 39 | * ------------------------------------------------- * 40 | * | F28 | F30 | S0 | S1 | S2 | S3 | * 41 | * ------------------------------------------------- * 42 | * ------------------------------------------------- * 43 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 44 | * ------------------------------------------------- * 45 | * | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | * 46 | * ------------------------------------------------- * 47 | * | S4 | S5 | S6 | S7 | FP |hiddn| RA | PC | * 48 | * ------------------------------------------------- * 49 | * ------------------------------------------------- * 50 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 51 | * ------------------------------------------------- * 52 | * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | * 53 | * ------------------------------------------------- * 54 | * | GP | FCTX| DATA| | | | | | * 55 | * ------------------------------------------------- * 56 | * * 57 | * *****************************************************/ 58 | 59 | .text 60 | .globl jq_make_fcontext 61 | .align 2 62 | .type jq_make_fcontext,@function 63 | .ent jq_make_fcontext 64 | jq_make_fcontext: 65 | #ifdef __PIC__ 66 | .set noreorder 67 | .cpload $t9 68 | .set reorder 69 | #endif 70 | # first arg of jq_make_fcontext() == top address of context-stack 71 | move $v0, $a0 72 | 73 | # shift address in A0 to lower 16 byte boundary 74 | move $v1, $v0 75 | li $v0, -16 # 0xfffffffffffffff0 76 | and $v0, $v1, $v0 77 | 78 | # reserve space for context-data on context-stack 79 | # including 48 byte of shadow space (sp % 16 == 0) 80 | addiu $v0, $v0, -112 81 | 82 | # third arg of jq_make_fcontext() == address of context-function 83 | sw $a2, 92($v0) 84 | # save global pointer in context-data 85 | sw $gp, 96($v0) 86 | 87 | # compute address of returned transfer_t 88 | addiu $t0, $v0, 52 89 | sw $t0, 84($v0) 90 | 91 | # compute abs address of label finish 92 | la $t9, finish 93 | # save address of finish as return-address for context-function 94 | # will be entered after context-function returns 95 | sw $t9, 88($v0) 96 | 97 | jr $ra # return pointer to context-data 98 | 99 | finish: 100 | lw $gp, 0($sp) 101 | # allocate stack space (contains shadow space for subroutines) 102 | addiu $sp, $sp, -32 103 | # save return address 104 | sw $ra, 28($sp) 105 | 106 | # restore GP (global pointer) 107 | # move $gp, $s1 108 | # exit code is zero 109 | move $a0, $zero 110 | # address of exit 111 | lw $t9, %call16(_exit)($gp) 112 | # exit application 113 | jalr $t9 114 | .end jq_make_fcontext 115 | .size jq_make_fcontext, .-jq_make_fcontext 116 | 117 | /* Mark that we don't need executable stack. */ 118 | .section .note.GNU-stack,"",%progbits 119 | -------------------------------------------------------------------------------- /boost_context/make_ppc32_ppc64_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Sergue E. Leontiev 2013. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // Stub file for universal binary 9 | 10 | #if defined(__ppc__) 11 | #include "make_ppc32_sysv_macho_gas.S" 12 | #elif defined(__ppc64__) 13 | #include "make_ppc64_sysv_macho_gas.S" 14 | #else 15 | #error "No arch's" 16 | #endif 17 | -------------------------------------------------------------------------------- /boost_context/make_ppc32_sysv_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /****************************************************** 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | * 14 | * ------------------------------------------------- * 15 | * | F14 | F15 | F16 | F17 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | * 21 | * ------------------------------------------------- * 22 | * | F18 | F19 | F20 | F21 | * 23 | * ------------------------------------------------- * 24 | * ------------------------------------------------- * 25 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 26 | * ------------------------------------------------- * 27 | * | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | * 28 | * ------------------------------------------------- * 29 | * | F22 | F23 | F24 | F25 | * 30 | * ------------------------------------------------- * 31 | * ------------------------------------------------- * 32 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 33 | * ------------------------------------------------- * 34 | * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | * 35 | * ------------------------------------------------- * 36 | * | F26 | F27 | F28 | F29 | * 37 | * ------------------------------------------------- * 38 | * ------------------------------------------------- * 39 | * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * 40 | * ------------------------------------------------- * 41 | * | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | * 42 | * ------------------------------------------------- * 43 | * | F30 | F31 | fpscr | R13 | R14 | * 44 | * ------------------------------------------------- * 45 | * ------------------------------------------------- * 46 | * | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | * 47 | * ------------------------------------------------- * 48 | * | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | * 49 | * ------------------------------------------------- * 50 | * | R15 | R16 | R17 | R18 | R19 | R20 | R21 | R22 | * 51 | * ------------------------------------------------- * 52 | * ------------------------------------------------- * 53 | * | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | * 54 | * ------------------------------------------------- * 55 | * | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | * 56 | * ------------------------------------------------- * 57 | * | R23 | R24 | R25 | R26 | R27 | R28 | R29 | R30 | * 58 | * ------------------------------------------------- * 59 | * ------------------------------------------------- * 60 | * | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | * 61 | * ------------------------------------------------- * 62 | * | 224 | 228 | 232 | 236 | 240 | 244 | 248 | 252 | * 63 | * ------------------------------------------------- * 64 | * | R31 |hiddn| CR | LR | PC |bchai|linkr| FCTX| * 65 | * ------------------------------------------------- * 66 | * ------------------------------------------------- * 67 | * | 64 | | * 68 | * ------------------------------------------------- * 69 | * | 256 | | * 70 | * ------------------------------------------------- * 71 | * | DATA| | * 72 | * ------------------------------------------------- * 73 | * * 74 | *******************************************************/ 75 | 76 | .text 77 | .globl jq_make_fcontext 78 | .align 2 79 | .type jq_make_fcontext,@function 80 | jq_make_fcontext: 81 | # save return address into R6 82 | mflr %r6 83 | 84 | # first arg of jq_make_fcontext() == top address of context-function 85 | # shift address in R3 to lower 16 byte boundary 86 | clrrwi %r3, %r3, 4 87 | 88 | # reserve space for context-data on context-stack 89 | # including 64 byte of linkage + parameter area (R1 % 16 == 0) 90 | subi %r3, %r3, 336 91 | 92 | # third arg of jq_make_fcontext() == address of context-function 93 | stw %r5, 240(%r3) 94 | 95 | # set back-chain to zero 96 | li %r0, 0 97 | stw %r0, 244(%r3) 98 | 99 | mffs %f0 # load FPSCR 100 | stfd %f0, 144(%r3) # save FPSCR 101 | 102 | # compute address of returned transfer_t 103 | addi %r0, %r3, 252 104 | mr %r4, %r0 105 | stw %r4, 228(%r3) 106 | 107 | # load LR 108 | mflr %r0 109 | # jump to label 1 110 | bl 1f 111 | 1: 112 | # load LR into R4 113 | mflr %r4 114 | # compute abs address of label finish 115 | addi %r4, %r4, finish - 1b 116 | # restore LR 117 | mtlr %r0 118 | # save address of finish as return-address for context-function 119 | # will be entered after context-function returns 120 | stw %r4, 236(%r3) 121 | 122 | # restore return address from R6 123 | mtlr %r6 124 | 125 | blr # return pointer to context-data 126 | 127 | finish: 128 | # save return address into R0 129 | mflr %r0 130 | # save return address on stack, set up stack frame 131 | stw %r0, 4(%r1) 132 | # allocate stack space, R1 % 16 == 0 133 | stwu %r1, -16(%r1) 134 | 135 | # exit code is zero 136 | li %r3, 0 137 | # exit application 138 | bl _exit@plt 139 | .size jq_make_fcontext, .-jq_make_fcontext 140 | 141 | /* Mark that we don't need executable stack. */ 142 | .section .note.GNU-stack,"",%progbits 143 | -------------------------------------------------------------------------------- /boost_context/make_ppc32_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /****************************************************** 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | * 14 | * ------------------------------------------------- * 15 | * | F14 | F15 | F16 | F17 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | * 21 | * ------------------------------------------------- * 22 | * | F18 | F19 | F20 | F21 | * 23 | * ------------------------------------------------- * 24 | * ------------------------------------------------- * 25 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 26 | * ------------------------------------------------- * 27 | * | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | * 28 | * ------------------------------------------------- * 29 | * | F22 | F23 | F24 | F25 | * 30 | * ------------------------------------------------- * 31 | * ------------------------------------------------- * 32 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 33 | * ------------------------------------------------- * 34 | * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | * 35 | * ------------------------------------------------- * 36 | * | F26 | F27 | F28 | F29 | * 37 | * ------------------------------------------------- * 38 | * ------------------------------------------------- * 39 | * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * 40 | * ------------------------------------------------- * 41 | * | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | * 42 | * ------------------------------------------------- * 43 | * | F30 | F31 | fpscr | R13 | R14 | * 44 | * ------------------------------------------------- * 45 | * ------------------------------------------------- * 46 | * | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | * 47 | * ------------------------------------------------- * 48 | * | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | * 49 | * ------------------------------------------------- * 50 | * | R15 | R16 | R17 | R18 | R19 | R20 | R21 | R22 | * 51 | * ------------------------------------------------- * 52 | * ------------------------------------------------- * 53 | * | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | * 54 | * ------------------------------------------------- * 55 | * | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | * 56 | * ------------------------------------------------- * 57 | * | R23 | R24 | R25 | R26 | R27 | R28 | R29 | R30 | * 58 | * ------------------------------------------------- * 59 | * ------------------------------------------------- * 60 | * | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | * 61 | * ------------------------------------------------- * 62 | * | 224 | 228 | 232 | 236 | 240 | 244 | 248 | 252 | * 63 | * ------------------------------------------------- * 64 | * | R31 |hiddn| CR | LR | PC |bchai|linkr| FCTX| * 65 | * ------------------------------------------------- * 66 | * ------------------------------------------------- * 67 | * | 64 | | * 68 | * ------------------------------------------------- * 69 | * | 256 | | * 70 | * ------------------------------------------------- * 71 | * | DATA| | * 72 | * ------------------------------------------------- * 73 | * * 74 | *******************************************************/ 75 | 76 | .text 77 | .globl _jq_make_fcontext 78 | .align 2 79 | _jq_make_fcontext: 80 | # save return address into R6 81 | mflr r6 82 | 83 | # first arg of make_fcontext() == top address of context-function 84 | # shift address in R3 to lower 16 byte boundary 85 | clrrwi r3, r3, 4 86 | 87 | # reserve space for context-data on context-stack 88 | # including 64 byte of linkage + parameter area (R1 16 == 0) 89 | subi r3, r3, 336 90 | 91 | # third arg of make_fcontext() == address of context-function 92 | stw r5, 240(r3) 93 | 94 | # set back-chain to zero 95 | li r0, 0 96 | stw r0, 244(r3) 97 | 98 | mffs f0 # load FPSCR 99 | stfd f0, 144(r3) # save FPSCR 100 | 101 | # compute address of returned transfer_t 102 | addi r0, r3, 252 103 | mr r4, r0 104 | stw r4, 228(r3) 105 | 106 | # load LR 107 | mflr r0 108 | # jump to label 1 109 | bl 1f 110 | 1: 111 | # load LR into R4 112 | mflr r4 113 | # compute abs address of label finish 114 | addi r4, r4, finish - 1b 115 | # restore LR 116 | mtlr r0 117 | # save address of finish as return-address for context-function 118 | # will be entered after context-function returns 119 | stw r4, 236(r3) 120 | 121 | # restore return address from R6 122 | mtlr r6 123 | 124 | blr # return pointer to context-data 125 | 126 | finish: 127 | # save return address into R0 128 | mflr r0 129 | # save return address on stack, set up stack frame 130 | stw r0, 4(r1) 131 | # allocate stack space, R1 16 == 0 132 | stwu r1, -16(r1) 133 | 134 | # exit code is zero 135 | li r3, 0 136 | # exit application 137 | bl _exit@plt 138 | -------------------------------------------------------------------------------- /boost_context/make_ppc32_sysv_xcoff_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /****************************************************** 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | * 14 | * ------------------------------------------------- * 15 | * | F14 | F15 | F16 | F17 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | * 21 | * ------------------------------------------------- * 22 | * | F18 | F19 | F20 | F21 | * 23 | * ------------------------------------------------- * 24 | * ------------------------------------------------- * 25 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 26 | * ------------------------------------------------- * 27 | * | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | * 28 | * ------------------------------------------------- * 29 | * | F22 | F23 | F24 | F25 | * 30 | * ------------------------------------------------- * 31 | * ------------------------------------------------- * 32 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 33 | * ------------------------------------------------- * 34 | * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | * 35 | * ------------------------------------------------- * 36 | * | F26 | F27 | F28 | F29 | * 37 | * ------------------------------------------------- * 38 | * ------------------------------------------------- * 39 | * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * 40 | * ------------------------------------------------- * 41 | * | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | * 42 | * ------------------------------------------------- * 43 | * | F30 | F31 | fpscr | R13 | R14 | * 44 | * ------------------------------------------------- * 45 | * ------------------------------------------------- * 46 | * | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | * 47 | * ------------------------------------------------- * 48 | * | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | * 49 | * ------------------------------------------------- * 50 | * | R15 | R16 | R17 | R18 | R19 | R20 | R21 | R22 | * 51 | * ------------------------------------------------- * 52 | * ------------------------------------------------- * 53 | * | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | * 54 | * ------------------------------------------------- * 55 | * | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | * 56 | * ------------------------------------------------- * 57 | * | R23 | R24 | R25 | R26 | R27 | R28 | R29 | R30 | * 58 | * ------------------------------------------------- * 59 | * ------------------------------------------------- * 60 | * | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | * 61 | * ------------------------------------------------- * 62 | * | 224 | 228 | 232 | 236 | 240 | 244 | 248 | 252 | * 63 | * ------------------------------------------------- * 64 | * | R31 |hiddn| CR | LR | PC |bchai|linkr| FCTX| * 65 | * ------------------------------------------------- * 66 | * ------------------------------------------------- * 67 | * | 64 | | * 68 | * ------------------------------------------------- * 69 | * | 256 | | * 70 | * ------------------------------------------------- * 71 | * | DATA| | * 72 | * ------------------------------------------------- * 73 | * * 74 | *******************************************************/ 75 | .globl jq_make_fcontext[DS] 76 | .globl .jq_make_fcontext[PR] 77 | .align 2 78 | .csect jq_make_fcontext[DS] 79 | jq_make_fcontext: 80 | .long .jq_make_fcontext[PR] 81 | .csect .jq_make_fcontext[PR], 3 82 | #.jq_make_fcontext: 83 | # save return address into R6 84 | mflr 6 85 | 86 | # first arg of jq_make_fcontext() == top address of context-function 87 | # shift address in R3 to lower 16 byte boundary 88 | clrrwi 3, 3, 4 89 | 90 | # reserve space for context-data on context-stack 91 | # including 64 byte of linkage + parameter area (R1 % 16 == 0) 92 | subi 3, 3, 336 93 | 94 | # third arg of jq_make_fcontext() == address of context-function 95 | stw 5, 240(3) 96 | 97 | # set back-chain to zero 98 | li 0, 0 99 | stw 0, 244(3) 100 | 101 | # compute address of returned transfer_t 102 | addi 0, 3, 252 103 | mr 4, 0 104 | stw 4, 228(3) 105 | 106 | # load LR 107 | mflr 0 108 | # jump to label 1 109 | bl .Label 110 | .Label: 111 | # load LR into R4 112 | mflr 4 113 | # compute abs address of label .L_finish 114 | addi 4, 4, .L_finish - .Label 115 | # restore LR 116 | mtlr 0 117 | # save address of finish as return-address for context-function 118 | # will be entered after context-function returns 119 | stw 4, 236(3) 120 | 121 | # restore return address from R6 122 | mtlr 6 123 | 124 | blr # return pointer to context-data 125 | 126 | .L_finish: 127 | # save return address into R0 128 | mflr 0 129 | # save return address on stack, set up stack frame 130 | stw 0, 4(1) 131 | # allocate stack space, R1 % 16 == 0 132 | stwu 1, -16(1) 133 | 134 | # exit code is zero 135 | li 3, 0 136 | # exit application 137 | bl ._exit 138 | nop 139 | -------------------------------------------------------------------------------- /boost_context/make_ppc64_sysv_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /******************************************************* 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | * 14 | * ------------------------------------------------- * 15 | * | TOC | R14 | R15 | R16 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | * 21 | * ------------------------------------------------- * 22 | * | R17 | R18 | R19 | R20 | * 23 | * ------------------------------------------------- * 24 | * ------------------------------------------------- * 25 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 26 | * ------------------------------------------------- * 27 | * | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | * 28 | * ------------------------------------------------- * 29 | * | R21 | R22 | R23 | R24 | * 30 | * ------------------------------------------------- * 31 | * ------------------------------------------------- * 32 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 33 | * ------------------------------------------------- * 34 | * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | * 35 | * ------------------------------------------------- * 36 | * | R25 | R26 | R27 | R28 | * 37 | * ------------------------------------------------- * 38 | * ------------------------------------------------- * 39 | * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * 40 | * ------------------------------------------------- * 41 | * | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | * 42 | * ------------------------------------------------- * 43 | * | R29 | R30 | R31 | hidden | * 44 | * ------------------------------------------------- * 45 | * ------------------------------------------------- * 46 | * | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | * 47 | * ------------------------------------------------- * 48 | * | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | * 49 | * ------------------------------------------------- * 50 | * | CR | LR | PC | back-chain| * 51 | * ------------------------------------------------- * 52 | * ------------------------------------------------- * 53 | * | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | * 54 | * ------------------------------------------------- * 55 | * | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | * 56 | * ------------------------------------------------- * 57 | * | cr saved | lr saved | compiler | linker | * 58 | * ------------------------------------------------- * 59 | * ------------------------------------------------- * 60 | * | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | * 61 | * ------------------------------------------------- * 62 | * | 224 | 228 | 232 | 236 | 240 | 244 | 248 | 252 | * 63 | * ------------------------------------------------- * 64 | * | TOC saved | FCTX | DATA | | * 65 | * ------------------------------------------------- * 66 | * * 67 | *******************************************************/ 68 | 69 | .globl jq_make_fcontext 70 | #if _CALL_ELF == 2 71 | .text 72 | .align 2 73 | jq_make_fcontext: 74 | addis %r2, %r12, .TOC.-jq_make_fcontext@ha 75 | addi %r2, %r2, .TOC.-jq_make_fcontext@l 76 | .localentry jq_make_fcontext, . - jq_make_fcontext 77 | #else 78 | .section ".opd","aw" 79 | .align 3 80 | jq_make_fcontext: 81 | # ifdef _CALL_LINUX 82 | .quad .L.jq_make_fcontext,.TOC.@tocbase,0 83 | .type jq_make_fcontext,@function 84 | .text 85 | .align 2 86 | .L.jq_make_fcontext: 87 | # else 88 | .hidden .jq_make_fcontext 89 | .globl .jq_make_fcontext 90 | .quad .jq_make_fcontext,.TOC.@tocbase,0 91 | .size jq_make_fcontext,24 92 | .type .jq_make_fcontext,@function 93 | .text 94 | .align 2 95 | .jq_make_fcontext: 96 | # endif 97 | #endif 98 | # save return address into R6 99 | mflr %r6 100 | 101 | # first arg of jq_make_fcontext() == top address of context-stack 102 | # shift address in R3 to lower 16 byte boundary 103 | clrrdi %r3, %r3, 4 104 | 105 | # reserve space for context-data on context-stack 106 | # including 64 byte of linkage + parameter area (R1 % 16 == 0) 107 | subi %r3, %r3, 248 108 | 109 | # third arg of jq_make_fcontext() == address of context-function 110 | # entry point (ELFv2) or descriptor (ELFv1) 111 | #if _CALL_ELF == 2 112 | # save address of context-function entry point 113 | std %r5, 176(%r3) 114 | #else 115 | # save address of context-function entry point 116 | ld %r4, 0(%r5) 117 | std %r4, 176(%r3) 118 | # save TOC of context-function 119 | ld %r4, 8(%r5) 120 | std %r4, 0(%r3) 121 | #endif 122 | 123 | # set back-chain to zero 124 | li %r0, 0 125 | std %r0, 184(%r3) 126 | 127 | # compute address of returned transfer_t 128 | addi %r0, %r3, 232 129 | mr %r4, %r0 130 | std %r4, 152(%r3) 131 | 132 | # load LR 133 | mflr %r0 134 | # jump to label 1 135 | bl 1f 136 | 1: 137 | # load LR into R4 138 | mflr %r4 139 | # compute abs address of label finish 140 | addi %r4, %r4, finish - 1b 141 | # restore LR 142 | mtlr %r0 143 | # save address of finish as return-address for context-function 144 | # will be entered after context-function returns 145 | std %r4, 168(%r3) 146 | 147 | # restore return address from R6 148 | mtlr %r6 149 | 150 | blr # return pointer to context-data 151 | 152 | finish: 153 | # save return address into R0 154 | mflr %r0 155 | # save return address on stack, set up stack frame 156 | std %r0, 8(%r1) 157 | # allocate stack space, R1 % 16 == 0 158 | stdu %r1, -32(%r1) 159 | 160 | # exit code is zero 161 | li %r3, 0 162 | # exit application 163 | bl _exit 164 | nop 165 | #if _CALL_ELF == 2 166 | .size jq_make_fcontext, .-jq_make_fcontext 167 | #else 168 | # ifdef _CALL_LINUX 169 | .size .jq_make_fcontext, .-.L.jq_make_fcontext 170 | # else 171 | .size .jq_make_fcontext, .-.jq_make_fcontext 172 | # endif 173 | #endif 174 | 175 | /* Mark that we don't need executable stack. */ 176 | .section .note.GNU-stack,"",%progbits 177 | -------------------------------------------------------------------------------- /boost_context/make_ppc64_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /******************************************************* 9 | * * 10 | * ------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ------------------------------------------------- * 13 | * | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | * 14 | * ------------------------------------------------- * 15 | * | TOC | R14 | R15 | R16 | * 16 | * ------------------------------------------------- * 17 | * ------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ------------------------------------------------- * 20 | * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | * 21 | * ------------------------------------------------- * 22 | * | R17 | R18 | R19 | R20 | * 23 | * ------------------------------------------------- * 24 | * ------------------------------------------------- * 25 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * 26 | * ------------------------------------------------- * 27 | * | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | * 28 | * ------------------------------------------------- * 29 | * | R21 | R22 | R23 | R24 | * 30 | * ------------------------------------------------- * 31 | * ------------------------------------------------- * 32 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * 33 | * ------------------------------------------------- * 34 | * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | * 35 | * ------------------------------------------------- * 36 | * | R25 | R26 | R27 | R28 | * 37 | * ------------------------------------------------- * 38 | * ------------------------------------------------- * 39 | * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * 40 | * ------------------------------------------------- * 41 | * | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | * 42 | * ------------------------------------------------- * 43 | * | R29 | R30 | R31 | hidden | * 44 | * ------------------------------------------------- * 45 | * ------------------------------------------------- * 46 | * | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | * 47 | * ------------------------------------------------- * 48 | * | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | * 49 | * ------------------------------------------------- * 50 | * | CR | LR | PC | back-chain| * 51 | * ------------------------------------------------- * 52 | * ------------------------------------------------- * 53 | * | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | * 54 | * ------------------------------------------------- * 55 | * | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | * 56 | * ------------------------------------------------- * 57 | * | cr saved | lr saved | compiler | linker | * 58 | * ------------------------------------------------- * 59 | * ------------------------------------------------- * 60 | * | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | * 61 | * ------------------------------------------------- * 62 | * | 224 | 228 | 232 | 236 | 240 | 244 | 248 | 252 | * 63 | * ------------------------------------------------- * 64 | * | TOC saved | FCTX | DATA | | * 65 | * ------------------------------------------------- * 66 | * * 67 | 68 | .text 69 | .globl _jq_make_fcontext 70 | _jq_make_fcontext: 71 | ; save return address into R6 72 | mflr r6 73 | 74 | ; first arg of make_fcontext() == top address of context-function 75 | ; shift address in R3 to lower 16 byte boundary 76 | clrrwi r3, r3, 4 77 | 78 | ; reserve space for context-data on context-stack 79 | ; including 64 byte of linkage + parameter area (R1 16 == 0) 80 | subi r3, r3, 248 81 | 82 | ; third arg of make_fcontext() == address of context-function 83 | stw r5, 176(r3) 84 | 85 | ; set back-chain to zero 86 | li %r0, 0 87 | std %r0, 184(%r3) 88 | 89 | ; compute address of returned transfer_t 90 | addi %r0, %r3, 232 91 | mr %r4, %r0 92 | std %r4, 152(%r3) 93 | 94 | ; load LR 95 | mflr r0 96 | ; jump to label 1 97 | bl l1 98 | l1: 99 | ; load LR into R4 100 | mflr r4 101 | ; compute abs address of label finish 102 | addi r4, r4, lo16((finish - .) + 4) 103 | ; restore LR 104 | mtlr r0 105 | ; save address of finish as return-address for context-function 106 | ; will be entered after context-function returns 107 | std r4, 168(r3) 108 | 109 | ; restore return address from R6 110 | mtlr r6 111 | 112 | blr ; return pointer to context-data 113 | 114 | finish: 115 | ; save return address into R0 116 | mflr r0 117 | ; save return address on stack, set up stack frame 118 | stw r0, 8(r1) 119 | ; allocate stack space, R1 16 == 0 120 | stwu r1, -32(r1) 121 | 122 | ; set return value to zero 123 | li r3, 0 124 | ; exit application 125 | bl __exit 126 | nop 127 | -------------------------------------------------------------------------------- /boost_context/make_ppc64_sysv_xcoff_gas.S: -------------------------------------------------------------------------------- 1 | .globl jq_make_fcontext[DS] 2 | .globl .jq_make_fcontext[PR] 3 | .align 2 4 | .csect .jq_make_fcontext[PR], 3 5 | .globl _jq_make_fcontext 6 | #._jq_make_fcontext: 7 | # save return address into R6 8 | mflr 6 9 | 10 | # first arg of jq_make_fcontext() == top address of context-function 11 | # shift address in R3 to lower 16 byte boundary 12 | clrrwi 3, 3, 4 13 | 14 | # reserve space for context-data on context-stack 15 | # including 64 byte of linkage + parameter area (R1 % 16 == 0) 16 | subi 3, 3, 248 17 | 18 | # third arg of jq_make_fcontext() == address of context-function 19 | stw 5, 176(3) 20 | 21 | # set back-chain to zero 22 | li 0, 0 23 | std 0, 184(3) 24 | 25 | # compute address of returned transfer_t 26 | addi 0, 3, 232 27 | mr 4, 0 28 | std 4, 152(3) 29 | 30 | # load LR 31 | mflr 0 32 | # jump to label 1 33 | bl .Label 34 | .Label: 35 | # load LR into R4 36 | mflr 4 37 | # compute abs address of label .L_finish 38 | addi 4, 4, .L_finish - .Label 39 | # restore LR 40 | mtlr 0 41 | # save address of finish as return-address for context-function 42 | # will be entered after context-function returns 43 | stw 4, 168(3) 44 | 45 | # restore return address from R6 46 | mtlr 6 47 | 48 | blr # return pointer to context-data 49 | 50 | .L_finish: 51 | # save return address into R0 52 | mflr 0 53 | # save return address on stack, set up stack frame 54 | stw 0, 8(1) 55 | # allocate stack space, R1 % 16 == 0 56 | stwu 1, -32(1) 57 | 58 | # exit code is zero 59 | li 3, 0 60 | # exit application 61 | bl ._exit 62 | nop 63 | -------------------------------------------------------------------------------- /boost_context/make_x86_64_sysv_elf_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /**************************************************************************************** 9 | * * 10 | * ---------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ---------------------------------------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | * 14 | * ---------------------------------------------------------------------------------- * 15 | * | fc_mxcsr|fc_x87_cw| R12 | R13 | R14 | * 16 | * ---------------------------------------------------------------------------------- * 17 | * ---------------------------------------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ---------------------------------------------------------------------------------- * 20 | * | 0x20 | 0x24 | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c | * 21 | * ---------------------------------------------------------------------------------- * 22 | * | R15 | RBX | RBP | RIP | * 23 | * ---------------------------------------------------------------------------------- * 24 | * * 25 | ****************************************************************************************/ 26 | 27 | .text 28 | .globl jq_make_fcontext 29 | .type jq_make_fcontext,@function 30 | .align 16 31 | jq_make_fcontext: 32 | /* first arg of jq_make_fcontext() == top of context-stack */ 33 | movq %rdi, %rax 34 | 35 | /* shift address in RAX to lower 16 byte boundary */ 36 | andq $-16, %rax 37 | 38 | /* reserve space for context-data on context-stack */ 39 | /* on context-function entry: (RSP -0x8) % 16 == 0 */ 40 | leaq -0x40(%rax), %rax 41 | 42 | /* third arg of jq_make_fcontext() == address of context-function */ 43 | /* stored in RBX */ 44 | movq %rdx, 0x28(%rax) 45 | 46 | /* save MMX control- and status-word */ 47 | stmxcsr (%rax) 48 | /* save x87 control-word */ 49 | fnstcw 0x4(%rax) 50 | 51 | /* compute abs address of label trampoline */ 52 | leaq trampoline(%rip), %rcx 53 | /* save address of trampoline as return-address for context-function */ 54 | /* will be entered after calling jump_fcontext() first time */ 55 | movq %rcx, 0x38(%rax) 56 | 57 | /* compute abs address of label finish */ 58 | leaq finish(%rip), %rcx 59 | /* save address of finish as return-address for context-function */ 60 | /* will be entered after context-function returns */ 61 | movq %rcx, 0x30(%rax) 62 | 63 | ret /* return pointer to context-data */ 64 | 65 | trampoline: 66 | /* store return address on stack */ 67 | /* fix stack alignment */ 68 | push %rbp 69 | /* jump to context-function */ 70 | jmp *%rbx 71 | 72 | finish: 73 | /* exit code is zero */ 74 | xorq %rdi, %rdi 75 | /* exit application */ 76 | call _exit@PLT 77 | hlt 78 | .size jq_make_fcontext,.-jq_make_fcontext 79 | 80 | /* Mark that we don't need executable stack. */ 81 | .section .note.GNU-stack,"",%progbits 82 | -------------------------------------------------------------------------------- /boost_context/make_x86_64_sysv_macho_gas.S: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright Oliver Kowalke 2009. 3 | Distributed under the Boost Software License, Version 1.0. 4 | (See accompanying file LICENSE_1_0.txt or copy at 5 | http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | /**************************************************************************************** 9 | * * 10 | * ---------------------------------------------------------------------------------- * 11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * 12 | * ---------------------------------------------------------------------------------- * 13 | * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | * 14 | * ---------------------------------------------------------------------------------- * 15 | * | fc_mxcsr|fc_x87_cw| R12 | R13 | R14 | * 16 | * ---------------------------------------------------------------------------------- * 17 | * ---------------------------------------------------------------------------------- * 18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * 19 | * ---------------------------------------------------------------------------------- * 20 | * | 0x20 | 0x24 | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c | * 21 | * ---------------------------------------------------------------------------------- * 22 | * | R15 | RBX | RBP | RIP | * 23 | * ---------------------------------------------------------------------------------- * 24 | * * 25 | ****************************************************************************************/ 26 | 27 | .text 28 | .globl _jq_make_fcontext 29 | .align 8 30 | _jq_make_fcontext: 31 | /* first arg of jq_make_fcontext() == top of context-stack */ 32 | movq %rdi, %rax 33 | 34 | /* shift address in RAX to lower 16 byte boundary */ 35 | andq $-16, %rax 36 | 37 | /* reserve space for context-data on context-stack */ 38 | /* on context-function entry: (RSP -0x8) % 16 == 0 */ 39 | leaq -0x40(%rax), %rax 40 | 41 | /* third arg of jq_make_fcontext() == address of context-function */ 42 | /* stored in RBX */ 43 | movq %rdx, 0x28(%rax) 44 | 45 | /* save MMX control- and status-word */ 46 | stmxcsr (%rax) 47 | /* save x87 control-word */ 48 | fnstcw 0x4(%rax) 49 | 50 | /* compute abs address of label trampoline */ 51 | leaq trampoline(%rip), %rcx 52 | /* save address of trampoline as return-address for context-function */ 53 | /* will be entered after calling jump_fcontext() first time */ 54 | movq %rcx, 0x38(%rax) 55 | 56 | /* compute abs address of label finish */ 57 | leaq finish(%rip), %rcx 58 | /* save address of finish as return-address for context-function */ 59 | /* will be entered after context-function returns */ 60 | movq %rcx, 0x30(%rax) 61 | 62 | ret /* return pointer to context-data */ 63 | 64 | trampoline: 65 | /* store return address on stack */ 66 | /* fix stack alignment */ 67 | push %rbp 68 | /* jump to context-function */ 69 | jmp *%rbx 70 | 71 | finish: 72 | /* exit code is zero */ 73 | xorq %rdi, %rdi 74 | /* exit application */ 75 | call __exit 76 | hlt 77 | -------------------------------------------------------------------------------- /demo/Makefile: -------------------------------------------------------------------------------- 1 | UNAME_S := $(shell uname -s) 2 | 3 | 4 | LDFLAGS=-lpthread -lcurses 5 | 6 | CFLAGS=-I.. -I../microprofile -I. -DGLEW_STATIC -Wall 7 | #CFLAGS+=-fsanitize=undefined-trap -fsanitize-undefined-trap-on-error 8 | CFLAGS+=-g -O2 -Wno-invalid-offsetof -Wno-format 9 | CFLAGS+=-DJQ_ASSERT_LOCKS 10 | CFLAGS+=-DJQ_MICROPROFILE 11 | CFLAGS+=-DMICROPROFILE_MAX_THREADS=128 12 | CPPFLAGS=$(CFLAGS) 13 | 14 | #CPPFLAGS+=-stdlib=libc++ -std=c++11 15 | 16 | CPPFLAGS+=-DMICROPROFILE_GPU_TIMERS=0 17 | CPPFLAGS+=-DJQ_MICROPROFILE_VERBOSE 18 | #CPPFLAGS+=-DJQ_MICROPROFILE 19 | 20 | 21 | 22 | 23 | CPP_SOURCES = ../microprofile/microprofile.cpp ../jqinternal.cpp 24 | DEMO_SOURCES = demo_stress.cpp demo_priority.cpp demo_cancel.cpp 25 | JQ_SOURCES=../jqlocked.cpp ../jqmultilocked.cpp 26 | C_SOURCES = 27 | ASM_SOURCES = ../boost_context/jump_x86_64_sysv_macho_gas.S ../boost_context/make_x86_64_sysv_macho_gas.S 28 | 29 | 30 | #osx 31 | ifeq ($(UNAME_S),Darwin) 32 | CPPFLAGS+=-stdlib=libc++ -std=c++11 33 | CCFLAGS += -D OSX 34 | ASM_SOURCES = ../boost_context/jump_x86_64_sysv_macho_gas.S ../boost_context/make_x86_64_sysv_macho_gas.S 35 | endif 36 | 37 | #linux 38 | ifeq ($(UNAME_S),Linux) 39 | LDFLAGS += -latomic 40 | ASM_SOURCES = ../boost_context/jump_x86_64_sysv_elf_gas.S ../boost_context/make_x86_64_sysv_elf_gas.S 41 | CCFLAGS += LINUX 42 | endif 43 | 44 | 45 | CC=clang 46 | CPP=clang++ 47 | LD=clang++ 48 | 49 | CPP_OBJS = $(patsubst %.cpp,%.o,$(CPP_SOURCES)) 50 | C_OBJS = $(patsubst %.c,%.o,$(C_SOURCES)) 51 | ASM_OBJS = $(patsubst %.S,%.o,$(ASM_SOURCES)) 52 | OBJS = $(C_OBJS) $(CPP_OBJS) $(ASM_OBJS) 53 | OM = ../jqlocked.o 54 | O2 = ../jq2.o 55 | 56 | default: m jq2 57 | 58 | m: demo_priority_m demo_stress_m demo_cancel_m demo_job_profile_m 59 | jq2: demo_priority_jq2 demo_stress_jq2 demo_cancel_jq2 demo_job_profile_jq2 60 | 61 | all: clean default 62 | 63 | x: clean demo_stress_ll 64 | 65 | #lockless demo 66 | 67 | 68 | #mutex demo 69 | demo_stress_m: demo_stress.o $(OBJS) $(OM) 70 | $(LD) -o demo_stress_m demo_stress.o $(OBJS) $(OM) $(LDFLAGS) $(CPPFLAGS) 71 | 72 | demo_priority_m: demo_priority.o $(OBJS) $(OM) 73 | $(LD) -o demo_priority_m demo_priority.o $(OBJS) $(OM) $(LDFLAGS) $(CPPFLAGS) 74 | 75 | demo_cancel_m: demo_cancel.o $(OBJS) $(OM) 76 | $(LD) -o demo_cancel_m demo_cancel.o $(OBJS) $(OM) $(LDFLAGS) $(CPPFLAGS) 77 | 78 | demo_job_profile_m: demo_job_profile.o $(OBJS) $(OM) 79 | $(LD) -o demo_job_profile_m demo_job_profile.o $(OBJS) $(OM) $(LDFLAGS) $(CPPFLAGS) 80 | 81 | 82 | 83 | #jq2 demo 84 | demo_stress_jq2: demo_stress.o $(OBJS) $(O2) 85 | $(LD) -o demo_stress_jq2 demo_stress.o $(OBJS) $(O2) $(LDFLAGS) $(CPPFLAGS) 86 | 87 | demo_priority_jq2: demo_priority.o $(OBJS) $(O2) 88 | $(LD) -o demo_priority_jq2 demo_priority.o $(OBJS) $(O2) $(LDFLAGS) $(CPPFLAGS) 89 | 90 | demo_cancel_jq2: demo_cancel.o $(OBJS) $(O2) 91 | $(LD) -o demo_cancel_jq2 demo_cancel.o $(OBJS) $(O2) $(LDFLAGS) $(CPPFLAGS) 92 | 93 | demo_job_profile_jq2: demo_job_profile.o $(OBJS) $(O2) 94 | $(LD) -o demo_job_profile_jq2 demo_job_profile.o $(OBJS) $(O2) $(LDFLAGS) $(CPPFLAGS) 95 | 96 | 97 | -include .depend 98 | 99 | .cpp.o: 100 | $(CPP) -c $< $(CPPFLAGS) -o $@ 101 | 102 | .c.o: 103 | $(CC) -c $< $(CFLAGS) -o $@ 104 | 105 | .S.o: 106 | $(CC) -c $< -o $@ 107 | 108 | remove_files: 109 | rm -f *.o ../*.o ../microprofile/*.o demo_priority_mm demo_stress_mm demo_cancel_mm .depend 110 | 111 | 112 | clean: remove_files depend 113 | 114 | 115 | depend: $(CPP_SOURCES) $(C_SOURCES) $(DEMO_SOURCES) $(JQ_SOURCES) 116 | $(CPP) -MM $(CPPFLAGS) $(CPP_SOURCES) $(DEMO_SOURCES) $(JQ_SOURCES) > .depend -------------------------------------------------------------------------------- /demo/demo_profile.cpp: -------------------------------------------------------------------------------- 1 | // This is free and unencumbered software released into the public domain. 2 | // Anyone is free to copy, modify, publish, use, compile, sell, or 3 | // distribute this software, either in source code form or as a compiled 4 | // binary, for any purpose, commercial or non-commercial, and by any 5 | // means. 6 | // In jurisdictions that recognize copyright laws, the author or authors 7 | // of this software dedicate any and all copyright interest in the 8 | // software to the public domain. We make this dedication for the benefit 9 | // of the public at large and to the detriment of our heirs and 10 | // successors. We intend this dedication to be an overt act of 11 | // relinquishment in perpetuity of all present and future rights to this 12 | // software under copyright law. 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 14 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 15 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | // IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 17 | // OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 18 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 19 | // OTHER DEALINGS IN THE SOFTWARE. 20 | // For more information, please refer to 21 | 22 | #include "jq.h" 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | #include "microprofile.h" 33 | 34 | uint32_t JobSpinWork(uint32_t nUs) 35 | { 36 | uint32_t result = 0; 37 | uint64_t nTick = JqGetTick(); 38 | uint64_t nTicksPerSecond = JqGetTicksPerSecond(); 39 | do 40 | { 41 | for(uint32_t i = 0; i < 1000; ++i) 42 | { 43 | result |= i << (i & 7); // do something.. whatever 44 | } 45 | } while((1000000ull * (JqGetTick() - nTick)) / nTicksPerSecond < nUs); 46 | return result; 47 | } 48 | 49 | #ifdef _WIN32 50 | void uprintf(const char* fmt, ...); 51 | #else 52 | #define uprintf printf 53 | #endif 54 | extern uint32_t g_TESTID; 55 | 56 | #define JQ_TEST_MAX_WORKERS 64 57 | 58 | #define STAGES (32 * 8) 59 | #define STAGE1_SPIN 100 60 | #define STAGE2_SPIN 50 61 | 62 | template 63 | T Min(const T& l, const T& r) 64 | { 65 | return l < r ? l : r; 66 | } 67 | 68 | template 69 | T Max(const T& l, const T& r) 70 | { 71 | return l > r ? l : r; 72 | } 73 | 74 | struct SBenchmarkData 75 | { 76 | uint64_t TickStart; 77 | uint64_t TickEnd; 78 | uint64_t ThreadId; 79 | 80 | uint8_t padding[256 - 8 * 3]; 81 | }; 82 | 83 | SBenchmarkData g_Stage1[STAGES]; 84 | SBenchmarkData g_Stage2[STAGES]; 85 | SBenchmarkData g_StageFinal; 86 | 87 | void Stage1(int Index) 88 | { 89 | SBenchmarkData& Data = g_Stage1[Index]; 90 | Data.TickStart = JqGetTick(); 91 | JobSpinWork(STAGE1_SPIN); 92 | Data.TickEnd = JqGetTick(); 93 | } 94 | void Stage2(int Index) 95 | { 96 | 97 | SBenchmarkData& Data = g_Stage2[Index]; 98 | Data.TickStart = JqGetTick(); 99 | JobSpinWork(STAGE2_SPIN); 100 | Data.TickEnd = JqGetTick(); 101 | } 102 | 103 | void JobBenchmark(const uint32_t NumWorkers) 104 | { 105 | MICROPROFILE_SCOPEI("JobBenchmark", "JobBenchmark", MP_AUTO); 106 | memset(g_Stage1, 0, sizeof(g_Stage1)); 107 | memset(g_Stage2, 0, sizeof(g_Stage2)); 108 | memset(&g_StageFinal, 0, sizeof(g_StageFinal)); 109 | 110 | uint64_t TicksPerSecond = JqGetTicksPerSecond(); 111 | 112 | // run it 100 times 113 | struct TimeInfo 114 | { 115 | double Time = 0; 116 | double Core = 0; 117 | double Spin = 0; 118 | double CoreOverhead = 0; 119 | double First = 0; 120 | double Last = 0; 121 | }; 122 | TimeInfo TimeTotal; 123 | TimeInfo TimeMin; 124 | TimeInfo TimeMax; 125 | TimeMax.Time = 0.0; 126 | TimeMax.Core = 0.0; 127 | TimeMax.Spin = 0.0; 128 | TimeMax.CoreOverhead = 0.0; 129 | TimeMax.First = 0.0; 130 | TimeMax.Last = 0.0; 131 | 132 | TimeMin.Time = 1e38; 133 | TimeMin.Core = 1e38; 134 | TimeMin.Spin = 1e38; 135 | TimeMin.CoreOverhead = 1e38; 136 | TimeMin.First = 1e38; 137 | TimeMin.Last = 1e38; 138 | 139 | const uint32_t RepeatCount = 256; 140 | for(uint32_t i = 0; i < RepeatCount; ++i) 141 | { 142 | uint64_t Start = JqGetTick(); 143 | 144 | JqHandle Stage1Job = JqAdd( 145 | "Stage1Job", 146 | [](int Index) { 147 | Stage1(Index); 148 | }, 149 | 0, STAGES); 150 | 151 | JqWait(Stage1Job, JQ_WAITFLAG_BLOCK); 152 | 153 | uint64_t End = JqGetTick(); 154 | 155 | uint64_t TotalTicks = End - Start; 156 | uint64_t TotalCoreTicks = TotalTicks * (NumWorkers); 157 | uint64_t JobTime = 0; 158 | 159 | uint64_t FirstJob = (uint64_t)-1; 160 | uint64_t LastJob = 0; 161 | for(uint32_t i = 0; i < STAGES; ++i) 162 | { 163 | if(g_Stage1[i].TickStart) 164 | { 165 | JobTime += g_Stage1[i].TickEnd - g_Stage1[i].TickStart; 166 | LastJob = g_Stage1[i].TickStart > LastJob ? g_Stage1[i].TickStart : LastJob; 167 | FirstJob = g_Stage1[i].TickStart < FirstJob ? g_Stage1[i].TickStart : FirstJob; 168 | } 169 | } 170 | 171 | double Time = 1000.0 * TotalTicks / TicksPerSecond; 172 | double Core = 1000.0 * TotalCoreTicks / TicksPerSecond; 173 | double Spin = 1000.0 * JobTime / TicksPerSecond; 174 | double CoreOverhead = Core - Spin; 175 | double First = 1000.0 * (FirstJob - Start) / TicksPerSecond; 176 | double Last = 1000.0 * (LastJob - Start) / TicksPerSecond; 177 | 178 | TimeTotal.Time += Time; 179 | TimeTotal.Core += Core; 180 | TimeTotal.Spin += Spin; 181 | TimeTotal.CoreOverhead += CoreOverhead; 182 | TimeTotal.First += First; 183 | TimeTotal.Last += Last; 184 | 185 | TimeMin.Time = Min(Time, TimeMin.Time); 186 | TimeMin.Core = Min(Core, TimeMin.Core); 187 | TimeMin.Spin = Min(Spin, TimeMin.Spin); 188 | TimeMin.CoreOverhead = Min(CoreOverhead, TimeMin.CoreOverhead); 189 | TimeMin.First = Min(First, TimeMin.First); 190 | TimeMin.Last = Min(Time, TimeMin.Last); 191 | 192 | TimeMax.Time = Max(Time, TimeMax.Time); 193 | TimeMax.Core = Max(Core, TimeMax.Core); 194 | TimeMax.Spin = Max(Spin, TimeMax.Spin); 195 | TimeMax.CoreOverhead = Max(CoreOverhead, TimeMax.CoreOverhead); 196 | TimeMax.First = Max(First, TimeMax.First); 197 | TimeMax.Last = Max(Time, TimeMax.Last); 198 | } 199 | TimeTotal.Time /= double(RepeatCount); 200 | TimeTotal.Core /= double(RepeatCount); 201 | TimeTotal.Spin /= double(RepeatCount); 202 | TimeTotal.CoreOverhead /= double(RepeatCount); 203 | TimeTotal.First /= double(RepeatCount); 204 | TimeTotal.Last /= double(RepeatCount); 205 | 206 | if(NumWorkers == 1) 207 | { 208 | 209 | printf("Cpus | Time | CoreTime | TimeFirst | TimeLast | | \n"); 210 | printf(" | Avg Min Max | Avg Min Max | Avg Min Max | Avg Min Max | Ovh Avg | SpinAvg \n"); 211 | printf("-----|--------------------------------|--------------------------------|--------------------------------|--------------------------------|----------|---------- \n"); 212 | } 213 | 214 | printf("%4d | %8.2f / %8.2f / %8.2f | %8.2f / %8.2f / %8.2f | %8.2f / %8.2f / %8.2f | %8.2f / %8.2f / %8.2f | %8.2f | %8.2f\n", NumWorkers, TimeTotal.Time, TimeMin.Time, TimeMax.Time, 215 | TimeTotal.Core, TimeMin.Core, TimeMax.Core, TimeTotal.First, TimeMin.First, TimeMax.First, TimeTotal.Last, TimeMin.Last, TimeMax.Last, TimeTotal.CoreOverhead, TimeTotal.Spin); 216 | } 217 | 218 | int main(int argc, char* argv[]) 219 | { 220 | 221 | uint32_t nJqInitFlags = JQ_INIT_USE_SEPERATE_STACK; 222 | for(int i = 1; i < argc; ++i) 223 | { 224 | if(0 == strcmp("-ns", argv[i])) 225 | { 226 | printf("disabling seperate stack\n"); 227 | nJqInitFlags &= ~JQ_INIT_USE_SEPERATE_STACK; 228 | } 229 | } 230 | MicroProfileOnThreadCreate("Main"); 231 | // #ifdef _WIN32 232 | // ShowWindow(GetConsoleWindow(), SW_MAXIMIZE); 233 | // #endif 234 | 235 | uint32_t MaxWorkers = JqGetNumCpus(); 236 | 237 | for(uint32_t i = 1; i < MaxWorkers; ++i) 238 | { 239 | const uint32_t NumWorkers = i; 240 | JqAttributes Attr; 241 | uint64_t Affinity = 0; 242 | for(uint64_t i = 0; i < NumWorkers; ++i) 243 | { 244 | Affinity |= (1llu << i); 245 | } 246 | JqInitAttributes(&Attr, 1, NumWorkers); 247 | Attr.Flags = nJqInitFlags; 248 | Attr.QueueOrder[0] = JqQueueOrder{ 7, { 0, 1, 2, 3, 4, 5, 6, 0xff } }; 249 | for(uint32_t i = 0; i < NumWorkers; ++i) 250 | { 251 | Attr.WorkerOrderIndex[i] = 0; 252 | Attr.WorkerThreadAffinity[i] = Affinity; 253 | } 254 | JqStart(&Attr); 255 | JqSetThreadQueueOrder(&Attr.QueueOrder[0]); 256 | 257 | JobBenchmark(i); 258 | 259 | JqStop(); 260 | } 261 | return 0; 262 | } 263 | -------------------------------------------------------------------------------- /demo/ng: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | IF NOT EXIST build.ninja python ngen/ngen.py 4 | if [ ! -f build.ninja ] 5 | then 6 | echo "hello1" 7 | python3 ngen/ngen.py 8 | echo "hello2" 9 | fi 10 | echo "hello3" 11 | ls -l 12 | which ninja 13 | ninja --version 14 | echo $@ 15 | echo ninja $@ 16 | ninja $@ 17 | -------------------------------------------------------------------------------- /demo/ng.bat: -------------------------------------------------------------------------------- 1 | IF NOT EXIST build.ninja python ngen/ngen.py 2 | ninja %* -------------------------------------------------------------------------------- /demo/ngen.cfg: -------------------------------------------------------------------------------- 1 | 2 | .tempdir _temp 3 | .outdir _out 4 | 5 | .config debug 6 | .config release 7 | 8 | 9 | .config nomicroprofile release 10 | .config lto release osx linux 11 | 12 | .config asan release osx linux 13 | .config ubsan release osx linux 14 | .config tsan release osx linux 15 | .config msan release linux 16 | 17 | 18 | includepath . 19 | includepath .. 20 | includepath ../microprofile 21 | 22 | 23 | 24 | cflags -DMICROPROFILE_MAX_THREADS=128 25 | cflags -DMICROPROFILE_GPU_TIMERS=0 26 | 27 | cflags -DJQ_MICROPROFILE 28 | cflags -DJQ_MICROPROFILE_VERBOSE 29 | cflags.nomicroprofile -DMICROPROFILE_ENABLED=0 30 | 31 | cflags.lto -DMICROPROFILE_ENABLED=0 32 | cflags.lto -DJQ_NO_ASSERT 33 | cflags.lto -flto=thin 34 | ldflags.lto -flto=thin 35 | 36 | 37 | 38 | cflags.asan -fsanitize=address 39 | ldflags.asan -fsanitize=address 40 | 41 | #disable because microprofile causes tsan to trigger 42 | cflags.tsan -DMICROPROFILE_ENABLED=0 43 | cflags.tsan -fsanitize=thread 44 | ldflags.tsan -fsanitize=thread 45 | 46 | cflags.ubsan -fsanitize=undefined 47 | #-fsanitize-trap=undefined 48 | ldflags.ubsan -fsanitize=undefined 49 | # -fsanitize-trap=undefined 50 | 51 | cflags.msan -fsanitize=memory 52 | cflags.msan -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer 53 | ldflags.msan -fsanitize=memory 54 | 55 | 56 | .ngen.osx ngen.osx 57 | .ngen.linux ngen.linux 58 | .ngen.win32 ngen.win32 59 | 60 | 61 | .file ../jq2.cpp 62 | .file ../jqinternal.cpp 63 | .file ../microprofile/microprofile.cpp 64 | 65 | 66 | .file.win32 ../boost_context/jump_x86_64_ms_pe_masm.asm 67 | .file.win32 ../boost_context/make_x86_64_ms_pe_masm.asm 68 | 69 | .file.linux ../boost_context/jump_x86_64_sysv_elf_gas.S 70 | .file.linux ../boost_context/make_x86_64_sysv_elf_gas.S 71 | 72 | .file.osx ../boost_context/jump_x86_64_sysv_macho_gas.S 73 | .file.osx ../boost_context/make_x86_64_sysv_macho_gas.S 74 | 75 | 76 | .target demo_simple 77 | .file demo_simple.cpp 78 | .end 79 | 80 | .target demo_full 81 | .file demo_full.cpp 82 | .end 83 | 84 | .target demo_profile 85 | .file demo_profile.cpp 86 | .end 87 | 88 | -------------------------------------------------------------------------------- /demo/ngen.linux: -------------------------------------------------------------------------------- 1 | 2 | 3 | cflags -DTARGET_X86_64 4 | cflags -DMICROPROFILE_GPU_TIMERS=0 5 | cflags.debug -D_DEBUG -O0 6 | cflags.release -D_DEBUG -O2 7 | cflags -g 8 | cflags -Wno-format 9 | 10 | ldflags -lpthread 11 | ldflags -ldl -rdynamic -lcrypto -lssl 12 | ldflags -lpthread 13 | ldflags -lcurses 14 | 15 | ldflags -latomic -------------------------------------------------------------------------------- /demo/ngen.osx: -------------------------------------------------------------------------------- 1 | 2 | 3 | mmflags -std=c++11 -x objective-c++ -mmacosx-version-min=10.12 4 | 5 | 6 | cflags -DTARGET_X86_64 7 | cflags -DMICROPROFILE_GPU_TIMERS=0 8 | 9 | cflags.debug -D_DEBUG 10 | cflags.debug -O0 11 | cflags.release -O2 12 | cflags -Wno-c++11-extensions -g 13 | cflags -stdlib=libc++ -std=c++17 14 | cflags -mmacosx-version-min=10.12 15 | 16 | ldflags -framework Cocoa -framework CoreFoundation -fobjc-link-runtime 17 | ldflags -framework CoreLocation 18 | ldflags -lpthread -lpthread 19 | ldflags -lcurses 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /demo/ngen.win32: -------------------------------------------------------------------------------- 1 | # win32 2 | 3 | 4 | .win32sdk 10.0.17763.0 5 | 6 | cflags /D TARGET_X86_64 7 | 8 | cflags /D MICROPROFILE_GPU_TIMERS=0 9 | 10 | cflags.debug /D "_DEBUG" 11 | cflags.debug /Od /RTC1 /MDd /Zi 12 | 13 | 14 | cflags.release /D "NDEBUG" 15 | cflags.release /O2 /Oi /MD /Gy /JMC /sdl 16 | cflags.release /GL 17 | 18 | cflags /GS /EHsc /Zi /W3 /fp:precise 19 | cflags /permissive- /Zc:wchar_t /Zc:forScope /Zc:inline 20 | cflags /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /Gd /std:c++17 /nologo 21 | 22 | ldflags /manifest:embed /MANIFEST /SUBSYSTEM:CONSOLE /MACHINE:X64 /NXCOMPAT 23 | ldflags wsock32.lib 24 | ldflags kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib 25 | ldflags ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Winmm.lib 26 | 27 | 28 | ldflags /DEBUG 29 | 30 | ldflags.debug /INCREMENTAL /DYNAMICBASE:NO 31 | ldflags.release /INCREMENTAL:NO /DYNAMICBASE 32 | ldflags.release /OPT:REF /OPT:ICF /LTCG:incremental 33 | 34 | ldflags.nomicroprofile /INCREMENTAL:NO /DYNAMICBASE -------------------------------------------------------------------------------- /demo/sln/demo_full.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | debug 6 | Win32 7 | 8 | 9 | nomicroprofile 10 | Win32 11 | 12 | 13 | nomicroprofile 14 | x64 15 | 16 | 17 | release 18 | Win32 19 | 20 | 21 | debug 22 | x64 23 | 24 | 25 | release 26 | x64 27 | 28 | 29 | 30 | 16.0 31 | {BF70FF6F-3DA7-4BA9-8013-40DDD3F90EF2} 32 | Win32Proj 33 | 34 | 35 | 36 | Makefile 37 | true 38 | v142 39 | 40 | 41 | Makefile 42 | false 43 | v142 44 | 45 | 46 | Makefile 47 | false 48 | v142 49 | 50 | 51 | Makefile 52 | true 53 | v142 54 | 55 | 56 | Makefile 57 | false 58 | v142 59 | 60 | 61 | Makefile 62 | false 63 | v142 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | ../_out/win32/demo_full_debug.exe 91 | _DEBUG;$(NMakePreprocessorDefinitions) 92 | cd .. && ng demo_full_debug 93 | ninja -t clean 94 | 95 | 96 | ../_out/win32/demo_full_debug.exe 97 | WIN32;_DEBUG;$(NMakePreprocessorDefinitions) 98 | cd .. && ng demo_full_debug 99 | ninja -t clean 100 | 101 | 102 | ../_out/win32/demo_full_release.exe 103 | WIN32;NDEBUG;$(NMakePreprocessorDefinitions) 104 | cd .. && ng demo_full_release 105 | ninja -t clean 106 | 107 | 108 | ../_out/win32/demo_full_nomicroprofile.exe 109 | WIN32;NDEBUG;$(NMakePreprocessorDefinitions) 110 | cd .. && ng demo_full_nomicroprofile 111 | ninja -t clean 112 | 113 | 114 | ../_out/win32/demo_full_release.exe 115 | NDEBUG;$(NMakePreprocessorDefinitions) 116 | cd .. && ng demo_full_release 117 | ninja -t clean 118 | 119 | 120 | ../_out/win32/demo_full_nomicroprofile.exe 121 | NDEBUG;$(NMakePreprocessorDefinitions) 122 | cd .. && ng demo_full_nomicroprofile 123 | ninja -t clean 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /demo/sln/demo_full.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /demo/sln/demo_profile.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | debug 6 | Win32 7 | 8 | 9 | nomicroprofile 10 | Win32 11 | 12 | 13 | nomicroprofile 14 | x64 15 | 16 | 17 | release 18 | Win32 19 | 20 | 21 | debug 22 | x64 23 | 24 | 25 | release 26 | x64 27 | 28 | 29 | 30 | 16.0 31 | {20BB438E-F6F3-4306-A539-E3AFD623042D} 32 | Win32Proj 33 | 34 | 35 | 36 | Makefile 37 | true 38 | v142 39 | 40 | 41 | Makefile 42 | false 43 | v142 44 | 45 | 46 | Makefile 47 | false 48 | v142 49 | 50 | 51 | Makefile 52 | true 53 | v142 54 | 55 | 56 | Makefile 57 | false 58 | v142 59 | 60 | 61 | Makefile 62 | false 63 | v142 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | ../_out/win32/demo_profile_debug.exe 91 | _DEBUG;$(NMakePreprocessorDefinitions) 92 | cd .. && ng demo_profile_debug 93 | ninja -t clean 94 | 95 | 96 | ../_out/win32/demo_profile_debug.exe 97 | WIN32;_DEBUG;$(NMakePreprocessorDefinitions) 98 | cd .. && ng demo_profile_debug 99 | ninja -t clean 100 | 101 | 102 | ../_out/win32/demo_profile_release.exe 103 | WIN32;NDEBUG;$(NMakePreprocessorDefinitions) 104 | ninja -t clean 105 | cd .. && ng demo_profile_release 106 | 107 | 108 | ../_out/win32/demo_profile_nomicroprofile.exe 109 | WIN32;NDEBUG;$(NMakePreprocessorDefinitions) 110 | ninja -t clean 111 | cd .. && ng demo_profile_nomicroprofile 112 | 113 | 114 | ../_out/win32/demo_profile_release.exe 115 | NDEBUG;$(NMakePreprocessorDefinitions) 116 | cd .. && ng demo_profile_release 117 | ninja -t clean 118 | 119 | 120 | ../_out/win32/demo_profile_nomicroprofile.exe 121 | NDEBUG;$(NMakePreprocessorDefinitions) 122 | cd .. && ng demo_profile_nomicroprofile 123 | ninja -t clean 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /demo/sln/demo_profile.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /demo/sln/demo_simple.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | debug 6 | Win32 7 | 8 | 9 | nomicroprofile 10 | Win32 11 | 12 | 13 | nomicroprofile 14 | x64 15 | 16 | 17 | release 18 | Win32 19 | 20 | 21 | debug 22 | x64 23 | 24 | 25 | release 26 | x64 27 | 28 | 29 | 30 | 16.0 31 | {8B1DF24C-1EE0-46AF-ACCC-6F22177B78CF} 32 | Win32Proj 33 | demo_simple 34 | 35 | 36 | 37 | Makefile 38 | true 39 | v142 40 | 41 | 42 | Makefile 43 | false 44 | v142 45 | 46 | 47 | Makefile 48 | false 49 | v142 50 | 51 | 52 | Makefile 53 | true 54 | v142 55 | 56 | 57 | Makefile 58 | false 59 | v142 60 | 61 | 62 | Makefile 63 | false 64 | v142 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | cd .. && ng demo_simple_debug 92 | ../_out/win32/demo_simple_debug.exe 93 | ninja -t clean 94 | WIN32;_DEBUG;$(NMakePreprocessorDefinitions) 95 | 96 | 97 | cd .. && ng demo_simple_debug 98 | ../_out/win32/demo_simple_debug.exe 99 | ninja -t clean 100 | _DEBUG;$(NMakePreprocessorDefinitions) 101 | 102 | 103 | cd .. && ng demo_simple_release 104 | ../_out/win32/demo_simple_release.exe 105 | ninja -t clean 106 | WIN32;NDEBUG;$(NMakePreprocessorDefinitions) 107 | 108 | 109 | cd .. && ng demo_simple_nomicroprofile 110 | ../_out/win32/demo_simple_nomicroprofile.exe 111 | ninja -t clean 112 | WIN32;NDEBUG;$(NMakePreprocessorDefinitions) 113 | 114 | 115 | cd .. && ng demo_simple_release 116 | ../_out/win32/demo_simple_release.exe 117 | ninja -t clean 118 | NDEBUG;$(NMakePreprocessorDefinitions) 119 | 120 | 121 | cd .. && ng demo_simple_nomicroprofile 122 | ../_out/win32/demo_simple_nomicroprofile.exe 123 | ninja -t clean 124 | NDEBUG;$(NMakePreprocessorDefinitions) 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /demo/sln/demo_simple.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /demo/sln/jq_demo.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30523.141 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "demo_simple", "demo_simple.vcxproj", "{8B1DF24C-1EE0-46AF-ACCC-6F22177B78CF}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {20BB438E-F6F3-4306-A539-E3AFD623042D} = {20BB438E-F6F3-4306-A539-E3AFD623042D} 9 | EndProjectSection 10 | EndProject 11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "demo_full", "demo_full.vcxproj", "{BF70FF6F-3DA7-4BA9-8013-40DDD3F90EF2}" 12 | EndProject 13 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "demo_profile", "demo_profile.vcxproj", "{20BB438E-F6F3-4306-A539-E3AFD623042D}" 14 | ProjectSection(ProjectDependencies) = postProject 15 | {BF70FF6F-3DA7-4BA9-8013-40DDD3F90EF2} = {BF70FF6F-3DA7-4BA9-8013-40DDD3F90EF2} 16 | EndProjectSection 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 20 | debug|x64 = debug|x64 21 | nomicroprofile|x64 = nomicroprofile|x64 22 | release|x64 = release|x64 23 | EndGlobalSection 24 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 25 | {8B1DF24C-1EE0-46AF-ACCC-6F22177B78CF}.debug|x64.ActiveCfg = debug|x64 26 | {8B1DF24C-1EE0-46AF-ACCC-6F22177B78CF}.debug|x64.Build.0 = debug|x64 27 | {8B1DF24C-1EE0-46AF-ACCC-6F22177B78CF}.nomicroprofile|x64.ActiveCfg = nomicroprofile|x64 28 | {8B1DF24C-1EE0-46AF-ACCC-6F22177B78CF}.nomicroprofile|x64.Build.0 = nomicroprofile|x64 29 | {8B1DF24C-1EE0-46AF-ACCC-6F22177B78CF}.release|x64.ActiveCfg = release|x64 30 | {8B1DF24C-1EE0-46AF-ACCC-6F22177B78CF}.release|x64.Build.0 = release|x64 31 | {BF70FF6F-3DA7-4BA9-8013-40DDD3F90EF2}.debug|x64.ActiveCfg = debug|x64 32 | {BF70FF6F-3DA7-4BA9-8013-40DDD3F90EF2}.debug|x64.Build.0 = debug|x64 33 | {BF70FF6F-3DA7-4BA9-8013-40DDD3F90EF2}.nomicroprofile|x64.ActiveCfg = nomicroprofile|x64 34 | {BF70FF6F-3DA7-4BA9-8013-40DDD3F90EF2}.nomicroprofile|x64.Build.0 = nomicroprofile|x64 35 | {BF70FF6F-3DA7-4BA9-8013-40DDD3F90EF2}.release|x64.ActiveCfg = release|x64 36 | {BF70FF6F-3DA7-4BA9-8013-40DDD3F90EF2}.release|x64.Build.0 = release|x64 37 | {20BB438E-F6F3-4306-A539-E3AFD623042D}.debug|x64.ActiveCfg = debug|x64 38 | {20BB438E-F6F3-4306-A539-E3AFD623042D}.debug|x64.Build.0 = debug|x64 39 | {20BB438E-F6F3-4306-A539-E3AFD623042D}.nomicroprofile|x64.ActiveCfg = nomicroprofile|x64 40 | {20BB438E-F6F3-4306-A539-E3AFD623042D}.nomicroprofile|x64.Build.0 = nomicroprofile|x64 41 | {20BB438E-F6F3-4306-A539-E3AFD623042D}.release|x64.ActiveCfg = release|x64 42 | {20BB438E-F6F3-4306-A539-E3AFD623042D}.release|x64.Build.0 = release|x64 43 | EndGlobalSection 44 | GlobalSection(SolutionProperties) = preSolution 45 | HideSolutionNode = FALSE 46 | EndGlobalSection 47 | GlobalSection(ExtensibilityGlobals) = postSolution 48 | SolutionGuid = {9F118C97-224C-4B4D-B996-3F3C8E1AE77E} 49 | EndGlobalSection 50 | EndGlobal 51 | -------------------------------------------------------------------------------- /jq.sublime-project: -------------------------------------------------------------------------------- 1 | { 2 | "folders": 3 | [ 4 | { 5 | "path": "." 6 | } 7 | ], 8 | "build_systems": 9 | [ 10 | { 11 | "name":"jq_demo", 12 | "osx" : { 13 | "shell_cmd": "ninja all", 14 | "file_regex": "(...*?):([0-9]*):([0-9]*):", 15 | "working_dir": "${project_path}/demo/" 16 | }, 17 | "linux" : { 18 | "shell_cmd": "ninja all", 19 | "file_regex": "(...*?):([0-9]*):([0-9]*):", 20 | "working_dir": "${project_path}/demo/" 21 | }, 22 | "windows" : { 23 | "shell_cmd": "ninja", 24 | "file_regex": "(...*?)\\(([0-9]*)\\):", 25 | "working_dir": "${project_path}/demo/" 26 | } 27 | }, 28 | 29 | ], 30 | "settings": { 31 | "ClangFormat": { 32 | "format_on_save": true 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /jqfcontext.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | // based on boost.context 5 | 6 | typedef void* JqFContext; 7 | struct JqTransfer 8 | { 9 | JqFContext fctx; 10 | void* data; 11 | }; 12 | 13 | extern "C" JqTransfer jq_jump_fcontext(JqFContext const to, void* vp); 14 | extern "C" JqFContext jq_make_fcontext(void* sp, size_t size, void (*fn)(JqTransfer)); 15 | --------------------------------------------------------------------------------