summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/glibc/glibc/0001-Add-atomic_exchange_relaxed.patch
blob: a33a135f781219743bf6a0d1d14403f04976d763 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
From ce74a620bf9e1a40b7ba06d35160e20633a4d8bb Mon Sep 17 00:00:00 2001
From: Catalin Enache <catalin.enache@windriver.com>
Date: Fri, 7 Jul 2017 13:11:16 +0300
Subject: [PATCH 1/6] Add atomic_exchange_relaxed.

* include/atomic.h (atomic_exchange_relaxed): New

Upstream-Status: Backport

Author: Torvald Riegel <triegel@redhat.com>
Signed-off-by: Catalin Enache <catalin.enache@windriver.com>
---
 ChangeLog        | 4 ++++
 include/atomic.h | 9 +++++++++
 2 files changed, 13 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 0fbda90..cb87279 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2016-08-05  Torvald Riegel  <triegel@redhat.com>
+
+	* include/atomic.h (atomic_exchange_relaxed): New.
+
 2016-01-28  Carlos O'Donell  <carlos@redhat.com>
 	    Alexey Makhalov <amakhalov@vmware.com>
 	    Florian Weimer <fweimer@redhat.com>
diff --git a/include/atomic.h b/include/atomic.h
index ad3db25..129ee24 100644
--- a/include/atomic.h
+++ b/include/atomic.h
@@ -588,6 +588,9 @@ void __atomic_link_error (void);
   __atomic_compare_exchange_n ((mem), (expected), (desired), 1,		      \
     __ATOMIC_RELEASE, __ATOMIC_RELAXED); })
 
+# define atomic_exchange_relaxed(mem, desired) \
+  ({ __atomic_check_size((mem));					      \
+  __atomic_exchange_n ((mem), (desired), __ATOMIC_RELAXED); })
 # define atomic_exchange_acquire(mem, desired) \
   ({ __atomic_check_size((mem));					      \
   __atomic_exchange_n ((mem), (desired), __ATOMIC_ACQUIRE); })
@@ -684,6 +687,12 @@ void __atomic_link_error (void);
    *(expected) == __atg103_expected; })
 # endif
 
+/* XXX Fall back to acquire MO because archs do not define a weaker
+   atomic_exchange.  */
+# ifndef atomic_exchange_relaxed
+#  define atomic_exchange_relaxed(mem, val) \
+   atomic_exchange_acq ((mem), (val))
+# endif
 # ifndef atomic_exchange_acquire
 #  define atomic_exchange_acquire(mem, val) \
    atomic_exchange_acq ((mem), (val))
-- 
2.10.2