More fixes for George
This commit was SVN r1323.
Этот коммит содержится в:
родитель
150ff21ef0
Коммит
6f35ec76a8
@ -30,16 +30,16 @@
|
||||
* Atomic compare and set of unsigned 32-bit integer.
|
||||
*
|
||||
* @param addr Address of integer.
|
||||
* @param old Comparison value.
|
||||
* @param new New value to set if comparision is true.
|
||||
* @param oldval Comparison value.
|
||||
* @param newval New value to set if comparision is true.
|
||||
*
|
||||
* Pseudo-code:
|
||||
*
|
||||
* @code
|
||||
* int ompi_atomic_cmpset_32(addr, old, new)
|
||||
* int ompi_atomic_cmpset_32(addr, oldval, newval)
|
||||
* {
|
||||
* if (*addr == old) {
|
||||
* *addr = new;
|
||||
* if (*addr == oldval) {
|
||||
* *addr = newval;
|
||||
* return 1; // success, set value
|
||||
* } else {
|
||||
* return 0; // failure, do not set value
|
||||
@ -48,8 +48,8 @@
|
||||
* @endcode
|
||||
*/
|
||||
static inline int ompi_atomic_cmpset_32(volatile uint32_t *addr,
|
||||
uint32_t old,
|
||||
uint32_t new);
|
||||
uint32_t oldval,
|
||||
uint32_t newval);
|
||||
|
||||
|
||||
/**
|
||||
@ -57,14 +57,14 @@ static inline int ompi_atomic_cmpset_32(volatile uint32_t *addr,
|
||||
* semantics.
|
||||
*
|
||||
* @param addr Address of integer.
|
||||
* @param old Comparison value.
|
||||
* @param new New value to set if comparision is true.
|
||||
* @param oldval Comparison value.
|
||||
* @param newval New value to set if comparision is true.
|
||||
*
|
||||
* See ompi_atomic_cmpset_32 for pseudo-code.
|
||||
*/
|
||||
static inline int ompi_atomic_cmpset_acq_32(volatile uint32_t *addr,
|
||||
uint32_t old,
|
||||
uint32_t new);
|
||||
uint32_t oldval,
|
||||
uint32_t newval);
|
||||
|
||||
|
||||
/**
|
||||
@ -72,28 +72,28 @@ static inline int ompi_atomic_cmpset_acq_32(volatile uint32_t *addr,
|
||||
* semantics.
|
||||
*
|
||||
* @param addr Address of integer.
|
||||
* @param old Comparison value.
|
||||
* @param new New value to set if comparision is true.
|
||||
* @param oldval Comparison value.
|
||||
* @param newval New value to set if comparision is true.
|
||||
*
|
||||
* See ompi_atomic_cmpset_32 for pseudo-code.
|
||||
*/
|
||||
static inline int ompi_atomic_cmpset_rel_32(volatile uint32_t *addr,
|
||||
uint32_t old,
|
||||
uint32_t new);
|
||||
uint32_t oldval,
|
||||
uint32_t newval);
|
||||
|
||||
|
||||
/**
|
||||
* Atomic compare and set of unsigned 64-bit integer.
|
||||
*
|
||||
* @param addr Address of integer.
|
||||
* @param old Comparison value.
|
||||
* @param new New value to set if comparision is true.
|
||||
* @param oldval Comparison value.
|
||||
* @param newval New value to set if comparision is true.
|
||||
*
|
||||
* See ompi_atomic_cmpset_32 for pseudo-code.
|
||||
*/
|
||||
static inline int ompi_atomic_cmpset_64(volatile uint64_t *addr,
|
||||
uint64_t old,
|
||||
uint64_t new);
|
||||
uint64_t oldval,
|
||||
uint64_t newval);
|
||||
|
||||
|
||||
/**
|
||||
@ -101,14 +101,14 @@ static inline int ompi_atomic_cmpset_64(volatile uint64_t *addr,
|
||||
* semantics.
|
||||
*
|
||||
* @param addr Address of integer.
|
||||
* @param old Comparison value.
|
||||
* @param new New value to set if comparision is true.
|
||||
* @param oldval Comparison value.
|
||||
* @param newval New value to set if comparision is true.
|
||||
*
|
||||
* See ompi_atomic_cmpset_32 for pseudo-code.
|
||||
*/
|
||||
static inline int ompi_atomic_cmpset_acq_64(volatile uint64_t *addr,
|
||||
uint64_t old,
|
||||
uint64_t new);
|
||||
uint64_t oldval,
|
||||
uint64_t newval);
|
||||
|
||||
|
||||
/**
|
||||
@ -116,98 +116,98 @@ static inline int ompi_atomic_cmpset_acq_64(volatile uint64_t *addr,
|
||||
* semantics.
|
||||
*
|
||||
* @param addr Address of integer.
|
||||
* @param old Comparison value.
|
||||
* @param new New value to set if comparision is true.
|
||||
* @param oldval Comparison value.
|
||||
* @param newval New value to set if comparision is true.
|
||||
*
|
||||
* See ompi_atomic_cmpset_32 for pseudo-code.
|
||||
*/
|
||||
static inline int ompi_atomic_cmpset_rel_64(volatile uint64_t *addr,
|
||||
uint64_t old,
|
||||
uint64_t new);
|
||||
uint64_t oldval,
|
||||
uint64_t newval);
|
||||
|
||||
|
||||
/**
|
||||
* Atomic compare and set of integer.
|
||||
*
|
||||
* @param addr Address of integer.
|
||||
* @param old Comparison value.
|
||||
* @param new New value to set if comparision is true.
|
||||
* @param oldval Comparison value.
|
||||
* @param newval New value to set if comparision is true.
|
||||
*
|
||||
* See ompi_atomic_cmpset_32 for pseudo-code.
|
||||
*/
|
||||
static inline int ompi_atomic_cmpset_int(volatile int *addr,
|
||||
int old,
|
||||
int new);
|
||||
int oldval,
|
||||
int newval);
|
||||
|
||||
|
||||
/**
|
||||
* Atomic compare and set of integer with acquire semantics.
|
||||
*
|
||||
* @param addr Address of integer.
|
||||
* @param old Comparison value.
|
||||
* @param new New value to set if comparision is true.
|
||||
* @param oldval Comparison value.
|
||||
* @param newval New value to set if comparision is true.
|
||||
*
|
||||
* See ompi_atomic_cmpset_32 for pseudo-code.
|
||||
*/
|
||||
static inline int ompi_atomic_cmpset_acq_int(volatile int *addr,
|
||||
int old,
|
||||
int new);
|
||||
int oldval,
|
||||
int newval);
|
||||
|
||||
|
||||
/**
|
||||
* Atomic compare and set of integer with release semantics.
|
||||
*
|
||||
* @param addr Address of integer.
|
||||
* @param old Comparison value.
|
||||
* @param new New value to set if comparision is true.
|
||||
* @param oldval Comparison value.
|
||||
* @param newval New value to set if comparision is true.
|
||||
*
|
||||
* See ompi_atomic_cmpset_32 for pseudo-code.
|
||||
*/
|
||||
static inline int ompi_atomic_cmpset_rel_int(volatile int *addr,
|
||||
int old,
|
||||
int new);
|
||||
int oldval,
|
||||
int newval);
|
||||
|
||||
|
||||
/**
|
||||
* Atomic compare and set of pointer.
|
||||
*
|
||||
* @param addr Address of integer.
|
||||
* @param old Comparison value.
|
||||
* @param new New value to set if comparision is true.
|
||||
* @param oldval Comparison value.
|
||||
* @param newval New value to set if comparision is true.
|
||||
*
|
||||
* See ompi_atomic_cmpset_32 for pseudo-code.
|
||||
*/
|
||||
static inline int ompi_atomic_cmpset_ptr(volatile void *addr,
|
||||
void *old,
|
||||
void *new);
|
||||
void *oldval,
|
||||
void *newval);
|
||||
|
||||
|
||||
/**
|
||||
* Atomic compare and set of pointer with acquire semantics.
|
||||
*
|
||||
* @param addr Address of integer.
|
||||
* @param old Comparison value.
|
||||
* @param new New value to set if comparision is true.
|
||||
* @param oldval Comparison value.
|
||||
* @param newval New value to set if comparision is true.
|
||||
*
|
||||
* See ompi_atomic_cmpset_32 for pseudo-code.
|
||||
*/
|
||||
static inline int ompi_atomic_cmpset_acq_ptr(volatile void *addr,
|
||||
void *old,
|
||||
void *new);
|
||||
void *oldval,
|
||||
void *newval);
|
||||
|
||||
|
||||
/**
|
||||
* Atomic compare and set of pointer with release semantics.
|
||||
*
|
||||
* @param addr Address of integer.
|
||||
* @param old Comparison value.
|
||||
* @param new New value to set if comparision is true.
|
||||
* @param oldval Comparison value.
|
||||
* @param newval New value to set if comparision is true.
|
||||
*
|
||||
* See ompi_atomic_cmpset_32 for pseudo-code.
|
||||
*/
|
||||
static inline int ompi_atomic_cmpset_rel_ptr(volatile void *addr,
|
||||
void *old,
|
||||
void *new);
|
||||
void *oldval,
|
||||
void *newval);
|
||||
|
||||
/**
|
||||
* Atomically add to a 32-bit integer.
|
||||
@ -276,59 +276,59 @@ static inline int ompi_atomic_add_int(int *addr, int delta);
|
||||
#if SIZEOF_INT == 4
|
||||
|
||||
static inline int ompi_atomic_cmpset_int(volatile int *addr,
|
||||
int old,
|
||||
int new)
|
||||
int oldval,
|
||||
int newval)
|
||||
{
|
||||
return ompi_atomic_cmpset_32((volatile uint32_t *) addr,
|
||||
(uint32_t) old,
|
||||
(uint32_t) new);
|
||||
(uint32_t) oldval,
|
||||
(uint32_t) newval);
|
||||
}
|
||||
|
||||
static inline int ompi_atomic_cmpset_acq_int(volatile int *addr,
|
||||
int old,
|
||||
int new)
|
||||
int oldval,
|
||||
int newval)
|
||||
{
|
||||
return ompi_atomic_cmpset_acq_32((volatile uint32_t *) addr,
|
||||
(uint32_t) old,
|
||||
(uint32_t) new);
|
||||
(uint32_t) oldval,
|
||||
(uint32_t) newval);
|
||||
}
|
||||
|
||||
static inline int ompi_atomic_cmpset_rel_int(volatile int *addr,
|
||||
int old,
|
||||
int new)
|
||||
int oldval,
|
||||
int newval)
|
||||
{
|
||||
return ompi_atomic_cmpset_rel_32((volatile uint32_t *) addr,
|
||||
(uint32_t) old,
|
||||
(uint32_t) new);
|
||||
(uint32_t) oldval,
|
||||
(uint32_t) newval);
|
||||
}
|
||||
|
||||
#elif SIZEOF_INT == 8
|
||||
|
||||
static inline int ompi_atomic_cmpset_int(volatile int *addr,
|
||||
int old,
|
||||
int new)
|
||||
int oldval,
|
||||
int newval)
|
||||
{
|
||||
return ompi_atomic_cmpset_64((volatile uint64_t *) addr,
|
||||
(uint64_t) old,
|
||||
(uint64_t) new);
|
||||
(uint64_t) oldval,
|
||||
(uint64_t) newval);
|
||||
}
|
||||
|
||||
static inline int ompi_atomic_cmpset_acq_int(volatile int *addr,
|
||||
int old,
|
||||
int new)
|
||||
int oldval,
|
||||
int newval)
|
||||
{
|
||||
return ompi_atomic_cmpset_acq_64((volatile uint64_t *) addr,
|
||||
(uint64_t) old,
|
||||
(uint64_t) new);
|
||||
(uint64_t) oldval,
|
||||
(uint64_t) newval);
|
||||
}
|
||||
|
||||
static inline int ompi_atomic_cmpset_rel_int(volatile int *addr,
|
||||
int old,
|
||||
int new)
|
||||
int oldval,
|
||||
int newval)
|
||||
{
|
||||
return ompi_atomic_cmpset_rel_64((volatile uint64_t *) addr,
|
||||
(uint64_t) old,
|
||||
(uint64_t) new);
|
||||
(uint64_t) oldval,
|
||||
(uint64_t) newval);
|
||||
}
|
||||
|
||||
#else
|
||||
@ -341,56 +341,56 @@ static inline int ompi_atomic_cmpset_rel_int(volatile int *addr,
|
||||
#if SIZEOF_VOID_P == 4
|
||||
|
||||
static inline int ompi_atomic_cmpset_ptr(volatile void *addr,
|
||||
void *old,
|
||||
void *new)
|
||||
void *oldval,
|
||||
void *newval)
|
||||
{
|
||||
return ompi_atomic_cmpset_32((volatile uint32_t *) addr,
|
||||
(uint32_t) old, (uint32_t) new);
|
||||
(uint32_t) oldval, (uint32_t) newval);
|
||||
}
|
||||
|
||||
static inline int ompi_atomic_cmpset_acq_ptr(volatile void *addr,
|
||||
void *old,
|
||||
void *new)
|
||||
void *oldval,
|
||||
void *newval)
|
||||
{
|
||||
return ompi_atomic_cmpset_acq_32((volatile uint32_t *) addr,
|
||||
(uint32_t) old, (uint32_t) new);
|
||||
(uint32_t) oldval, (uint32_t) newval);
|
||||
}
|
||||
|
||||
static inline int ompi_atomic_cmpset_rel_ptr(volatile void *addr,
|
||||
void *old,
|
||||
void *new)
|
||||
void *oldval,
|
||||
void *newval)
|
||||
{
|
||||
return ompi_atomic_cmpset_rel_32((volatile uint32_t *) addr,
|
||||
(uint32_t) old, (uint32_t) new);
|
||||
(uint32_t) oldval, (uint32_t) newval);
|
||||
}
|
||||
|
||||
#elif SIZEOF_VOID_P == 8
|
||||
|
||||
static inline int ompi_atomic_cmpset_ptr(volatile void *addr,
|
||||
void *old,
|
||||
void *new)
|
||||
void *oldval,
|
||||
void *newval)
|
||||
{
|
||||
return ompi_atomic_cmpset_64((volatile uint64_t *) addr,
|
||||
(uint64_t) old,
|
||||
(uint64_t) new);
|
||||
(uint64_t) oldval,
|
||||
(uint64_t) newval);
|
||||
}
|
||||
|
||||
static inline int ompi_atomic_cmpset_acq_ptr(volatile void *addr,
|
||||
void *old,
|
||||
void *new)
|
||||
void *oldval,
|
||||
void *newval)
|
||||
{
|
||||
return ompi_atomic_cmpset_acq_64((volatile uint64_t *) addr,
|
||||
(uint64_t) old,
|
||||
(uint64_t) new);
|
||||
(uint64_t) oldval,
|
||||
(uint64_t) newval);
|
||||
}
|
||||
|
||||
static inline int ompi_atomic_cmpset_rel_ptr(volatile void *addr,
|
||||
void *old,
|
||||
void *new)
|
||||
void *oldval,
|
||||
void *newval)
|
||||
{
|
||||
return ompi_atomic_cmpset_rel_64((volatile uint64_t *) addr,
|
||||
(uint64_t) old,
|
||||
(uint64_t) new);
|
||||
(uint64_t) oldval,
|
||||
(uint64_t) newval);
|
||||
}
|
||||
|
||||
#else
|
||||
@ -402,34 +402,34 @@ static inline int ompi_atomic_cmpset_rel_ptr(volatile void *addr,
|
||||
|
||||
static inline uint32_t ompi_atomic_add_32(uint32_t *addr, int delta)
|
||||
{
|
||||
uint32_t old;
|
||||
uint32_t oldval;
|
||||
|
||||
do {
|
||||
old = *addr;
|
||||
} while (0 == ompi_atomic_cmpset_32(addr, old, old + delta));
|
||||
return (old + delta);
|
||||
oldval = *addr;
|
||||
} while (0 == ompi_atomic_cmpset_32(addr, oldval, oldval + delta));
|
||||
return (oldval + delta);
|
||||
}
|
||||
|
||||
|
||||
static inline uint64_t ompi_atomic_add_64(uint64_t *addr, int delta)
|
||||
{
|
||||
uint64_t old;
|
||||
uint64_t oldval;
|
||||
|
||||
do {
|
||||
old = *addr;
|
||||
} while (0 == ompi_atomic_cmpset_64(addr, old, old + delta));
|
||||
return (old + delta);
|
||||
oldval = *addr;
|
||||
} while (0 == ompi_atomic_cmpset_64(addr, oldval, oldval + delta));
|
||||
return (oldval + delta);
|
||||
}
|
||||
|
||||
|
||||
static inline int ompi_atomic_add_int(int *addr, int delta)
|
||||
{
|
||||
int old;
|
||||
int oldval;
|
||||
|
||||
do {
|
||||
old = *addr;
|
||||
} while (0 == ompi_atomic_cmpset_int(addr, old, old + delta));
|
||||
return (old + delta);
|
||||
oldval = *addr;
|
||||
} while (0 == ompi_atomic_cmpset_int(addr, oldval, oldval + delta));
|
||||
return (oldval + delta);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -43,13 +43,13 @@ static inline void ompi_atomic_wmb(void)
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_32(volatile uint32_t *addr,
|
||||
uint32_t old,
|
||||
uint32_t new)
|
||||
uint32_t oldval,
|
||||
uint32_t newval)
|
||||
{
|
||||
uint32_t ret;
|
||||
|
||||
__asm __volatile__ (
|
||||
"1: ldl_l %0, %1 // load old value \n\
|
||||
"1: ldl_l %0, %1 // load oldval value \n\
|
||||
cmpeq %0, %2, %0 // compare \n\
|
||||
beq %0, 2f // exit if not equal \n\
|
||||
mov %3, %0 // value to store \n\
|
||||
@ -59,7 +59,7 @@ static inline int ompi_atomic_cmpset_32(volatile uint32_t *addr,
|
||||
3: br 1b // try again \n\
|
||||
.previous \n"
|
||||
: "=&r" (ret), "+m" (*addr)
|
||||
: "r" (old), "r" (new)
|
||||
: "r" (oldval), "r" (newval)
|
||||
: "memory");
|
||||
|
||||
return ret;
|
||||
@ -67,12 +67,12 @@ static inline int ompi_atomic_cmpset_32(volatile uint32_t *addr,
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_acq_32(volatile uint32_t *addr,
|
||||
uint32_t old,
|
||||
uint32_t new)
|
||||
uint32_t oldval,
|
||||
uint32_t newval)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = ompi_atomic_cmpset_32(addr, old, new);
|
||||
rc = ompi_atomic_cmpset_32(addr, oldval, newval);
|
||||
ompi_atomic_rmb();
|
||||
|
||||
return rc;
|
||||
@ -80,22 +80,22 @@ static inline int ompi_atomic_cmpset_acq_32(volatile uint32_t *addr,
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_rel_32(volatile uint32_t *addr,
|
||||
uint32_t old,
|
||||
uint32_t new)
|
||||
uint32_t oldval,
|
||||
uint32_t newval)
|
||||
{
|
||||
ompi_atomic_wmb();
|
||||
return ompi_atomic_cmpset_32(addr, old, new);
|
||||
return ompi_atomic_cmpset_32(addr, oldval, newval);
|
||||
}
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_64(volatile uint64_t *addr,
|
||||
uint64_t old,
|
||||
uint64_t new)
|
||||
uint64_t oldval,
|
||||
uint64_t newval)
|
||||
{
|
||||
uint32_t ret;
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"1: ldq_l %0, %1 // load old value \n\
|
||||
"1: ldq_l %0, %1 // load oldval value \n\
|
||||
cmpeq %0, %2, %0 // compare \n\
|
||||
beq %0, 2f // exit if not equal \n\
|
||||
mov %3, %0 // value to store \n\
|
||||
@ -105,7 +105,7 @@ static inline int ompi_atomic_cmpset_64(volatile uint64_t *addr,
|
||||
3: br 1b // try again \n\
|
||||
.previous \n"
|
||||
: "=&r" (ret), "+m" (*addr)
|
||||
: "r" (old), "r" (new)
|
||||
: "r" (oldval), "r" (newval)
|
||||
: "memory");
|
||||
|
||||
return ret;
|
||||
@ -113,12 +113,12 @@ static inline int ompi_atomic_cmpset_64(volatile uint64_t *addr,
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_acq_64(volatile uint64_t *addr,
|
||||
uint64_t old,
|
||||
uint64_t new)
|
||||
uint64_t oldval,
|
||||
uint64_t newval)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = ompi_atomic_cmpset_64(addr, old, new);
|
||||
rc = ompi_atomic_cmpset_64(addr, oldval, newval);
|
||||
ompi_atomic_rmb();
|
||||
|
||||
return rc;
|
||||
@ -126,11 +126,11 @@ static inline int ompi_atomic_cmpset_acq_64(volatile uint64_t *addr,
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_rel_64(volatile uint64_t *addr,
|
||||
uint64_t old,
|
||||
uint64_t new)
|
||||
uint64_t oldval,
|
||||
uint64_t newval)
|
||||
{
|
||||
ompi_atomic_wmb();
|
||||
return ompi_atomic_cmpset_64(addr, old, new);
|
||||
return ompi_atomic_cmpset_64(addr, oldval, newval);
|
||||
}
|
||||
|
||||
|
||||
|
@ -11,10 +11,10 @@
|
||||
|
||||
|
||||
#ifdef HAVE_SMP
|
||||
#define LOCK "lock; "
|
||||
#define SMPLOCK "lock; "
|
||||
#define MB() __asm__ __volatile__("": : :"memory")
|
||||
#else
|
||||
#define LOCK
|
||||
#define SMPLOCK
|
||||
#define MB()
|
||||
#endif
|
||||
|
||||
@ -38,70 +38,70 @@ static inline void ompi_atomic_wmb(void)
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_32(volatile uint32_t *addr,
|
||||
uint32_t old,
|
||||
uint32_t new)
|
||||
uint32_t oldval,
|
||||
uint32_t newval)
|
||||
{
|
||||
uint32_t ret = old;
|
||||
uint32_t ret = oldval;
|
||||
|
||||
__asm__ __volatile (
|
||||
LOCK "cmpxchgl %1,%2 \n\
|
||||
SMPLOCK "cmpxchgl %1,%2 \n\
|
||||
setz %%al \n\
|
||||
movzbl %%al,%0 \n"
|
||||
: "+a" (ret)
|
||||
: "r" (new), "m" (*(addr))
|
||||
: "r" (newval), "m" (*(addr))
|
||||
: "memory");
|
||||
|
||||
return (ret == old);
|
||||
return (ret == oldval);
|
||||
}
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_acq_32(volatile uint32_t *addr,
|
||||
uint32_t old,
|
||||
uint32_t new)
|
||||
uint32_t oldval,
|
||||
uint32_t newval)
|
||||
{
|
||||
return ompi_atomic_cmpset_32(addr, old, new);
|
||||
return ompi_atomic_cmpset_32(addr, oldval, newval);
|
||||
}
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_rel_32(volatile uint32_t *addr,
|
||||
uint32_t old,
|
||||
uint32_t new)
|
||||
uint32_t oldval,
|
||||
uint32_t newval)
|
||||
{
|
||||
return ompi_atomic_cmpset_32(addr, old, new);
|
||||
return ompi_atomic_cmpset_32(addr, oldval, newval);
|
||||
}
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_64(volatile uint64_t *addr,
|
||||
uint64_t old,
|
||||
uint64_t new)
|
||||
uint64_t oldval,
|
||||
uint64_t newval)
|
||||
{
|
||||
uint64_t ret = old;
|
||||
uint64_t ret = oldval;
|
||||
|
||||
__asm__ __volatile (
|
||||
LOCK "cmpxchgq %1,%2 \n\
|
||||
SMPLOCK "cmpxchgq %1,%2 \n\
|
||||
setz %%al \n\
|
||||
movzbl %%al,%0 \n"
|
||||
: "+a" (ret)
|
||||
: "r" (new), "m" (*(addr))
|
||||
: "r" (newval), "m" (*(addr))
|
||||
: "memory");
|
||||
|
||||
return (ret == old);
|
||||
return (ret == oldval);
|
||||
}
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_acq_64(volatile uint64_t *addr,
|
||||
uint64_t old,
|
||||
uint64_t new)
|
||||
uint64_t oldval,
|
||||
uint64_t newval)
|
||||
{
|
||||
return ompi_atomic_cpmset_64(addr, old, new);
|
||||
return ompi_atomic_cpmset_64(addr, oldval, newval);
|
||||
}
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_rel_64(volatile uint64_t *addr,
|
||||
uint64_t old,
|
||||
uint64_t new)
|
||||
uint64_t oldval,
|
||||
uint64_t newval)
|
||||
{
|
||||
return ompi_atomic_cpmset_64(addr, old, new);
|
||||
return ompi_atomic_cpmset_64(addr, oldval, newval);
|
||||
}
|
||||
|
||||
#endif /* ! OMPI_SYS_ATOMIC_H_INCLUDED */
|
||||
|
@ -38,51 +38,51 @@ static inline void ompi_atomic_wmb(void)
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_32(volatile uint32_t *addr,
|
||||
uint32_t old,
|
||||
uint32_t new)
|
||||
uint32_t oldval,
|
||||
uint32_t newval)
|
||||
{
|
||||
uint32_t ret = old;
|
||||
uint32_t ret = oldval;
|
||||
|
||||
__asm__ __volatile (
|
||||
SMPLOCK "cmpxchgl %1,%2 \n\
|
||||
setz %%al \n\
|
||||
movzbl %%al,%0 \n"
|
||||
: "+a" (ret)
|
||||
: "r" (new), "m" (*addr)
|
||||
: "r" (newval), "m" (*addr)
|
||||
: "memory");
|
||||
|
||||
return (ret == old);
|
||||
return (ret == oldval);
|
||||
}
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_acq_32(volatile uint32_t *addr,
|
||||
uint32_t old,
|
||||
uint32_t new)
|
||||
uint32_t oldval,
|
||||
uint32_t newval)
|
||||
{
|
||||
return ompi_atomic_cmpset_32(addr, old, new);
|
||||
return ompi_atomic_cmpset_32(addr, oldval, newval);
|
||||
}
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_rel_32(volatile uint32_t *addr,
|
||||
uint32_t old,
|
||||
uint32_t new)
|
||||
uint32_t oldval,
|
||||
uint32_t newval)
|
||||
{
|
||||
return ompi_atomic_cmpset_32(addr, old, new);
|
||||
return ompi_atomic_cmpset_32(addr, oldval, newval);
|
||||
}
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_64(volatile uint64_t *addr,
|
||||
uint64_t old,
|
||||
uint64_t new)
|
||||
uint64_t oldval,
|
||||
uint64_t newval)
|
||||
{
|
||||
/*
|
||||
* Compare EDX:EAX with m64. If equal, set ZF and load ECX:EBX into
|
||||
* m64. Else, clear ZF and load m64 into EDX:EAX.
|
||||
*/
|
||||
|
||||
uint64_t ret = old;
|
||||
uint64_t ret = oldval;
|
||||
#if 0
|
||||
struct { uint32_t lo; uint32_t hi; } *p = (struct lwords *) &new;
|
||||
struct { uint32_t lo; uint32_t hi; } *p = (struct lwords *) &newval;
|
||||
|
||||
__asm__ __volatile(
|
||||
SMPLOCK "cmpxchg8b %1\n"
|
||||
@ -90,23 +90,23 @@ SMPLOCK "cmpxchg8b %1\n"
|
||||
: "m" (*addr), "b" (p->lo), "c" (p->hi)
|
||||
: "memory");
|
||||
#endif
|
||||
return (ret == old);
|
||||
return (ret == oldval);
|
||||
}
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_acq_64(volatile uint64_t *addr,
|
||||
uint64_t old,
|
||||
uint64_t new)
|
||||
uint64_t oldval,
|
||||
uint64_t newval)
|
||||
{
|
||||
return ompi_atomic_cmpset_64(addr, old, new);
|
||||
return ompi_atomic_cmpset_64(addr, oldval, newval);
|
||||
}
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_rel_64(volatile uint64_t *addr,
|
||||
uint64_t old,
|
||||
uint64_t new)
|
||||
uint64_t oldval,
|
||||
uint64_t newval)
|
||||
{
|
||||
return ompi_atomic_cmpset_64(addr, old, new);
|
||||
return ompi_atomic_cmpset_64(addr, oldval, newval);
|
||||
}
|
||||
|
||||
#endif /* ! OMPI_SYS_ATOMIC_H_INCLUDED */
|
||||
|
@ -36,8 +36,8 @@ static inline void ompi_atomic_wmb(void)
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_acq_32(volatile uint32_t *addr,
|
||||
uint32_t old,
|
||||
uint32_t new)
|
||||
uint32_t oldval,
|
||||
uint32_t newval)
|
||||
{
|
||||
uint32_t ret;
|
||||
|
||||
@ -45,16 +45,16 @@ static inline int ompi_atomic_cmpset_acq_32(volatile uint32_t *addr,
|
||||
" mov ar.ccv=%2 \n\
|
||||
cmpxchg4.acq %0=%4,%3,ar.ccv \n"
|
||||
: "=r"(ret), "=m"(*addr)
|
||||
: "r"(old), "r"(new), "m"(*addr)
|
||||
: "r"(oldval), "r"(newval), "m"(*addr)
|
||||
: "memory");
|
||||
|
||||
return (ret == old);
|
||||
return (ret == oldval);
|
||||
}
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_rel_32(volatile uint32_t *addr,
|
||||
uint32_t old,
|
||||
uint32_t new)
|
||||
uint32_t oldval,
|
||||
uint32_t newval)
|
||||
{
|
||||
uint32_t ret;
|
||||
|
||||
@ -62,24 +62,24 @@ static inline int ompi_atomic_cmpset_rel_32(volatile uint32_t *addr,
|
||||
" mov ar.ccv=%2 \n\
|
||||
cmpxchg4.rel %0=%4,%3,ar.ccv \n"
|
||||
: "=r"(ret), "=m"(*addr)
|
||||
: "r"(old), "r"(new), "m"(*addr)
|
||||
: "r"(oldval), "r"(newval), "m"(*addr)
|
||||
: "memory");
|
||||
|
||||
return (ret == old);
|
||||
return (ret == oldval);
|
||||
}
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_32(volatile uint32_t *addr,
|
||||
uint32_t old,
|
||||
uint32_t new)
|
||||
uint32_t oldval,
|
||||
uint32_t newval)
|
||||
{
|
||||
return ompi_atomic_cmpset_acq_32(addr, old, new);
|
||||
return ompi_atomic_cmpset_acq_32(addr, oldval, newval);
|
||||
}
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_acq_64(volatile uint64_t *addr,
|
||||
uint64_t old,
|
||||
uint64_t new)
|
||||
uint64_t oldval,
|
||||
uint64_t newval)
|
||||
{
|
||||
uint64_t ret;
|
||||
|
||||
@ -87,16 +87,16 @@ static inline int ompi_atomic_cmpset_acq_64(volatile uint64_t *addr,
|
||||
" mov ar.ccv=%2 \n\
|
||||
cmpxchg8.acq %0=%4,%3,ar.ccv \n"
|
||||
: "=r"(ret), "=m"(*addr)
|
||||
: "r"(old), "r"(new), "m"(*addr)
|
||||
: "r"(oldval), "r"(newval), "m"(*addr)
|
||||
: "memory");
|
||||
|
||||
return (ret == old);
|
||||
return (ret == oldval);
|
||||
}
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_rel_64(volatile uint64_t *addr,
|
||||
uint64_t old,
|
||||
uint64_t new)
|
||||
uint64_t oldval,
|
||||
uint64_t newval)
|
||||
{
|
||||
uint64_t ret;
|
||||
|
||||
@ -104,17 +104,17 @@ static inline int ompi_atomic_cmpset_rel_64(volatile uint64_t *addr,
|
||||
" mov ar.ccv=%2 \n\
|
||||
cmpxchg8.rel %0=%4,%3,ar.ccv \n"
|
||||
: "=r"(ret), "=m"(*addr)
|
||||
: "r"(old), "r"(new), "m"(*addr)
|
||||
: "r"(oldval), "r"(newval), "m"(*addr)
|
||||
: "memory");
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_64(volatile uint64_t *addr,
|
||||
uint64_t old,
|
||||
uint64_t new)
|
||||
uint64_t oldval,
|
||||
uint64_t newval)
|
||||
{
|
||||
return ompi_atomic_cmpset_acq_64(addr, old, new);
|
||||
return ompi_atomic_cmpset_acq_64(addr, oldval, newval);
|
||||
}
|
||||
|
||||
|
||||
|
@ -43,8 +43,8 @@ static inline void ompi_atomic_wmb(void)
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_32(volatile uint32_t *addr,
|
||||
uint32_t old,
|
||||
uint32_t new)
|
||||
uint32_t oldval,
|
||||
uint32_t newval)
|
||||
{
|
||||
uint32_t ret;
|
||||
|
||||
@ -56,20 +56,20 @@ static inline int ompi_atomic_cmpset_32(volatile uint32_t *addr,
|
||||
bne- 1b \n\
|
||||
2:"
|
||||
: "=&r" (ret), "=m" (*addr)
|
||||
: "r" (addr), "r" (old), "r" (new), "m" (*addr)
|
||||
: "r" (addr), "r" (oldval), "r" (newval), "m" (*addr)
|
||||
: "cc", "memory");
|
||||
|
||||
return (ret == old);
|
||||
return (ret == oldval);
|
||||
}
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_acq_32(volatile uint32_t *addr,
|
||||
uint32_t old,
|
||||
uint32_t new)
|
||||
uint32_t oldval,
|
||||
uint32_t newval)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = ompi_atomic_cmpset_32(addr, old, new);
|
||||
rc = ompi_atomic_cmpset_32(addr, oldval, newval);
|
||||
ompi_atomic_rmb();
|
||||
|
||||
return rc;
|
||||
@ -77,17 +77,17 @@ static inline int ompi_atomic_cmpset_acq_32(volatile uint32_t *addr,
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_rel_32(volatile uint32_t *addr,
|
||||
uint32_t old,
|
||||
uint32_t new)
|
||||
uint32_t oldval,
|
||||
uint32_t newval)
|
||||
{
|
||||
ompi_atomic_wmb();
|
||||
return ompi_atomic_cmpset_32(addr, old, new);
|
||||
return ompi_atomic_cmpset_32(addr, oldval, newval);
|
||||
}
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_64(volatile uint64_t *addr,
|
||||
uint64_t old,
|
||||
uint64_t new)
|
||||
uint64_t oldval,
|
||||
uint64_t newval)
|
||||
{
|
||||
uint64_t ret;
|
||||
|
||||
@ -99,20 +99,20 @@ static inline int ompi_atomic_cmpset_64(volatile uint64_t *addr,
|
||||
bne- 1b \n\
|
||||
2:"
|
||||
: "=&r" (ret), "=m" (*addr)
|
||||
: "r" (addr), "r" (old), "r" (new), "m" (*addr)
|
||||
: "r" (addr), "r" (oldval), "r" (newval), "m" (*addr)
|
||||
: "cc", "memory");
|
||||
|
||||
return (ret == old);
|
||||
return (ret == oldval);
|
||||
}
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_acq_64(volatile uint64_t *addr,
|
||||
uint64_t old,
|
||||
uint64_t new)
|
||||
uint64_t oldval,
|
||||
uint64_t newval)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = ompi_atomic_cmpset_64(addr, old, new);
|
||||
rc = ompi_atomic_cmpset_64(addr, oldval, newval);
|
||||
ompi_atomic_rmb();
|
||||
|
||||
return rc;
|
||||
@ -120,11 +120,11 @@ static inline int ompi_atomic_cmpset_acq_64(volatile uint64_t *addr,
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_rel_64(volatile uint64_t *addr,
|
||||
uint64_t old,
|
||||
uint64_t new)
|
||||
uint64_t oldval,
|
||||
uint64_t newval)
|
||||
{
|
||||
ompi_atomic_wmb();
|
||||
return ompi_atomic_cmpset_64(addr, old, new);
|
||||
return ompi_atomic_cmpset_64(addr, oldval, newval);
|
||||
}
|
||||
|
||||
|
||||
|
@ -35,25 +35,25 @@ static inline void ompi_atomic_wmb(void)
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_32(volatile uint32_t *addr,
|
||||
uint32_t old,
|
||||
uint32_t new)
|
||||
uint32_t oldval,
|
||||
uint32_t newval)
|
||||
{
|
||||
uint32_t ret = old;
|
||||
uint32_t ret = oldval;
|
||||
|
||||
__asm__ __volatile("casa [%1] ASI_P, %2, %0"
|
||||
: "+r" (ret)
|
||||
: "r" (addr), "r" (new));
|
||||
return (ret == old);
|
||||
: "r" (addr), "r" (newval));
|
||||
return (ret == oldval);
|
||||
}
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_acq_32(volatile uint32_t *addr,
|
||||
uint32_t old,
|
||||
uint32_t new)
|
||||
uint32_t oldval,
|
||||
uint32_t newval)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = ompi_atomic_cmpset_32(addr, old, new);
|
||||
rc = ompi_atomic_cmpset_32(addr, oldval, newval);
|
||||
ompi_atomic_rmb();
|
||||
|
||||
return rc;
|
||||
@ -61,34 +61,34 @@ static inline int ompi_atomic_cmpset_acq_32(volatile uint32_t *addr,
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_rel_32(volatile uint32_t *addr,
|
||||
uint32_t old,
|
||||
uint32_t new)
|
||||
uint32_t oldval,
|
||||
uint32_t newval)
|
||||
{
|
||||
ompi_atomic_wmb();
|
||||
return ompi_atomic_cmpset_32(addr, old, new);
|
||||
return ompi_atomic_cmpset_32(addr, oldval, newval);
|
||||
}
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_64(volatile uint64_t *addr,
|
||||
uint64_t old,
|
||||
uint64_t new)
|
||||
uint64_t oldval,
|
||||
uint64_t newval)
|
||||
{
|
||||
uint64_t ret = old;
|
||||
uint64_t ret = oldval;
|
||||
|
||||
__asm__ __volatile("casxa [%1] ASI_P, %2, %0"
|
||||
: "+r" (ret)
|
||||
: "r" (addr), "r" (new));
|
||||
return (ret == old);
|
||||
: "r" (addr), "r" (newval));
|
||||
return (ret == oldval);
|
||||
}
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_acq_64(volatile uint64_t *addr,
|
||||
uint64_t old,
|
||||
uint64_t new)
|
||||
uint64_t oldval,
|
||||
uint64_t newval)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = ompi_atomic_cmpset_64(addr, old, new);
|
||||
rc = ompi_atomic_cmpset_64(addr, oldval, newval);
|
||||
ompi_atomic_rmb();
|
||||
|
||||
return rc;
|
||||
@ -96,11 +96,11 @@ static inline int ompi_atomic_cmpset_acq_64(volatile uint64_t *addr,
|
||||
|
||||
|
||||
static inline int ompi_atomic_cmpset_rel_64(volatile uint64_t *addr,
|
||||
uint64_t old,
|
||||
uint64_t new)
|
||||
uint64_t oldval,
|
||||
uint64_t newval)
|
||||
{
|
||||
ompi_atomic_wmb();
|
||||
return ompi_atomic_cmpset_64(addr, old, new);
|
||||
return ompi_atomic_cmpset_64(addr, oldval, newval);
|
||||
}
|
||||
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user