[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] qemu/atomic.h: prefix qemu_ to solve <stdatomic.h> collisions
- To: Stefan Hajnoczi <stefanha@xxxxxxxxxx>, qemu-devel@xxxxxxxxxx
- From: Paolo Bonzini <pbonzini@xxxxxxxxxx>
- Date: Tue, 22 Sep 2020 08:27:05 +0200
- Authentication-results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@xxxxxxxxxx
- Cc: qemu-riscv@xxxxxxxxxx, Fam Zheng <fam@xxxxxxxxxx>, Yoshinori Sato <ysato@xxxxxxxxxxxxxxxxxxxx>, Alberto Garcia <berto@xxxxxxxxxx>, Jiri Slaby <jslaby@xxxxxxx>, Richard Henderson <rth@xxxxxxxxxxx>, Peter Lieven <pl@xxxxxxx>, David Hildenbrand <david@xxxxxxxxxx>, Halil Pasic <pasic@xxxxxxxxxxxxx>, Eric Blake <eblake@xxxxxxxxxx>, Max Reitz <mreitz@xxxxxxxxxx>, Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>, Daniel P. Berrangé <berrange@xxxxxxxxxx>, Palmer Dabbelt <palmer@xxxxxxxxxxx>, Markus Armbruster <armbru@xxxxxxxxxx>, kvm@xxxxxxxxxxxxxxx, Yuval Shaia <yuval.shaia.ml@xxxxxxxxx>, "Michael S. Tsirkin" <mst@xxxxxxxxxx>, Cornelia Huck <cohuck@xxxxxxxxxx>, qemu-block@xxxxxxxxxx, Stefan Weil <sw@xxxxxxxxxxx>, "Dr. David Alan Gilbert" <dgilbert@xxxxxxxxxx>, Michael Roth <mdroth@xxxxxxxxxxxxxxxxxx>, Jiaxun Yang <jiaxun.yang@xxxxxxxxxxx>, John Snow <jsnow@xxxxxxxxxx>, Max Filippov <jcmvbkbc@xxxxxxxxx>, Marcel Apfelbaum <marcel.apfelbaum@xxxxxxxxx>, Alistair Francis <Alistair.Francis@xxxxxxx>, Aurelien Jarno <aurelien@xxxxxxxxxxx>, Aleksandar Rikalo <aleksandar.rikalo@xxxxxxxxxx>, Huacai Chen <chenhc@xxxxxxxxxx>, Aleksandar Markovic <aleksandar.qemu.devel@xxxxxxxxx>, Eduardo Habkost <ehabkost@xxxxxxxxxx>, Christian Borntraeger <borntraeger@xxxxxxxxxx>, Sunil Muthuswamy <sunilmut@xxxxxxxxxxxxx>, Thomas Huth <thuth@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>, Gerd Hoffmann <kraxel@xxxxxxxxxx>, Peter Maydell <peter.maydell@xxxxxxxxxx>, Liu Yuan <namei.unix@xxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Kevin Wolf <kwolf@xxxxxxxxxx>, Bastian Koppelmann <kbastian@xxxxxxxxxxxxxxxxxxxxx>, Sagar Karandikar <sagark@xxxxxxxxxxxxxxxxx>, Jason Wang <jasowang@xxxxxxxxxx>, Laurent Vivier <laurent@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, Matthew Rosato <mjrosato@xxxxxxxxxxxxx>, sheepdog@xxxxxxxxxxxxxx, qemu-s390x@xxxxxxxxxx, qemu-arm@xxxxxxxxxx, Juan Quintela <quintela@xxxxxxxxxx>, Hailiang Zhang <zhang.zhanghailiang@xxxxxxxxxx>
- Delivery-date: Tue, 22 Sep 2020 06:27:15 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 21/09/20 18:23, Stefan Hajnoczi wrote:
> 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 qemu_ so that atomic.h
> and <stdatomic.h> can co-exist.
>
> This patch was generated using:
>
> $ git diff | grep -o '\<atomic_[a-z0-9_]\+' | sort -u
> >/tmp/changed_identifiers
> $ for identifier in $(</tmp/changed_identifiers64); do \
> sed -i "s%\<$identifier\>%qemu_$identifier%" $(git grep -l
> "\<$identifier\>") \
> done
It's certainly a good idea but it's quite verbose.
What about using atomic__* as the prefix? It is not very common in QEMU
but there are some cases (and I cannot think of anything better).
Paolo
|