Something went wrong. Try again.
Cider Isn't Darwin Emulation, Really
Something went wrong. Try again.
1.7 kB · 75 lines
C++
at android
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576#include "OpenTransport.h"
#if defined(__i386__) || defined(__ppc__) // This is deprecated stuff for Carbon apps
Boolean OTAtomicSetBit(UInt8* bytePtr, OTByteCount bitNumber){ UInt8 bitValue = 1 << bitNumber; while (true) { UInt8 value = *bytePtr; if (value & bitValue) return false; if (__sync_bool_compare_and_swap(bytePtr, value, value | bitValue)) return true; }}
Boolean OTAtomicClearBit(UInt8* bytePtr, OTByteCount bitNumber){ UInt8 bitValue = 1 << bitNumber; while (true) { UInt8 value = *bytePtr; if ((value & bitValue) == 0) return false; if (__sync_bool_compare_and_swap(bytePtr, value, value & ~bitValue)) return true; }}
Boolean OTAtomicTestBit(UInt8* bytePtr, OTByteCount bitNumber){ return *bytePtr & (1 << bitNumber);}
Boolean OTCompareAndSwapPtr(void* oldValue, void* newValue, void** dest){ return __sync_bool_compare_and_swap(dest, oldValue, newValue);}
Boolean OTCompareAndSwap32(UInt32 oldValue, UInt32 newValue, UInt32* dest){ return __sync_bool_compare_and_swap(dest, oldValue, newValue);}
Boolean OTCompareAndSwap16(UInt32 oldValue, UInt32 newValue, UInt16* dest){ return __sync_bool_compare_and_swap(dest, oldValue, newValue);}
Boolean OTCompareAndSwap8(UInt32 oldValue, UInt32 newValue, UInt8* dest){ return __sync_bool_compare_and_swap(dest, oldValue, newValue);}
SInt32 OTAtomicAdd32(SInt32 toAdd, SInt32* dest){ return __sync_add_and_fetch(dest, toAdd);}
SInt16 OTAtomicAdd16(SInt32 toAdd, SInt16* dest){ return __sync_add_and_fetch(dest, toAdd);}
SInt8 OTAtomicAdd8(SInt32 toAdd, SInt8* dest){ return __sync_add_and_fetch(dest, toAdd);}
#endif