[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <457C913A.20600@s5r6.in-berlin.de>
Date: Sun, 10 Dec 2006 23:59:06 +0100
From: Stefan Richter <stefanr@...6.in-berlin.de>
To: Kristian Høgsberg <krh@...hat.com>
CC: Jeff Garzik <jeff@...zik.org>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/3] Import fw-ohci driver.
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 majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists