diff options
author | Alex Bennée <alex.bennee@linaro.org> | 2016-09-30 22:30:53 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-10-04 10:00:25 +0200 |
commit | e653bc6b0ff645c25b8a2eb607c18a5c98b59db6 (patch) | |
tree | 2a558ef7e18bf2a423d2a52ebc7bfb9135e95f01 /include | |
parent | 23ea7f57949f2f5934f4d5bbc29fe321b3a7067b (diff) | |
download | qemu-e653bc6b0ff645c25b8a2eb607c18a5c98b59db6.zip qemu-e653bc6b0ff645c25b8a2eb607c18a5c98b59db6.tar.gz qemu-e653bc6b0ff645c25b8a2eb607c18a5c98b59db6.tar.bz2 |
atomic.h: comment on use of atomic_read/set
Add some notes on the use of the relaxed atomic access helpers and their
importance for defined behaviour in C11's multi-threaded memory model.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20160930213106.20186-3-alex.bennee@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/qemu/atomic.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h index c493f89..c4f6950 100644 --- a/include/qemu/atomic.h +++ b/include/qemu/atomic.h @@ -92,6 +92,12 @@ /* Weak atomic operations prevent the compiler moving other * loads/stores past the atomic operation load/store. However there is * no explicit memory barrier for the processor. + * + * The C11 memory model says that variables that are accessed from + * different threads should at least be done with __ATOMIC_RELAXED + * primitives or the result is undefined. Generally this has little to + * no effect on the generated code but not using the atomic primitives + * will get flagged by sanitizers as a violation. */ #define atomic_read(ptr) \ ({ \ |