ce2823b8f42cdb77580915e9be0eebca4ae7f15c
[musl] / arch / mips / atomic_arch.h
1 #define a_ll a_ll
2 static inline int a_ll(volatile int *p)
3 {
4         int v;
5         __asm__ __volatile__ (
6                 ".set push ; .set mips2\n\t"
7                 "ll %0, %1"
8                 "\n\t.set pop"
9                 : "=r"(v) : "m"(*p));
10         return v;
11 }
12
13 #define a_sc a_sc
14 static inline int a_sc(volatile int *p, int v)
15 {
16         int r;
17         __asm__ __volatile__ (
18                 ".set push ; .set mips2\n\t"
19                 "sc %0, %1"
20                 "\n\t.set pop"
21                 : "=r"(r), "=m"(*p) : "0"(v) : "memory");
22         return r;
23 }
24
25 #define a_barrier a_barrier
26 static inline void a_barrier()
27 {
28         /* mips2 sync, but using too many directives causes
29          * gcc not to inline it, so encode with .long instead. */
30         __asm__ __volatile__ (".long 0xf" : : : "memory");
31 #if 0
32         __asm__ __volatile__ (
33                 ".set push ; .set mips2 ; sync ; .set pop"
34                 : : : "memory");
35 #endif
36 }
37
38 #define a_pre_llsc a_barrier
39 #define a_post_llsc a_barrier