[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Libunwind-devel] [PATCH 07/35] Use __sync builtin atomics on all archit
From: |
Tommi Rantala |
Subject: |
[Libunwind-devel] [PATCH 07/35] Use __sync builtin atomics on all architectures if available |
Date: |
Tue, 18 Sep 2012 16:31:16 +0300 |
We can use the __sync builtin atomics also on other architectures than
IA64. GCC 4.7 documentation notes that these builtins are ``legacy'' --
adding support for the newer GCC __atomic atomics should be fairly easy.
---
configure.ac | 13 +++++++++++++
include/libunwind_i.h | 8 ++++----
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/configure.ac b/configure.ac
index afd63c1..0176c24 100644
--- a/configure.ac
+++ b/configure.ac
@@ -283,6 +283,19 @@ if test x$have__builtin___clear_cache = xyes; then
fi
AC_MSG_RESULT([$have__builtin___clear_cache])
+AC_MSG_CHECKING([for __sync atomics])
+AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM([[]], [[
+ __sync_fetch_and_add((int *)0, 1);
+ ]])],
+ [have_sync_atomics=yes],
+ [have_sync_atomics=no])
+if test x$have_sync_atomics = xyes; then
+ AC_DEFINE([HAVE_SYNC_ATOMICS], [1],
+ [Defined if __sync atomics are available])
+fi
+AC_MSG_RESULT([$have_sync_atomics])
+
CCASFLAGS="${CCASFLAGS} ${CPPFLAGS}"
arch="$target_arch"
diff --git a/include/libunwind_i.h b/include/libunwind_i.h
index acc6bbb..d7554b2 100644
--- a/include/libunwind_i.h
+++ b/include/libunwind_i.h
@@ -130,13 +130,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. */
# define fetch_and_add1(_ptr) AO_fetch_and_add1(_ptr)
# define fetch_and_add(_ptr, value) AO_fetch_and_add(_ptr, value)
# define HAVE_FETCH_AND_ADD
-#else
+#elif defined(HAVE_SYNC_ATOMICS) || defined(HAVE_IA64INTRIN_H)
# ifdef HAVE_IA64INTRIN_H
# include <ia64intrin.h>
-# define fetch_and_add1(_ptr) __sync_fetch_and_add(_ptr, 1)
-# define fetch_and_add(_ptr, value) __sync_fetch_and_add(_ptr, value)
-# define HAVE_FETCH_AND_ADD
# endif
+# define fetch_and_add1(_ptr) __sync_fetch_and_add(_ptr, 1)
+# define fetch_and_add(_ptr, value) __sync_fetch_and_add(_ptr, value)
+# define HAVE_FETCH_AND_ADD
#endif
#define atomic_read(ptr) (*(ptr))
--
1.7.9.5
- Re: [Libunwind-devel] [PATCH 04/35] Align `sos_memory' to MAX_ALIGN, (continued)
- [Libunwind-devel] [PATCH 01/35] Remove unneeded `atomic_ops.h' inclusion in `dwarf.h', Tommi Rantala, 2012/09/18
- [Libunwind-devel] [PATCH 02/35] Use GCC __BIGGEST_ALIGNMENT__ for sos-pool MAX_ALIGN, Tommi Rantala, 2012/09/18
- [Libunwind-devel] [PATCH 03/35] Workaround non-power-of-two i386 sizeof(long double) in src/mi/mempool.c, Tommi Rantala, 2012/09/18
- [Libunwind-devel] [PATCH 11/35] PPC: remove unused `PAGE_START' macro from Ginit.c, Tommi Rantala, 2012/09/18
- [Libunwind-devel] [PATCH 05/35] Simplify `sos_alloc()' implementation, Tommi Rantala, 2012/09/18
- [Libunwind-devel] [PATCH 09/35] IA64: avoid -Wunused-but-set-variable in src/ia64/init.h, Tommi Rantala, 2012/09/18
- [Libunwind-devel] [PATCH 10/35] Remove unused src/x86_64/Lis_signal_frame.c, Tommi Rantala, 2012/09/18
- [Libunwind-devel] [PATCH 15/35] Clear out `ip' to avoid -Wuninitialized warning in tests/test-coredump-unwind.c, Tommi Rantala, 2012/09/18
- [Libunwind-devel] [PATCH 07/35] Use __sync builtin atomics on all architectures if available,
Tommi Rantala <=
- [Libunwind-devel] [PATCH 13/35] HPPA: kludge out unused variable in unw_get_save_loc() stub, Tommi Rantala, 2012/09/18
- [Libunwind-devel] [PATCH 08/35] Apply UNW_ALIGN more in src/mi/mempool.c, Tommi Rantala, 2012/09/18
- [Libunwind-devel] [PATCH 12/35] HPPA: properly check dwarf_get() return value in unw_step(), Tommi Rantala, 2012/09/18
- [Libunwind-devel] [PATCH 17/35] Workaround volatileness warning in tests/ia64-test-setjmp.c, Tommi Rantala, 2012/09/18
- [Libunwind-devel] [PATCH 14/35] Default to non-verbose mode in Ltest-cxx-exceptions, Tommi Rantala, 2012/09/18
- [Libunwind-devel] [PATCH 16/35] Avoid -Wunused-value warning in tests/Gia64-test-stack.c, Tommi Rantala, 2012/09/18
- [Libunwind-devel] [PATCH 20/35] Annotate potentially unused variable in tests/test-coredump-unwind.c, Tommi Rantala, 2012/09/18