This intrinsic inserts a SWP{size} instruction
into the instruction stream generated by the compiler. It enables
you to swap data between memory locations from your C or C++ code.
Note
The use of SWP and SWPB is deprecated
in ARMv6 and above.
Syntax
unsigned int __swp(unsigned int val, volatile void *ptr)
where:
val
Is the data value to be written to memory.
ptr
Points to the address of the data to be written
to in memory. To specify the size of the data to be written, cast
the parameter to an appropriate integral type.
Table 21. Access widths supported by the __swp intrinsic
Instruction
Size of data loaded
C cast
SWPB
unsigned byte
(char *)
SWP
word
(int *)
Return value
The __swp intrinsic returns the data
value that previously, is in the memory address pointed to by ptr,
before this value is overwritten by val.
Example
int foo(void)
{
int loc=0xff;
return(__swp(0x20, (volatile int *)loc));
}
This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.
ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.