Commit 7e6fecf5 by Ian Lance Taylor

runtime: for FFI, treat directIface types as pointers

    
    This only matters on systems that pass a struct with a single pointer
    field differently than passing a single pointer.  I noticed it on
    32-bit PPC, where the reflect package TestDirectIfaceMethod failed.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/195878

From-SVN: r275814
parent 033425d0
7aabaf8623cf88e2378057476a034093abbe5aab 09ca3c1ea8a52b5d3d6c4331c59d44e0b6bfab57
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the gofrontend repository. merge done from the gofrontend repository.
...@@ -224,6 +224,9 @@ func structToFFI(typ *structtype) *__ffi_type { ...@@ -224,6 +224,9 @@ func structToFFI(typ *structtype) *__ffi_type {
if c == 0 { if c == 0 {
return emptyStructToFFI() return emptyStructToFFI()
} }
if typ.typ.kind&kindDirectIface != 0 {
return ffi_type_pointer()
}
fields := make([]*__ffi_type, 0, c+1) fields := make([]*__ffi_type, 0, c+1)
checkPad := false checkPad := false
...@@ -307,6 +310,9 @@ func arrayToFFI(typ *arraytype) *__ffi_type { ...@@ -307,6 +310,9 @@ func arrayToFFI(typ *arraytype) *__ffi_type {
if typ.len == 0 { if typ.len == 0 {
return emptyStructToFFI() return emptyStructToFFI()
} }
if typ.typ.kind&kindDirectIface != 0 {
return ffi_type_pointer()
}
elements := make([]*__ffi_type, typ.len+1) elements := make([]*__ffi_type, typ.len+1)
et := typeToFFI(typ.elem) et := typeToFFI(typ.elem)
for i := uintptr(0); i < typ.len; i++ { for i := uintptr(0); i < typ.len; i++ {
......
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