Re: [patch-2.4.0-test2]Re: Linux-2.4.0-test2

From: Andi Kleen (ak@suse.de)
Date: Sat Jun 24 2000 - 13:59:59 EST


On Sat, Jun 24, 2000 at 10:08:24AM -0700, Philipp Rumpf wrote:
> On Sat, Jun 24, 2000 at 06:54:24PM +0200, Urban Widmark wrote:
> > So all drivers (I'm sure there are a few) that use something like
> >
> > struct foo {
> > u32 a;
> > u32 b;
> > u32 c;
> > u32 d;
> > }
> >
> > to communicate with some hardware (4 32-bit values with addresses in
> > sequence) should be fixed not to make assumptions about the layout of a
> > struct?
>
> They should be fixed to use __attribute__((packed)). Also they shouldn't
> have any unaligned struct members.

Linux kernel is not writen in ANSI-C. It makes certain assumptions about
the environment which are not guaranteed by the standard. One of them
is that void * fits into unsigned long. Another is that no structure elements
get have a bigger alignment than their size (so u32 gets at worst 3 bytes
alignment and u8/u16 can be used to pad that explicitely ). If a machine
cannot satisfy that maybe it should look for a different kernel.

-Andi

-
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/



This archive was generated by hypermail 2b29 : Mon Jun 26 2000 - 21:00:05 EST