Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Jan 2010 15:48:25 +0000
From:      Rui Paulo <rpaulo@freebsd.org>
To:        Sebastian Huber <sebastian.huber@embedded-brains.de>
Cc:        FreeBSD-Hackers <hackers@freebsd.org>
Subject:   Re: ARM and structure size boundary
Message-ID:  <2B030914-1EC4-4887-856D-994FB66378F5@freebsd.org>
In-Reply-To: <4B582AC4.9030502@embedded-brains.de>
References:  <4B582AC4.9030502@embedded-brains.de>

next in thread | previous in thread | raw e-mail | index | archive | help

On 21 Jan 2010, at 10:21, Sebastian Huber wrote:

> Hi,
>=20
> on ARM the GCC has an option for the structure size boundary:
>=20
> http://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html#ARM-Options
>=20
> In the GCC sources (gcc/config/arm) you see that NetBSD changes the =
default
> value to 8 from 32.
>=20
> For FreeBSD I did not found something similar.  What value is used on =
FreeBSD
> by default?
>=20
> This value is (or was) important for the network stack.  Do you know =
if the
> current FreeBSD network stack is dependent on this value?  In the file
> gcc/config/arm/netbsd.h (GCC sources) is a comment about this topic.
>=20
> Have a nice day!

Just for clarification, on FreeBSD, given it's use of the default =
structure size boundary, if you composing a packet format using a =
structure, you need to use __packed if the structure is not a multiple =
of 4.

struct a {
	int8_t b;
	int8_t b;
};

sizeof(struct a) on FreeBSD/arm is 4 and not 2. To make sure it will get =
the correct value, you need to type:

struct a {
	...
} __packed;

--
Rui Paulo




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2B030914-1EC4-4887-856D-994FB66378F5>