diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-05-24 21:20:07 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-05-24 21:20:07 -0700 |
commit | 7a6e0e4cc882833578bdfb09fc48ceb7b090f719 (patch) | |
tree | 5d5b017236b67ad0cc1b941657ed1bbb2a9766a0 /ffi.c | |
parent | a18c7822a44770e476a3cbb1b5979d368c596b37 (diff) | |
download | txr-7a6e0e4cc882833578bdfb09fc48ceb7b090f719.tar.gz txr-7a6e0e4cc882833578bdfb09fc48ceb7b090f719.tar.bz2 txr-7a6e0e4cc882833578bdfb09fc48ceb7b090f719.zip |
ffi: buffix: alignment still wrong for ptr types.
For pointers, the code still reflects the wrong assumption
that the size and alignment are the same.
* ffi.c (make_ffi_type_pointer): Remove the size argument;
it's always passed as sizeof (mem_t *), which is pointless.
Just initialize the size and align members in a fixed way.
Use sizeof and alignof to do this right.
(ffi_type_compile): Remove size argument from all
make_ffi_type_pointer calls.
Diffstat (limited to 'ffi.c')
-rw-r--r-- | ffi.c | 13 |
1 files changed, 4 insertions, 9 deletions
@@ -1472,7 +1472,7 @@ static val make_ffi_type_builtin(val syntax, val lisp_type, return obj; } -static val make_ffi_type_pointer(val syntax, val lisp_type, cnum size, +static val make_ffi_type_pointer(val syntax, val lisp_type, void (*put)(struct txr_ffi_type *, val obj, mem_t *dst, val self), val (*get)(struct txr_ffi_type *, @@ -1493,7 +1493,8 @@ static val make_ffi_type_pointer(val syntax, val lisp_type, cnum size, tft->ft = &ffi_type_pointer; tft->syntax = syntax; tft->lt = lisp_type; - tft->size = tft->align = size; + tft->size = sizeof (mem_t *); + tft->align = alignof (mem_t *); tft->put = put; tft->get = get; tft->eltype = tgtype; @@ -1663,7 +1664,7 @@ val ffi_type_compile(val syntax) if (length(syntax) == two) { val eltype_syntax = cadr(syntax); val eltype = ffi_type_compile(eltype_syntax); - val type = make_ffi_type_pointer(syntax, vec_s, sizeof (mem_t *), + val type = make_ffi_type_pointer(syntax, vec_s, ffi_varray_put, ffi_void_get, ffi_varray_in, 0, ffi_varray_release, eltype); @@ -1723,42 +1724,36 @@ val ffi_type_compile(val syntax) } else if (sym == ptr_in_s) { val target_type = ffi_type_compile(cadr(syntax)); return make_ffi_type_pointer(syntax, ffi_get_lisp_type(target_type), - sizeof (mem_t *), ffi_ptr_in_put, ffi_ptr_get, ffi_ptr_in_in, ffi_ptr_in_out, ffi_ptr_in_release, target_type); } else if (sym == ptr_in_d_s) { val target_type = ffi_type_compile(cadr(syntax)); return make_ffi_type_pointer(syntax, ffi_get_lisp_type(target_type), - sizeof (mem_t *), ffi_ptr_in_put, ffi_ptr_d_get, ffi_ptr_in_d_in, ffi_ptr_in_out, ffi_ptr_in_release, target_type); } else if (sym == ptr_out_s) { val target_type = ffi_type_compile(cadr(syntax)); return make_ffi_type_pointer(syntax, ffi_get_lisp_type(target_type), - sizeof (mem_t *), ffi_ptr_out_put, ffi_ptr_get, ffi_ptr_out_in, ffi_ptr_out_out, ffi_simple_release, target_type); } else if (sym == ptr_out_d_s) { val target_type = ffi_type_compile(cadr(syntax)); return make_ffi_type_pointer(syntax, ffi_get_lisp_type(target_type), - sizeof (mem_t *), ffi_ptr_out_null_put, ffi_ptr_d_get, ffi_ptr_out_in, ffi_ptr_out_out, 0, target_type); } else if (sym == ptr_s) { val target_type = ffi_type_compile(cadr(syntax)); return make_ffi_type_pointer(syntax, ffi_get_lisp_type(target_type), - sizeof (mem_t *), ffi_ptr_in_put, ffi_ptr_get, ffi_ptr_out_in, ffi_ptr_out_out, ffi_ptr_in_release, target_type); } else if (sym == ptr_out_s_s) { val target_type = ffi_type_compile(cadr(syntax)); return make_ffi_type_pointer(syntax, ffi_get_lisp_type(target_type), - sizeof (mem_t *), ffi_ptr_out_null_put, ffi_ptr_get, ffi_ptr_out_s_in, ffi_ptr_out_out, 0, target_type); |