From fb1bfd4d37d40cd5e4969ac631cf979d7b08f1a2 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 3 Aug 2022 23:01:08 -0400 Subject: all: remove pre-Go 1.17 workarounds The Go bootstrap toolchain requirement is now Go 1.17. We can finally delete all these pre-Go 1.17 workarounds. For #44505. Change-Id: I59d4dff1cde23da022892b5b6a116eb3dbad9ce4 Reviewed-on: https://go-review.googlesource.com/c/go/+/420903 Auto-Submit: Dmitri Shuralyov Run-TryBot: Russ Cox Reviewed-by: Austin Clements TryBot-Result: Gopher Robot --- src/internal/pkgbits/frames_go1.go | 21 --------------------- src/internal/pkgbits/frames_go17.go | 28 ---------------------------- src/internal/pkgbits/sync.go | 19 +++++++++++++++++++ 3 files changed, 19 insertions(+), 49 deletions(-) delete mode 100644 src/internal/pkgbits/frames_go1.go delete mode 100644 src/internal/pkgbits/frames_go17.go (limited to 'src/internal/pkgbits') diff --git a/src/internal/pkgbits/frames_go1.go b/src/internal/pkgbits/frames_go1.go deleted file mode 100644 index 5294f6a63e..0000000000 --- a/src/internal/pkgbits/frames_go1.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2021 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build !go1.7 -// +build !go1.7 - -// TODO(mdempsky): Remove after #44505 is resolved - -package pkgbits - -import "runtime" - -func walkFrames(pcs []uintptr, visit frameVisitor) { - for _, pc := range pcs { - fn := runtime.FuncForPC(pc) - file, line := fn.FileLine(pc) - - visit(file, line, fn.Name(), pc-fn.Entry()) - } -} diff --git a/src/internal/pkgbits/frames_go17.go b/src/internal/pkgbits/frames_go17.go deleted file mode 100644 index 2324ae7adf..0000000000 --- a/src/internal/pkgbits/frames_go17.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2021 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build go1.7 -// +build go1.7 - -package pkgbits - -import "runtime" - -// walkFrames calls visit for each call frame represented by pcs. -// -// pcs should be a slice of PCs, as returned by runtime.Callers. -func walkFrames(pcs []uintptr, visit frameVisitor) { - if len(pcs) == 0 { - return - } - - frames := runtime.CallersFrames(pcs) - for { - frame, more := frames.Next() - visit(frame.File, frame.Line, frame.Function, frame.PC-frame.Entry) - if !more { - return - } - } -} diff --git a/src/internal/pkgbits/sync.go b/src/internal/pkgbits/sync.go index 4b9ea4863f..72f776af05 100644 --- a/src/internal/pkgbits/sync.go +++ b/src/internal/pkgbits/sync.go @@ -6,6 +6,7 @@ package pkgbits import ( "fmt" + "runtime" "strings" ) @@ -34,6 +35,24 @@ func fmtFrames(pcs ...uintptr) []string { type frameVisitor func(file string, line int, name string, offset uintptr) +// walkFrames calls visit for each call frame represented by pcs. +// +// pcs should be a slice of PCs, as returned by runtime.Callers. +func walkFrames(pcs []uintptr, visit frameVisitor) { + if len(pcs) == 0 { + return + } + + frames := runtime.CallersFrames(pcs) + for { + frame, more := frames.Next() + visit(frame.File, frame.Line, frame.Function, frame.PC-frame.Entry) + if !more { + return + } + } +} + // SyncMarker is an enum type that represents markers that may be // written to export data to ensure the reader and writer stay // synchronized. -- cgit v1.2.1