Changeset View
Changeset View
Standalone View
Standalone View
head/sys/powerpc/include/atomic.h
Show First 20 Lines • Show All 602 Lines • ▼ Show 20 Lines | __asm __volatile ( | ||||
"li %0, 0\n\t" /* failure - retval = 0 */ | "li %0, 0\n\t" /* failure - retval = 0 */ | ||||
"3:\n\t" | "3:\n\t" | ||||
: "=&r" (ret), "=m" (*p) | : "=&r" (ret), "=m" (*p) | ||||
: "r" (p), "r" (cmpval), "r" (newval), "m" (*p) | : "r" (p), "r" (cmpval), "r" (newval), "m" (*p) | ||||
: "cr0", "memory"); | : "cr0", "memory"); | ||||
return (ret); | return (ret); | ||||
} | } | ||||
#else | |||||
static __inline int | |||||
atomic_cmpset_masked(uint32_t *p, uint32_t cmpval, uint32_t newval, | |||||
uint32_t mask) | |||||
{ | |||||
int ret; | |||||
uint32_t tmp; | |||||
__asm __volatile ( | |||||
"1:\tlwarx %2, 0, %2\n\t" /* load old value */ | |||||
"and %0, %2, %7\n\t" | |||||
"cmplw %4, %0\n\t" /* compare */ | |||||
"bne- 2f\n\t" /* exit if not equal */ | |||||
"andc %2, %2, %7\n\t" | |||||
"or %2, %2, %5\n\t" | |||||
"stwcx. %2, 0, %3\n\t" /* attempt to store */ | |||||
"bne- 1b\n\t" /* spin if failed */ | |||||
"li %0, 1\n\t" /* success - retval = 1 */ | |||||
"b 3f\n\t" /* we've succeeded */ | |||||
"2:\n\t" | |||||
"stwcx. %2, 0, %3\n\t" /* clear reservation (74xx) */ | |||||
"li %0, 0\n\t" /* failure - retval = 0 */ | |||||
"3:\n\t" | |||||
: "=&r" (ret), "=m" (*p), "+&r" (tmp) | |||||
: "r" (p), "r" (cmpval), "r" (newval), "m" (*p), | |||||
"r" (mask) | |||||
: "cr0", "memory"); | |||||
return (ret); | |||||
} | |||||
#define _atomic_cmpset_masked_word(a,o,v,m) atomic_cmpset_masked(a, o, v, m) | |||||
#endif | #endif | ||||
static __inline int | static __inline int | ||||
atomic_cmpset_int(volatile u_int* p, u_int cmpval, u_int newval) | atomic_cmpset_int(volatile u_int* p, u_int cmpval, u_int newval) | ||||
{ | { | ||||
int ret; | int ret; | ||||
__asm __volatile ( | __asm __volatile ( | ||||
▲ Show 20 Lines • Show All 379 Lines • Show Last 20 Lines |