There is a __cmpxchg function under include/asm/system.h:
/*
* Atomic Compare and Exchange. Compare old with MEM, if identical,
* Store NEW in MEM. Return to the initial value in MEM. Success is
* indicated by comparing return with old.
*/
Static inline unsigned long __cmpxchg (volatile void *ptr, unsigned long old,
unsigned long new, int size)
{
unsigned long tmp = 0;
unsigned long flags = 0;
Local_irq_save (flags);
switch (size) {
Case 1:
__asm__ __volatile__
("%0 = b%3 (z);/n/t")
"CC =%1 = =%0;/n/t"
"IF! CC JUMP 1f;/n/t "
"b%3 =%2;/n/t"
"1:/n/t"
: "=&d" (TMP): "D" (old), "D" (New), "M" (*__xg (PTR)): "Memory");
Break
Case 2:
__asm__ __volatile__
("%0 = w%3 (z);/n/t")
"CC =%1 = =%0;/n/t"
"IF! CC JUMP 1f;/n/t "
"w%3 =%2;/n/t"
"1:/n/t"
: "=&d" (TMP): "D" (old), "D" (New), "M" (*__xg (PTR)): "Memory");
Break
Case 4:
__asm__ __volatile__
("%0 =%3;/n/t"
"CC =%1 = =%0;/n/t"
"IF! CC JUMP 1f;/n/t "
"%3 =%2;/n/t"
"1:/n/t"
: "=&d" (TMP): "D" (old), "D" (New), "M" (*__xg (PTR)): "Memory");
Break
}
Local_irq_restore (flags);
return TMP;
}
Compiling under VDSP will produce the following syntax error:
".. /.. /include/asm/system.h ", line 209:cc1101:error:invalid constraint in
ASM statement
: "=&d" (TMP): "D" (old), "D" (New), "M" (*__xg (PTR)): "Memory");
^
".. /.. /include/asm/system.h ", line 209:cc1155:error:gnu ASM operand
Requires integral or pointer type
: "=&d" (TMP): "D" (old), "D" (New), "M" (*__xg (PTR)): "Memory");
^
".. /.. /include/asm/system.h ", line 218:cc1101:error:invalid constraint in
ASM statement
: "=&d" (TMP): "D" (old), "D" (New), "M" (*__xg (PTR)): "Memory");
^
".. /.. /include/asm/system.h ", line 218:cc1155:error:gnu ASM operand
Requires integral or pointer type
: "=&d" (TMP): "D" (old), "D" (New), "M" (*__xg (PTR)): "Memory");
^
".. /.. /include/asm/system.h ", line 227:cc1101:error:invalid constraint in
ASM statement
: "=&d" (TMP): "D" (old), "D" (New), "M" (*__xg (PTR)): "Memory");
^
".. /.. /include/asm/system.h ", line 227:cc1155:error:gnu ASM operand
Requires integral or pointer type
: "=&d" (TMP): "D" (old), "D" (New), "M" (*__xg (PTR)): "Memory");
^
6 Errors detected in the compilation of ". /.. /fs/sysfs/dir.c ".
Cc3089:fatal Error:compilation failed