lkml.org 
[lkml]   [2000]   [Feb]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] isa_{read,write}{w,l} fixed
Date
From
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/

\
 
 \ /
  Last update: 2005-03-22 13:56    [W:0.078 / U:0.104 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site