diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2018-02-06 15:18:50 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2018-02-06 15:18:50 +0000 |
commit | 387c353ebc9b928e31168c75ee38b1a3a76a2387 (patch) | |
tree | fb04c3aa403bdf247afafcc485c9fe87cf71fd3b /libgo | |
parent | 35c607837df294fbd8c477f5c814627ea0c46731 (diff) |
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
Reviewed-on: https://go-review.googlesource.com/92275
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@257413 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo')
-rw-r--r-- | libgo/go/runtime/cgocall.go | 2 | ||||
-rw-r--r-- | libgo/go/runtime/type.go | 18 |
2 files changed, 14 insertions, 6 deletions
diff --git a/libgo/go/runtime/cgocall.go b/libgo/go/runtime/cgocall.go index 9d161202dfa..d5794bc3341 100644 --- a/libgo/go/runtime/cgocall.go +++ b/libgo/go/runtime/cgocall.go @@ -189,7 +189,7 @@ func cgoCheckArg(t *_type, p unsafe.Pointer, indir, top bool, msg string) { 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 6788f2425e1..0ec0da41179 100644 --- a/libgo/go/runtime/type.go +++ b/libgo/go/runtime/type.go @@ -113,11 +113,19 @@ type ptrtype struct { } 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 { |