llgo/ssa: AtomicCmpXchg fix

This commit is contained in:
xushiwei
2024-06-16 17:03:41 +08:00
parent 7d2f68c5e4
commit 4a3446a0a5
5 changed files with 31 additions and 26 deletions

View File

@@ -11,15 +11,15 @@ func main() {
atomic.Store(&v, 100)
c.Printf(c.Str("store: %ld\n"), atomic.Load(&v))
atomic.Add(&v, 1)
c.Printf(c.Str("v: %ld\n"), v)
ret := atomic.Add(&v, 1)
c.Printf(c.Str("ret: %ld, v: %ld\n"), ret, v)
atomic.CompareAndExchange(&v, 100, 102)
c.Printf(c.Str("v: %ld\n"), v)
ret, _ = atomic.CompareAndExchange(&v, 100, 102)
c.Printf(c.Str("ret: %ld vs 100, v: %ld\n"), ret, v)
atomic.CompareAndExchange(&v, 101, 102)
c.Printf(c.Str("v: %ld\n"), v)
ret, _ = atomic.CompareAndExchange(&v, 101, 102)
c.Printf(c.Str("ret: %ld vs 101, v: %ld\n"), ret, v)
atomic.Sub(&v, 1)
c.Printf(c.Str("v: %ld\n"), v)
ret = atomic.Sub(&v, 1)
c.Printf(c.Str("ret: %ld, v: %ld\n"), ret, v)
}