This is the mail archive of the libffi-discuss@sourceware.org mailing list for the libffi project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, libffi, alpha]: Use FFI_ASSERT in ffi_closure_osf_inner


[replying to an ancient post here..]

Uros Bizjak <ubizjak@gmail.com> writes:

> Hello!
>
> Attached patch fixes libgo reflect test failure with libffi closures.
> The gccgo compiler started to use FFI closures recently; the compiler
> passes ffi_type_void for structures with zero members.

Why not just pass an FFI_TYPE_STRUCT with zero members?

> ffi_call form src/alpha/ffi.c allows FFI_TYPE_VOID arguments in
> non-debug mode through the default: case, but ffi_closure_osf_inner
> aborts with this type of argument.
>
> The patch changes the default case in ffi_closure_osf_inner from abort
> to FFI_ASSERT, an this way synchronizes argument handling in both
> cases.
>
> 2014-07-21  Uros Bizjak  <ubizjak@gmail.com>
>
>     * src/alpha/ffi.c: Do not include stdlib.h.
>     (ffi_closure_osf_inner) <default>: Use FFI_ASSERT instead of abort.
>
> Patch was tested with libffi testsuite on alphaev6-linux-gnu.
> Additionally, the patch fixed reflect test from the libgo testsuite
> and go.test/test/recover.go test from the gcc testsuite.

Why not add an FFI_TYPE_VOID case so it doesn't ever abort if that's
expected behaviour?  The default case is there to catch unexpected
values.

AG




>
> Uros.
>
> Index: src/alpha/ffi.c
> ===================================================================
> --- src/alpha/ffi.c	(revision 212882)
> +++ src/alpha/ffi.c	(working copy)
> @@ -27,7 +27,6 @@
>  
>  #include <ffi.h>
>  #include <ffi_common.h>
> -#include <stdlib.h>
>  
>  /* Force FFI_TYPE_LONGDOUBLE to be different than FFI_TYPE_DOUBLE;
>     all further uses in this file will refer to the 128-bit type.  */
> @@ -273,7 +272,7 @@ ffi_closure_osf_inner(ffi_closure *closure, void *
>  	  break;
>  
>  	default:
> -	  abort ();
> +	  FFI_ASSERT (0);
>  	}
>  
>        argn += ALIGN(size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]