[lkml]   [2002]   [Jan]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRE: [PATCH] C undefined behavior fix

On Wed, 9 Jan 2002, Bernard Dautrevaux wrote:

> > -----Original Message-----
> > From: []
> > Sent: Wednesday, January 09, 2002 11:42 AM
> > To:;;
> > Subject: Re: [PATCH] C undefined behavior fix
> >
> >
> > <<Especially if there are cases were this optimization yields
> > a slower =
> >
> > access (or even worse indirect bugs).
> > E.g. if the referenced "volatile short" is a hardware register and the
> > access is multiplexed over a slow 8 bit bus. There are
> > embedded systems
> > around where this is the case and the (cross-)compiler has no way to
> > know this (except it can be told by the programmer).
> > >>
> >
> > Well that of course is a situation where the compiler is
> > being deliberately
> > misinformed as to the relative costs of various machine
> > instructions, and
> > that is definitely a problem. One can even imagine hardware
> > (not such a hard
> > feat, one of our customers had such hardware) where a word
> > access works, but
> > a byte access fails due to hardware shortcuts,
> Tht's quite often the case with MMIO, and the only portable way to give a
> hint to the compiler that it should refrain from optimizing is "volatile";
> that's why I think the compiler should not do this optimization on volatile
> objects at all.

The C programming language and MMIO are two different things that must not
be mixed.

'volatile' is not enough a portable a concept to deal with MMIO. You also
need to tell about what is atomic and what is not atomic regarding
accesses through the involved BUS, for example. As a result, you may use
'volatile' to avoid assembly for MMIO, but you want to put the code in
architecture dependant code.

The atomicity issue also applies to memory-like access obviously, but the
compiler is expected to know about the architecture capabilities. If this
may differ for a given architecture family, then some compiler options
should be made available.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

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