Messages in this thread | | | Date | Sat, 12 Aug 2000 06:14:23 +0100 | From | Philipp Rumpf <> | Subject | Re: ioremap return type |
| |
On Fri, Aug 11, 2000 at 05:24:30PM +0200, Jes Sorensen wrote: > >>>>> "Philipp" == Philipp Rumpf <prumpf@parcelfarce.linux.theplanet.co.uk> writes: > > Philipp> On Thu, Aug 10, 2000 at 02:14:13PM +0200, Jamie Lokier wrote: > >> Many drivers use a struct to define the offsets in their I/O or > >> iomem space. E.g. acenic.c: readl(®s->CpuCtrl). We know that's > >> not portable in the sense that struct layout is not guaranteed. > >> However, provided all the fields are suitably padded & aligned, it > >> works in practice. (So far..) > > Philipp> Not only does it work in practice, it's used by most drivers > Philipp> and file systems when they describe on-disk or dma > Philipp> structures. Currently the rules are: > > Philipp> - naturally align everything - all struct sizes might be > Philipp> aligned to a multiple of four bytes
This was meant as imperative. Unless you explicitly pad things so everything is naturally aligned, the compiler can do whatever it wants. Furthermore, it might still add padding to achieve a multiple-of-four size.
> If you use structures to describe hardware you should *always* > perform explicit padding and never ever expect the compiler to do it > for you.
We agree, then.
Philipp
- 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/
| |