summaryrefslogtreecommitdiff
path: root/recipes/mozilla/firefox-3.6.2/Bug405992.atomic.nspr.diff
blob: f54f916a6a4ec60b2a3bb8c421476ea8fddefb1a (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
#    Add atomic operations for ARM.
diff --git a/nsprpub/pr/include/md/_linux.h b/nsprpub/pr/include/md/_linux.h
index 5b794c5..cb8d58e 100644
--- a/nsprpub/pr/include/md/_linux.h
+++ b/nsprpub/pr/include/md/_linux.h
@@ -194,6 +194,42 @@ extern PRInt32 _PR_x86_64_AtomicSet(PRInt32 *val, PRInt32 newval);
 })
 #endif
 
+#if defined(__arm__)
+#define _PR_HAVE_ATOMIC_OPS
+#define _MD_INIT_ATOMIC()
+
+typedef int (__kernel_cmpxchg_t)(int oldval, int newval, volatile int *ptr);
+#define __kernel_cmpxchg (*(__kernel_cmpxchg_t *)0xffff0fc0)
+
+#define _MD_ATOMIC_INCREMENT(ptr) _MD_ATOMIC_ADD(ptr, 1)
+#define _MD_ATOMIC_DECREMENT(ptr) _MD_ATOMIC_ADD(ptr, -1)
+#define _MD_ATOMIC_ADD(ptr, n)                  \
+    ({                                          \
+        PRInt32 ov, nv;                         \
+        volatile PRInt32 *vp = (ptr);           \
+                                                \
+        do {                                    \
+            ov = *vp;                           \
+            nv = ov + (n);                      \
+        }                                       \
+        while (__kernel_cmpxchg(ov, nv, vp));   \
+                                                \
+        nv;                                     \
+    })
+#define _MD_ATOMIC_SET(ptr, nv)                 \
+    ({                                          \
+        PRInt32 ov;                             \
+        volatile PRInt32 *vp = (ptr);           \
+                                                \
+        do {                                    \
+            ov = *vp;                           \
+        }                                       \
+        while (__kernel_cmpxchg(ov, (nv), vp)); \
+                                                \
+        ov;                                     \
+    })
+#endif
+
 #define USE_SETJMP
 #if defined(__GLIBC__) && __GLIBC__ >= 2
 #define _PR_POLL_AVAILABLE