diff options
author | Anurag Gupta <anurag@linux.vnet.ibm.com> | 2014-08-26 17:53:29 -0700 |
---|---|---|
committer | Antonio Terceiro <terceiro@debian.org> | 2014-08-26 18:10:16 -0700 |
commit | 30f155d05cac28d82baf0283404b675222616f9d (patch) | |
tree | 5457a36e339ce51f245dc5b201758da264ec92c6 | |
parent | 53fedc22339d1447b4690c352acce0d3010bfe21 (diff) | |
download | ffi-30f155d05cac28d82baf0283404b675222616f9d.tar.gz |
Fix variadic calls with float/double arguments
Problem was due to incorrect way to call C method ffi_prep_cif_var,
where third argument was passed as total number of arguments instead of
fixed number of arguments
This fixes ruby-ffi on the ppc64el architecture, and should be harmless
on other architectures. This was tested at least on amd64 (x86_64) and
ppc64el.
Signed-off-by: Antonio Terceiro <terceiro@debian.org>
-rw-r--r-- | ext/ffi_c/Variadic.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/ffi_c/Variadic.c b/ext/ffi_c/Variadic.c index 687e8bc..0027be2 100644 --- a/ext/ffi_c/Variadic.c +++ b/ext/ffi_c/Variadic.c @@ -170,7 +170,7 @@ variadic_invoke(VALUE self, VALUE parameterTypes, VALUE parameterValues) ffi_type* ffiReturnType; Type** paramTypes; VALUE* argv; - int paramCount = 0, i; + int paramCount = 0, fixedCount = 0, i; ffi_status ffiStatus; rbffi_frame_t frame = { 0 }; @@ -229,8 +229,12 @@ variadic_invoke(VALUE self, VALUE parameterTypes, VALUE parameterValues) if (ffiReturnType == NULL) { rb_raise(rb_eArgError, "Invalid return type"); } + + /*Get the number of fixed args from @fixed array*/ + fixedCount = RARRAY_LEN(rb_iv_get(self, "@fixed")); + #ifdef HAVE_FFI_PREP_CIF_VAR - ffiStatus = ffi_prep_cif_var(&cif, invoker->abi, paramCount, paramCount, ffiReturnType, ffiParamTypes); + ffiStatus = ffi_prep_cif_var(&cif, invoker->abi, fixedCount, paramCount, ffiReturnType, ffiParamTypes); #else ffiStatus = ffi_prep_cif(&cif, invoker->abi, paramCount, ffiReturnType, ffiParamTypes); #endif |