Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 09 Jul 2009 09:01:59 -0700
From:      Tim Kientzle <kientzle@freebsd.org>
To:        =?UTF-8?B?RGFnLUVybGluZyBTbcO4cmdyYXY=?= <des@des.no>
Cc:        svn-src-projects@freebsd.org, src-committers@freebsd.org, Rui Paulo <rpaulo@freebsd.org>, Bruce Evans <brde@optusnet.com.au>
Subject:   Re: svn commit: r195460 - projects/mesh11s/sys/net80211
Message-ID:  <4A561477.7000508@freebsd.org>
In-Reply-To: <86prc9g8yf.fsf@ds4.des.no>
References:  <200907081526.n68FQYDb055185@svn.freebsd.org>	<20090709041145.G46111@delplex.bde.org> <86prc9g8yf.fsf@ds4.des.no>

next in thread | previous in thread | raw e-mail | index | archive | help
Dag-Erling Smørgrav wrote:
> Bruce Evans <brde@optusnet.com.au> writes:
>> Broken ABIs (e.g., arm?) may add padding at the end of structs,
> 
> Padding at the end of a struct is *required* to ensure proper alignment
> of the next element in an array, e.g.
> 
> struct foo { int i; char c; } bar[2];
> 
> Assuming a four-byte alignment requirement for int, the compiler *must*
> add three bytes of padding at the end of struct foo so bar[1].i is
> correctly aligned.
> 
> cf. ISO/IEC 9899:1999 §6.7.2.1:
> 
> 15 There may be unnamed padding at the end of a structure or union.

Everyone (I hope!) expects alignment in the
case you outlined.  But many of us have been
surprised to see the ARM compiler pad

   struct foo {
       char f1[4];
       char f2[1];
       char f3[1];
   };

to 12 bytes.  This breaks a lot of traditional
code that uses structs of char arrays to
define memory and disk layouts.

I'm not claiming that the ARM compiler is broken,
just that its padding behavior surprises
a lot of people.

Tim



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