diff mbox

Use static chain and libffi for Go closures

Message ID CAOyqgcVi2hUSJXpcEjSNiVLb2ex30CE0HPZSW6BAdLXwM+-1Ag@mail.gmail.com
State New
Headers show

Commit Message

Ian Lance Taylor Jan. 19, 2015, 2:56 a.m. UTC
On Sat, Jan 17, 2015 at 2:42 PM, Richard Henderson <rth@redhat.com> wrote:
>
> I tested non-support of libffi go closures before applying the patches
> for them for ppc, but I guess I busted something in the meantime.
>
> Please try this.

I don't think that will work if configured with --without-libffi.

I'm going to commit this patch, which seems simpler and should fix
this problem.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu, where admittedly the problem does not occur.

Ian

Comments

Andreas Schwab Jan. 19, 2015, 10:26 a.m. UTC | #1
Ian Lance Taylor <iant@golang.org> writes:

> @@ -83,7 +83,7 @@
>  #else /* !defined(USE_LIBFFI_CLOSURES) */
>  
>  void
> -makeFuncFFI(const struct __go_func_type *ftyp, ffi_go_closure *impl)
> +makeFuncFFI(const struct __go_func_type *ftyp, void *impl)
>  {
>    runtime_panicstring ("libgo built without FFI does not support "
>  		       "reflect.MakeFunc");

../../../libgo/go/reflect/makefunc_ffi_c.c: In function ‘makeFuncFFI’:
../../../libgo/go/reflect/makefunc_ffi_c.c:86:42: error: unused parameter ‘ftyp’ [-Werror=unused-parameter]
 makeFuncFFI(const struct __go_func_type *ftyp, void *impl)
                                          ^
../../../libgo/go/reflect/makefunc_ffi_c.c:86:54: error: unused parameter ‘impl’ [-Werror=unused-parameter]
 makeFuncFFI(const struct __go_func_type *ftyp, void *impl)
                                                      ^

Andreas.
diff mbox

Patch

diff -r 49d48c62427f libgo/go/reflect/makefunc.go
--- a/libgo/go/reflect/makefunc.go	Fri Jan 16 15:22:43 2015 -0800
+++ b/libgo/go/reflect/makefunc.go	Sun Jan 18 18:52:45 2015 -0800
@@ -63,7 +63,7 @@ 
 		method: -1,
 	}
 
-	makeFuncFFI(ftyp, impl)
+	makeFuncFFI(ftyp, unsafe.Pointer(impl))
 
 	return Value{t, unsafe.Pointer(&impl), flag(Func) | flagIndir}
 }
@@ -102,7 +102,7 @@ 
 		rcvr:   rcvr,
 	}
 
-	makeFuncFFI(ftyp, fv)
+	makeFuncFFI(ftyp, unsafe.Pointer(fv))
 
 	return Value{ft, unsafe.Pointer(&fv), v.flag&flagRO | flag(Func) | flagIndir}
 }
@@ -128,7 +128,7 @@ 
 		rcvr:   v,
 	}
 
-	makeFuncFFI(ftyp, impl)
+	makeFuncFFI(ftyp, unsafe.Pointer(impl))
 
 	return Value{t, unsafe.Pointer(&impl), v.flag&flagRO | flag(Func) | flagIndir}
 }
diff -r 49d48c62427f libgo/go/reflect/makefunc_ffi.go
--- a/libgo/go/reflect/makefunc_ffi.go	Fri Jan 16 15:22:43 2015 -0800
+++ b/libgo/go/reflect/makefunc_ffi.go	Sun Jan 18 18:52:45 2015 -0800
@@ -10,7 +10,7 @@ 
 
 // The makeFuncFFI function, written in C, fills in an FFI closure.
 // It arranges for ffiCall to be invoked directly from FFI.
-func makeFuncFFI(ftyp *funcType, impl *makeFuncImpl)
+func makeFuncFFI(ftyp *funcType, impl unsafe.Pointer)
 
 // FFICallbackGo implements the Go side of the libffi callback.
 // It is exported so that C code can call it.
diff -r 49d48c62427f libgo/go/reflect/makefunc_ffi_c.c
--- a/libgo/go/reflect/makefunc_ffi_c.c	Fri Jan 16 15:22:43 2015 -0800
+++ b/libgo/go/reflect/makefunc_ffi_c.c	Sun Jan 18 18:52:45 2015 -0800
@@ -18,7 +18,7 @@ 
 
 /* Declare C functions with the names used to call from Go.  */
 
-void makeFuncFFI(const struct __go_func_type *ftyp, ffi_go_closure *impl)
+void makeFuncFFI(const struct __go_func_type *ftyp, void *impl)
   __asm__ (GOSYM_PREFIX "reflect.makeFuncFFI");
 
 #ifdef USE_LIBFFI_CLOSURES
@@ -70,7 +70,7 @@ 
 /* Allocate an FFI closure and arrange to call ffi_callback.  */
 
 void
-makeFuncFFI(const struct __go_func_type *ftyp, ffi_go_closure *impl)
+makeFuncFFI(const struct __go_func_type *ftyp, void *impl)
 {
   ffi_cif *cif;
 
@@ -83,7 +83,7 @@ 
 #else /* !defined(USE_LIBFFI_CLOSURES) */
 
 void
-makeFuncFFI(const struct __go_func_type *ftyp, ffi_go_closure *impl)
+makeFuncFFI(const struct __go_func_type *ftyp, void *impl)
 {
   runtime_panicstring ("libgo built without FFI does not support "
 		       "reflect.MakeFunc");