Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Nov 2006 12:15:46 +0300
From:      Yar Tikhiy <yar@comp.chem.msu.su>
To:        "Daniel O'Connor" <doconnor@gsoft.com.au>
Cc:        src-committers@freebsd.org, Bruce Evans <bde@zeta.org.au>, jkoshy@freebsd.org, Marcel Moolenaar <xcllnt@mac.com>, cvs-all@freebsd.org, phk@phk.freebsd.dk, cvs-src@freebsd.org, "M. Warner Losh" <imp@bsdimp.com>
Subject:   Re: cvs commit: src/include ar.h
Message-ID:  <20061119091545.GE80527@comp.chem.msu.su>
In-Reply-To: <200611191842.17673.doconnor@gsoft.com.au>
References:  <20061117201432.X11101@delplex.bde.org> <20061118202125.GD80527@comp.chem.msu.su> <1F361437-69AC-4823-8FF8-506EA450ED2F@mac.com> <200611191842.17673.doconnor@gsoft.com.au>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Nov 19, 2006 at 06:42:07PM +1030, Daniel O'Connor wrote:
> On Sunday 19 November 2006 07:35, Marcel Moolenaar wrote:
> > Also, since this discussion is the result of ARM aligning structures
> > on 4-byte boundaries, I think that the use of __packed to compensate
> > for excessive alignment is just plain wrong. We have __aligned(x) to
> > inform the compiler about what the alignment of an object should be
> > and that's the tool we should use to tell the compiler on ARM that
> > we in fact want 1-byte alignment. take for example, the following
> > structure:
> 
> Just a quick point..
> __aligned__ only specified a minimum packing requirement - there is no way to 
> specify a maximum (I believe)
> 
> If the underlying problem IS too large an alignment then you're screwed if you 
> want a reasonably portable solution.. Perhaps __packed__ convinces the 
> compiler to reduce alignment.

Quoting the GCC docs:

    aligned (alignment)
	This attribute specifies a minimum alignment for the variable or
	structure field, measured in bytes.
	...
	The aligned attribute can only increase the alignment; but you
	can decrease it by specifying packed as well.

This can be read as follows: __packed and __aligned(FOO) together
can specify an exact alignment FOO less than the default one.

-- 
Yar



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