Article View: gnu.gcc.bug
Article #2638Re: the idea of a new feature for gcc
From: Mark H. Colburn
Date: Fri, 12 May 1989 14:57
Date: Fri, 12 May 1989 14:57
28 lines
1416 bytes
1416 bytes
In article <8905111829.AA18182@decwrl.dec.com> skubi%decprl.DEC@DECWRL.DEC.COM writes:
>Gnu C should differentiate between ordinary RAM cells and hardware registers
>mapped into (virtual or not) memory.
>
>Examples:
>
> /* the example above, modified */
> hardware long int adr*;
> do {
> res_brut = *adr;
> } while (res_brut & 0x60000);
The example that you gave is precisely the reason that the ANSI X3J11
commitee added the "volatile" keyword. Volatile is to be used when the
compiler should not optimize away variable references since they may be
required to latch devices, or to read constantly changing memory.
I think that if you change your example above to read:
volatile long int *adr;
do {
res_brut = *adr;
} while (res_brut & 0x60000);
You will get the results that you want.
--
Mark H. Colburn mark@jhereg.mn.org
Minnetech Consulting, Inc.
Technical Details
Message-ID:
<878@jhereg.Jhereg.MN.ORG>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!uxc!tank!shamash!com50!jhereg!markReferences:
<8905111829.AA18182@decwrl.dec.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!uxc!tank!shamash!com50!jhereg!mark From: mark@jhereg.Jhereg.MN.ORG (Mark H. Colburn) Newsgroups: gnu.gcc.bug Subject: Re: the idea of a new feature for gcc Message-ID: <878@jhereg.Jhereg.MN.ORG> Date: 12 May 89 14:57:28 GMT References: <8905111829.AA18182@decwrl.dec.com> Reply-To: mark@jhereg.MN.ORG (Mark H. Colburn) Distribution: gnu Organization: Minnetech Consulting, Inc., St. Paul, MN Lines: 28