-
-void sig_ffi_cif(
- CYPool &pool,
- struct Signature *signature,
- ffi_cif *cif,
- size_t skip,
- ffi_type **types,
- size_t offset
-) {
- if (types == NULL)
- types = new(pool) ffi_type *[signature->count - 1];
- ffi_type *type = signature->elements[0].type->GetFFI(pool);
- sig_ffi_types(pool, signature, types, 1 + skip, offset);
- ffi_status status = ffi_prep_cif(cif, FFI_DEFAULT_ABI, signature->count - 1 - skip + offset, type, types);
+#endif
+
+void sig_ffi_cif(CYPool &pool, size_t variadic, const Signature &signature, ffi_cif *cif) {
+ _assert(signature.count != 0);
+ size_t count(signature.count - 1);
+ ffi_type *type(signature.elements[0].type->GetFFI(pool));
+
+ ffi_type **types(new(pool) ffi_type *[count]);
+ for (size_t index(0); index != count; ++index)
+ types[index] = signature.elements[index + 1].type->GetFFI(pool);
+
+ ffi_status status;
+#ifdef HAVE_FFI_PREP_CIF_VAR
+ if (variadic == 0)
+#endif
+ status = ffi_prep_cif(cif, FFI_DEFAULT_ABI, count, type, types);
+#ifdef HAVE_FFI_PREP_CIF_VAR
+ else
+ status = ffi_prep_cif_var(cif, FFI_DEFAULT_ABI, variadic - 1, count, type, types);
+#endif