This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: const volatile
- From: Toby Douglass <toby at winterflaw dot net>
- To: gcc-help at gcc dot gnu dot org
- Date: Wed, 26 Sep 2018 15:04:26 +0200
- Subject: Re: const volatile
- References: <CAJWNc-7+qHBZSq7=S=+HRBWQ37LK_oeNeoA+CQjWyYNaR5+woQ@mail.gmail.com>
On 26/09/2018 14:54, Kalamatee wrote:
Hi
I am wondering if there is a reason globals marked const volatile are put
into the data section and not read-only as const should imply?
I have no clue as such, I know nothing about GCC internals, but
read-only to me implies you could cache it and it would never change,
which is not the case with volatile, as you're then indicating the value
can change.
I am trying to compile code for m68k AmigaOS
Woot!
How can we have a global that is both volatile (to prevent incorrect
sequencing)
Careful with that axe, Eugene.
I may be wrong, but I think volatile only indicates to the *compiler*
that the value can change at any time.
However, *when* the value changes is down mainly to the hardware : you
need to use load and store barriers appropriate, as also perhaps atomic
writes (or the equivalent function thereof) to flush store buffers.