9.137 __strexd intrinsic

The __strexd intrinsic lets you use an STREXD instruction in your C or C++ code to perform an exclusive doubleword data store to memory.

Note

The compiler does not guarantee to preserve the state of the exclusive monitor. It might generate load and store instructions between the LDREXD instruction generated for the __ldrexd intrinsic and the STREXD instruction generated for the __strexd intrinsic. Because memory accesses can clear the exclusive monitor, code using the __ldrexd and __strexd intrinsics can have unexpected behavior. Where LDREXD and STREXD instructions are needed, ARM recommends using embedded assembly.

Syntax

int __strexd(unsigned long long val, volatile void *ptr)
Where:
val
is the 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 9-12 Access widths that the __strexd intrinsic supports

Instruction Size of data stored Pointer type
STREXD long long long long *

Return value

The __strexd intrinsic returns:
0
if the STREXD instruction succeeds
1
if the STREXD instruction is locked out.

Errors

The compiler does not recognize the __strexd intrinsic when compiling for a target that does not support the STREXD instruction. The compiler generates either a warning or an error in this case, depending on the source language:
  • In C code: Warning: #223-D: function "__strexd" declared implicitly.
  • In C++ code: Error: #20: identifier "__strexd" is undefined.
The __strexd intrinsic only supports access to doubleword data. The compiler generates an error if you specify an access width that is not supported.
Related reference
9.115 __ldrex intrinsic
9.116 __ldrexd intrinsic
9.136 __strex intrinsic
Related information
STREX
Non-ConfidentialPDF file icon PDF versionARM DUI0375F
Copyright © 2007, 2008, 2011, 2012, 2014 ARM. All rights reserved.