mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-09-11 15:09:32 +00:00
runtime: check for heap allocations inside interrupts
This is unsafe and should never be done.
This commit is contained in:
committed by
Ron Evans
parent
e066e67baf
commit
f41b6a3b96
@@ -27,3 +27,12 @@ func Disable() (state State) {
|
||||
func Restore(state State) {
|
||||
riscv.EnableInterrupts(uintptr(state))
|
||||
}
|
||||
|
||||
// In returns whether the system is currently in an interrupt.
|
||||
func In() bool {
|
||||
// There is one exception that has the value 0 (instruction address
|
||||
// misaligned), but it's not very likely and even if it happens, it's not
|
||||
// really something that can be recovered from. Therefore I think it's safe
|
||||
// to ignore it. It's handled specially (in handleException).
|
||||
return riscv.MCAUSE.Get() != 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user