2.5.2.8 Programming Hints for the Synchronization Primitives

ISO/IEC C cannot directly generate the exclusive access instructions. Some CMSIS  provides intrinsic functions for generation of these instructions. The following table lists the functions that CMSIS provides.

Table 2-15. CMSIS Functions for Exclusive Access Instructions
InstructionIntrinsic Function
LDREX, LDREXH, or LDREXBunsigned char__LDREXB(volatile char *ptr)

unsigned short __LDREXH(volatile short *ptr)

unsigned int __LDREXB(volatile int *ptr)

STREX, STREXH, or STREXBint __STREXB(unsigned char val, volatile char *ptr)

int __STREXB(unsigned short val, volatile short *ptr)

int __STREXB(unsigned int val, volatile int *ptr)

CLREXvoid __CLREX(void)

The actual exclusive access instruction generated depends on the data type of the pointer passed to the intrinsic function.