[PATCH] Fix for failing float/double variadic args test cases

40 views
Skip to first unread message

Anurag Gupta

unread,
Feb 4, 2014, 6:19:10 AM2/4/14
to ruby...@googlegroups.com, Anurag Gupta
This patch will fix the problem of passing float/double values as part of
variadic argument list from ruby-ffi package. All the test cases related to
float/double arguments passed as part of ruby variadic list were failing on
ppc64le arch. 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.

Signed-off-by: Anurag Gupta <anurag...@gmail.com>
---
ext/ffi_c/Variadic.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/ext/ffi_c/Variadic.c b/ext/ffi_c/Variadic.c
index 51e9785..acde70b 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
--
1.9.rc1

Anurag Gupta

unread,
Feb 7, 2014, 1:00:16 AM2/7/14
to ruby...@googlegroups.com, Anurag Gupta
Hi Thomas/Charles,

Kindly look into the patch for for test case failure on PowerPC 64 little Endian system and let know your views/comments.


Regards,
Anurag
Reply all
Reply to author
Forward
0 new messages