add uatomic_generic.h, use it for common definitions
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 1 Mar 2010 18:57:00 +0000 (13:57 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Mon, 1 Mar 2010 18:57:00 +0000 (13:57 -0500)
commit8760d94e0ef6d52260765a9246aaac073613055e
tree87f56b4246f427e1154a695b89ec7d448428d863
parent35cb42646126bb629dadfe1a16f11124a1c8922c
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>
Makefile.am
tests/test_uatomic.c
urcu/uatomic_arch_ppc.h
urcu/uatomic_arch_s390.h
urcu/uatomic_arch_sparc64.h
urcu/uatomic_arch_x86.h
urcu/uatomic_generic.h [new file with mode: 0644]
This page took 0.055752 seconds and 4 git commands to generate.