Fix the dtrace ARM atomic compare-and-set functions. These functions are

expected to return the data in the memory location pointed at by target
after the operation. The FreeBSD atomic functions previously used return
either 0 or 1 to indicate if the comparison succeeded or not respectively.

With this change these functions only support ARMv6 and later are supported
by these functions.

Sponsored by:	ABT Systems Ltd
This commit is contained in:
Andrew Turner 2015-03-01 10:04:14 +00:00
parent ae750c192b
commit 2b6af94bc8
2 changed files with 22 additions and 31 deletions

View file

@ -195,3 +195,25 @@ ENTRY(dtrace_caller)
mov r0, #-1
RET
END(dtrace_caller)
/*
uint32_t
dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new)
void *
dtrace_casptr(volatile void *target, volatile void *cmp, volatile void *new)
*/
ENTRY(dtrace_cas32)
EENTRY(dtrace_casptr)
1: ldrex r3, [r0] /* Load target */
cmp r3, r1 /* Check if *target == cmp */
bne 2f /* No, return */
strex r3, r2, [r0] /* Store new to target */
cmp r3, #0 /* Did the store succeed? */
bne 1b /* No, try again */
mov r0, r2 /* Return the new value of the store */
2: movne r0, r3 /* The first compare failed, return */
/* the value loaded from memory */
RET
EEND(dtrace_casptr)
END(dtrace_cas32)

View file

@ -262,34 +262,3 @@ dtrace_fuword64(void *uaddr)
}
return (dtrace_fuword64_nocheck(uaddr));
}
#define __with_interrupts_disabled(expr) \
do { \
u_int cpsr_save, tmp; \
\
__asm __volatile( \
"mrs %0, cpsr;" \
"orr %1, %0, %2;" \
"msr cpsr_fsxc, %1;" \
: "=r" (cpsr_save), "=r" (tmp) \
: "I" (PSR_I | PSR_F) \
: "cc" ); \
(expr); \
__asm __volatile( \
"msr cpsr_fsxc, %0" \
: /* no output */ \
: "r" (cpsr_save) \
: "cc" ); \
} while(0)
uint32_t dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new)
{
return atomic_cmpset_32((uint32_t*)target, (uint32_t)cmp, (uint32_t)new);
}
void * dtrace_casptr(volatile void *target, volatile void *cmp, volatile void *new)
{
return (void*)dtrace_cas32((uint32_t*)target, (uint32_t)cmp, (uint32_t)new);
}