summaryrefslogtreecommitdiff
path: root/libguile/foreign.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2018-08-11 14:22:32 +0200
committerAndy Wingo <wingo@pobox.com>2018-08-11 14:25:07 +0200
commit939b1ae23f680365fb6fd0a78653a281aaed95b6 (patch)
tree969e96ccfb96c4399978ee9af86e9783674fe7b0 /libguile/foreign.c
parent602702772412ffcf2476afa0a41b4e290fb67f59 (diff)
downloadguile-939b1ae23f680365fb6fd0a78653a281aaed95b6.tar.gz
Rework foreign-call trampoline
* libguile/foreign.c (scm_i_foreign_call): Rename back from foreign_call. Need a new trampoline that's easier to call from JIT, until we actually rewrite the FFI in terms of the JIT. (scm_register_foreign): Remove foreign_call intrinsic init. * libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): Foreign-call intrinsic sets return directly on stack. * libguile/vm-engine.c (foreign-call): Adapt to new intrinsic behavior. * libguile/vm.c (foreign_call, scm_bootstrap_vm): Add new intrinsic wrapper.
Diffstat (limited to 'libguile/foreign.c')
-rw-r--r--libguile/foreign.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/libguile/foreign.c b/libguile/foreign.c
index 7a6f44eac..68fa5b256 100644
--- a/libguile/foreign.c
+++ b/libguile/foreign.c
@@ -1016,9 +1016,9 @@ pack (const ffi_type * type, const void *loc, int return_value_p)
#define MAX(A, B) ((A) >= (B) ? (A) : (B))
-static SCM
-foreign_call (SCM cif_scm, SCM pointer_scm, SCM *errno_ret,
- const union scm_vm_stack_element *argv)
+SCM
+scm_i_foreign_call (SCM cif_scm, SCM pointer_scm, int *errno_ret,
+ const union scm_vm_stack_element *argv)
{
/* FOREIGN is the pair that cif_to_procedure set as the 0th element of the
objtable. */
@@ -1070,7 +1070,7 @@ foreign_call (SCM cif_scm, SCM pointer_scm, SCM *errno_ret,
/* off we go! */
errno = 0;
ffi_call (cif, func, rvalue, args);
- *errno_ret = scm_from_int (errno);
+ *errno_ret = errno;
return pack (cif->rtype, rvalue, 1);
}
@@ -1305,6 +1305,5 @@ scm_register_foreign (void)
"scm_init_foreign",
(scm_t_extension_init_func)scm_init_foreign,
NULL);
- scm_vm_intrinsics.foreign_call = foreign_call;
pointer_weak_refs = scm_c_make_weak_table (0, SCM_WEAK_TABLE_KIND_KEY);
}