Re: [PATCH] isa_{read,write}{w,l} fixed

From: Horst von Brand (vonbrand@sleipnir.valparaiso.cl)
Date: Sat Feb 12 2000 - 17:07:35 EST


Philipp Rumpf <prumpf@inwestnet.de> said:

[...]

> It might, in theory, add padding.

gcc _will_ add padding in many cases.

> In practice a lot of code assumes that if
> if you do all padding yourself so structure members are naturally aligned[*]
> gcc will leave them in the order they are in and not add padding.

If structure members are laid out the right way, no padding is added. As
claimed, depends on architecure, CPU family, optimization flags, ...

> There is no reason to require readb() to compute offsets by hand while
> letting TCP, DMA code aso use structs ( (u32 *)ip_header)[IP_SADDR] =
> source_address; - yuck), and what I'm saying there is no reason to "fix"
> drivers that use structs for readb() offsets.

TCP was designed for natural alignment of the fields, for efficiency. This
is _not_ to be taken for granted for any random struct.

Besides, the aliasing rules of C allow the compiler to assume your
(illegal) assignent doesn't modify *ip_header...

-- 
Horst von Brand                             vonbrand@sleipnir.valparaiso.cl
Casilla 9G, Viņa del Mar, Chile                               +56 32 672616

- 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 : Tue Feb 15 2000 - 21:00:23 EST