github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/runtime/scheduler_tasks.go (about)

     1  //go:build scheduler.tasks
     2  
     3  package runtime
     4  
     5  import "internal/task"
     6  
     7  // getSystemStackPointer returns the current stack pointer of the system stack.
     8  // This is not necessarily the same as the current stack pointer.
     9  func getSystemStackPointer() uintptr {
    10  	// TODO: this always returns the correct stack on Cortex-M, so don't bother
    11  	// comparing against 0.
    12  	sp := task.SystemStack()
    13  	if sp == 0 {
    14  		sp = getCurrentStackPointer()
    15  	}
    16  	return sp
    17  }