This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Host endian independence


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]