| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (float_s): Variable removed. This is a duplicate
definition; we already have this symbol in lib.c.
(ffi_type_s): Duplicate definition removed; it is
repeated two lines below.
(ffi_str_put): Remove pointless const qualifier on u8s
variable.
(ffi_call_wrap): Cast return value of alloca. Also,
rc pointer needs to be cast to mem_t *.
(ffi_init): Remove initialization of float_s.
* ffi.h (float_s): Declaration removed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fix incorrect memory allocation in (ptr-in buf)
and (ptr-in-out buf) passing.
Buffer arguments passed to a function as
(ptr-in buf) or (ptr-in-out buf) now pass the buffer
directly without allocating another copy, as in the
case of arrays or structs.
* ffi.c (struct txr_ffi_type): New members alloc, free.
The pointer types use these functions, together with fill,
for the management of the buffering of their target type.
(ffi_fixed_alloc, ffi_noop_free, ffi_buf_alloc,
ffi_ptr_in_in): New static functions.
(ffi_ptr_in_put): Use target type's alloc function,
rather than chk_malloc. A struct or array will actually
allocate the buffer needed for their C version. A buffer
will not; it will just return its internal pointer,
just like what the wstr type does with strings.
This function now sets up ffi_ptr_in_in as the in handler
for this pointer type, rather than ffi_freeing_in,
because the freeing has to go through the target type
interface, and not directly to free. Buffers use the
no-op free function.
(ffi_ptr_out_in): Use the target type's free function
rathr than free.
(ffi_ptr_out_put, ffi_ptr_in_out_put): Use the target type's
allocator instead of chk_malloc.
(make_ffi_type_pointer, make_ffi_type_struct,
make_ffi_type_array): Initialize the alloc and free function
pointer members of the txr_ffi_type struct.
(ffi_type_compile): Set up alloc and free for buffers.
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (array_s): New symbol variable.
(ffi_array_put, ffi_array_get, ffi_array_fill,
make_ffi_type_array): New static functions.
(ffi_type_compile): Support (array <dim> <type>)
syntax.
(ffi_init): Initialize array_s.
* ffi.h (array_s): Declared.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* ffi.c (ffi_type_struct_destroy_op): Fix silly code.
The size field most certainly doesn't indicate the number
of elements, but rather the byte size. The array is
documented by libffi as null-pointer terminated, so let's take
advantage of that.
(make_ffi_type_struct): Speaking of the array being
null-terminated, it is we who are required to ensure this
representation and we are not. Let's fix it.
Also, we are here wrongly storing the number of elements
into the struct type's size field, which is the basis for
misusing that in the destroy op. The documentation says
that the size field should be initialized to zero.
|
|
|
|
|
|
| |
ffi.c (ffi_str_put, ffi_str_get, ffi_wstr_put, ffi_wstr_get):
Use assignment instead of memcpy to move the string pointer to
and from the buffer.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* buf.c (make_duplicate_buf, buf_get, buf_fill): New
functions.
* buf.h (make_duplicate_buf, buf_get, buf_fill): Declared.
* ffi.c (struct txr_ffi_type): New member, nelem.
Keeps track of number of elements, for types that are
FFI pointers. This lets us support the get method so that
a buf can be a C function return value, if its size is
declared in our FFI type system.
(ffi_buf_put, ffi_buf_get, ffi_buf_fill): New functions.
(ffi_type_compile): Handle two new cases of syntax for
buffers: (buf <size>) and buf.
|
|
* Makefile (OBJS): Add ffi.o.
* configure (have_libffi): New variable.
(gen_config_make): Generate have_libffi make variable.
New check for availability of libffi.
* ffi.c, ffi.h: New files.
* lib.c (init): Call ffi_init.
|