Messages in this thread | | | Date | 02 Jul 2000 12:27:00 +0200 | From | (Kai Henningsen) | Subject | Re: [patch-2.4.0-test2]Re: Linux-2.4.0-test2 |
| |
vonbrand@sleipnir.valparaiso.cl (Horst von Brand) wrote on 24.06.00 in <200006250221.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.
> > 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? > > 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.
MfG Kai
- 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/
| |