This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Host endian independence
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: Damien Zammit <damien at zamaudio dot com>, libc-alpha <libc-alpha at sourceware dot org>
- Date: Fri, 30 Aug 2019 16:22:46 +0000
- Subject: Re: Host endian independence
- Ironport-sdr: K1xl68rX9fWAKXE7KNP/53vwsXMU3CpcJXlbtGHeBV1tE+5Uf0q6wTFTmvg+q3R7rbrW6R61ci Mw0pq9Yg78/4pnOTXhCUHsY4GmuztcF18gv3vXsRQl1I1/AoBfmAGNwnefufnVC9ToVyQ85+QO y0b4obh/mqaLzMhxLXrZZigjvTCm8FBj/OU+I44njHS8mq0NGB20xzbCTJQGF0Qz8LakTTyCyc FFFTch5eZuLAaPzcWfNJ6kwLaikxplIW8KpiK1yjrVdiL+3n+zypNQDJN5xvSuI6LuiHVvavFE WEg=
- Ironport-sdr: Up8tsU/MOGZGJh53d7XRHqIQeKc0u5CKnp3w36ORonkS1kodJkLDRIxfcO7V+o3AqZq3sJ/8fD yNUbNT19D3yOVzjij7ei58wu97yvY6+leUy/KWPcVmUq0OmvK4V6jxEcYzZ7H6GzezBKKFYoP5 iv/JKRSoA4UoIfMeo/h/HvdWNwFwT/00ycavV54uspoCYoLUF6gMyRtOgQEydMb2rHdw19wHRo ptdZfEviFwGH3PGuHqZMr+8u1i/WRr++yjBDbxlsMISBL1X0Wkcc/GlnBm8wW82G41NG1m04lb h8g=
- References: <18c8a820-b2c4-8ab2-58d1-8d8c851dbf01@zamaudio.com> <alpine.DEB.2.21.1908271544290.18629@digraph.polyomino.org.uk> <878srb6jmh.fsf@oldenburg2.str.redhat.com>
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