summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/glibc/glibc/0006-Fix-atomic_fetch_xor_release.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/glibc/glibc/0006-Fix-atomic_fetch_xor_release.patch')
-rw-r--r--meta/recipes-core/glibc/glibc/0006-Fix-atomic_fetch_xor_release.patch81
1 files changed, 81 insertions, 0 deletions
diff --git a/meta/recipes-core/glibc/glibc/0006-Fix-atomic_fetch_xor_release.patch b/meta/recipes-core/glibc/glibc/0006-Fix-atomic_fetch_xor_release.patch
new file mode 100644
index 0000000000..7616efa183
--- /dev/null
+++ b/meta/recipes-core/glibc/glibc/0006-Fix-atomic_fetch_xor_release.patch
@@ -0,0 +1,81 @@
1From b671f20cc160238b62894d032a55baf85867106e Mon Sep 17 00:00:00 2001
2From: Catalin Enache <catalin.enache@windriver.com>
3Date: Fri, 30 Jun 2017 19:12:43 +0300
4Subject: [PATCH 6/6] Fix atomic_fetch_xor_release.
5
6No code uses atomic_fetch_xor_release except for the upcoming
7conditional variable rewrite. Therefore there is no user
8visible bug here. The use of atomic_compare_and_exchange_bool_rel
9is removed (since it doesn't exist anymore), and is replaced
10by atomic_compare_exchange_weak_release.
11
12We use weak_release because it provides better performance in
13the loop (the weak semantic) and because the xor is release MO
14(the release semantic). We don't reload expected in the loop
15because atomic_compare_and_exchange_weak_release does this for
16us as part of the CAS failure.
17
18It is otherwise a fairly plain conversion that fixes building
19the new condvar for 32-bit x86. Passes all regression tests
20for x86.
21
22Upstream-Status: Backport
23
24Author: Carlos O'Donell <carlos@systemhalted.org>
25Signed-off-by: Catalin Enache <catalin.enache@windriver.com>
26---
27 ChangeLog | 6 ++++++
28 include/atomic.h | 19 +++++++++++--------
29 2 files changed, 17 insertions(+), 8 deletions(-)
30
31diff --git a/ChangeLog b/ChangeLog
32index 44c518b..893262d 100644
33--- a/ChangeLog
34+++ b/ChangeLog
35@@ -1,3 +1,9 @@
36+2016-10-26 Carlos O'Donell <carlos@redhat.com>
37+
38+ * include/atomic.h
39+ [USE_COMPILER_ATOMIC_BUILTINS && !atomic_fetch_xor_release]
40+ (atomic_fetch_xor_release): Use atomic_compare_exchange_weak_release.
41+
42 2017-04-04 Adhemerval Zanella <adhemerval.zanella@linaro.org>
43
44 * nptl/pthreadP.h (USE_REQUEUE_PI): Remove ununsed macro.
45diff --git a/include/atomic.h b/include/atomic.h
46index 5a8e7e7..c8b4664 100644
47--- a/include/atomic.h
48+++ b/include/atomic.h
49@@ -777,18 +777,21 @@ void __atomic_link_error (void);
50 # endif
51
52 # ifndef atomic_fetch_xor_release
53+/* Failing the atomic_compare_exchange_weak_release reloads the value in
54+ __atg104_expected, so we need only do the XOR again and retry. */
55 # define atomic_fetch_xor_release(mem, operand) \
56- ({ __typeof (*(mem)) __atg104_old; \
57- __typeof (mem) __atg104_memp = (mem); \
58+ ({ __typeof (mem) __atg104_memp = (mem); \
59+ __typeof (*(mem)) __atg104_expected = (*__atg104_memp); \
60+ __typeof (*(mem)) __atg104_desired; \
61 __typeof (*(mem)) __atg104_op = (operand); \
62 \
63 do \
64- __atg104_old = (*__atg104_memp); \
65- while (__builtin_expect \
66- (atomic_compare_and_exchange_bool_rel ( \
67- __atg104_memp, __atg104_old ^ __atg104_op, __atg104_old), 0));\
68- \
69- __atg104_old; })
70+ __atg104_desired = __atg104_expected ^ __atg104_op; \
71+ while (__glibc_unlikely \
72+ (atomic_compare_exchange_weak_release ( \
73+ __atg104_memp, &__atg104_expected, __atg104_desired) \
74+ == 0)); \
75+ __atg104_expected; })
76 #endif
77
78 #endif /* !USE_ATOMIC_COMPILER_BUILTINS */
79--
802.10.2
81