GNU extensions on FreeBSD 5.x headers

Stefan Farfeleder stefan at fafoe.dyndns.org
Wed Jun 4 03:09:39 PDT 2003


On Wed, Jun 04, 2003 at 09:38:21AM +0100, Tony Finch wrote:
> On Tue, Jun 03, 2003 at 09:03:38PM -0400, Mike Barcroft wrote:
> > 
> > I think those of us who've played with alternative compilers are aware
> > of this requirement.  I'm not sure there's anything we can do about
> > it.  If anyone has any tricks to force 128-bit alignment without a
> > 128-bit type in standard C, I'd love to hear it.
> 
> Not in standard C (since it doesn't allow you to express alignment and
> padding requirements), but in C-as-she-is-spoke why not insert the
> necessary padding explicitly?

By adding padding to a struct you can only align the offset of a struct
member:

struct foo {
	...
	char	padding[N];
	bar	aligned;
	...
};

What you cannot do with padding is to align a non-dynamically allocated
object of type struct foo as in:

	struct foo	f;

There's no way I can see to guarantee that f.aligned is 128-bit aligned.

Regards,
Stefan


More information about the freebsd-standards mailing list