Hello, Suppose the following C code.
int t = __sync_fetch_and_add(&s->r, 1); s is a struct with member r, which is an volatile int. Is this an atomic operation, even if you include the indirection? In other words, can a thread come between the dereferencing operation and the atomic increment of another thread? If so, is there a solution besides whileing with a compare and swap? What about stdatomic.h in C11, is there a way to do what I want there? Pointers to documentation on stdatomic, or the gnu extensions are greatly appreciated (I know about http://gcc.gnu.org/wiki/Atomic, http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1349.htm, and http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html). Thanks for your time. Leo -- Leo Ferres, Ph.D. Assistant Professor Department of Computer Science University of ConcepciĆ³n, ConcepciĆ³n, Chile