Skip to content

Commit

Permalink
[fiber] arm64 contect switch: Use ASM labels instead of jinja templat…
Browse files Browse the repository at this point in the history
…e magic
  • Loading branch information
rleh committed Jan 21, 2024
1 parent 26aa24d commit 1e36434
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/modm/processing/fiber/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ modm_context_start(modm_context_t *to);
* to jump from one fiber to the next.
*/
void
modm_context_jump(modm_context_t *from, modm_context_t *to);
modm_context_jump(modm_context_t *from, modm_context_t *to) asm("_modm_context_jump");

/**
* Switches control from the fiber context back to the main context.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,11 @@ constexpr uintptr_t StackWatermark = 0xc0ffee'f00d'facade;

}

extern "C" void modm_context_entry();
extern "C" void modm_context_entry() asm("_modm_context_entry");
asm
(
%% if is_darwin
".globl _modm_context_entry \n\t"
"_modm_context_entry: \n\t"
%% else
".globl modm_context_entry \n\t"
"modm_context_entry: \n\t"
%% endif
"ldr x0, [sp] \n\t" // Load closure data pointer
"ldr x1, [sp, #8] \n\t" // Load closure function
"br x1 \n\t" // Jump to closure function
Expand Down Expand Up @@ -156,13 +151,8 @@ See https://github.com/boostorg/context/tree/develop/src/asm

asm
(
%% if is_darwin
".globl _modm_context_jump \n\t"
"_modm_context_jump: \n\t"
%% else
".globl modm_context_jump \n\t"
"modm_context_jump: \n\t"
%% endif

/* move stack pointer down */
"sub sp, sp, #0xa0 \n\t"
Expand Down
2 changes: 1 addition & 1 deletion src/modm/processing/fiber/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def build(env):
elif "arm64" in core:
env.substitutions["stack_minimum"] = (20 + 2) * 8
env.substitutions["default_stack_size"] = 2**20 # 1MB
env.template("context_arm64.cpp.in")
env.copy("context_arm64.cpp")

env.copy("context.h")
env.template("stack.hpp.in")
Expand Down

0 comments on commit 1e36434

Please sign in to comment.