Format
#include <builtin.h>unsigned int __smp_xadd4(unsigned int *op1, unsigned int op2)
Language Level: None
__smp_xadd4 exchanges the 4 byte memory operand, *op1,
with the 4 byte immediate operand, op2, and stores the
sum of the two values in the memory operand. The exchange and add
operation is atomic even on multi-processor machines. This
builtin function will not work on a 386 processor.
Return Value
The original value of the memory operand is returned.
Example
This example adds 1 to the value of mem and
prints out the original value of mem.
#include <stdio.h> #include <builtin.h>
unsigned int mem = -1;
int main(void)
{
if (__smp_xadd4(&mem, 1) == -1)
{
printf("Memory location should now be zero.\n");
}
printf("mem = %u\n", mem);
/****************************************
The output should be:
Memory location should now be zero.
mem = 0
****************************************/
return 0; }
![]()
__xadd4 --
Exchange and Add 4 Byte Values