Files
llgo/cl/_testlibc/atomic/in.go

19 lines
306 B
Go
Raw Normal View History

2024-06-16 03:49:09 +08:00
package main
import (
"github.com/goplus/llgo/c"
"github.com/goplus/llgo/c/sync"
)
func main() {
var v int64 = 100
sync.FetchAndAdd(&v, 1)
c.Printf(c.Str("%ld\n"), v)
sync.CompareAndXchg(&v, 100, 102)
c.Printf(c.Str("%ld\n"), v)
sync.CompareAndXchg(&v, 101, 102)
c.Printf(c.Str("%ld\n"), v)
}