From owner-cvs-all Wed May 29 13:19:58 2002 Delivered-To: cvs-all@freebsd.org Received: from kayak.xcllnt.net (209-128-86-226.bayarea.net [209.128.86.226]) by hub.freebsd.org (Postfix) with ESMTP id 93C4A37B406; Wed, 29 May 2002 13:19:47 -0700 (PDT) Received: (from marcel@localhost) by kayak.xcllnt.net (8.11.6/8.11.4) id g4TKJRF65177; Wed, 29 May 2002 13:19:27 -0700 (PDT) (envelope-from marcel) Date: Wed, 29 May 2002 13:19:27 -0700 From: Marcel Moolenaar To: Tony Finch Cc: Poul-Henning Kamp , cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG Subject: Re: cvs commit: src/sys/sys gpt.h Message-ID: <20020529131927.C64995@kayak.xcllnt.net> References: <200205290258.g4T2wgF83137@freefall.freebsd.org> <9551.1022648961@critter.freebsd.dk> <20020529053653.GA306@dhcp01.pn.xcllnt.net> <20020529173621.B11817@chiark.greenend.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020529173621.B11817@chiark.greenend.org.uk> User-Agent: Mutt/1.3.22.1i Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, May 29, 2002 at 05:36:21PM +0100, Tony Finch wrote: > On Tue, May 28, 2002 at 10:36:53PM -0700, Marcel Moolenaar wrote: > > > > I see what you mean, but packing and unpacking is not the problem. It's > > sizeof() that's got it wrong. I don't quite understand why sizeof() > > would yield a size that's 4 bytes longer than the structure actually > > is. It smells like a gcc bug, but I assume for now I'm just missing > > something. > > It's required for correct alignment of the uint64_t members when you > create an array of the struct. I think it's a mistake to make the padding between elements in an array part of the type of element. An int32_t followed by an int64_t in a struct also doesn't cause the int32_t to have a 64-bit size to handle the alignment of the int64_t that follows it. It's now totally impossible to answer trivial questions like: what's the size of struct X { int64_t a; int32_t b; }; There's no value in an answer that starts of with "It depends...". The size should always be 12 bytes, independent of any alignment requirements I may attach to it. Size and alignment are independent properties. -- Marcel Moolenaar USPA: A-39004 marcel@xcllnt.net To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message