From 9c2ab20d483b38d483d3a40f4a9ffe250d58013c Mon Sep 17 00:00:00 2001 From: qiulaidongfeng <2645477756@qq.com> Date: Sat, 28 Oct 2023 07:09:01 +0000 Subject: [PATCH] internal/fmtsort: makeChans pin pointer 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 Reviewed-by: Keith Randall Auto-Submit: Keith Randall Commit-Queue: Keith Randall Run-TryBot: qiulaidongfeng <2645477756@qq.com> TryBot-Result: Gopher Robot Reviewed-by: Keith Randall --- src/internal/fmtsort/sort_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/internal/fmtsort/sort_test.go b/src/internal/fmtsort/sort_test.go index 55c80ad426..7d5de9f56b 100644 --- a/src/internal/fmtsort/sort_test.go +++ b/src/internal/fmtsort/sort_test.go @@ -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()) }) -- 2.44.0