diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-05-11 19:53:29 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-05-11 19:53:29 -0700 |
commit | 1b615a6667660b353c7719d805a0a40cdd948789 (patch) | |
tree | 90e6442aca2974f37c15925015363b253c881a1a /ffi.h | |
parent | f226f44490a31e88017b2c3e2032d6926ef1c336 (diff) | |
download | txr-1b615a6667660b353c7719d805a0a40cdd948789.tar.gz txr-1b615a6667660b353c7719d805a0a40cdd948789.tar.bz2 txr-1b615a6667660b353c7719d805a0a40cdd948789.zip |
ffi: a measure of safety for callbacks.
We don't want, by default, for callbacks to capture delimited
continuations across foreign code, or perpetrate non-local
transfers across foreign code. Here, we take an approach
similar for what was done in ftw_wrap.
* ffi.c (s_exit_point): New global variable with internal
linkage.
(ffi_call_wrap): If s_exit_point isn't nil, then it means that
the callback intercepted a nonlocal transfer and stored its
exit point. We resume the transfer to that exit point instead
of returning normally.
(ffi_closure_dispatch_safe): New static function.
(ffi_make_closure): Support a new argument which indicates
whether to make a closure which uses
ffi_closure_dispatch_safe, or ffi_closure_dispatch.
(ffi_init): Update registration of ffi-make-closure intrinsic.
* ffi.h (ffi_make_closure): Declaration updated.
* share/txr/stdlib/ffi.tl (sys:deffi-cb-expander): New
function.
(deffi-cb): Macro internals replaced by call to new
function.
(deffi-cb-safe): New macro.
* txr.1: Documentation of ffi-make-closure updated.
New deffi-cb-unsafe macro documented.
Diffstat (limited to 'ffi.h')
-rw-r--r-- | ffi.h | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -53,7 +53,7 @@ extern val ffi_type_s, ffi_call_desc_s, ffi_closure_s; val ffi_type_compile(val syntax); val ffi_make_call_desc(val ntotal, val nfixed, val rettype, val argtypes); -val ffi_make_closure(val fun, val call_desc); +val ffi_make_closure(val fun, val call_desc, val safe_p_in); mem_t *ffi_closure_get_fptr(val closure); val ffi_call_wrap(val ffi_call_desc, val fptr, val args); val ffi_typedef(val name, val type); |