Kristian Høgsberg wrote:
> Stefan Richter wrote:
>> Kristian Høgsberg wrote:
>>> Yup, I've done away with the bitfields and switched to a mix of __le16
>>> and __le32 struct fields.
>>
>> I suppose the struct should get __attribute__((packed)) then.
>
> I guess it wouldn't harm, but is it really necessary? Would gcc ever
> insert padding here, all the 32 bit fields a 32 bit aligned, and so are
> the 16 bit fields.
Is 2-byte alignment of 16bit struct members guaranteed on all platforms?
A related question:
If I specify a struct which, among else, contains 32bit quantities, then
any variable of this struct type is supposed to be at least 4-byte-aligned.
No if I specifiy this struct as packed, will variables of this type still
be aligned on 4 byte boundaries or will the compiler assume no alignment?
In other words, should it be __attribute__((packed,aligned(4))) then?
I'm speaking about situations where I not only wish to avoid unnecessarily
bad machine code due to unaligned access but where the device requires
4-byte alignment too.
--
Stefan Richter
-=====-=-==- ==-- -=-=-
http://arcgraph.de/sr/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]