| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
| |
* buf.c, ffi.c: Must include <stdarg.h> for va_list.
|
|
|
|
|
|
|
| |
* configure: the dlvsym test relies on a nonexistent
make variable EXTRA_CFLAGS. The correct one is EXTRA_FLAGS.
The function name is misspelled in the test code and the
test message.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (stuct txr_ffi_closure): New member, abort_retval.
(ffi_closure_mark_op): Mark the new member.
(ffi_closure_dispatch_safe): Implement the abort_retval.
If it is not nil, use put to place the value into the
return buffer. There is a risk that this could also throw
an exception, which is no longer protected: programer's
problem.
(ffi_make_closure): New abort_ret_in argument, which is
defaulted and stored.
(ffi_init): Update registration of ffi-make-closure to
reflect new argument.
* ffi.h (ffi_make_closure): Declaration updated.
* share/txr/stdlib/ffi.tl (sys:deffi-cb-expander):
Add abort-retval parameter; insert into ffi-make-closure
call.
(deffi-cb): Take optional abort-retval expression;
pass it down to the expander function.
(deffi-cb-unsafe): Pass nil as abort-retval down to expander.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
| |
If the object being encoded is a string, and the array element
type is char, wchar or bchar, then encode a string, honoring
null termination flag. Unused space in the destination array
is filled with zeros.
* ffi.c (ffi_char_array_put, ffi_wchar_array_put,
ffi_bchar_array_put): New functions.
(ffi_array_put, ffi_array_out): Use new functions under
the right conditions.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (struct txr_ffi_type): is_varray flag removed.
We no longer need to test this and adjust behavior.
(ffi_array_in, ffi_array_out): Don't calculate nelem
differently based on flag; just pass down tft->nelem. Code
cleaned up.
(ffi_varray_put, ffi_varray_in): New functions.
(ffi_type_compile): Use ffi_varray_put and ffi_varray_in for
variable array type instead of setting flag. Also, specify the
out function as null; it never made sense to have one, since
there is no get. Finally, set the size of the type to zero,
since it has no pass by value semantics.
|
|
|
|
|
|
| |
* ffi.c (ffi_varray_alloc): We must use the element type's
size, not the array's size. Also, cosmetic issue in error
message fixed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This anticipates a redesign of variable arrays. Variable
arrays will have their own put, in, get and out functions,
which will share some implementation.
* ffi.c (ffi_array_in_common): New function.
(ffi_array_in): Bulk of code replaced by call to
ffi_array_in_common.
(ffi_array_put_common, ffi_array_out_common,
ffi_array_get_common): New functions.
(ffi_array_put, ffi_array_out, ffi_array_get): Reduced to thin
wrappers.
|
|
|
|
|
|
| |
* ffi.c (ffi_make_call_desc): Throw if any argument
type is something with zero size. Throw if the return
type has zero size and isn't the type void.
|
|
|
|
|
|
|
| |
* ffi.c (ffi_char_array_get, ffi_wchar_array_get,
ffi_bchar_array_get): New static functions.
(ffi_array_in, ffi_array_get): Replace common code
with calls to code moved out into functons.
|
|
|
|
|
|
|
|
|
| |
Arrays can be varray, whose size is just pointer size.
The string extraction operations shouldn't be referring
to the size.
* ffi.c (ffi_array_in, ffi_array_et): Use nelem instead
of tft->size.
|
|
|
|
|
|
|
|
|
|
|
|
| |
What this allows is for situations when a foreign function
returns the pointer that it has been passed. If that pointer
is temporary storage allocated by FFI, then it is no longer
valid after performing the in pass on the args. Therefore, we
should decode the return value first, while the returned
pointer is valid.
* ffi.c (ffi_call_wrap): Move the return value get before
the argument post-processing in pass.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We want to be able to extract null-terminated UTF-8 strings
from arrays, without trailing junk, yet retain the ability to
extract the entire array including embedded nulls. The natural
way is to use the array/zarray distinction.
* ffi.c (ffi_array_in, ffi_array_get): Don't try to guess
whether the array is null terminated; just rely on the
null_term flag, and treat accordingly.
* txr.1: Doc updated.
|
|
|
|
| |
* txr.1: The cptr type is now documented.
|
|
|
|
|
|
| |
* txr.1: Buffer literals are now described much
earlier in the document under Additional Syntax
rather than in the Buffers section.
|
|
|
|
| |
* txr.1: Update ASCII diagram in Object Types section.
|
|
|
|
|
| |
* txr.1: Documented dlopen, dlclose and friends,
plus the rtld-* variables.
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Register cptr-int, ctpr-obj, cptr-zap
and cptr-free functions and cptr-null variable.
* lib.c (cptr_int, cptr_obj, cptr_zap, cptr_free): New
functions.
* lib.c (cptr_int, cptr_obj, cptr_zap, cptr_free): Declared.
|
|
|
|
|
| |
* ffi.c (cptr_make): Function removed.
(ffi_init): Registration of cptr and cptr-null removed.
|
|
|
|
|
|
|
|
|
| |
* ffi.c (ffi_float_put, ffi_double_put): Support a useful
type looseness by allowing integers and character Lisp
values to pair with FFI floating-point types, imitating
the conversion which happens in C function calls.
* txr.1: Updated.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (ffi_i8_put, ffi_u8_put, ffi_i16_put, ffi_i16_get,
ffi_u16_put, ffi_u16_get, ffi_i32_put, ffi_i32_get,
ffi_u32_put, ffi_u32_get, ffi_i64_put, ffi_i64_get,
ffi_u64_put, ffi_u64_get, ffi_char_put, ffi_char_get,
ffi_uchar_get, ffi_short_get, ffi_ushort_put, ffi_ushort_get,
ffi_int_put, ffi_int_get, ffi_uint_put, ffi_uint_get,
ffi_long_put, ffi_long_get, ffi_ulong_put, ffi_ulong_get,
ffi_float_put, ffi_float_get, ffi_double_put, ffi_double_get,
ffi_wchar_put, ffi_wchar_get, ffi_cptr_put, ffi_cptr_get):
memcpy operations replaced by by assignments through pointer
casts.
|
|
|
|
|
|
| |
* ffi.c (ffi_closure_print_op): Add information to the
printed representation: the Lisp function, and call desc.
Eliminate spurious # character before closing angle bracket.
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (ffi_struct_put, ffi_struct_out): Just skip the space
corresponding to the anonymous padding member; don't memset
with zeros. Doing this is inconsistent because we are not
zero-filling the ordinary alignment padding between members
and at the end of the struct. If the uninitialized garbage
is a problem in some uses, we can provide a variation of
the struct type which is zero initialized.
|
| |
|
|
|
|
|
|
|
| |
* buf.c (buf_put_bytes): We must extend the buffer based
on looking at the end position of the data transfer,
not the start position, so the buffer is large enough to
old the entire transfer.
|
|
|
|
|
|
|
| |
* buf.c (buf_shrink): If a buffer has zero length,
don't shrink the allocation size all the way down to
zero, because that value indicates a non-resizeable
buffer.
|
|
|
|
|
|
|
| |
* ffi.c (ffi_array_put, ffi_array_out): If dealign with
a variable array that is null terminated, let's add one to
nelem, so that all elements of the Lisp sequence are
converted, and then a null.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Backing out of the scheme of (ptr buf) passing the
address of the internal pointer within buf objects.
Also giving buf in handlers, to prevent the fallback
on get.
* buf.c (buf_addr_of): Function removed.
* buf.h (buf_addr_of): Declaration removed.
* ffi.c (ffi_buf_in, ffi_buf_d_in): New functions.
(ffi_buf_alloc): Function removed.
(ffi_type_compile, ffi_init_types): Remove specialty alloc and
free functions from buffers, so the regular fixed allocator is
used. Give buffers the new in functions.
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (ffi_ptr_in_in): Don't just free the buffer for
the pointer itself, but call the in handler of the target
type if it has one. Pass a false copy flag to it, so that
that a ptr-in pass semantically resembles a by-value pass.
(ffi_ptr_in_d_in): New static function.
(ffi_type_compile): Give ptr-in-d type the ffi_ptr_in_d_in
function.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (ffi_ptr_out_in, ffi_ptr_out_s_in): If the target type
has no in handler, fall back on its get. Here, it is without
regard for the copy flag, because a zero value of that flag
just indicates that the ptr-out itself is passed by-value.
The target object is never by value
(ffi_in): Add copy flag parameter, so the full interface
is exposed, like in ffi_out. Fall back on get, if there is
no in and the copy flag is true. Just return the original
object if the type has no in, and copy is false.
(ffi_init): Registration of ffi-in adjusted to four
parameters.
* ffi.h (ffi_in): Declaration updated.
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (ffi_struct_in, ffi_array_in): Only fall back on get
if the copy flag is true. If the copy flag is false, we must
not extract. That's not ony as an optimization (no point in
extracting back from by-value objects). We also avoid
extracting from pointers we don't own, like in the case
of str-d, where the pointer is owned by the foreign function
and may have been freed.
|
|
|
|
|
|
|
| |
* ffi.c (ffi_struct_out, ffi_array_out): For any element
which has no out function, do a put if the copy flag is
true. Otherwise callbacks cannot update members in
aggregates passed by pointer.
|
|
|
|
|
|
| |
* ffi.c (ffi_bstr_in): New function.
(ffi_init_types): Give bstr type ffi_bstr_in as the in
function.
|
|
|
|
|
|
|
|
|
| |
* ffi.c (ffi_closure_dispatch): Only call out on those
arguments which have a non-null out pointer, otherwise we will
crash. Those non-null values are the reason we even execute
that loop at all.
(ffi_out): Do a put for basic types (which have no out
handler).
|
|
|
|
|
|
|
|
|
|
| |
Omission of the dimension will be expressed by actual omission
rather than the void placeholder. It's just a harmless bit of
parsing providing a reasonably intuitive syntax that doesn't
leave readers wondering what void is doing there.
* ffi.c (ffi_type_compile): Rearrange array parsing code.
Also diagnose if the form has more than thre elements.
|
|
|
|
|
|
|
|
| |
* lisplib.c (ffi_set_entries, ffi_instantiate): New static
functions.
(lisplib_init): Register auto-loading of ffi.tl.
* share/txr/stdlib/ffi.tl: New file.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This solves the second issue described in parent
commit. When a str type is passed in-out using
(ptr str) in a struct or array, the struct or array
is not picking up the new string. The pointer is
freed, but the old object persists.
* ffi.c (ffi_str_in): Function renamed to ffi_str_in. If the
copy flag is true, retrieves a string from the pointer and
that string is returned instead of the incoming one, mapping a
null pointer to nil. Either way, the pointer is freed. Since
ffi_ptr_out_in passes 1 for the copy flag, that ensures we
extract the new string and plant it into the array.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We have two problems. Firstly, the in handler is being
called on by-value struct and array arguments, and is
wastefully updating the members in the Lisp object.
The second issue is opposite the str type fails to retrieve
the updated string because ffi_freeing_in just frees.
We don't address this issue here, but the groundwork
is laid to fix it in the next commit.
* ffi.c (struct txr_ffi_type *): Add a copy flag argument
to the in virtual function.
(ffi_freeing_in, ffi_ptr_in_in, ffi_ptr_out_in,
(ffi_ptr_out_in, ffi_ptr_out_s_in): Take new copy argument.
Don't pass it down to the recursive in; pass 1.
(ffi_struct_in, ffi_array_in): Take copy argument and pass it
down.
(make_ffi_type_pointer): Type of in parameter updated.
(ffi_call_wrap): Pass 0 to top level in functions.
(ffi_in): Pass to in, so new object is returned.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If an array dimension is void, it is a varray. The C
representation is pointer. The size is inferred
from the length of the object. Doesn't support get
method.
* ffi.c (struct txr_ffi_type): New bitfield flag, is_varray.
(ffi_varray_alloc): New function.
(ffi_array_in, ffi_array_put, ffi_array_out): Check is_varray
flag and use dynamic array size from object.
(ffi_type_compile): If the array dimension is the symbol
void, create a varray: a mongrel created using
make_ffi_type_pointer, but using the array functions,
plus alloc and free handlers, and the is_varray flag
being set.
|
|
|
|
|
|
|
|
| |
* ffi.c (make_ffi_type_pointer): The underlying ffi type
is always ffi_type_pointer, so the parameter for specifying
it is removed, and it is hard-coded.
(ffi_type_compile): Remove &ffi_type_pointer argument from
a half dozen calls.
|
|
|
|
|
|
|
|
|
| |
This will support a sizeof macro.
* ffi.c (ffi_size): New function.
(ffi_init): Register ffi-size intrinsic.
* ffi.h (ffi_size): Declared.
|
|
|
|
|
|
| |
* lib.c (obj_print_impl): Remove spurious output statement
from quasi word list literal printing code. The spurious
output completely ruins the printed representation.
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (ffi_put_into, ffi_put, ffi_in, ffi_get, ffi_out):
New functions.
(ffi_init): ffi-put-into, ffi-put, ffi-in, ffi-get, ffi-out:
intrinsics registered.
* ffi.h (ffi_put_into, ffi_put, ffi_in, ffi_get, ffi_out):
Declared.
|
|
|
|
|
| |
* itypes.c (c_u8, c_u16, c_u32, c_u64, c_uint): Fix messages
referring to signed version of type.
|
|
|
|
| |
* lib.c (length): Handle BUF case via length_buf.
|
|
|
|
|
| |
* arith.c (comp_trunc, logtrunc): Check for a negative
bits value and throw.
|
|
|
|
|
| |
* lib.c (mkstring, mkustring, vector, vec_set_length): Reject
negative length.
|
|
|
|
|
| |
* ffi.c (ffi_type_compile): Check for a negative buffer
size and throw.
|
|
|
|
|
|
| |
* ffi.c (ffi_type_compile): Throw error if the dimension
is negative in any array operator, or also if it is zero in a
zarray operator.
|