aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhopehook <hopehook.com@gmail.com>2022-09-09 08:48:34 +0800
committerGopher Robot <gobot@golang.org>2022-09-09 01:59:25 +0000
commit41089704ddafa736e73ebd54f837706e979ecb49 (patch)
treef81379eaab59c09e3d2b00fa37c6c3adf6085012 /src
parentd734203e393745626d2c705aaf433b210d86c241 (diff)
downloadgo-41089704ddafa736e73ebd54f837706e979ecb49.tar.xz
all: transfer reflect.{SliceHeader, StringHeader} to unsafeheader.{Slice, String}
After we deprecated reflect.{SliceHeader, StringHeader}, it is recommended to use unsafe.{Slice, String} to replace its work. However, the compiler and linker cannot be migrated for the time being. As a temporary strategy, using the "internal/unsafeheader" package like other code is the most suitable choice at present. For #53003. Change-Id: I69d0ef72e2d95caabd0706bbb247a719d225c758 Reviewed-on: https://go-review.googlesource.com/c/go/+/429755 Auto-Submit: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: hopehook <hopehook@golangcn.org>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/compile/internal/base/mapfile_mmap.go6
-rw-r--r--src/cmd/link/internal/ld/outbuf_windows.go6
-rw-r--r--src/reflect/value.go2
3 files changed, 7 insertions, 7 deletions
diff --git a/src/cmd/compile/internal/base/mapfile_mmap.go b/src/cmd/compile/internal/base/mapfile_mmap.go
index e154a3f9e0..3a5f4cfe21 100644
--- a/src/cmd/compile/internal/base/mapfile_mmap.go
+++ b/src/cmd/compile/internal/base/mapfile_mmap.go
@@ -8,8 +8,8 @@
package base
import (
+ "internal/unsafeheader"
"os"
- "reflect"
"runtime"
"syscall"
"unsafe"
@@ -34,10 +34,10 @@ func MapFile(f *os.File, offset, length int64) (string, error) {
}
buf = buf[x:]
- pSlice := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
+ pSlice := (*unsafeheader.Slice)(unsafe.Pointer(&buf))
var res string
- pString := (*reflect.StringHeader)(unsafe.Pointer(&res))
+ pString := (*unsafeheader.String)(unsafe.Pointer(&res))
pString.Data = pSlice.Data
pString.Len = pSlice.Len
diff --git a/src/cmd/link/internal/ld/outbuf_windows.go b/src/cmd/link/internal/ld/outbuf_windows.go
index a568a17011..95937e781c 100644
--- a/src/cmd/link/internal/ld/outbuf_windows.go
+++ b/src/cmd/link/internal/ld/outbuf_windows.go
@@ -5,7 +5,7 @@
package ld
import (
- "reflect"
+ "internal/unsafeheader"
"syscall"
"unsafe"
)
@@ -35,8 +35,8 @@ func (out *OutBuf) Mmap(filesize uint64) error {
if err != nil {
return err
}
- bufHdr := (*reflect.SliceHeader)(unsafe.Pointer(&out.buf))
- bufHdr.Data = ptr
+ bufHdr := (*unsafeheader.Slice)(unsafe.Pointer(&out.buf))
+ bufHdr.Data = unsafe.Pointer(ptr)
bufHdr.Len = int(filesize)
bufHdr.Cap = int(filesize)
diff --git a/src/reflect/value.go b/src/reflect/value.go
index 917a5a69c9..4e5d3977ec 100644
--- a/src/reflect/value.go
+++ b/src/reflect/value.go
@@ -2155,7 +2155,7 @@ func (v Value) Pointer() uintptr {
return uintptr(p)
case Slice:
- return (*SliceHeader)(v.ptr).Data
+ return uintptr((*unsafeheader.Slice)(v.ptr).Data)
}
panic(&ValueError{"reflect.Value.Pointer", v.kind()})
}