Re: Help with SH2E -O2 instruction ordering with volatile

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2015-12-20 at 21:52 +1100, Alex Brown wrote:
> Hi,
> 
> Thanks for that.
> 
> I was trying to avoid using a memory barrier (ever time I write non
> portable code, I shed a small tear),

Well, change the #define memory_barrier to whatever your toolchain
supports and make it portable in the build setup :)

You can also make all the stores that need to be strictly ordered store
to volatile mems (like you did in one of your working examples). 
 However, using volatile alone is sometimes not enough when doing
hardware access/communication, because the compiler doesn't know about
the side effects of memory mapped IO.

>  but I am guessing that because I
> only access the address of the text variable, rather than the value,
> GCC can't know that it needs to fill in the values before the
> assignment ?

Yes, it only treats that volatile store as volatile.  Whether the
stored value is an address or not doesn't matter at that point.

Cheers,
Oleg



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux