2018-09-05 16:43:34 +00:00
|
|
|
#include "libc.h"
|
|
|
|
|
2016-01-21 19:28:15 +00:00
|
|
|
#if defined(__SH4A__)
|
2015-05-17 18:46:38 +00:00
|
|
|
|
2016-01-21 19:28:15 +00:00
|
|
|
#define a_ll a_ll
|
|
|
|
static inline int a_ll(volatile int *p)
|
2015-05-17 18:46:38 +00:00
|
|
|
{
|
2016-01-21 19:28:15 +00:00
|
|
|
int v;
|
|
|
|
__asm__ __volatile__ ("movli.l @%1, %0" : "=z"(v) : "r"(p), "m"(*p));
|
|
|
|
return v;
|
2015-05-17 18:46:38 +00:00
|
|
|
}
|
|
|
|
|
2016-01-21 19:28:15 +00:00
|
|
|
#define a_sc a_sc
|
|
|
|
static inline int a_sc(volatile int *p, int v)
|
2015-05-17 18:46:38 +00:00
|
|
|
{
|
2016-01-21 19:28:15 +00:00
|
|
|
int r;
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
"movco.l %2, @%3 ; movt %0"
|
|
|
|
: "=r"(r), "=m"(*p) : "z"(v), "r"(p) : "memory", "cc");
|
|
|
|
return r;
|
2015-05-17 18:46:38 +00:00
|
|
|
}
|
|
|
|
|
2016-01-21 19:28:15 +00:00
|
|
|
#define a_barrier a_barrier
|
|
|
|
static inline void a_barrier()
|
2015-05-17 18:46:38 +00:00
|
|
|
{
|
2017-07-28 21:05:54 +00:00
|
|
|
__asm__ __volatile__ ("synco" ::: "memory");
|
2015-05-17 18:46:38 +00:00
|
|
|
}
|
|
|
|
|
2016-01-21 19:28:15 +00:00
|
|
|
#define a_pre_llsc a_barrier
|
|
|
|
#define a_post_llsc a_barrier
|
2015-05-17 18:46:38 +00:00
|
|
|
|
2016-01-21 19:28:15 +00:00
|
|
|
#else
|
2015-05-17 18:46:38 +00:00
|
|
|
|
2016-01-21 19:28:15 +00:00
|
|
|
#define a_cas a_cas
|
2018-09-05 16:43:34 +00:00
|
|
|
extern hidden const void *__sh_cas_ptr;
|
2016-01-21 19:28:15 +00:00
|
|
|
static inline int a_cas(volatile int *p, int t, int s)
|
2015-05-17 18:46:38 +00:00
|
|
|
{
|
2016-01-21 19:28:15 +00:00
|
|
|
register int r1 __asm__("r1");
|
|
|
|
register int r2 __asm__("r2") = t;
|
|
|
|
register int r3 __asm__("r3") = s;
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
"jsr @%4 ; nop"
|
|
|
|
: "=r"(r1), "+r"(r3) : "z"(p), "r"(r2), "r"(__sh_cas_ptr)
|
|
|
|
: "memory", "pr", "cc");
|
|
|
|
return r3;
|
2015-05-17 18:46:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|