]> git.ipfire.org Git - ipfire-3.x.git/blob - directfb/patches/DirectFB-1.5.3-gcc-atomics-on-arm.patch
1f488e95213649b0126c9475b0e7e4d24c1bf2cf
[ipfire-3.x.git] / directfb / patches / DirectFB-1.5.3-gcc-atomics-on-arm.patch
1 --- DirectFB-1.5.3_orig/lib/direct/atomic.h 2011-07-31 14:51:06.000000000 -0400
2 +++ DirectFB-1.5.3/lib/direct/atomic.h 2012-05-09 01:24:02.692169840 -0400
3 @@ -185,20 +185,13 @@
4
5 #if defined(ARCH_ARM) && !defined(ARCH_IWMMXT)
6
7 -static inline int _D__atomic_cmpxchg(volatile int *ptr, int old, int new)
8 +static inline int _D__atomic_cmpxchg(volatile int *ptr, int old, int _new)
9 {
10 - unsigned long oldval, res;
11
12 - do {
13 - __asm__ __volatile__("@ atomic_cmpxchg\n"
14 - "ldrex %1, [%2]\n"
15 - "mov %0, #0\n"
16 - "teq %1, %3\n"
17 - "strexeq %0, %4, [%2]\n"
18 - : "=&r" (res), "=&r" (oldval)
19 - : "r" (ptr), "Ir" (old), "r" (new)
20 - : "cc");
21 - } while (res);
22 + unsigned long oldval = old;
23 +
24 + __atomic_compare_exchange_n(ptr, &oldval, _new,
25 + false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
26
27 return oldval;
28 }
29 @@ -220,24 +213,14 @@ static inline int _D__atomic_cmpxchg(vol
30
31 static inline int _D__atomic_add_return(int i, volatile int *v)
32 {
33 - unsigned long tmp;
34 - int result;
35
36 - __asm__ __volatile__("@ atomic_add_return\n"
37 -"1: ldrex %0, [%2]\n"
38 -" add %0, %0, %3\n"
39 -" strex %1, %0, [%2]\n"
40 -" teq %1, #0\n"
41 -" bne 1b"
42 - : "=&r" (result), "=&r" (tmp)
43 - : "r" (v), "Ir" (i)
44 - : "cc");
45 + int result = __atomic_add_fetch(v, i, __ATOMIC_SEQ_CST);
46
47 return result;
48 }
49
50 #define D_SYNC_ADD_AND_FETCH( ptr, value ) \
51 - (_D__atomic_add_return( (int) (value), (void*) (ptr) ))
52 + (_D__atomic_add_return( (int) (value), (volatile int*) (ptr) ))
53
54 #endif
55
56 @@ -308,7 +291,7 @@ static inline int _D__atomic_add_return(
57 }
58
59 #define D_SYNC_ADD_AND_FETCH( ptr, value ) \
60 - (_D__atomic_add_return( (int) (value), (void*) (ptr) ))
61 + (_D__atomic_add_return( (int) (value), (volatile int*) (ptr) ))
62
63 #endif
64