This is the mail archive of the
mailing list for the GCC project.
Re: Byte swapping support
- From: David Brown <david at westcontrol dot com>
- To: Eric Botcazou <ebotcazou at adacore dot com>
- Cc: <gcc at gcc dot gnu dot org>, Jim Wilson <jim dot wilson at linaro dot org>, Jürg Billeter <juerg dot billeter at codethink dot co dot uk>
- Date: Thu, 14 Sep 2017 12:41:39 +0200
- Subject: Re: Byte swapping support
- Authentication-results: sourceware.org; auth=none
- References: <email@example.com> <6407936.qTSUNFDvMC@polaris> <59BA46F1.firstname.lastname@example.org> <1872145.DVXSkDLm6l@polaris>
On 14/09/17 11:30, Eric Botcazou wrote:
>> I seem to remember it being able to attach a big-endian or little-endian
>> label to any individual variable (rather than a type), which could be a
>> scaler rather than a struct. So it was a bit more flexible than gcc.
> Well, the only thing I see in the documentation for "Byte Ordering" is the
> reference to pragma Pack and the __packed__ keyword for structures, which can
> toggle byte ordering by means of the byte-swap argument:
> "#pragma pack
> [ ([[max_member_alignment] , [min_structure_alignment][, byte-swap ]] ) ]
> The pack directive specifies that all subsequent structures..."
> with the same limitation as GCC about taking the address:
> "It is not possible to take the address of a byte-swapped member."
It is, as I say, a /long/ time since I looked at it. I could easily be
remembering incorrectly - and it could also be a difference in the versions.
Being unable to take the address of a byte-swapped member is a
reasonable and understandable limitation when byte-swapping is expressed
this way. It would be one of the advantages in using a named address
space - then you /could/ take a pointer, but it would be a pointer
qualified by the address space name, and incompatible with normal pointers.