summaryrefslogtreecommitdiffstats
path: root/genprotsym.txr
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-05-23 11:50:47 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-05-23 11:50:47 -0700
commit4666a2fa59648e02b057038aa68fa99958f34ecf (patch)
tree18da340538e98357a3fa4dbf4abde438f274e3c4 /genprotsym.txr
parent16eb3d22a29911981371b98e83008f8741903cc8 (diff)
downloadtxr-4666a2fa59648e02b057038aa68fa99958f34ecf.tar.gz
txr-4666a2fa59648e02b057038aa68fa99958f34ecf.tar.bz2
txr-4666a2fa59648e02b057038aa68fa99958f34ecf.zip
ffi: bitfield tests and fixes.
The bitfield allocation rules are wrong. Some of it is due to the recent changes which are based on incorrect analysis, but reverting things doesn't fix it. The idea that we compare the current member's alignment with the previous is wrong; it is not borne out by empirical tests with gcc. So we do a straight revert of that. In GNU C, an __attribute__((aligned (N))) attribute applied to a bitfield member will perform the requested alignment if, evidently, the bit field is already being placed into a new byte. (If the bit field is about to be packed into an existing byte, then there is a warning about the align attribute being ignored). Because we don't have alignment as a member attribute, but only as a type attribute, we must implement a flag which indicates that a type has had align applied to it (even if the alignment didn't change) so we can then honor this in the right place in the bitfield allocation code. * ffi.c (struct txr_ffi_type): New attribute flag, aligned. (make_ffi_type_struct): Remove the prev_align variable and all related logic. Consolidate all alignment into one place, which is done before we allocate the bitfield or regular member. We align if the new member isn't a bitfield, or even if it is a bitfield if it has the aligned attribute, or if the bitfield is changing endian compared to the previous member (our local rule, not from GNU C). (ffi_type_compile): The align and pack operators now set the aligned attribute, except in the (pack 1 ...) case which semantically denotes lack of alignment. * tests/017/bitfields.tl: New file. * txr.1: Documented.
Diffstat (limited to 'genprotsym.txr')
0 files changed, 0 insertions, 0 deletions