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

     1  //go:build cortexm
     2  
     3  package runtime
     4  
     5  import (
     6  	"device/arm"
     7  )
     8  
     9  const GOARCH = "arm"
    10  
    11  // The bitness of the CPU (e.g. 8, 32, 64).
    12  const TargetBits = 32
    13  
    14  const deferExtraRegs = 0
    15  
    16  const callInstSize = 4 // "bl someFunction" is 4 bytes
    17  
    18  // Align on word boundary.
    19  func align(ptr uintptr) uintptr {
    20  	return (ptr + 7) &^ 7
    21  }
    22  
    23  func getCurrentStackPointer() uintptr {
    24  	return uintptr(stacksave())
    25  }
    26  
    27  // The safest thing to do here would just be to disable interrupts for
    28  // procPin/procUnpin. Note that a global variable is safe in this case, as any
    29  // access to procPinnedMask will happen with interrupts disabled.
    30  
    31  var procPinnedMask uintptr
    32  
    33  //go:linkname procPin sync/atomic.runtime_procPin
    34  func procPin() {
    35  	procPinnedMask = arm.DisableInterrupts()
    36  }
    37  
    38  //go:linkname procUnpin sync/atomic.runtime_procUnpin
    39  func procUnpin() {
    40  	arm.EnableInterrupts(procPinnedMask)
    41  }