Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Jan 2005 19:46:06 -0800 (PST)
From:      Doug White <dwhite@gumbysoft.com>
To:        Scott Long <scottl@freebsd.org>
Cc:        Pawel Jakub Dawidek <pjd@freebsd.org>
Subject:   Re: BigDisk project: du(1) 64bit clean.
Message-ID:  <20050104194302.O21516@carver.gumbysoft.com>
In-Reply-To: <41DB5AAB.9080705@freebsd.org>
References:  <20050104224043.GM784@darkness.comp.waw.pl> <20050104183627.O20855@carver.gumbysoft.com> <41DB5AAB.9080705@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 4 Jan 2005, Scott Long wrote:

> > dwlab3,ttyp1,~,24>uname -m
> > i386
> > dwlab3,ttyp1,~,25>./test
> > sizeof(long) [4] + sizeof(void *) [4] == 8 == sizeof(int64_t) [8]
> >
> > ok .. but:
> >
> > dwlab4,ttyp1,~,20>uname -m
> > amd64
> > dwlab4,ttyp1,~,21>./test
> > sizeof(long) [8] + sizeof(void *) [8] == 16 != sizeof(int64_t) [8]
> >
> > oops! The struct just grew by 8 bytes!
> >
> > (*) On the same platform, obviously.
> >
>
> I'm not sure how you are getting this.  The structure goes from
>
> 	long fts_number;	        /* local numeric value */
> 	void *fts_pointer;	        /* local address value */
>
> to
>
> 	union {
> 		struct {
> 			long __fts_number;	/* local numeric value */
> 			void *__fts_pointer;	/* local address value */
> 		} __struct_ftsent;
> 		int64_t __fts_bignum;
> 	} __union_ftsent;
>
>
> Regardless of how big a pointer or a long is on your platform, the two
> fields are going to combine to consume at least 64 bits.  All that the
> change does is overlay those >= 64bits with a int64_t.

Oops, you're right.  Since the new member is <= in size to the previous
members, strictly speaking it shouldn't change size.

Now there is a question if gcc will do something odd to that embedded
struct for alignment purposes. I haven't checked the original code for
__packed, however...

I'm also not clear on if endianness plays a part, but I need to read the
code.

-- 
Doug White                    |  FreeBSD: The Power to Serve
dwhite@gumbysoft.com          |  www.FreeBSD.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050104194302.O21516>