#include <stdlib.h>
static inline uint
xchg(volatile unsigned int *addr, unsigned int newval)
{
uint result;
asm volatile("lock; xchgl %0, %1" : "+m" (*addr), "=a" (result) : "1" (newval) : "cc");
return result;
}
Can some one tell me what this code does exactly? I mean I have an idea or the parts of this command. "1" newval is the input, "=a" is to flush out its previous value and update it. "m" is for the memory operation but I am confused about the functionality of this function. What does the "+m" sign do? Does this function do something like m=a; m = newval; return a