summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-05-21 18:50:10 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-05-21 18:50:10 -0700
commit663b75b357e77bfc47e31830b4e49cf1b026b141 (patch)
tree6a06226b56ac114e17a2d1a1bc0506e857d07cf8
parent128261df50be4d7f73ffe18b53388bc2e9cced65 (diff)
downloadtxr-663b75b357e77bfc47e31830b4e49cf1b026b141.tar.gz
txr-663b75b357e77bfc47e31830b4e49cf1b026b141.tar.bz2
txr-663b75b357e77bfc47e31830b4e49cf1b026b141.zip
ffi: fat bitfield bugfix for big endian.
* ffi.c (make_ffi_type_struct, make_ffi_type_union): We must take fat bitfields into account when calculating mtft->shift on big endian. We must subtract from bits_llint not bits_int for big endian.
-rw-r--r--ffi.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/ffi.c b/ffi.c
index c8b7c62d..a2bad2b3 100644
--- a/ffi.c
+++ b/ffi.c
@@ -3588,7 +3588,12 @@ static val make_ffi_type_struct(val syntax, val lisp_type,
#if HAVE_LITTLE_ENDIAN
mtft->shift = bit_offs;
#else
- mtft->shift = bits_int - bit_offs - bits;
+#if HAVE_I64
+ if (size > sizeof (int))
+ mtft->shift = bits_llint - bit_offs - bits;
+ else
+#endif
+ mtft->shift = bits_int - bit_offs - bits;
#endif
#if HAVE_I64
@@ -3748,7 +3753,12 @@ static val make_ffi_type_union(val syntax, val use_existing, val self)
#if HAVE_LITTLE_ENDIAN
mtft->shift = 0;
#else
- mtft->shift = bits_int - bits;
+#if HAVE_I64
+ if (size > sizeof (int))
+ mtft->shift = bits_llint - bits;
+ else
+#endif
+ mtft->shift = bits_int - bits;
#endif
#if HAVE_I64