Re: [head tinderbox] failure on arm/arm

From: Ruslan Ermilov <ru_at_FreeBSD.org>
Date: Mon, 13 Nov 2006 02:28:54 +0300
On Sun, Nov 12, 2006 at 04:05:39PM -0700, M. Warner Losh wrote:
> Yea, that's clearly bogus of it.  It does this because it thinks that
> eh is going to be 4-byte aligned, which it isn't in this case.  I
> think that we may need to change:
> 
> /*
>  * Structure of a 10Mb/s Ethernet header.
>  */
> struct	ether_header {
> 	u_char	ether_dhost[ETHER_ADDR_LEN];
> 	u_char	ether_shost[ETHER_ADDR_LEN];
> 	u_short	ether_type;
> };
> 
> to be
> 
> struct	ether_header {
> 	u_char	ether_dhost[ETHER_ADDR_LEN];
> 	u_char	ether_shost[ETHER_ADDR_LEN];
> 	u_short	ether_type;
> } __packed;
> 
> since that would fit.
> 
"fit" == avoid 32-bit loads (I've similarly checked adding
__packed to "struct ar_hdr" here, and it indeed stops using
32-bit loads instructions now):

%%%
Index: ar.h
===================================================================
RCS file: /home/ncvs/src/include/ar.h,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 ar.h
--- ar.h	24 May 1994 09:57:26 -0000	1.1.1.1
+++ ar.h	12 Nov 2006 23:26:38 -0000
_at__at_ -44,6 +44,8 _at__at_
 #ifndef _AR_H_
 #define	_AR_H_
 
+#include <sys/cdefs.h>
+
 /* Pre-4BSD archives had these magic numbers in them. */
 #define	OARMAG1	0177555
 #define	OARMAG2	0177545
_at__at_ -62,6 +64,6 _at__at_ struct ar_hdr {
 	char ar_size[10];		/* size in bytes */
 #define	ARFMAG	"`\n"
 	char ar_fmag[2];		/* consistency check */
-};
+} __packed;
 
 #endif /* !_AR_H_ */
%%%

> There's one caveat that I'd caution people about.  NetBSD had lots of
> issues with gcc4 and packed when the struct doesn't need to be packed.
> 
We don't have a lot of packed structs yet, and we should certainly
have more of them.  :-)


Cheers,
-- 
Ruslan Ermilov
ru_at_FreeBSD.org
FreeBSD committer

Received on Sun Nov 12 2006 - 22:31:52 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:02 UTC