From owner-svn-src-projects@FreeBSD.ORG  Fri Jul 10 10:28:39 2009
Return-Path: <owner-svn-src-projects@FreeBSD.ORG>
Delivered-To: svn-src-projects@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 2BDE5106564A;
	Fri, 10 Jul 2009 10:28:39 +0000 (UTC)
	(envelope-from rpaulo@gmail.com)
Received: from mail-ew0-f227.google.com (mail-ew0-f227.google.com
	[209.85.219.227])
	by mx1.freebsd.org (Postfix) with ESMTP id 7F9528FC18;
	Fri, 10 Jul 2009 10:28:38 +0000 (UTC)
	(envelope-from rpaulo@gmail.com)
Received: by ewy27 with SMTP id 27so89249ewy.43
	for <multiple recipients>; Fri, 10 Jul 2009 03:28:37 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:received:received:sender:cc:message-id:from:to
	:in-reply-to:content-type:content-transfer-encoding:mime-version
	:subject:date:references:x-mailer;
	bh=uS0rPrmQdjAIgKdiHm7V+BZrA2H12fS9MFPE+TNc3Ik=;
	b=X0wIvuSocmVsDqRIap9G6zrK27wqq6pRIKwABu6mUEH5HWipeu2Sf7ORhaSTUnqWa+
	dGYgC4oVWGgiGM0NR50KjAXc+ny4GZ5zdzm22EqL3jYxlTtYqlEnGYnKpZsnjFunGTk4
	gLjqKyfLR6Qw4sFuQt8v3+DkEI38gdfbSk0iE=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=sender:cc:message-id:from:to:in-reply-to:content-type
	:content-transfer-encoding:mime-version:subject:date:references
	:x-mailer;
	b=gMlUMUErhcqUrIQ+1r3eyzT8L+Yj4LQpI++I3MmtEQmFPacfbG01EI7jQOH/j3Tyv0
	QKMb12NdD26QU481Ry42VG5qHT5fid/GvJ5hLVVt/qw/KXW4Wkqzlg7klm6RM0Kb3RXg
	KgRIl5opCRlIRMGCIZzT/KEl52w26+0rClD6k=
Received: by 10.210.63.18 with SMTP id l18mr2261178eba.11.1247221717351;
	Fri, 10 Jul 2009 03:28:37 -0700 (PDT)
Received: from omega.lan (bl6-157-190.dsl.telepac.pt [82.155.157.190])
	by mx.google.com with ESMTPS id 5sm2348690eyf.24.2009.07.10.03.28.36
	(version=TLSv1/SSLv3 cipher=RC4-MD5);
	Fri, 10 Jul 2009 03:28:36 -0700 (PDT)
Sender: Rui Paulo <rpaulo@gmail.com>
Message-Id: <8C5DD2ED-C2C2-4101-8FCC-4690A838684B@freebsd.org>
From: Rui Paulo <rpaulo@freebsd.org>
To: M. Warner Losh <imp@bsdimp.com>
In-Reply-To: <20090710.012630.-875846397.imp@bsdimp.com>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
Content-Transfer-Encoding: 7bit
Mime-Version: 1.0 (Apple Message framework v935.3)
Date: Fri, 10 Jul 2009 11:28:35 +0100
References: <20090709041145.G46111@delplex.bde.org>
	<86prc9g8yf.fsf@ds4.des.no> <4A561477.7000508@freebsd.org>
	<20090710.012630.-875846397.imp@bsdimp.com>
X-Mailer: Apple Mail (2.935.3)
Cc: svn-src-projects@freebsd.org, des@des.no, kientzle@freebsd.org,
	src-committers@freebsd.org, brde@optusnet.com.au
Subject: Re: svn commit: r195460 - projects/mesh11s/sys/net80211
X-BeenThere: svn-src-projects@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the src &quot; projects&quot;
	tree" <svn-src-projects.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-projects>, 
	<mailto:svn-src-projects-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-projects>
List-Post: <mailto:svn-src-projects@freebsd.org>
List-Help: <mailto:svn-src-projects-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-projects>, 
	<mailto:svn-src-projects-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Fri, 10 Jul 2009 10:28:39 -0000


On 10 Jul 2009, at 08:26, M. Warner Losh wrote:
> It isn't a compiler bug.  It is an ABI requirement for ARM.  At least
> for the ABI we use.  there are others that might be better, and not
> suffer from this surprise.  We[*] should investigate them.


Verbatim copy from gcc/config/arm/netbsd-elf.h:

/* VERY BIG NOTE: Change of structure alignment for NetBSD/arm.
    There are consequences you should be aware of...

    Normally GCC/arm uses a structure alignment of 32 for compatibility
    with armcc.  This means that structures are padded to a word
    boundary.  However this causes problems with bugged NetBSD kernel
    code (possibly userland code as well - I have not checked every
    binary).  The nature of this bugged code is to rely on sizeof()
    returning the correct size of various structures rounded to the
    nearest byte (SCSI and ether code are two examples, the vm system
    is another).  This code breaks when the structure alignment is 32
    as sizeof() will report a word=rounded size.  By changing the
    structure alignment to 8. GCC will conform to what is expected by
    NetBSD.

    This has several side effects that should be considered.
    1. Structures will only be aligned to the size of the largest  
member.
       i.e. structures containing only bytes will be byte aligned.
            structures containing shorts will be half word aligned.
            structures containing ints will be word aligned.

       This means structures should be padded to a word boundary if
       alignment of 32 is required for byte structures etc.

    2. A potential performance penalty may exist if strings are no  
longer
       word aligned.  GCC will not be able to use word load/stores to  
copy
       short strings.

    This modification is not encouraged but with the present state of  
the
    NetBSD source tree it is currently the only solution that meets the
    requirements.  */

#undef DEFAULT_STRUCTURE_SIZE_BOUNDARY
#define DEFAULT_STRUCTURE_SIZE_BOUNDARY 8

--

So, this is how NetBSD avoided it, don't know if it's the best way to  
do it. We have DEFAULT_STRUCTURE_SIZE_BOUNDARY equal to 32 (the  
default), so our case is different and this is the reason why  
alignment will always be done on a word basis.

--
Rui Paulo