Use static chain and libffi for Go closures

Uros Bizjak ubizjak@gmail.com
Mon Jan 19 18:15:00 GMT 2015


On Sat, Jan 17, 2015 at 7:34 PM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Sat, Jan 17, 2015 at 12:19 AM, Ian Lance Taylor <iant@golang.org> wrote:
>
>>> You should also revert alpha specific change to
>>> libgo/go/testing/quick/quick_test.go, please see [1] and [2].
>>>
>>> [1] https://gcc.gnu.org/ml/gcc-patches/2013-03/msg00038.html
>>> [2] https://gcc.gnu.org/ml/gcc-patches/2013-03/msg00038/foo.patch
>>
>> Done like so.  Committed to mainline.
>
> Thanks!
>
> There is another part in runtime/go-ffi.c that looks like it is not
> necessary anymore with FFI_TARGET_HAS_COMPLEX_TYPE.

Attached is a more conservative v2 patch that conditionally enables
fixup code when FFI_TARGET_HAS_COMPLEX_TYPE is not defined.

Tested on x86_64-linux-gnu {-m32} without regressions.

Uros.
-------------- next part --------------
Index: runtime/go-ffi.c
===================================================================
--- runtime/go-ffi.c	(revision 219832)
+++ runtime/go-ffi.c	(working copy)
@@ -290,8 +290,8 @@ go_func_return_ffi (const struct __go_func_type *f
 
   if (count == 1)
     {
-
-#if defined (__i386__) && !defined (__x86_64__)
+#ifndef FFI_TARGET_HAS_COMPLEX_TYPE
+# if defined (__i386__) && !defined (__x86_64__)
       /* FFI does not support complex types.  On 32-bit x86, a
 	 complex64 will be returned in %eax/%edx.  We normally tell
 	 FFI that a complex64 is a struct of two floats.  On 32-bit
@@ -300,6 +300,7 @@ go_func_return_ffi (const struct __go_func_type *f
 	 by pretending that complex64 is int64.  */
       if ((types[0]->__code & GO_CODE_MASK) == GO_COMPLEX64)
 	return &ffi_type_sint64;
+# endif
 #endif
 
       return go_type_to_ffi (types[0]);


More information about the Gcc-patches mailing list