blob: 0dff2c86dcdacfbc02895f7a90bd02999f606dcf [file] [log] [blame]
Patrick Williamsf1e5d692016-03-30 15:21:19 -05001From 24484e80b3e329c9edee1995e102f8612eedb79c Mon Sep 17 00:00:00 2001
2From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3Date: Tue, 13 May 2014 23:32:27 +0200
4Subject: [PATCH] Add AO_REQUIRE_CAS to fix build on ARM < v6
5
6ARM earlier than ARMv6, such as ARMv4 and ARMv5 do not provide
7optimize atomic operations in libatomic_ops. Since libunwind is using
8such operations, it should define AO_REQUIRE_CAS before including
9<atomic_ops.h> so that libatomic_ops knows it should use emulated
10atomic operations instead (even though they are obviously a lot more
11expensive).
12
13Also, while real atomic operations are all inline functions and
14therefore linking against libatomic_ops was not required, the emulated
15atomic operations actually require linking against libatomic_ops, so
16the commented AC_CHECK_LIB test in acinclude.m4 is uncommented to make
17sure we link against libatomic_ops.
18
19Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050020Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Patrick Williamsf1e5d692016-03-30 15:21:19 -050021
22Upstream-Status: Pending
23Taken from:
24https://raw.githubusercontent.com/rdnetto/teapot-buildroot/master/package/libunwind/libunwind-02-Add-AO_REQUIRE_CAS-to-fix-build-on-ARM-v6.patch
25
26---
27 acinclude.m4 | 8 +-------
28 include/libunwind_i.h | 1 +
29 2 files changed, 2 insertions(+), 7 deletions(-)
30
31diff --git a/acinclude.m4 b/acinclude.m4
32index 497f7c2..9c15af1 100644
33--- a/acinclude.m4
34+++ b/acinclude.m4
35@@ -22,11 +22,5 @@ fi])
36 AC_DEFUN([CHECK_ATOMIC_OPS],
37 [dnl Check whether the system has the atomic_ops package installed.
38 AC_CHECK_HEADERS(atomic_ops.h)
39-#
40-# Don't link against libatomic_ops for now. We don't want libunwind
41-# to depend on libatomic_ops.so. Fortunately, none of the platforms
42-# we care about so far need libatomic_ops.a (everything is done via
43-# inline macros).
44-#
45-# AC_CHECK_LIB(atomic_ops, main)
46+ AC_CHECK_LIB(atomic_ops, main)
47 ])
48diff --git a/include/libunwind_i.h b/include/libunwind_i.h
49index 23f615e..deabdfd 100644
50--- a/include/libunwind_i.h
51+++ b/include/libunwind_i.h
52@@ -95,6 +95,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
53 (pthread_mutex_unlock != NULL ? pthread_mutex_unlock (l) : 0)
54
55 #ifdef HAVE_ATOMIC_OPS_H
56+# define AO_REQUIRE_CAS
57 # include <atomic_ops.h>
58 static inline int
59 cmpxchg_ptr (void *addr, void *old, void *new)
60--
611.9.2
62