Re: howto avoid optimizing a read?

Jamie Lokier (lkd@tantalophile.demon.co.uk)
Tue, 1 Jun 1999 16:33:21 +0200


Alan Cox wrote:
> > Whats the easiest way to avoid having the read optimized away? I am
> > fairly fluent in C, but compiler optimizations are bit too much black
> > magic for me.
>
> Look up the volatile keyword in a C manual. It exists for exactly these
> sort of occasions.

The documentation says to use readb/readw/readl to read memory-mapped
devices, and they use volatile already so use them.

Don't read existing device drivers, you might learn bad habits. :-)

References: Documentation/IO-mapping.txt, <asm/io.h>

-- Jamie

-
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/