This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
volatile shared memory
- From: NightStrike <nightstrike at gmail dot com>
- To: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Thu, 15 Mar 2012 14:56:57 -1000
- Subject: volatile shared memory
If I am interacting with shared memory, gcc doesn't know if another
process changes values. This creates issues for optimization. I know
that "volatile" can help address this, but it winds up causing a giant
mess of other problems (like, for instance, I can't pass a volatile
into memcpy.. or pretty much anything else from the standard
libraries).
So for instance, if I do something stupidly simple like busy-wait on a
shm value to change:
while (shm->index == oldindex) ;
gcc will kill that loop.
For simple things like this, and much more complicated things beyond
it, is there a way to cast something to "volatile" for one particular
usage?