summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-10-17 18:55:43 -0700
committerKaz Kylheku <kaz@kylheku.com>2019-10-17 18:55:43 -0700
commit45fa8653f7a3ece2eb0c3e92057fdfa9bc5b3780 (patch)
tree0e5b995fb749830dafeadd4da1c7fde7cc7ef860
parent2a0033ebad7883109bc2a2053986aeaed7be9525 (diff)
downloadtxr-45fa8653f7a3ece2eb0c3e92057fdfa9bc5b3780.tar.gz
txr-45fa8653f7a3ece2eb0c3e92057fdfa9bc5b3780.tar.bz2
txr-45fa8653f7a3ece2eb0c3e92057fdfa9bc5b3780.zip
doc: bitfield allocation rules: endiannness.
* txr.1: Add discussion about endinanness to Bitfield Allocation Rules for completeness.
-rw-r--r--txr.131
1 files changed, 27 insertions, 4 deletions
diff --git a/txr.1 b/txr.1
index 126fd8c9..0bc8eb93 100644
--- a/txr.1
+++ b/txr.1
@@ -64883,10 +64883,33 @@ has a nonzero value, then the offset
.I O
is incremented by one to cover that byte.
-Lastly, the size of the structure is then padded up to a size
-which is a multiple of the alignment of the most strictly aligned
-member.
-
+As the last allocation step, the size of the structure is then padded up to a
+size which is a multiple of the alignment of the most strictly aligned member.
+
+The description isn't complete without a treatment of byte and bit order.
+Bitfield allocation follows an imaginary "bit endianness" whose direction
+follows the machine's byte order: most significant bits are allocated first on
+big endian, least significant bits first on little-endian.
+
+If a one-bit-wide bitfield is allocated into a hitherto empty structure, it
+will be placed into the first byte of that structure, regardless of the
+machine's endianness, and regardless of the underlying storage unit size for
+that bitfield. Within that first byte, it will be placed into the most
+significant bit position on a big-endian machine (bit 7); and on a
+little-endian machine, it will be placed into the least significant bit
+position (bit 0). If another one-bit-wide is allocated, it is placed into
+bit 6 on big-endian, and bit 1 on little-endian.
+
+More generally, whenever a bitfield is allocated for a big-endian machine, and
+the storage unit is determined into which that bitfield shall be placed, that
+field will be placed at that unit's most significant bit position that is still
+available for allocation. On a little-endian machine, that field will be placed
+at the least significant available bit position of the storage unit. On either
+type of machine, that field will be placed at the lowest-addressed byte or
+bytes that are available, and within that byte or those bytes, the field
+will occupy the most significant bit positions that are available. If the
+field partially occupies a byte, the bits that remain free are the least
+significant ones.
.SS* FFI Call Descriptors