cvs commit: src/include ar.h

Yar Tikhiy yar at comp.chem.msu.su
Sun Nov 19 09:16:05 UTC 2006


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


More information about the cvs-src mailing list