From: Paolo Bonzini Date: Mon, 1 Mar 2010 18:57:00 +0000 (-0500) Subject: add uatomic_generic.h, use it for common definitions X-Git-Tag: v0.4.2~15 X-Git-Url: https://git.lttng.org/?a=commitdiff_plain;h=8760d94e0ef6d52260765a9246aaac073613055e;hp=8760d94e0ef6d52260765a9246aaac073613055e;p=urcu.git 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 Signed-off-by: Mathieu Desnoyers ---