diff options
Diffstat (limited to 'libgo/go/syscall/syscall_unix.go')
-rw-r--r-- | libgo/go/syscall/syscall_unix.go | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/libgo/go/syscall/syscall_unix.go b/libgo/go/syscall/syscall_unix.go index 16e4d480..4d963fb 100644 --- a/libgo/go/syscall/syscall_unix.go +++ b/libgo/go/syscall/syscall_unix.go @@ -8,6 +8,7 @@ package syscall import ( "internal/race" + "internal/unsafeheader" "runtime" "sync" "unsafe" @@ -55,15 +56,12 @@ func (m *mmapper) Mmap(fd int, offset int64, length int, prot int, flags int) (d return nil, errno } - // Slice memory layout - var sl = struct { - addr uintptr - len int - cap int - }{addr, length, length} - - // Use unsafe to turn sl into a []byte. - b := *(*[]byte)(unsafe.Pointer(&sl)) + // Use unsafe to turn addr into a []byte. + var b []byte + hdr := (*unsafeheader.Slice)(unsafe.Pointer(&b)) + hdr.Data = unsafe.Pointer(addr) + hdr.Cap = length + hdr.Len = length // Register mapping in m and return it. p := &b[cap(b)-1] |