File: fix-for-variadic-float-double-values.diff

package info (click to toggle)
ruby-ffi 1.9.6debian-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,376 kB
  • ctags: 2,126
  • sloc: ansic: 7,471; ruby: 5,585; sh: 24; makefile: 14
file content (35 lines) | stat: -rw-r--r-- 1,553 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Description: Fix for failing float/double variadic args test cases in ruby-ffi package
 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
Author: Anurag Gupta <anurag@linux.vnet.ibm.com>

---

--- ruby-ffi-1.9.3debian.orig/ext/ffi_c/Variadic.c
+++ ruby-ffi-1.9.3debian/ext/ffi_c/Variadic.c
@@ -170,7 +170,7 @@ variadic_invoke(VALUE self, VALUE parame
     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 parame
     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