qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PULL 13/13] qemu/atomic.h: rename atomic_ to qatomic_


From: Andrew Jones
Subject: Re: [PULL 13/13] qemu/atomic.h: rename atomic_ to qatomic_
Date: Wed, 30 Sep 2020 17:28:05 +0200

On Wed, Sep 23, 2020 at 05:10:31PM +0100, 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 '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>
> ---
>  include/qemu/atomic.h                         | 248 +++++++++---------
>  docs/devel/lockcnt.txt                        |   8 +-
>  docs/devel/rcu.txt                            |  34 +--
>  accel/tcg/atomic_template.h                   |  20 +-
>  include/block/aio-wait.h                      |   4 +-
>  include/block/aio.h                           |   8 +-
>  include/exec/cpu_ldst.h                       |   2 +-
>  include/exec/exec-all.h                       |   6 +-
>  include/exec/log.h                            |   6 +-
>  include/exec/memory.h                         |   2 +-
>  include/exec/ram_addr.h                       |  26 +-
>  include/exec/ramlist.h                        |   2 +-
>  include/exec/tb-lookup.h                      |   4 +-
>  include/hw/core/cpu.h                         |   2 +-
>  include/qemu/atomic128.h                      |   6 +-
>  include/qemu/bitops.h                         |   2 +-
>  include/qemu/coroutine.h                      |   2 +-
>  include/qemu/log.h                            |   6 +-
>  include/qemu/queue.h                          |   7 +-
>  include/qemu/rcu.h                            |  10 +-
>  include/qemu/rcu_queue.h                      | 100 +++----
>  include/qemu/seqlock.h                        |   8 +-
>  include/qemu/stats64.h                        |  28 +-
>  include/qemu/thread.h                         |  24 +-
>  .../infiniband/hw/vmw_pvrdma/pvrdma_ring.h    |  14 +-

Hi Stefan,

pvrdma_ring.h is an update-linux-headers.sh file. When running the
script again we lose the atomic_ to qatomic_ renaming. I've hacked
the script by adding

 -e 's/\batomic_read/qatomic_read/g;s/\batomic_set/qatomic_set/g'

to the cp_portable() sed command, but only considering the two
qatomic_ functions currently used is obviously not a complete
solution.

Any ideas?

Thanks,
drew




reply via email to

[Prev in Thread] Current Thread [Next in Thread]