diff options
| author | Stefan Hajnoczi <stefanha@redhat.com> | 2020-09-23 11:56:46 +0100 |
|---|---|---|
| committer | Stefan Hajnoczi <stefanha@redhat.com> | 2020-09-23 16:07:44 +0100 |
| commit | d73415a315471ac0b127ed3fad45c8ec5d711de1 (patch) | |
| tree | bae20b3a39968fdfb4340b1a39b533333a8e6fd0 /include/qemu/stats64.h | |
| parent | ed7db34b5aedba4487fd949b2e545eef954f093e (diff) | |
| download | focaccia-qemu-d73415a315471ac0b127ed3fad45c8ec5d711de1.tar.gz focaccia-qemu-d73415a315471ac0b127ed3fad45c8ec5d711de1.zip | |
qemu/atomic.h: rename atomic_ to qatomic_
clang's C11 atomic_fetch_*() functions only take a C11 atomic type
pointer argument. QEMU uses direct types (int, etc) and this causes a
compiler error when a QEMU code calls these functions in a source file
that also included <stdatomic.h> via a system header file:
$ CC=clang CXX=clang++ ./configure ... && make
../util/async.c:79:17: error: address argument to atomic operation must be a pointer to _Atomic type ('unsigned int *' invalid)
Avoid using atomic_*() names in QEMU's atomic.h since that namespace is
used by <stdatomic.h>. Prefix QEMU's APIs with 'q' so that atomic.h
and <stdatomic.h> can co-exist. I checked /usr/include on my machine and
searched GitHub for existing "qatomic_" users but there seem to be none.
This patch was generated using:
$ git grep -h -o '\<atomic\(64\)\?_[a-z0-9_]\+' include/qemu/atomic.h | \
sort -u >/tmp/changed_identifiers
$ for identifier in $(</tmp/changed_identifiers); do
sed -i "s%\<$identifier\>%q$identifier%g" \
$(git grep -I -l "\<$identifier\>")
done
I manually fixed line-wrap issues and misaligned rST tables.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200923105646.47864-1-stefanha@redhat.com>
Diffstat (limited to 'include/qemu/stats64.h')
| -rw-r--r-- | include/qemu/stats64.h | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/include/qemu/stats64.h b/include/qemu/stats64.h index 19a5ac4c56..fdd3d1b8f9 100644 --- a/include/qemu/stats64.h +++ b/include/qemu/stats64.h @@ -37,27 +37,27 @@ static inline void stat64_init(Stat64 *s, uint64_t value) static inline uint64_t stat64_get(const Stat64 *s) { - return atomic_read__nocheck(&s->value); + return qatomic_read__nocheck(&s->value); } static inline void stat64_add(Stat64 *s, uint64_t value) { - atomic_add(&s->value, value); + qatomic_add(&s->value, value); } static inline void stat64_min(Stat64 *s, uint64_t value) { - uint64_t orig = atomic_read__nocheck(&s->value); + uint64_t orig = qatomic_read__nocheck(&s->value); while (orig > value) { - orig = atomic_cmpxchg__nocheck(&s->value, orig, value); + orig = qatomic_cmpxchg__nocheck(&s->value, orig, value); } } static inline void stat64_max(Stat64 *s, uint64_t value) { - uint64_t orig = atomic_read__nocheck(&s->value); + uint64_t orig = qatomic_read__nocheck(&s->value); while (orig < value) { - orig = atomic_cmpxchg__nocheck(&s->value, orig, value); + orig = qatomic_cmpxchg__nocheck(&s->value, orig, value); } } #else @@ -79,7 +79,7 @@ static inline void stat64_add(Stat64 *s, uint64_t value) low = (uint32_t) value; if (!low) { if (high) { - atomic_add(&s->high, high); + qatomic_add(&s->high, high); } return; } @@ -101,7 +101,7 @@ static inline void stat64_add(Stat64 *s, uint64_t value) * the high 32 bits, so it can race just fine with stat64_add32_carry * and even stat64_get! */ - old = atomic_cmpxchg(&s->low, orig, result); + old = qatomic_cmpxchg(&s->low, orig, result); if (orig == old) { return; } @@ -116,7 +116,7 @@ static inline void stat64_min(Stat64 *s, uint64_t value) high = value >> 32; low = (uint32_t) value; do { - orig_high = atomic_read(&s->high); + orig_high = qatomic_read(&s->high); if (orig_high < high) { return; } @@ -128,7 +128,7 @@ static inline void stat64_min(Stat64 *s, uint64_t value) * the write barrier in stat64_min_slow. */ smp_rmb(); - orig_low = atomic_read(&s->low); + orig_low = qatomic_read(&s->low); if (orig_low <= low) { return; } @@ -138,7 +138,7 @@ static inline void stat64_min(Stat64 *s, uint64_t value) * we may miss being lucky. */ smp_rmb(); - orig_high = atomic_read(&s->high); + orig_high = qatomic_read(&s->high); if (orig_high < high) { return; } @@ -156,7 +156,7 @@ static inline void stat64_max(Stat64 *s, uint64_t value) high = value >> 32; low = (uint32_t) value; do { - orig_high = atomic_read(&s->high); + orig_high = qatomic_read(&s->high); if (orig_high > high) { return; } @@ -168,7 +168,7 @@ static inline void stat64_max(Stat64 *s, uint64_t value) * the write barrier in stat64_max_slow. */ smp_rmb(); - orig_low = atomic_read(&s->low); + orig_low = qatomic_read(&s->low); if (orig_low >= low) { return; } @@ -178,7 +178,7 @@ static inline void stat64_max(Stat64 *s, uint64_t value) * we may miss being lucky. */ smp_rmb(); - orig_high = atomic_read(&s->high); + orig_high = qatomic_read(&s->high); if (orig_high > high) { return; } |