Move the __packed declarations. This makes sizeof(struct llc) 8 again

on the arm.  Add an assert to ensure that the size is 8 to prefent others
from falling into this trap (we should have more of these).

Why the construct:

	struct foo {
		union bar {
			struct {
				...
			} __packed fred;
			...
		} __packed wilma;
	} __packed;

has a different packing than:

	struct foo {
		union bar {
			struct {
				...
			} fred __packed;
			...
		} wilma __packed;
	} __packed;

is beyond my ability to ferret out of the gcc documentation.  Most
likely some subtle binding issue (eg before it says the struct itself
is packed, while after it means that the whole struct is packed into
the thing it is in).  Pointers to relevant documentation would be
appreciated.
This commit is contained in:
Warner Losh 2006-12-01 17:50:11 +00:00
parent c94d50f166
commit ff4323418b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=164804

View File

@ -52,15 +52,15 @@ struct llc {
u_int8_t format_id;
u_int8_t class;
u_int8_t window_x2;
} type_u __packed;
} __packed type_u;
struct {
u_int8_t num_snd_x2;
u_int8_t num_rcv_x2;
} type_i __packed;
} __packed type_i;
struct {
u_int8_t control;
u_int8_t num_rcv_x2;
} type_s __packed;
} __packed type_s;
struct {
u_int8_t control;
/*
@ -72,17 +72,17 @@ struct llc {
u_int8_t frmr_control;
u_int8_t frmr_control_ext;
u_int8_t frmr_cause;
} type_frmr __packed;
} __packed type_frmr;
struct {
u_int8_t control;
u_int8_t org_code[3];
u_int16_t ether_type;
} type_snap __packed;
} __packed type_snap;
struct {
u_int8_t control;
u_int8_t control_ext;
} type_raw __packed;
} llc_un /* XXX __packed ??? */;
} __packed type_raw;
} __packed llc_un;
} __packed;
struct frmrinfo {
@ -114,6 +114,10 @@ struct frmrinfo {
#define LLC_FRMRLEN 7
#define LLC_SNAPFRAMELEN 8
#ifdef CTASSERT
CTASSERT(sizeof (struct llc) == LLC_SNAPFRAMELEN);
#endif
/*
* Unnumbered LLC format commands
*/