From d73415a315471ac0b127ed3fad45c8ec5d711de1 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Wed, 23 Sep 2020 11:56:46 +0100 Subject: qemu/atomic.h: rename atomic_ to qatomic_ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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 . Prefix QEMU's APIs with 'q' so that atomic.h and 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 '\/tmp/changed_identifiers $ for identifier in $(%q$identifier%g" \ $(git grep -I -l "\<$identifier\>") done I manually fixed line-wrap issues and misaligned rST tables. Signed-off-by: Stefan Hajnoczi Reviewed-by: Philippe Mathieu-Daudé Acked-by: Paolo Bonzini Message-Id: <20200923105646.47864-1-stefanha@redhat.com> --- migration/multifd.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'migration/multifd.c') diff --git a/migration/multifd.c b/migration/multifd.c index ac84a61..fd57378 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -410,7 +410,7 @@ static int multifd_send_pages(QEMUFile *f) MultiFDPages_t *pages = multifd_send_state->pages; uint64_t transferred; - if (atomic_read(&multifd_send_state->exiting)) { + if (qatomic_read(&multifd_send_state->exiting)) { return -1; } @@ -508,7 +508,7 @@ static void multifd_send_terminate_threads(Error *err) * threads at the same time, we can end calling this function * twice. */ - if (atomic_xchg(&multifd_send_state->exiting, 1)) { + if (qatomic_xchg(&multifd_send_state->exiting, 1)) { return; } @@ -632,7 +632,7 @@ static void *multifd_send_thread(void *opaque) while (true) { qemu_sem_wait(&p->sem); - if (atomic_read(&multifd_send_state->exiting)) { + if (qatomic_read(&multifd_send_state->exiting)) { break; } qemu_mutex_lock(&p->mutex); @@ -760,7 +760,7 @@ int multifd_save_setup(Error **errp) multifd_send_state->params = g_new0(MultiFDSendParams, thread_count); multifd_send_state->pages = multifd_pages_init(page_count); qemu_sem_init(&multifd_send_state->channels_ready, 0); - atomic_set(&multifd_send_state->exiting, 0); + qatomic_set(&multifd_send_state->exiting, 0); multifd_send_state->ops = multifd_ops[migrate_multifd_compression()]; for (i = 0; i < thread_count; i++) { @@ -997,7 +997,7 @@ int multifd_load_setup(Error **errp) thread_count = migrate_multifd_channels(); multifd_recv_state = g_malloc0(sizeof(*multifd_recv_state)); multifd_recv_state->params = g_new0(MultiFDRecvParams, thread_count); - atomic_set(&multifd_recv_state->count, 0); + qatomic_set(&multifd_recv_state->count, 0); qemu_sem_init(&multifd_recv_state->sem_sync, 0); multifd_recv_state->ops = multifd_ops[migrate_multifd_compression()]; @@ -1037,7 +1037,7 @@ bool multifd_recv_all_channels_created(void) return true; } - return thread_count == atomic_read(&multifd_recv_state->count); + return thread_count == qatomic_read(&multifd_recv_state->count); } /* @@ -1058,7 +1058,7 @@ bool multifd_recv_new_channel(QIOChannel *ioc, Error **errp) error_propagate_prepend(errp, local_err, "failed to receive packet" " via multifd channel %d: ", - atomic_read(&multifd_recv_state->count)); + qatomic_read(&multifd_recv_state->count)); return false; } trace_multifd_recv_new_channel(id); @@ -1079,7 +1079,7 @@ bool multifd_recv_new_channel(QIOChannel *ioc, Error **errp) p->running = true; qemu_thread_create(&p->thread, p->name, multifd_recv_thread, p, QEMU_THREAD_JOINABLE); - atomic_inc(&multifd_recv_state->count); - return atomic_read(&multifd_recv_state->count) == + qatomic_inc(&multifd_recv_state->count); + return qatomic_read(&multifd_recv_state->count) == migrate_multifd_channels(); } -- cgit v1.1