The Driver Services Library provides several 32-, 16-, and 8-bit atomic memory operations for use by device drivers. These routines take logical address pointers and ensure that the operations are atomic with respect to all devices (for example, other processors and DMA engines) that participate in the coherency architecture of the Power Macintosh system.
Memory locations used by these operations must be long word aligned; if they are stored in a structure, you should use the compiler directive #pragma options align=power.
Boolean
CompareAndSwap (long oldValue, long newValue, long *Value);
SInt32 IncrementAtomic (SInt32 *value);
SInt32 DecrementAtomic (SInt32 *value);
SInt32 AddAtomic (SInt32 amount, SInt32 *value);
UInt32 BitAndAtomic (UInt32 mask, UInt32 *value);
UInt32 BitOrAtomic (UInt32 mask, UInt32 *value);
UInt32 BitXorAtomic (UInt32 mask, UInt32 *value);
SInt16 IncrementAtomic16 (SInt16 *value);
SInt16 DecrementAtomic16 (SInt16 *value);
SInt16 AddAtomic16 (SInt32 amount, SInt16 *value);
UInt16 BitAndAtomic16 (UInt32 mask, UInt16 *value);
UInt16 BitOrAtomic16 (UInt32 mask, UInt16 *value);
UInt16 BitXorAtomic16 (UInt32 mask, UInt16 *value);
SInt8 IncrementAtomic8 (SInt8 *value);
SInt8 DecrementAtomic8 (SInt8 *value);
SInt8 AddAtomic8 (SInt32 amount, SInt8 *value);
UInt8 BitAndAtomic8 (UInt32 mask, UInt8 *value);
UInt8 BitOrAtomic8 (UInt32 mask, UInt8 *value);
UInt8 BitXorAtomic8 (UInt32 mask, UInt8 *value);
The atomic routines perform various operations on the memory address specified by value :