Skip to content

Commit cbc54da

Browse files
author
Hood
committed
Add CALL_FUNC_PTR macro to allow pyodide to define custom calling behavior to handle fpcast
1 parent af7caa2 commit cbc54da

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/wasm32/ffi.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@
8080
#define ALIGN_ADDRESS(addr, align) (addr &= (~((align) - 1)))
8181
#define STACK_ALLOC(stack, size, align) (ALIGN_ADDRESS(stack, align), (stack -= (size)))
8282

83+
#ifndef CALL_FUNC_PTR
84+
#define CALL_FUNC_PTR(func, args...) \
85+
wasmTable.get(func).apply(null, args)
86+
#endif
87+
8388
#define VARARGS_FLAG 1
8489

8590
ffi_status FFI_HIDDEN
@@ -285,7 +290,7 @@ ffi_call, (ffi_cif * cif, ffi_fp fn, void *rvalue, void **avalue),
285290
args.push(varargs_addr);
286291
stackRestore(varargs_addr);
287292
}
288-
var result = wasmTable.get(fn).apply(null, args);
293+
var result = CALL_FUNC_PTR(fn, args);
289294
// Put the stack pointer back (we moved it if we made a varargs call)
290295
stackRestore(orig_stack_ptr);
291296

@@ -540,10 +545,10 @@ ffi_prep_closure_loc_helper,
540545
varargs += 4;
541546
}
542547
stackRestore(cur_ptr);
543-
wasmTable.get(CLOSURE__fun(closure))(
548+
CALL_FUNC_PTR(CLOSURE__fun(closure), [
544549
CLOSURE__cif(closure), ret_ptr, args_ptr,
545550
CLOSURE__user_data(closure)
546-
);
551+
]);
547552
stackRestore(orig_stack_ptr);
548553

549554
if (!ret_by_arg) {

0 commit comments

Comments
 (0)