add explicit barrier operation to internal atomic.h API

This commit is contained in:
Rich Felker 2014-10-10 18:17:09 -04:00
parent 08b996d180
commit 867b1822f3
9 changed files with 33 additions and 6 deletions

View File

@ -101,7 +101,9 @@ static inline void a_store(volatile int *p, int x)
while (__k_cas(*p, x, p));
}
static inline void a_spin()
#define a_spin a_barrier
static inline void a_barrier()
{
__k_cas(0, 0, &(int){0});
}

View File

@ -96,6 +96,11 @@ static inline void a_spin()
__asm__ __volatile__( "pause" : : : "memory" );
}
static inline void a_barrier()
{
__asm__ __volatile__( "" : : : "memory" );
}
static inline void a_crash()
{
__asm__ __volatile__( "hlt" : : : "memory" );

View File

@ -95,7 +95,9 @@ static inline void a_store(volatile int *p, int x)
: "=m"(*p) : "r"(x) : "memory" );
}
static inline void a_spin()
#define a_spin a_barrier
static inline void a_barrier()
{
a_cas(&(int){0}, 0, 0);
}

View File

@ -135,7 +135,9 @@ static inline void a_store(volatile int *p, int x)
: "+m"(*p) : "r"(x) : "memory" );
}
static inline void a_spin()
#define a_spin a_barrier
static inline void a_barrier()
{
a_cas(&(int){0}, 0, 0);
}

View File

@ -72,7 +72,9 @@ static inline void a_store(volatile int *p, int x)
a_swap(p, x);
}
static inline void a_spin()
#define a_spin a_barrier
static inline void a_barrier()
{
a_cas(&(int){0}, 0, 0);
}

View File

@ -78,7 +78,9 @@ static inline void a_store(volatile int *p, int x)
: "=m"(*p) : "r"(x) : "memory" );
}
static inline void a_spin()
#define a_spin a_barrier
static inline void a_barrier()
{
a_cas(&(int){0}, 0, 0);
}

View File

@ -51,7 +51,9 @@ static inline void a_dec(volatile int *x)
a_fetch_add(x, -1);
}
static inline void a_spin()
#define a_spin a_barrier
static inline void a_barrier()
{
a_cas(&(int){0}, 0, 0);
}

View File

@ -91,6 +91,11 @@ static inline void a_spin()
__asm__ __volatile__( "pause" : : : "memory" );
}
static inline void a_barrier()
{
__asm__ __volatile__( "" : : : "memory" );
}
static inline void a_crash()
{
__asm__ __volatile__( "hlt" : : : "memory" );

View File

@ -91,6 +91,11 @@ static inline void a_spin()
__asm__ __volatile__( "pause" : : : "memory" );
}
static inline void a_barrier()
{
__asm__ __volatile__( "" : : : "memory" );
}
static inline void a_crash()
{
__asm__ __volatile__( "hlt" : : : "memory" );