ARM and structure size boundary

Rui Paulo rpaulo at freebsd.org
Thu Jan 21 15:48:29 UTC 2010


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

> Hi,
> 
> on ARM the GCC has an option for the structure size boundary:
> 
> http://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html#ARM-Options
> 
> In the GCC sources (gcc/config/arm) you see that NetBSD changes the default
> value to 8 from 32.
> 
> For FreeBSD I did not found something similar.  What value is used on FreeBSD
> by default?
> 
> 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.
> 
> 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



More information about the freebsd-hackers mailing list