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