Are arrays guaranteed to be affected by a "memory" clobber?

Sebastian sebastianspublicaddress@googlemail.com
Thu Jun 11 21:39:00 GMT 2015


On Thu, 11 Jun 2015 12:21:23 +0100
Andrew Haley <aph@redhat.com> wrote:

> I'd use a full memory barrier.  __sync_synchronize() 
Isn't __sync_synchronize() the same as a memory clobber + hardware barrier?

> Even if your processor does not use a relaxed
> memory model,
It doesn't, so I'm not much concerned about hardware barriers, and assume it's ok to continue to use the macros provided in avr-libc, assuming the implementers of that knew their job.

> this guarantees that no memory operations will not
> be moved  across the barrier.
Still the open question: Is access to array elements (or dereferencing a pointer) always considered a "memory operation", unlike the variable access in the example in [2]?

> or one of the __atomic fences.
As far as I can see, you can only use them on integers or pointers, but not on arrays.
So you think it would be enough to do the pointer manipulations atomically, and then the array accesses which depend on these pointers should be ok? That's what I'm thinking, too, but what I'm not sure about...

[2]: http://www.nongnu.org/avr-libc/user-manual/optimization.html

Sebastian



More information about the Gcc-help mailing list