From owner-freebsd-current Mon Jul 15 5:56:56 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A8DAB37B400 for ; Mon, 15 Jul 2002 05:56:53 -0700 (PDT) Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by mx1.FreeBSD.org (Postfix) with SMTP id E097343E42 for ; Mon, 15 Jul 2002 05:56:51 -0700 (PDT) (envelope-from tmoestl@gmx.net) Received: (qmail 18937 invoked by uid 0); 15 Jul 2002 12:56:50 -0000 Received: from p5086fd16.dip.t-dialin.net (HELO forge.local) (80.134.253.22) by mail.gmx.net (mp006-rz3) with SMTP; 15 Jul 2002 12:56:50 -0000 Received: from tmm by forge.local with local (Exim 3.36 #1) id 17U5Pz-0000j5-00; Mon, 15 Jul 2002 14:57:35 +0200 Date: Mon, 15 Jul 2002 14:57:35 +0200 From: Thomas Moestl To: Terry Lambert Cc: Luigi Rizzo , Mike Barcroft , current@FreeBSD.org Subject: Re: different packing of structs in kernel vs. userland ? Message-ID: <20020715125735.GC314@crow.dom2ip.de> Mail-Followup-To: Terry Lambert , Luigi Rizzo , Mike Barcroft , current@FreeBSD.org References: <20020714011810.A72236@iguana.icir.org> <20020714203642.GD314@crow.dom2ip.de> <20020714230821.C64412@espresso.q9media.com> <20020715105158.GA314@crow.dom2ip.de> <20020715040008.A85276@iguana.icir.org> <3D32B0F1.27EA45EE@mindspring.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3D32B0F1.27EA45EE@mindspring.com> User-Agent: Mutt/1.4i Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Mon, 2002/07/15 at 04:24:33 -0700, Terry Lambert wrote: > Luigi Rizzo wrote: > > sorry but all this just does not make sense to me. > > > > sizeof(foo) should give the same result irrespective of > > where you use it. > > > > Perhaps the best thing would be to put a > > > > printf("struct ip_fw has size %d\n", sizeof(struct ip_fw)); > > > > both in ipfw2.c and somewhere in ip_fw2.c and see if there is > > a mismatch between the two numbers. > > I have to assume that what didn't make sense was that his patch > worked? 8-). > > He's making the valid point that for: > > struct foo *fee; > > It's possible that: > > sizeof(struct foo) != (((char *)&fee[1]) - ((char *)&fee[0])) No, I do not. In fact, the opposite: sizeof(struct foo) = (((char *)&fee[1]) - ((char *)&fee[0])) _must_ always be true, since it is legal to compute the size of storage needed for an n-element array of struct foo by using (sizeof(struct foo) * n). My point was that, because of the above, any padding that might be required between the first and last member of two struct foo's immediately following each other must be _included_ in struct foo, after the last element. - thomas -- Thomas Moestl http://www.tu-bs.de/~y0015675/ http://people.FreeBSD.org/~tmm/ PGP fingerprint: 1C97 A604 2BD0 E492 51D0 9C0F 1FE6 4F1D 419C 776C To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message