Commit 2be84a8c authored by David Symonds's avatar David Symonds

undo CL 8363045 / a3ce42f9748b

It changes an exported API, and breaks the build.

««« original CL description
reflect: use unsafe.Pointer in StringHeader and SliceHeader

Relates to issue 5193.

R=r
CC=golang-dev
https://golang.org/cl/8363045
»»»

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/8357051
parent 487721fd
......@@ -910,7 +910,7 @@ func (v Value) Index(i int) Value {
tt := (*sliceType)(unsafe.Pointer(v.typ))
typ := tt.elem
fl |= flag(typ.Kind()) << flagKindShift
val := unsafe.Pointer(uintptr(s.Data) + uintptr(i)*typ.size)
val := unsafe.Pointer(s.Data + uintptr(i)*typ.size)
return Value{typ, val, fl}
case String:
......@@ -919,7 +919,7 @@ func (v Value) Index(i int) Value {
if i < 0 || i >= s.Len {
panic("reflect: string index out of range")
}
val := *(*byte)(unsafe.Pointer(uintptr(s.Data) + uintptr(i)))
val := *(*byte)(unsafe.Pointer(s.Data + uintptr(i)))
return Value{uint8Type, unsafe.Pointer(uintptr(val)), fl}
}
panic(&ValueError{"reflect.Value.Index", k})
......@@ -1310,7 +1310,7 @@ func (v Value) Pointer() uintptr {
return uintptr(p)
case Slice:
return uintptr((*SliceHeader)(v.val).Data)
return (*SliceHeader)(v.val).Data
}
panic(&ValueError{"reflect.Value.Pointer", k})
}
......@@ -1565,7 +1565,7 @@ func (v Value) Slice(beg, end int) Value {
}
var x string
val := (*StringHeader)(unsafe.Pointer(&x))
val.Data = unsafe.Pointer(uintptr(s.Data) + uintptr(beg))
val.Data = s.Data + uintptr(beg)
val.Len = end - beg
return Value{v.typ, unsafe.Pointer(&x), v.flag}
}
......@@ -1579,7 +1579,7 @@ func (v Value) Slice(beg, end int) Value {
// Reinterpret as *SliceHeader to edit.
s := (*SliceHeader)(unsafe.Pointer(&x))
s.Data = unsafe.Pointer(uintptr(base) + uintptr(beg)*typ.elem.Size())
s.Data = uintptr(base) + uintptr(beg)*typ.elem.Size()
s.Len = end - beg
s.Cap = cap - beg
......@@ -1701,14 +1701,14 @@ func (v Value) UnsafeAddr() uintptr {
// StringHeader is the runtime representation of a string.
// It cannot be used safely or portably.
type StringHeader struct {
Data unsafe.Pointer
Data uintptr
Len int
}
// SliceHeader is the runtime representation of a slice.
// It cannot be used safely or portably.
type SliceHeader struct {
Data unsafe.Pointer
Data uintptr
Len int
Cap int
}
......@@ -1988,7 +1988,7 @@ func MakeSlice(typ Type, len, cap int) Value {
// Reinterpret as *SliceHeader to edit.
s := (*SliceHeader)(unsafe.Pointer(&x))
s.Data = unsafe_NewArray(typ.Elem().(*rtype), cap)
s.Data = uintptr(unsafe_NewArray(typ.Elem().(*rtype), cap))
s.Len = len
s.Cap = cap
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment