]> git.saurik.com Git - apple/xnu.git/blobdiff - libkern/gen/OSAtomicOperations.c
xnu-2782.20.48.tar.gz
[apple/xnu.git] / libkern / gen / OSAtomicOperations.c
index 3484791d567a41a288f28e005679baf2d03d8e78..25ff477ff7424472c86c105d81ffac637070fbaa 100644 (file)
@@ -54,48 +54,10 @@ enum {
  * Like standards, there are a lot of atomic ops to choose from!
  */
 
  * Like standards, there are a lot of atomic ops to choose from!
  */
 
-#if !defined(__i386__) && !defined(__x86_64__)
+#if defined(__i386__) || defined(__x86_64__)
 /* Implemented in assembly for i386 and x86_64 */
 /* Implemented in assembly for i386 and x86_64 */
-#undef OSAddAtomic
-SInt32
-OSAddAtomic(SInt32 amount, volatile SInt32 * value)
-{
-       SInt32 oldValue;
-       SInt32 newValue;
-
-       do {
-               oldValue = *value;
-               newValue = oldValue + amount;
-       } while (!OSCompareAndSwap((UInt32)oldValue,
-                               (UInt32)newValue,
-                               (volatile UInt32 *) value));
-       return oldValue;
-}
-
-#undef OSAddAtomicLong
-long
-OSAddAtomicLong(long theAmount, volatile long *address)
-{
-#if __LP64__
-#error Unimplemented
-#else
-       return (long)OSAddAtomic((SInt32)theAmount, address);
-#endif
-}
-
-/* Implemented as an assembly alias for i386 */
-#undef OSCompareAndSwapPtr
-Boolean OSCompareAndSwapPtr(void *oldValue, void *newValue,
-                           void * volatile *address)
-{
-#if __LP64__
-  return OSCompareAndSwap64((UInt64)oldValue, (UInt64)newValue,
-                         (volatile UInt64 *)address);
 #else
 #else
-  return OSCompareAndSwap((UInt32)oldValue, (UInt32)newValue,
-                         (volatile UInt32 *)address);
-#endif
-}
+#error Unsupported arch
 #endif
 
 #undef OSIncrementAtomic
 #endif
 
 #undef OSIncrementAtomic
@@ -141,6 +103,7 @@ UInt32      OSBitXorAtomic(UInt32 mask, volatile UInt32 * value)
        return OSBitwiseAtomic((UInt32) -1, 0, mask, value);
 }
 
        return OSBitwiseAtomic((UInt32) -1, 0, mask, value);
 }
 
+#if defined(__i386__) || defined(__x86_64__)
 static Boolean OSCompareAndSwap8(UInt8 oldValue8, UInt8 newValue8, volatile UInt8 * value8)
 {
        UInt32                          mask            = 0x000000ff;
 static Boolean OSCompareAndSwap8(UInt8 oldValue8, UInt8 newValue8, volatile UInt8 * value8)
 {
        UInt32                          mask            = 0x000000ff;
@@ -159,6 +122,7 @@ static Boolean OSCompareAndSwap8(UInt8 oldValue8, UInt8 newValue8, volatile UInt
 
        return OSCompareAndSwap(oldValue, newValue, value32);
 }
 
        return OSCompareAndSwap(oldValue, newValue, value32);
 }
+#endif
 
 static Boolean OSTestAndSetClear(UInt32 bit, Boolean wantSet, volatile UInt8 * startAddress)
 {
 
 static Boolean OSTestAndSetClear(UInt32 bit, Boolean wantSet, volatile UInt8 * startAddress)
 {
@@ -204,6 +168,7 @@ SInt8       OSDecrementAtomic8(volatile SInt8 * value)
        return OSAddAtomic8(-1, value);
 }
 
        return OSAddAtomic8(-1, value);
 }
 
+#if defined(__i386__) || defined(__x86_64__)
 SInt8  OSAddAtomic8(SInt32 amount, volatile SInt8 * value)
 {
        SInt8   oldValue;
 SInt8  OSAddAtomic8(SInt32 amount, volatile SInt8 * value)
 {
        SInt8   oldValue;
@@ -216,6 +181,7 @@ SInt8       OSAddAtomic8(SInt32 amount, volatile SInt8 * value)
        
        return oldValue;
 }
        
        return oldValue;
 }
+#endif
 
 static UInt8   OSBitwiseAtomic8(UInt32 and_mask, UInt32 or_mask, UInt32 xor_mask, volatile UInt8 * value)
 {
 
 static UInt8   OSBitwiseAtomic8(UInt32 and_mask, UInt32 or_mask, UInt32 xor_mask, volatile UInt8 * value)
 {
@@ -245,6 +211,7 @@ UInt8       OSBitXorAtomic8(UInt32 mask, volatile UInt8 * value)
        return OSBitwiseAtomic8((UInt32) -1, 0, mask, value);
 }
 
        return OSBitwiseAtomic8((UInt32) -1, 0, mask, value);
 }
 
+#if defined(__i386__) || defined(__x86_64__)
 static Boolean OSCompareAndSwap16(UInt16 oldValue16, UInt16 newValue16, volatile UInt16 * value16)
 {
        UInt32                          mask            = 0x0000ffff;
 static Boolean OSCompareAndSwap16(UInt16 oldValue16, UInt16 newValue16, volatile UInt16 * value16)
 {
        UInt32                          mask            = 0x0000ffff;
@@ -263,6 +230,7 @@ static Boolean OSCompareAndSwap16(UInt16 oldValue16, UInt16 newValue16, volatile
 
        return OSCompareAndSwap(oldValue, newValue, value32);
 }
 
        return OSCompareAndSwap(oldValue, newValue, value32);
 }
+#endif
 
 SInt16 OSIncrementAtomic16(volatile SInt16 * value)
 {
 
 SInt16 OSIncrementAtomic16(volatile SInt16 * value)
 {
@@ -274,6 +242,7 @@ SInt16      OSDecrementAtomic16(volatile SInt16 * value)
        return OSAddAtomic16(-1, value);
 }
 
        return OSAddAtomic16(-1, value);
 }
 
+#if defined(__i386__) || defined(__x86_64__)
 SInt16 OSAddAtomic16(SInt32 amount, volatile SInt16 * value)
 {
        SInt16  oldValue;
 SInt16 OSAddAtomic16(SInt32 amount, volatile SInt16 * value)
 {
        SInt16  oldValue;
@@ -286,6 +255,7 @@ SInt16      OSAddAtomic16(SInt32 amount, volatile SInt16 * value)
        
        return oldValue;
 }
        
        return oldValue;
 }
+#endif
 
 static UInt16  OSBitwiseAtomic16(UInt32 and_mask, UInt32 or_mask, UInt32 xor_mask, volatile UInt16 * value)
 {
 
 static UInt16  OSBitwiseAtomic16(UInt32 and_mask, UInt32 or_mask, UInt32 xor_mask, volatile UInt16 * value)
 {