@@ -167,12 +167,12 @@ } alloc_failed_exception; #ifndef OF_HAVE_ATOMIC_OPS # define NUM_SPINLOCKS 8 /* needs to be a power of 2 */ # define SPINLOCK_HASH(p) ((uintptr_t)p >> 4) & (NUM_SPINLOCKS - 1) -static of_spinlock_t blockSpinlocks[NUM_SPINLOCKS]; -static of_spinlock_t byrefSpinlocks[NUM_SPINLOCKS]; +static OFSpinlock blockSpinlocks[NUM_SPINLOCKS]; +static OFSpinlock byrefSpinlocks[NUM_SPINLOCKS]; #endif void * _Block_copy(const void *block_) { @@ -202,13 +202,13 @@ #ifdef OF_HAVE_ATOMIC_OPS of_atomic_int_inc(&block->flags); #else unsigned hash = SPINLOCK_HASH(block); - OF_ENSURE(of_spinlock_lock(&blockSpinlocks[hash]) == 0); + OF_ENSURE(OFSpinlockLock(&blockSpinlocks[hash]) == 0); block->flags++; - OF_ENSURE(of_spinlock_unlock(&blockSpinlocks[hash]) == 0); + OF_ENSURE(OFSpinlockUnlock(&blockSpinlocks[hash]) == 0); #endif } return block; } @@ -229,22 +229,22 @@ free(block); } #else unsigned hash = SPINLOCK_HASH(block); - OF_ENSURE(of_spinlock_lock(&blockSpinlocks[hash]) == 0); + OF_ENSURE(OFSpinlockLock(&blockSpinlocks[hash]) == 0); if ((--block->flags & OF_BLOCK_REFCOUNT_MASK) == 0) { - OF_ENSURE(of_spinlock_unlock(&blockSpinlocks[hash]) == 0); + OF_ENSURE(OFSpinlockUnlock(&blockSpinlocks[hash]) == 0); if (block->flags & OF_BLOCK_HAS_COPY_DISPOSE) block->descriptor->dispose_helper(block); free(block); return; } - OF_ENSURE(of_spinlock_unlock(&blockSpinlocks[hash]) == 0); + OF_ENSURE(OFSpinlockUnlock(&blockSpinlocks[hash]) == 0); #endif } void _Block_object_assign(void *dst_, const void *src_, const int flags_) @@ -294,33 +294,33 @@ *dst = src->forwarding; } #else unsigned hash = SPINLOCK_HASH(src); - OF_ENSURE(of_spinlock_lock(&byrefSpinlocks[hash]) == 0); + OF_ENSURE(OFSpinlockLock(&byrefSpinlocks[hash]) == 0); if (src->forwarding == src) src->forwarding = *dst; else { src->byref_dispose(*dst); free(*dst); *dst = src->forwarding; } OF_ENSURE( - of_spinlock_unlock(&byrefSpinlocks[hash]) == 0); + OFSpinlockUnlock(&byrefSpinlocks[hash]) == 0); #endif } else *dst = src; #ifdef OF_HAVE_ATOMIC_OPS of_atomic_int_inc(&(*dst)->flags); #else unsigned hash = SPINLOCK_HASH(*dst); - OF_ENSURE(of_spinlock_lock(&byrefSpinlocks[hash]) == 0); + OF_ENSURE(OFSpinlockLock(&byrefSpinlocks[hash]) == 0); (*dst)->flags++; - OF_ENSURE(of_spinlock_unlock(&byrefSpinlocks[hash]) == 0); + OF_ENSURE(OFSpinlockUnlock(&byrefSpinlocks[hash]) == 0); #endif break; } } @@ -355,21 +355,21 @@ free(object); } #else unsigned hash = SPINLOCK_HASH(object); - OF_ENSURE(of_spinlock_lock(&byrefSpinlocks[hash]) == 0); + OF_ENSURE(OFSpinlockLock(&byrefSpinlocks[hash]) == 0); if ((--object->flags & OF_BLOCK_REFCOUNT_MASK) == 0) { OF_ENSURE( - of_spinlock_unlock(&byrefSpinlocks[hash]) == 0); + OFSpinlockUnlock(&byrefSpinlocks[hash]) == 0); if (object->flags & OF_BLOCK_HAS_COPY_DISPOSE) object->byref_dispose(object); free(object); } - OF_ENSURE(of_spinlock_unlock(&byrefSpinlocks[hash]) == 0); + OF_ENSURE(OFSpinlockUnlock(&byrefSpinlocks[hash]) == 0); #endif break; } } @@ -376,12 +376,12 @@ @implementation OFBlock + (void)load { #ifndef OF_HAVE_ATOMIC_OPS for (size_t i = 0; i < NUM_SPINLOCKS; i++) - if (of_spinlock_new(&blockSpinlocks[i]) != 0 || - of_spinlock_new(&byrefSpinlocks[i]) != 0) + if (OFSpinlockNew(&blockSpinlocks[i]) != 0 || + OFSpinlockNew(&byrefSpinlocks[i]) != 0) @throw [OFInitializationFailedException exceptionWithClass: self]; #endif #ifdef OF_APPLE_RUNTIME