[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <88B766C272F2C64B944B21AD078333151C964A68E3@EXMAIL.ad.emulex.com>
Date: Fri, 23 Mar 2012 12:16:52 -0700
From: <Parav.Pandit@...lex.Com>
To: <jgunthorpe@...idianresearch.com>
CC: <David.Laight@...LAB.COM>, <roland@...estorage.com>,
<linux-rdma@...r.kernel.org>, <netdev@...r.kernel.org>
Subject: RE: [PATCH 2/9] ocrdma: Driver for Emulex OneConnect RDMA adapter
Got it. You did mention about typedef in email chain, but I understood as different way to achieve same.
I reviewed my code and found that most of the fields between driver-adapter doesn't need attribute.
So far (a) removing packed and (b) BUILD_BUG_ON looks sufficient for current set of structures. Initial test suffice the need.
Thanks.
Parav
> -----Original Message-----
> From: Jason Gunthorpe [mailto:jgunthorpe@...idianresearch.com]
> Sent: Friday, March 23, 2012 10:24 PM
> To: Pandit, Parav
> Cc: David.Laight@...LAB.COM; roland@...estorage.com; linux-
> rdma@...r.kernel.org; netdev@...r.kernel.org
> Subject: Re: [PATCH 2/9] ocrdma: Driver for Emulex OneConnect RDMA
> adapter
>
> On Fri, Mar 23, 2012 at 07:03:37AM -0700, Parav.Pandit@...lex.Com wrote:
>
> > > David is saying you will get a 12 byte struct and fieldb will be
> > > unaligned. Since
> > > 12 is aligned to 4 no padding is added.
> >
> > So I decided to experiment above example before implementing in
> > driver. However I find structure of 16 bytes (instead of 12) with
> > padding after fielda in below example. Am I missing some compiler
> > option or syntax error in attribute? Sorry to ask this silly question.
> > I tried __attribute__((__aligned__(4))); too based on usage in other
> > kernel code.
>
> I got the syntax wrong for that specific case (it is a little unintuitive.. IMHO,
> capping the alignment of a container should cap the alignment of all
> members, otherwise it is nonsense!):
>
> typedef uint64_t u64_unaligned_8 __attribute__((__aligned__(4)));
>
> struct foo {
> uint32_t fielda;
> u64_unaligned_8 fieldb;
> };
>
> struct foo2 {
> uint32_t fielda;
> uint64_t fieldb;
> };
>
> int main(int argc,const char *argv[])
> {
> printf("sizeof(foo) = %zu, fieldb = %zu\n",sizeof(struct foo),
> offsetof(struct foo,fieldb));
> printf("sizeof(foo2) = %zu, fieldb = %zu\n",sizeof(struct foo2),
> offsetof(struct foo2,fieldb));
> return 0;
> }
>
> sizeof(foo) = 12, fieldb = 4
> sizeof(foo2) = 16, fieldb = 8
>
> gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)
>
> Jason
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists