add uatomic_generic.h, use it for common definitions
uatomic_generic.h can be included by uatomic_arch_*.h to provide useful
default definitions. uatomic_arch_*.h can define whatever builtins
it wants to override, then uatomic_generic.h will provide what is not
already defined, as follows:
- uatomic_cmpxchg will use __sync_val_compare_and_swap builtins;
- uatomic_add_return will use __sync_fetch_and_add if uatomic_arch_*.h
did not provide a definition of uatomic_cmpxchg. If it did, we assume
__sync builtins are buggy or otherwise undesirable on this platform,
so uatomic_generic.h will implement uatomic_add_return in terms of
uatomic_cmpxchg too.
- uatomic_xchg is like uatomic_add_return. However, since GCC does
not provide an adequate builtin, it needs to use a compare-and-swap
loop using __sync_bool_compare_and_swap if uatomic_cmpxchg is not
provided.
- uatomic_sub_return/uatomic_add/uatomic_sub will be implemented
in terms of uatomic_add_return;
- uatomic_inc/uatomic_dec will be implemented in terms of uatomic_add.
After this patch, uatomic_generic.h is already used for the latter two
categories. The next patch will use uatomic_generic.h whenever there is
no assembly code involved, or otherwise it makes no difference to use
uatomic_generic.h. We keep custom per-arch macros to provide support for
compilers back to early GCC 3.x versions; however future ports may
not have this limitation.
The hunk in tests/test_uatomic.c is only needed for bisectability
and will be removed later.
[edit by Mathieu Desnoyers]
Fixed Makefile.am conflict.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
This page took 0.028482 seconds and 4 git commands to generate.