From 446853ed69188bb6d3080eb852d07b240ddd0db2 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 19 May 2022 18:13:13 -0700 Subject: ffi: bugfix in fat bitfields. * ffi.c (make_ffi_type_struct, make_ffi_type_union): Do not fall back from the fat (64 bit) bitfield case to the regular (32 bit) case when the number of bits is less than 32. This is completely wrong. --- ffi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ffi.c b/ffi.c index fcfea96e..1e60e95b 100644 --- a/ffi.c +++ b/ffi.c @@ -3561,7 +3561,7 @@ static val make_ffi_type_struct(val syntax, val lisp_type, if (size > sizeof (int)) { if (bits == bits_llint) mtft->m.fmask = convert(u64_t, -1); - else if (bits > bits_int) + else mtft->m.fmask = ((convert(u64_t, 1) << bits) - 1) << mtft->shift; } else #endif @@ -3722,7 +3722,7 @@ static val make_ffi_type_union(val syntax, val use_existing, val self) if (mtft->size > (int) sizeof (int)) { if (bits == bits_llint) mtft->m.fmask = convert(u64_t, -1); - else if (bits > bits_int) + else mtft->m.fmask = ((convert(u64_t, 1) << bits) - 1) << mtft->shift; } else #endif -- cgit v1.2.3