]> Cypherpunks.ru repositories - gostls13.git/commitdiff
internal/fmtsort: makeChans pin pointer
authorqiulaidongfeng <2645477756@qq.com>
Sat, 28 Oct 2023 07:09:01 +0000 (07:09 +0000)
committerGopher Robot <gobot@golang.org>
Mon, 30 Oct 2023 21:00:16 +0000 (21:00 +0000)
Complete TODO.

For #49431

Change-Id: I1399205e430ebd83182c3e0c4becf1fde32d433e
GitHub-Last-Rev: 02cdea740bccbe0993c53fecdd32608f08861e59
GitHub-Pull-Request: golang/go#62673
Reviewed-on: https://go-review.googlesource.com/c/go/+/528796
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Commit-Queue: Keith Randall <khr@golang.org>
Run-TryBot: qiulaidongfeng <2645477756@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
src/internal/fmtsort/sort_test.go

index 55c80ad426e27b51a32aaac9e374d2c3faf12a4f..7d5de9f56b9363382ea9b4e72fe7812a2736b437 100644 (file)
@@ -9,6 +9,7 @@ import (
        "internal/fmtsort"
        "math"
        "reflect"
+       "runtime"
        "sort"
        "strings"
        "testing"
@@ -190,12 +191,15 @@ func sprintKey(key reflect.Value) string {
 var (
        ints  [3]int
        chans = makeChans()
+       pin   runtime.Pinner
 )
 
 func makeChans() []chan int {
        cs := []chan int{make(chan int), make(chan int), make(chan int)}
        // Order channels by address. See issue #49431.
-       // TODO: pin these pointers once pinning is available (#46787).
+       for i := range cs {
+               pin.Pin(reflect.ValueOf(cs[i]).UnsafePointer())
+       }
        sort.Slice(cs, func(i, j int) bool {
                return uintptr(reflect.ValueOf(cs[i]).UnsafePointer()) < uintptr(reflect.ValueOf(cs[j]).UnsafePointer())
        })