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]

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?


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