mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 19:17:47 +00:00
runtime: implement KeepAlive using inline assembly
This commit is contained in:
committed by
Ron Evans
parent
361ecf9ea4
commit
c02cc339c5
Vendored
+10
@@ -1,5 +1,7 @@
|
||||
package main
|
||||
|
||||
import "runtime"
|
||||
|
||||
var xorshift32State uint32 = 1
|
||||
|
||||
func xorshift32(x uint32) uint32 {
|
||||
@@ -17,6 +19,7 @@ func randuint32() uint32 {
|
||||
|
||||
func main() {
|
||||
testNonPointerHeap()
|
||||
testKeepAlive()
|
||||
}
|
||||
|
||||
var scalarSlices [4][]byte
|
||||
@@ -64,3 +67,10 @@ func testNonPointerHeap() {
|
||||
}
|
||||
println("ok")
|
||||
}
|
||||
|
||||
func testKeepAlive() {
|
||||
// There isn't much we can test, but at least we can test that
|
||||
// runtime.KeepAlive compiles correctly.
|
||||
var x int
|
||||
runtime.KeepAlive(&x)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user