summaryrefslogtreecommitdiffstats
path: root/ffi.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-05-19 18:21:07 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-05-19 18:21:07 -0700
commit79a67942651b7b1f15838fda053d72d17b3f2884 (patch)
treef1d52cae5c304aae37997172a6f5b2206e99250f /ffi.c
parent446853ed69188bb6d3080eb852d07b240ddd0db2 (diff)
downloadtxr-79a67942651b7b1f15838fda053d72d17b3f2884.tar.gz
txr-79a67942651b7b1f15838fda053d72d17b3f2884.tar.bz2
txr-79a67942651b7b1f15838fda053d72d17b3f2884.zip
ffi: bugfix: empty structs/unions have alignment of 1.
* ffi.c (make_ffi_type_struct, make_ffi_type_union): Initialize most_align local variable to 1, so the lower bound of alignment is that, rather than zero. * tests/017/ffi-misc.tl: Tests added.
Diffstat (limited to 'ffi.c')
-rw-r--r--ffi.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/ffi.c b/ffi.c
index 1e60e95b..79d59a8b 100644
--- a/ffi.c
+++ b/ffi.c
@@ -3461,7 +3461,7 @@ static val make_ffi_type_struct(val syntax, val lisp_type,
tft->self,
cobj(coerce(mem_t *, tft), ffi_type_cls, &ffi_type_struct_ops));
ucnum offs = 0;
- ucnum most_align = 0;
+ ucnum most_align = 1;
int need_out_handler = 0;
int bit_offs = 0;
const unsigned bits_int = 8 * sizeof(int);
@@ -3642,7 +3642,7 @@ static val make_ffi_type_union(val syntax, val use_existing, val self)
val obj = if3(use_existing,
tft->self,
cobj(coerce(mem_t *, tft), ffi_type_cls, &ffi_type_struct_ops));
- ucnum most_align = 0;
+ ucnum most_align = 1;
ucnum biggest_size = 0;
const unsigned bits_int = 8 * sizeof(int);
#if HAVE_I64