mirror of
https://github.com/rwinkhart/sys.git
synced 2026-09-02 23:27:31 -04:00
unix: use unsafe.Slice instead of unsafeheader package
Go 1.18 is the minimum supported Go version and unsafe.Slice was introduced in Go 1.17. Change-Id: Ie5f1fad01f219e7b7a190de2c49676f366ad3bc7 Reviewed-on: https://go-review.googlesource.com/c/sys/+/428515 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Benny Siegert <bsiegert@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
This commit is contained in:
committed by
Benny Siegert
parent
27713097b9
commit
aba9fc2a8f
@@ -13,8 +13,6 @@ import (
|
||||
"sync"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/internal/unsafeheader"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -117,11 +115,7 @@ func (m *mmapper) Mmap(fd int, offset int64, length int, prot int, flags int) (d
|
||||
}
|
||||
|
||||
// Use unsafe to convert addr into a []byte.
|
||||
var b []byte
|
||||
hdr := (*unsafeheader.Slice)(unsafe.Pointer(&b))
|
||||
hdr.Data = unsafe.Pointer(addr)
|
||||
hdr.Cap = length
|
||||
hdr.Len = length
|
||||
b := unsafe.Slice((*byte)(unsafe.Pointer(addr)), length)
|
||||
|
||||
// Register mapping in m and return it.
|
||||
p := &b[cap(b)-1]
|
||||
|
||||
Reference in New Issue
Block a user