reflect: unexport FFICallbackGo; use go:linkname instead

The function was always intended to be internal-only, but was exported
    so that C code could call it. Now that have go:linkname for that, use it.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/195857

From-SVN: r275809
This commit is contained in:
Ian Lance Taylor 2019-09-17 17:22:18 +00:00
parent d0bc0cb66b
commit 99a28ee8c1
3 changed files with 10 additions and 9 deletions

View File

@ -1,4 +1,4 @@
722990deeede7801e4ed3ca5d53ce312a19fcd7a ff18e041624b8c23ffcd747f51e9dda945777d2a
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.

View File

@ -15,19 +15,20 @@ func makeFuncFFI(cif unsafe.Pointer, impl unsafe.Pointer)
// The makeCIF function, implemented in the runtime package, allocates a CIF. // The makeCIF function, implemented in the runtime package, allocates a CIF.
func makeCIF(ft *funcType) unsafe.Pointer func makeCIF(ft *funcType) unsafe.Pointer
// FFICallbackGo implements the Go side of the libffi callback. // Export ffiCallbackGo so that C code in makefunc_ffi_c.c can call it.
// It is exported so that C code can call it. //go:linkname ffiCallbackGo
// ffiCallbackGo implements the Go side of the libffi callback.
// //
// The call chain arriving here looks like // The call chain arriving here looks like
// some_go_caller // some_go_caller
// ->some_ffi_internals // ->some_ffi_internals
// ->ffi_callback (in C) // ->ffi_callback (in C)
// ->FFICallbackGo // ->ffiCallbackGo
// //
// The ffi_callback handles __go_makefunc_can_recover, and // The ffi_callback handles __go_makefunc_can_recover, and
// then passes off the data as received from ffi here. // then passes off the data as received from ffi here.
func ffiCallbackGo(results unsafe.Pointer, params unsafe.Pointer, impl *makeFuncImpl) {
func FFICallbackGo(results unsafe.Pointer, params unsafe.Pointer, impl *makeFuncImpl) {
ftyp := impl.typ ftyp := impl.typ
in := make([]Value, 0, len(ftyp.in)) in := make([]Value, 0, len(ftyp.in))
ap := params ap := params

View File

@ -25,8 +25,8 @@ void makeFuncFFI(void *cif, void *impl)
function ffiCall with the pointer to the arguments, the results area, function ffiCall with the pointer to the arguments, the results area,
and the closure structure. */ and the closure structure. */
extern void FFICallbackGo(void *result, void **args, ffi_go_closure *closure) extern void ffiCallbackGo(void *result, void **args, ffi_go_closure *closure)
__asm__ (GOSYM_PREFIX "reflect.FFICallbackGo"); __asm__ (GOSYM_PREFIX "reflect.ffiCallbackGo");
extern void makefuncfficanrecover(Slice) extern void makefuncfficanrecover(Slice)
__asm__ (GOSYM_PREFIX "runtime.makefuncfficanrecover"); __asm__ (GOSYM_PREFIX "runtime.makefuncfficanrecover");
@ -72,7 +72,7 @@ ffi_callback (ffi_cif* cif __attribute__ ((unused)), void *results,
makefuncfficanrecover (s); makefuncfficanrecover (s);
} }
FFICallbackGo(results, args, closure); ffiCallbackGo(results, args, closure);
if (i < n) if (i < n)
makefuncreturning (); makefuncreturning ();