lkml.org 
[lkml]   [2000]   [Aug]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: 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(&regs->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/

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