Re: padding/alignment question.

Alan Cox (alan@lxorguk.ukuu.org.uk)
Sat, 30 Oct 1999 19:32:06 +0100 (BST)


> __u16 bg_used_dirs_count; /* Directories count */
> __u16 bg_pad;
> __u32 bg_reserved[3];
> };
>
> why are the last 14 bytes split into __u16 and __u32[3]? Isn't it more
> economical to write:
>
> __u16 bg_used_dirs_count; /* Directories count */
> __u8 bg_reserved[14];
> };
>
> a trivial program that prints sizeof of both confirms that it is 32 bytes
> in both cases. So, why is it not done via __u8[14]? Is there some
> alignment-related issue on non-intel architecture or what?

On the M68K at least it only uses word alignment not long word. So the two
come out different sizes. Putting in the padding explicitly makes it more
portable

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/