diff options
author | Justin A. Wilson <[email protected]> | 2023-03-05 00:57:23 -0600 |
---|---|---|
committer | Ron Evans <[email protected]> | 2023-03-27 12:35:39 +0200 |
commit | a3fdbec13d3da3a337e0202fecbaf8c08db17b96 (patch) | |
tree | 376a4545321348f6fff4fa3d792ebaaee610bea3 /src/internal | |
parent | 360f6904f50da875c60b5b971cf0c7f8905c1ada (diff) | |
download | tinygo-a3fdbec13d3da3a337e0202fecbaf8c08db17b96.tar.gz tinygo-a3fdbec13d3da3a337e0202fecbaf8c08db17b96.zip |
Refactor SystemStack function for arm targets.
Removing usage of AsmFull in favor of writing inline assembly in C.
Diffstat (limited to 'src/internal')
-rw-r--r-- | src/internal/task/task_stack_cortexm.c | 12 | ||||
-rw-r--r-- | src/internal/task/task_stack_cortexm.go | 8 |
2 files changed, 16 insertions, 4 deletions
diff --git a/src/internal/task/task_stack_cortexm.c b/src/internal/task/task_stack_cortexm.c new file mode 100644 index 000000000..8580fdbfd --- /dev/null +++ b/src/internal/task/task_stack_cortexm.c @@ -0,0 +1,12 @@ +#include <stdint.h> + +uintptr_t SystemStack() { + uintptr_t sp; + asm volatile( + "mrs %0, MSP" + : "=r"(sp) + : + : "memory" + ); + return sp; +}
\ No newline at end of file diff --git a/src/internal/task/task_stack_cortexm.go b/src/internal/task/task_stack_cortexm.go index 442a717a4..39b90b75c 100644 --- a/src/internal/task/task_stack_cortexm.go +++ b/src/internal/task/task_stack_cortexm.go @@ -8,8 +8,8 @@ package task // PSP, which is used for goroutines) so that goroutines do not need extra stack // space for interrupts. +import "C" import ( - "device/arm" "unsafe" ) @@ -67,6 +67,6 @@ func (s *state) pause() { // SystemStack returns the system stack pointer. On Cortex-M, it is always // available. -func SystemStack() uintptr { - return arm.AsmFull("mrs {}, MSP", nil) -} +// +//export SystemStack +func SystemStack() uintptr |