runtime: correct runtime structfield type to match reflect
The offset field in structfield has changed to offsetAnon, and now
requires a shift to get the actual offset value.
Fixes golang/go#23391
Change-Id: I663997eb4a6e73c6e8333e29c305df469db94954
Reviewed-on: https://go-review.googlesource.com/92275
Reviewed-by: Than McIntosh <thanm@google.com>
diff --git a/libgo/go/runtime/cgocall.go b/libgo/go/runtime/cgocall.go
index 9d16120..d5794bc 100644
--- a/libgo/go/runtime/cgocall.go
+++ b/libgo/go/runtime/cgocall.go
@@ -189,7 +189,7 @@
return
}
for _, f := range st.fields {
- cgoCheckArg(f.typ, add(p, f.offset), true, top, msg)
+ cgoCheckArg(f.typ, add(p, f.offset()), true, top, msg)
}
case kindPtr, kindUnsafePointer:
if indir {
diff --git a/libgo/go/runtime/type.go b/libgo/go/runtime/type.go
index 6788f24..0ec0da4 100644
--- a/libgo/go/runtime/type.go
+++ b/libgo/go/runtime/type.go
@@ -113,11 +113,19 @@
}
type structfield struct {
- name *string // nil for embedded fields
- pkgPath *string // nil for exported Names; otherwise import path
- typ *_type // type of field
- tag *string // nil if no tag
- offset uintptr // byte offset of field within struct
+ name *string // nil for embedded fields
+ pkgPath *string // nil for exported Names; otherwise import path
+ typ *_type // type of field
+ tag *string // nil if no tag
+ offsetAnon uintptr // byte offset of field<<1 | isAnonymous
+}
+
+func (f *structfield) offset() uintptr {
+ return f.offsetAnon >> 1
+}
+
+func (f *structfield) anon() bool {
+ return f.offsetAnon&1 != 0
}
type structtype struct {