Host endian independence
Joseph Myers
joseph@codesourcery.com
Fri Aug 30 16:22:00 GMT 2019
On Fri, 30 Aug 2019, Florian Weimer wrote:
> The problem with the existing interfaces is that that they make it hard
> to take alignment issues into account. See bug 20243. When used for
> parsing packet buffers, they also tend to introduce aliasing violations.
That seems like a matter of declaring your structure appropriately (with
the right alignment if e.g. it's being allocated on the stack, or with the
packed attribute if it might genuinely be at arbitrary alignments; with
the may_alias attribute if it's necessary for it to alias something with a
different effective type).
The scalar_storage_order attribute could certainly be added to an
appropriately declared structure to move the endianness information
entirely into how the structure is defined and out of the code using the
structure.
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Libc-alpha
mailing list