5ad7ff6...
by
Paolo Bonzini <email address hidden>
lock-free queue with RCU-based garbage collection
A lock-free queue example using RCU to avoid the need for double-word
compare-and-swap and, at the same time, to implement efficient garbage
collection. I tested it lightly, and I don't think it's fully ready
for inclusion. It does need the previous two patches to avoid deadlocks,
so I did test it somewhat. :-)
See individual files for detailed comments on how it works.
Cc: Paul E. McKenney <email address hidden>
1b27a77...
by
Paolo Bonzini <email address hidden>
centralize definition of BITS_PER_LONG
Use __SIZEOF_LONG__, defined by GCC 4.3 or later, or _LP64, defined
by GCC 3.4 or later.
8760d94...
by
Paolo Bonzini <email address hidden>
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.