]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: convert local var stop,ready at TestDebugCallUnsafePoint to atomic type
authorcuiweixie <cuiweixie@gmail.com>
Fri, 2 Sep 2022 02:18:51 +0000 (10:18 +0800)
committerDaniel Martí <mvdan@mvdan.cc>
Mon, 5 Sep 2022 08:07:47 +0000 (08:07 +0000)
For #53821

Change-Id: Id972d4ccadc72de69dea46f8be146c9843d1d095
Reviewed-on: https://go-review.googlesource.com/c/go/+/427135
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: xie cui <523516579@qq.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/runtime/debug_test.go

index 75fe07ec2a2df87e3d6857ff920911440c708948..b231be344c0d666bd33345eee2c1921c22002d54 100644 (file)
@@ -224,7 +224,7 @@ func TestDebugCallGrowStack(t *testing.T) {
 }
 
 //go:nosplit
-func debugCallUnsafePointWorker(gpp **runtime.G, ready, stop *uint32) {
+func debugCallUnsafePointWorker(gpp **runtime.G, ready, stop *atomic.Bool) {
        // The nosplit causes this function to not contain safe-points
        // except at calls.
        runtime.LockOSThread()
@@ -232,8 +232,8 @@ func debugCallUnsafePointWorker(gpp **runtime.G, ready, stop *uint32) {
 
        *gpp = runtime.Getg()
 
-       for atomic.LoadUint32(stop) == 0 {
-               atomic.StoreUint32(ready, 1)
+       for !stop.Load() {
+               ready.Store(true)
        }
 }
 
@@ -253,10 +253,10 @@ func TestDebugCallUnsafePoint(t *testing.T) {
 
        // Test that the runtime refuses call injection at unsafe points.
        var g *runtime.G
-       var ready, stop uint32
-       defer atomic.StoreUint32(&stop, 1)
+       var ready, stop atomic.Bool
+       defer stop.Store(true)
        go debugCallUnsafePointWorker(&g, &ready, &stop)
-       for atomic.LoadUint32(&ready) == 0 {
+       for !ready.Load() {
                runtime.Gosched()
        }