Skip to content

Commit

Permalink
Improve usage of libatomic_ops for word size atomics
Browse files Browse the repository at this point in the history
Use AO_fetch_compare_and_swap*() when present
  • Loading branch information
rickard-green committed Nov 10, 2014
1 parent 9417f04 commit d5a4eb5
Show file tree
Hide file tree
Showing 9 changed files with 469 additions and 10 deletions.
22 changes: 22 additions & 0 deletions aclocal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -1421,9 +1421,31 @@ case "$THR_LIB_NAME" in
int z;
AO_nop_full();
#if defined(AO_HAVE_store)
AO_store(&x, (AO_t) 0);
#elif defined(AO_HAVE_store_release)
AO_store_release(&x, (AO_t) 0);
#else
#error No store
#endif
#if defined(AO_HAVE_load)
z = AO_load(&x);
#elif defined(AO_HAVE_load_acquire)
z = AO_load_acquire(&x);
#else
#error No load
#endif
#if defined(AO_HAVE_compare_and_swap_full)
z = AO_compare_and_swap_full(&x, (AO_t) 0, (AO_t) 1);
#elif defined(AO_HAVE_compare_and_swap_release)
z = AO_compare_and_swap_release(&x, (AO_t) 0, (AO_t) 1);
#elif defined(AO_HAVE_compare_and_swap_acquire)
z = AO_compare_and_swap_acquire(&x, (AO_t) 0, (AO_t) 1);
#elif defined(AO_HAVE_compare_and_swap)
z = AO_compare_and_swap(&x, (AO_t) 0, (AO_t) 1);
#else
#error No compare_and_swap
#endif
],
[ethr_have_native_atomics=yes
ethr_have_libatomic_ops=yes])
Expand Down
22 changes: 22 additions & 0 deletions erts/aclocal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -1421,9 +1421,31 @@ case "$THR_LIB_NAME" in
int z;
AO_nop_full();
#if defined(AO_HAVE_store)
AO_store(&x, (AO_t) 0);
#elif defined(AO_HAVE_store_release)
AO_store_release(&x, (AO_t) 0);
#else
#error No store
#endif
#if defined(AO_HAVE_load)
z = AO_load(&x);
#elif defined(AO_HAVE_load_acquire)
z = AO_load_acquire(&x);
#else
#error No load
#endif
#if defined(AO_HAVE_compare_and_swap_full)
z = AO_compare_and_swap_full(&x, (AO_t) 0, (AO_t) 1);
#elif defined(AO_HAVE_compare_and_swap_release)
z = AO_compare_and_swap_release(&x, (AO_t) 0, (AO_t) 1);
#elif defined(AO_HAVE_compare_and_swap_acquire)
z = AO_compare_and_swap_acquire(&x, (AO_t) 0, (AO_t) 1);
#elif defined(AO_HAVE_compare_and_swap)
z = AO_compare_and_swap(&x, (AO_t) 0, (AO_t) 1);
#else
#error No compare_and_swap
#endif
],
[ethr_have_native_atomics=yes
ethr_have_libatomic_ops=yes])
Expand Down
2 changes: 1 addition & 1 deletion erts/include/internal/ethread.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ extern ethr_runtime_t ethr_runtime__;
# include "sparc64/ethread.h"
# endif
# endif
# include "gcc/ethread.h"
# include "libatomic_ops/ethread.h"
# include "gcc/ethread.h"
# endif
# elif defined(ETHR_HAVE_LIBATOMIC_OPS)
# include "libatomic_ops/ethread.h"
Expand Down
Loading

0 comments on commit d5a4eb5

Please sign in to comment.