mirror of
https://github.com/golang/go
synced 2024-11-18 14:54:40 -07:00
cmd/compile/internal/base: use runtime.KeepAlive in MapFile
Go 1.17 will be used instead of Go 1.4 as minimum required version for bootstrap, so runtime.KeepAlive introduced in Go 1.7 can be used in cmd/compile. For #44505 Change-Id: I96bd6619c4476e36ee1d93ca049da622a3a78f97 Reviewed-on: https://go-review.googlesource.com/c/go/+/427114 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
54c7bc9cff
commit
274528eca1
@ -10,6 +10,7 @@ package base
|
||||
import (
|
||||
"os"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
@ -27,7 +28,7 @@ func MapFile(f *os.File, offset, length int64) (string, error) {
|
||||
length += x
|
||||
|
||||
buf, err := syscall.Mmap(int(f.Fd()), offset, int(length), syscall.PROT_READ, syscall.MAP_SHARED)
|
||||
keepAlive(f)
|
||||
runtime.KeepAlive(f)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@ -43,7 +44,3 @@ func MapFile(f *os.File, offset, length int64) (string, error) {
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// keepAlive is a reimplementation of runtime.KeepAlive, which wasn't
|
||||
// added until Go 1.7, whereas we need to compile with Go 1.4.
|
||||
var keepAlive = func(interface{}) {}
|
||||
|
Loading…
Reference in New Issue
Block a user