Important: The information in this document is obsolete and should not be used for new development.
OTAtomicAdd16
Atomically adds a 16-bit value to a memory location.C INTERFACE
SInt16 OTAtomicAdd16(SInt32 toAdd, SInt16* where)C++ INTERFACE
None. C++ applications use the C interface to this function.PARAMETERS
toAdd- A signed 16-bit value to add to the value referenced by the where
parameter.where- A pointer to a signed 16-bit value that is added to the value specified by the parameter
toAdd.- function result
- The sum of the values specified by the function's parameters.
DISCUSSION
This function atomically adds the least significat 16 bits oftoAddto the value referenced by thewhereparameter and returns the result. It also stores the result in the location referenced by thewhereparameterYou can use this function to subtract from the toAdd value from the value referenced by the
whereparameter by reversing the sign oftoAdd.
Use the
- WARNING
- The pointer
wheremust be at an address where the second byte of the 16 bit value is not in a different 4-byte cell than the first byte (i.e. (where % 4) != 3).![]()
OTAtomicAdd32function to add two 32-bit values.Use the
OTAtomicAdd8function to add two 8-bit values.