@@ -24,11 +24,11 @@ #include #import "OFObject.h" #import "OFTimer.h" -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS # import "OFThread.h" #endif #import "OFRunLoop.h" #import "OFAutoreleasePool.h" @@ -55,13 +55,13 @@ #endif #import "OFString.h" #import "instance.h" -#if defined(OF_ATOMIC_OPS) +#if defined(OF_HAVE_ATOMIC_OPS) # import "atomic.h" -#elif defined(OF_THREADS) +#elif defined(OF_HAVE_THREADS) # import "threading.h" #endif #if defined(OF_APPLE_RUNTIME) && !defined(__ppc64__) extern id of_forward(id, SEL, ...); @@ -69,11 +69,11 @@ #endif struct pre_ivar { int32_t retainCount; struct pre_mem *firstMem, *lastMem; -#if !defined(OF_ATOMIC_OPS) && defined(OF_THREADS) +#if !defined(OF_HAVE_ATOMIC_OPS) && defined(OF_HAVE_THREADS) of_spinlock_t retainCountSpinlock; #endif }; struct pre_mem { @@ -197,11 +197,11 @@ ((struct pre_ivar*)instance)->retainCount = 1; ((struct pre_ivar*)instance)->firstMem = NULL; ((struct pre_ivar*)instance)->lastMem = NULL; -#if !defined(OF_ATOMIC_OPS) && defined(OF_THREADS) +#if !defined(OF_HAVE_ATOMIC_OPS) && defined(OF_HAVE_THREADS) if OF_UNLIKELY (!of_spinlock_new( &((struct pre_ivar*)instance)->retainCountSpinlock)) { free(instance); @throw [OFInitializationFailedException exceptionWithClass: class]; @@ -252,13 +252,13 @@ #ifdef HAVE_OBJC_ENUMERATIONMUTATION objc_setEnumerationMutationHandler(enumeration_mutation_handler); #endif -#if defined(OF_HAVE_ARC4RANDOM) +#if defined(HAVE_ARC4RANDOM) of_hash_seed = arc4random(); -#elif defined(OF_HAVE_RANDOM) +#elif defined(HAVE_RANDOM) struct timeval t; gettimeofday(&t, NULL); srandom((unsigned)(t.tv_sec ^ t.tv_usec)); of_hash_seed = (uint32_t)((random() << 16) | (random() & 0xFFFF)); #else @@ -623,11 +623,11 @@ repeats: NO]; objc_autoreleasePoolPop(pool); } -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS - (void)performSelector: (SEL)selector onThread: (OFThread*)thread waitUntilDone: (BOOL)waitUntilDone { void *pool = objc_autoreleasePoolPush(); @@ -969,18 +969,16 @@ selector: selector]; } - retain { -#if defined(OF_ATOMIC_OPS) +#if defined(OF_HAVE_ATOMIC_OPS) of_atomic_inc_32(&PRE_IVARS->retainCount); -#elif defined(OF_THREADS) +#else OF_ENSURE(of_spinlock_lock(&PRE_IVARS->retainCountSpinlock)); PRE_IVARS->retainCount++; OF_ENSURE(of_spinlock_unlock(&PRE_IVARS->retainCountSpinlock)); -#else - PRE_IVARS->retainCount++; #endif return self; } @@ -990,25 +988,22 @@ return PRE_IVARS->retainCount; } - (void)release { -#if defined(OF_ATOMIC_OPS) +#if defined(OF_HAVE_ATOMIC_OPS) if (of_atomic_dec_32(&PRE_IVARS->retainCount) <= 0) [self dealloc]; -#elif defined(OF_THREADS) +#else size_t c; OF_ENSURE(of_spinlock_lock(&PRE_IVARS->retainCountSpinlock)); c = --PRE_IVARS->retainCount; OF_ENSURE(of_spinlock_unlock(&PRE_IVARS->retainCountSpinlock)); if (c == 0) [self dealloc]; -#else - if (--PRE_IVARS->retainCount == 0) - [self dealloc]; #endif } - autorelease {