Skip to content

Commit

Permalink
Fix getcontext return value for aarch64/darwin
Browse files Browse the repository at this point in the history
Signed-off-by: Petr Shumilov <[email protected]>
  • Loading branch information
PetrShumilov committed Oct 27, 2024
1 parent def1651 commit a130fb4
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions common/ucontext/darwin/aarch64/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,8 @@ asm(".global " NAME(getcontext_portable) ";\n"
".align 2;\n"
NAME(getcontext_portable) ":\n"
"str xzr, [x0, #((184) + ((0) * (8)))]\n" // #REG_OFFSET(0)
/* save GPRs */
"stp x0, x1, [x0, #((184) + ((0) * (8)))]\n" // REG_OFFSET(0)
/* save x2 and x3 for reuse */
"stp x2, x3, [x0, #((184) + ((2) * (8)))]\n" // REG_OFFSET(2)
"stp x4, x5, [x0, #((184) + ((4) * (8)))]\n" // REG_OFFSET(4)
"stp x6, x7, [x0, #((184) + ((6) * (8)))]\n" // REG_OFFSET(6)
"stp x8, x9, [x0, #((184) + ((8) * (8)))]\n" // REG_OFFSET(8)
"stp x10, x11, [x0, #((184) + ((10) * (8)))]\n" // REG_OFFSET(10)
"stp x12, x13, [x0, #((184) + ((12) * (8)))]\n" // REG_OFFSET(12)
"stp x14, x15, [x0, #((184) + ((14) * (8)))]\n" // REG_OFFSET(14)
"stp x16, x17, [x0, #((184) + ((16) * (8)))]\n" // REG_OFFSET(16)
"stp x18, x19, [x0, #((184) + ((18) * (8)))]\n" // REG_OFFSET(18)
"stp x20, x21, [x0, #((184) + ((20) * (8)))]\n" // REG_OFFSET(20)
"stp x22, x23, [x0, #((184) + ((22) * (8)))]\n" // REG_OFFSET(22)
"stp x24, x25, [x0, #((184) + ((24) * (8)))]\n" // REG_OFFSET(24)
"stp x26, x27, [x0, #((184) + ((26) * (8)))]\n" // REG_OFFSET(26)
"stp x28, x29, [x0, #((184) + ((28) * (8)))]\n" // REG_OFFSET(28)
"str x30, [x0, #((184) + ((30) * (8)))]\n" // REG_OFFSET(30)
/* save current program counter in link register */
"str x30, [x0, #440]\n" // PC_OFFSET
/* save current stack pointer */
Expand All @@ -107,7 +92,25 @@ asm(".global " NAME(getcontext_portable) ";\n"
"stp q10, q11, [x2, #176]\n"
"stp q12, q13, [x2, #208]\n"
"stp q14, q15, [x2, #240]\n"
/* save GPRs and return value 0 */
"mov x2, x0\n"
"mov x0, #0\n"
"stp x0, x1, [x2, #((184) + ((0) * (8)))]\n" // REG_OFFSET(0)
/* x2 and x3 have already been saved */
"stp x4, x5, [x2, #((184) + ((4) * (8)))]\n" // REG_OFFSET(4)
"stp x6, x7, [x2, #((184) + ((6) * (8)))]\n" // REG_OFFSET(6)
"stp x8, x9, [x2, #((184) + ((8) * (8)))]\n" // REG_OFFSET(8)
"stp x10, x11, [x2, #((184) + ((10) * (8)))]\n" // REG_OFFSET(10)
"stp x12, x13, [x2, #((184) + ((12) * (8)))]\n" // REG_OFFSET(12)
"stp x14, x15, [x2, #((184) + ((14) * (8)))]\n" // REG_OFFSET(14)
"stp x16, x17, [x2, #((184) + ((16) * (8)))]\n" // REG_OFFSET(16)
"stp x18, x19, [x2, #((184) + ((18) * (8)))]\n" // REG_OFFSET(18)
"stp x20, x21, [x2, #((184) + ((20) * (8)))]\n" // REG_OFFSET(20)
"stp x22, x23, [x2, #((184) + ((22) * (8)))]\n" // REG_OFFSET(22)
"stp x24, x25, [x2, #((184) + ((24) * (8)))]\n" // REG_OFFSET(24)
"stp x26, x27, [x2, #((184) + ((26) * (8)))]\n" // REG_OFFSET(26)
"stp x28, x29, [x2, #((184) + ((28) * (8)))]\n" // REG_OFFSET(28)
"str x30, [x2, #((184) + ((30) * (8)))]\n" // REG_OFFSET(30)
"ret\n");
asm(".global " NAME(setcontext_portable) ";\n"
Expand Down

0 comments on commit a130fb4

Please sign in to comment.