diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-02-17 10:03:16 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-02-17 14:37:30 +0300 |
commit | ce88f00f7a71a84c4cb0987146477a677f3d7a84 (patch) | |
tree | 4a30121541492eec21cfa9aaf8cde3cd04c3e678 | |
parent | c3dc5b622249a75018ec0cdb0545ef5502dc820f (diff) | |
download | libatomic_ops-ce88f00f7a71a84c4cb0987146477a677f3d7a84.tar.gz |
Move gcc-4/alpha workaround outside AO_stack_pop_explicit_aux_acquire
(refactoring)
* src/atomic_ops_stack.c [AO_USE_ALMOST_LOCK_FREE && __alpha__
&& __GNUC__==4] (AO_EXPECT_FALSE): Redefine to expr (before
AO_stack_push_explicit_aux_release); move comment from
AO_stack_pop_explicit_aux_acquire.
* src/atomic_ops_stack.c [AO_USE_ALMOST_LOCK_FREE && __alpha__
&& __GNUC__==4] (AO_stack_pop_explicit_aux_acquire): Use
AO_EXPECT_FALSE (in the same way as for non-alpha case).
-rw-r--r-- | src/atomic_ops_stack.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/atomic_ops_stack.c b/src/atomic_ops_stack.c index 3a4c665..35db1e2 100644 --- a/src/atomic_ops_stack.c +++ b/src/atomic_ops_stack.c @@ -67,6 +67,13 @@ AO_API AO_t *AO_real_next_ptr(AO_t next) } /* extern "C" */ # endif +# if defined(__alpha__) && (__GNUC__ == 4) + /* Workaround __builtin_expect bug found in */ + /* gcc-4.6.3/alpha causing test_stack failure. */ +# undef AO_EXPECT_FALSE +# define AO_EXPECT_FALSE(expr) (expr) +# endif + /* LIFO linked lists based on compare-and-swap. We need to avoid */ /* the case of a node deletion and reinsertion while I'm deleting */ /* it, since that may cause my CAS to succeed eventhough the next */ @@ -193,27 +200,17 @@ AO_API AO_t *AO_real_next_ptr(AO_t next) /* list. We need to make sure that first is still the first entry */ /* on the list. Otherwise it is possible that a reinsertion of it */ /* was already started before we added the black list entry. */ -# if defined(__alpha__) && (__GNUC__ == 4) - if (first != AO_load_acquire(list)) - /* Workaround __builtin_expect bug found in */ - /* gcc-4.6.3/alpha causing test_stack failure. */ -# else - if (AO_EXPECT_FALSE(first != AO_load_acquire(list))) + if (AO_EXPECT_FALSE(first != AO_load_acquire(list))) /* Workaround test failure on AIX, at least, by */ /* using acquire ordering semantics for this */ /* load. Probably, it is not the right fix. */ -# endif { AO_store_release(a->AO_stack_bl+i, 0); goto retry; } first_ptr = AO_REAL_NEXT_PTR(first); next = AO_load_next(first_ptr); -# if defined(__alpha__) && (__GNUC__ == 4) - if (!AO_compare_and_swap_release(list, first, next)) -# else - if (AO_EXPECT_FALSE(!AO_compare_and_swap_release(list, first, next))) -# endif + if (AO_EXPECT_FALSE(!AO_compare_and_swap_release(list, first, next))) { AO_store_release(a->AO_stack_bl+i, 0); goto retry; |