This is the mail archive of the
mailing list for the GCC project.
Information on atomics in the gnu extensions: is a dereference atomic?
- From: Leo Ferres <leoferres at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 29 Apr 2014 09:11:41 -0400
- Subject: Information on atomics in the gnu extensions: is a dereference atomic?
- Authentication-results: sourceware.org; auth=none
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,
Thanks for your time.
Leo Ferres, Ph.D.
Department of Computer Science
University of ConcepciÃn, ConcepciÃn,