These things are very important. Can some point me neccesary changes to make it portable?
1. What type it works on ? Let me explicitly state that.
a. Does it work on int32
b Does it work on uint32
c. Does it work on int64
d Does it work on uint64
e. Does it work on unsigned long?
f. Does it work on signed long?
2. What architecture 32 or 64 bit.?
a. Will same code work on both if not then what changes are required?
3. What is the return value (old or updated one)? It must return a value. So that old and new value can be compare later.
4. What OS it will support? If not then what changes or API to use if available.
a. Will it work on windows 32 and 64 bit?
b. Will it work linux 32 or 64 bit
c. Will it work Sun Solaris
d. will it work on HP AIX
int32 val = 1;
asm volatile ("lock; xaddl %0,%1"
: "=r" (val), "=m" (*mem)
: "0" (val), "m" (*mem)
: "memory", "cc");