[PATCH 8/8] firmware: mark some structs as packed

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/baseband-devel@lists.osmocom.org/.

Alexander Huemer alexander.huemer at xx.vu
Thu Nov 24 10:51:04 UTC 2011

On Thu, Nov 24, 2011 at 11:33:09AM +0100, Harald Welte wrote:
> normally, the compiler will lay out the structure in a way that
> optimizes accesses to members.  So e.g. on an ARM, a 
> struct {
> 	uint8_t byte1;
> 	uint8_t byte2;
> };
> will very likely contain 3 bytes padding between the two uint8 values in
> order to make sure no unaligned loads/stores will be required.
> However, if you change that to '__packed', the padding will not be
> generated and any access to struct members will need to deal with
> unaligned accesses, which can be inflating the code size considerably.
thanks for pointing that out. It's actually obvious after a moment of

One additional thought on the switch/enum situation and initialisation:
what about adding an additional member to the enum, let's say VOID and
instances of the enum are initialised to that. A switch statement that
handles this enum gets a case for VOID which produces a runtime warning,
much like a default case. this way the compiler is happy, because the
variable is  initialised and also tells you when enum values are not

More information about the baseband-devel mailing list