From 41ef16653a61b45ff39fbe6875060aba5b8d064b Mon Sep 17 00:00:00 2001 From: retropikzel Date: Tue, 11 Mar 2025 11:07:24 +0200 Subject: [PATCH] Fixes to Chibi and Gauche --- retropikzel/pffi/gauche.scm | 2 +- src/chibi/pffi.stub | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/retropikzel/pffi/gauche.scm b/retropikzel/pffi/gauche.scm index cfec3ca..45e111b 100644 --- a/retropikzel/pffi/gauche.scm +++ b/retropikzel/pffi/gauche.scm @@ -136,7 +136,7 @@ ((equal? type 'unsigned-long) (get-ffi-type-ulong)) ((equal? type 'float) (get-ffi-type-float)) ((equal? type 'double) (get-ffi-type-double)) - ((equal? type 'void) (get-ffi-type-void)) + ((equal? type 'void) (get-ffi-type-pointer)) ((equal? type 'pointer) (get-ffi-type-pointer)) ((equal? type 'callback) (get-ffi-type-pointer))))) diff --git a/src/chibi/pffi.stub b/src/chibi/pffi.stub index e0b64f3..e719b70 100644 --- a/src/chibi/pffi.stub +++ b/src/chibi/pffi.stub @@ -241,9 +241,17 @@ }") (define-c int (internal-ffi-prep-cif internal_ffi_prep_cif) (unsigned-int (pointer void*) (array void*))) (c-declare - "void internal_ffi_call(unsigned int nargs, void* rtype, void** atypes, void* fn, void* rvalue, void* avalues) { + "void internal_ffi_call(unsigned int nargs, void* rtype, void** atypes, void* fn, void* rvalue, void* avalues[]) { ffi_prep_cif(&cif, FFI_DEFAULT_ABI, nargs, (ffi_type*)rtype, (ffi_type**)atypes); - ffi_call(&cif, FFI_FN(fn), rvalue, &avalues); + void* c_avalues[nargs]; + for(int i = 0; i < nargs; i++) { + if(atypes[i] == &ffi_type_pointer) { + c_avalues[i] = &avalues[i]; + } else { + c_avalues[i] = avalues[i]; + } + } + ffi_call(&cif, FFI_FN(fn), rvalue, c_avalues); }") (define-c void (internal-ffi-call internal_ffi_call)