@@ -17,21 +17,21 @@ #import "ObjFWRT.h" #import "private.h" #ifdef OF_HAVE_THREADS -# import "mutex.h" +# import "OFPlainMutex.h" #endif -struct weak_ref { +struct WeakRef { id **locations; size_t count; }; static struct objc_hashtable *hashtable; #ifdef OF_HAVE_THREADS -static of_spinlock_t spinlock; +static OFSpinlock spinlock; #endif static uint32_t hash(const void *object) { @@ -47,11 +47,11 @@ OF_CONSTRUCTOR() { hashtable = objc_hashtable_new(hash, equal, 2); #ifdef OF_HAVE_THREADS - if (of_spinlock_new(&spinlock) != 0) + if (OFSpinlockNew(&spinlock) != 0) OBJC_ERROR("Failed to create spinlock!"); #endif } id @@ -115,14 +115,14 @@ } id objc_storeWeak(id *object, id value) { - struct weak_ref *old; + struct WeakRef *old; #ifdef OF_HAVE_THREADS - if (of_spinlock_lock(&spinlock) != 0) + if (OFSpinlockLock(&spinlock) != 0) OBJC_ERROR("Failed to lock spinlock!"); #endif if (*object != nil && (old = objc_hashtable_get(hashtable, *object)) != NULL) { @@ -153,11 +153,11 @@ } } if (value != nil && class_respondsToSelector(object_getClass(value), @selector(allowsWeakReference)) && [value allowsWeakReference]) { - struct weak_ref *ref = objc_hashtable_get(hashtable, value); + struct WeakRef *ref = objc_hashtable_get(hashtable, value); if (ref == NULL) { if ((ref = calloc(1, sizeof(*ref))) == NULL) OBJC_ERROR("Not enough memory to allocate weak " "reference!"); @@ -175,11 +175,11 @@ value = nil; *object = value; #ifdef OF_HAVE_THREADS - if (of_spinlock_unlock(&spinlock) != 0) + if (OFSpinlockUnlock(&spinlock) != 0) OBJC_ERROR("Failed to unlock spinlock!"); #endif return value; } @@ -186,23 +186,23 @@ id objc_loadWeakRetained(id *object) { id value = nil; - struct weak_ref *ref; + struct WeakRef *ref; #ifdef OF_HAVE_THREADS - if (of_spinlock_lock(&spinlock) != 0) + if (OFSpinlockLock(&spinlock) != 0) OBJC_ERROR("Failed to lock spinlock!"); #endif if (*object != nil && (ref = objc_hashtable_get(hashtable, *object)) != NULL) value = *object; #ifdef OF_HAVE_THREADS - if (of_spinlock_unlock(&spinlock) != 0) + if (OFSpinlockUnlock(&spinlock) != 0) OBJC_ERROR("Failed to unlock spinlock!"); #endif if (class_respondsToSelector(object_getClass(value), @selector(retainWeakReference)) && [value retainWeakReference]) @@ -237,14 +237,14 @@ } void objc_moveWeak(id *dest, id *src) { - struct weak_ref *ref; + struct WeakRef *ref; #ifdef OF_HAVE_THREADS - if (of_spinlock_lock(&spinlock) != 0) + if (OFSpinlockLock(&spinlock) != 0) OBJC_ERROR("Failed to lock spinlock!"); #endif if (*src != nil && (ref = objc_hashtable_get(hashtable, *src)) != NULL) { @@ -258,22 +258,22 @@ *dest = *src; *src = nil; #ifdef OF_HAVE_THREADS - if (of_spinlock_unlock(&spinlock) != 0) + if (OFSpinlockUnlock(&spinlock) != 0) OBJC_ERROR("Failed to unlock spinlock!"); #endif } void -objc_zero_weak_references(id value) +objc_zeroWeakReferences(id value) { - struct weak_ref *ref; + struct WeakRef *ref; #ifdef OF_HAVE_THREADS - if (of_spinlock_lock(&spinlock) != 0) + if (OFSpinlockLock(&spinlock) != 0) OBJC_ERROR("Failed to lock spinlock!"); #endif if ((ref = objc_hashtable_get(hashtable, value)) != NULL) { for (size_t i = 0; i < ref->count; i++) @@ -283,9 +283,9 @@ free(ref->locations); free(ref); } #ifdef OF_HAVE_THREADS - if (of_spinlock_unlock(&spinlock) != 0) + if (OFSpinlockUnlock(&spinlock) != 0) OBJC_ERROR("Failed to unlock spinlock!"); #endif }