This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: const volatile


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]