aboutsummaryrefslogtreecommitdiff
path: root/tests/rcutorture.c
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@redhat.com>2020-09-23 11:56:46 +0100
committerStefan Hajnoczi <stefanha@redhat.com>2020-09-23 16:07:44 +0100
commitd73415a315471ac0b127ed3fad45c8ec5d711de1 (patch)
treebae20b3a39968fdfb4340b1a39b533333a8e6fd0 /tests/rcutorture.c
parented7db34b5aedba4487fd949b2e545eef954f093e (diff)
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 'tests/rcutorture.c')
-rw-r--r--tests/rcutorture.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/tests/rcutorture.c b/tests/rcutorture.c
index 732f03abda..de6f649058 100644
--- a/tests/rcutorture.c
+++ b/tests/rcutorture.c
@@ -123,7 +123,7 @@ static void *rcu_read_perf_test(void *arg)
rcu_register_thread();
*(struct rcu_reader_data **)arg = &rcu_reader;
- atomic_inc(&nthreadsrunning);
+ qatomic_inc(&nthreadsrunning);
while (goflag == GOFLAG_INIT) {
g_usleep(1000);
}
@@ -149,7 +149,7 @@ static void *rcu_update_perf_test(void *arg)
rcu_register_thread();
*(struct rcu_reader_data **)arg = &rcu_reader;
- atomic_inc(&nthreadsrunning);
+ qatomic_inc(&nthreadsrunning);
while (goflag == GOFLAG_INIT) {
g_usleep(1000);
}
@@ -172,7 +172,7 @@ static void perftestinit(void)
static void perftestrun(int nthreads, int duration, int nreaders, int nupdaters)
{
- while (atomic_read(&nthreadsrunning) < nthreads) {
+ while (qatomic_read(&nthreadsrunning) < nthreads) {
g_usleep(1000);
}
goflag = GOFLAG_RUN;
@@ -259,8 +259,8 @@ static void *rcu_read_stress_test(void *arg)
}
while (goflag == GOFLAG_RUN) {
rcu_read_lock();
- p = atomic_rcu_read(&rcu_stress_current);
- if (atomic_read(&p->mbtest) == 0) {
+ p = qatomic_rcu_read(&rcu_stress_current);
+ if (qatomic_read(&p->mbtest) == 0) {
n_mberror++;
}
rcu_read_lock();
@@ -268,7 +268,7 @@ static void *rcu_read_stress_test(void *arg)
garbage++;
}
rcu_read_unlock();
- pc = atomic_read(&p->age);
+ pc = qatomic_read(&p->age);
rcu_read_unlock();
if ((pc > RCU_STRESS_PIPE_LEN) || (pc < 0)) {
pc = RCU_STRESS_PIPE_LEN;
@@ -301,7 +301,7 @@ static void *rcu_read_stress_test(void *arg)
static void *rcu_update_stress_test(void *arg)
{
int i, rcu_stress_idx = 0;
- struct rcu_stress *cp = atomic_read(&rcu_stress_current);
+ struct rcu_stress *cp = qatomic_read(&rcu_stress_current);
rcu_register_thread();
*(struct rcu_reader_data **)arg = &rcu_reader;
@@ -319,11 +319,11 @@ static void *rcu_update_stress_test(void *arg)
p = &rcu_stress_array[rcu_stress_idx];
/* catching up with ourselves would be a bug */
assert(p != cp);
- atomic_set(&p->mbtest, 0);
+ qatomic_set(&p->mbtest, 0);
smp_mb();
- atomic_set(&p->age, 0);
- atomic_set(&p->mbtest, 1);
- atomic_rcu_set(&rcu_stress_current, p);
+ qatomic_set(&p->age, 0);
+ qatomic_set(&p->mbtest, 1);
+ qatomic_rcu_set(&rcu_stress_current, p);
cp = p;
/*
* New RCU structure is now live, update pipe counts on old
@@ -331,7 +331,7 @@ static void *rcu_update_stress_test(void *arg)
*/
for (i = 0; i < RCU_STRESS_PIPE_LEN; i++) {
if (i != rcu_stress_idx) {
- atomic_set(&rcu_stress_array[i].age,
+ qatomic_set(&rcu_stress_array[i].age,
rcu_stress_array[i].age + 1);
}
}