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

From: Horst von Brand (vonbrand@sleipnir.valparaiso.cl)
Date: Mon Jul 03 2000 - 19:45:51 EST


kaih@khms.westfalen.de (Kai Henningsen) said:
> vonbrand@sleipnir.valparaiso.cl (Horst von Brand) wrote on 24.06.00 in <200006
> 250221.e5P2LPG04091@sleipnir.valparaiso.cl>:
> > Urban Widmark <urban@svenskatest.se> said:
> > > On Sat, 24 Jun 2000, Tigran Aivazian wrote:
> > > > K&R says (page 213, A8.3):

> > > > Adjacent field members of structures are packed into
> > > > implementation-dependent storage units in an
> > > > implementation-dependent direction. ... The members of a
> > > > structure have addresses increasing in the order of their
> > > > declaration.

> > > > I think Alan Cox is right - there is no guarantee that field members of
> > > > a structure can be found one after another starting from the first
> > > > field.

> > AFAIU, the "implementation dependent direction" here is big vs
> > little enedian, at most. See that that _addresses_ are guaranteed to be
> > increasing. Modulo padding (which in the example below isn't applicable
> > anywhere I know), they are the same anywhere.

> Bull. Language like that would *never* be used for endianness. And
> structure layout isn't something endianness has ever come into anyway.

It is not endianness per se, but endianness plus starting from either end
of larger units when allocating fields, and perhaps leaving padding in.
*Read* what they say.

[...]

> > This would break one of the important uses of C (hardware fiddling) big
> > way.

> Well, there is no portable support for hardware fiddling in the C
> standard, and there never has been any. And lots of hardware (like
> anything on x86 I/O ports) can't be accessed from C anyway.

The guarantee that structure fields are laid out in declaration order, and
the above language give rather strong guarantees. Not that everything will
automatically work the same on ia32 and sparc64, but with some care (look
at the kernel source before you for examples...) it does work.

-- 
Horst von Brand                             vonbrand@sleipnir.valparaiso.cl
Casilla 9G, Vin~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 : Fri Jul 07 2000 - 21:00:14 EST