Re: Alignment question, sparc-centric

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Jun 3 2007 12:14, Bernhard R. Link wrote:
>
>* David Miller <davem@xxxxxxxxxxxxx> [070602 22:09]:
>> Types must be aligned on their natural size, and GCC can assume
>> this everywhere you reference such types unless you use the
>> "packed" GCC attribute.
>
>And even with packed, the struct itself must be naturally aligned
>(unless itself is in a packed struct, if course).

It is not a struct actually. It is a bytestream that is reinterpreted
as an integer, that is, for example (it does not really need to be
skb_network_header),

unsigned char *p = skb_network_header(skb);
uint32_t value   = *(uint32_t *)(p[9]);

I suppose this won't work, so one would have to...

uint32_t value = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];



	Jan
-- 
-
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Development]     [DCCP]     [Linux ARM Development]     [Linux]     [Photo]     [Yosemite Help]     [Linux ARM Kernel]     [Linux SCSI]     [Linux x86_64]     [Linux Hams]

  Powered by Linux