Index: Doxyfile ================================================================== --- Doxyfile +++ Doxyfile @@ -6,15 +6,15 @@ GENERATE_LATEX = NO HIDE_UNDOC_CLASSES = YES HIDE_UNDOC_MEMBERS = YES PREDEFINED = OF_HAVE_PROPERTIES \ OF_HAVE_BLOCKS \ - OF_THREADS \ + OF_HAVE_THREADS \ OF_SENTINEL \ OF_RETURNS_RETAINED \ OF_RETURNS_NOT_RETAINED \ OF_RETURNS_INNER_POINTER \ OF_CONSUMED \ OF_WEAK_UNAVAILABLE MACRO_EXPANSION = YES EXPAND_ONLY_PREDEF = YES IGNORE_PREFIX = OF of_ Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -104,11 +104,11 @@ AC_DEFINE_UNQUOTED(PLUGIN_SUFFIX, "$PLUGIN_SUFFIX", [Suffix for plugins]) AS_IF([test x"$PLUGIN_SUFFIX" != x""], [ AC_SUBST(USE_SRCS_PLUGINS, '${SRCS_PLUGINS}') AC_SUBST(TESTPLUGIN, "plugin") - AC_DEFINE(OF_PLUGINS, 1, [Whether we have plugin support]) + AC_DEFINE(OF_HAVE_PLUGINS, 1, [Whether we have plugin support]) ]) objc_runtime="ObjFW runtime" AC_CHECK_HEADER(objc/objc.h) AC_MSG_CHECKING(which Objective C runtime to use) @@ -402,14 +402,14 @@ ]) test x"$have_asprintf" != x"yes" -a x"$ac_cv_snprintf_useful_ret" != x"yes" && \ AC_MSG_ERROR(No asprintf and no snprintf returning required space!) AC_CHECK_FUNC(arc4random, [ - AC_DEFINE(OF_HAVE_ARC4RANDOM, 1, [Whether we have arc4random()]) + AC_DEFINE(HAVE_ARC4RANDOM, 1, [Whether we have arc4random()]) ], [ AC_CHECK_FUNC(random, [ - AC_DEFINE(OF_HAVE_RANDOM, 1, [Whether we have random()]) + AC_DEFINE(HAVE_RANDOM, 1, [Whether we have random()]) ]) ]) AC_CHECK_LIB(dl, dlopen, LIBS="$LIBS -ldl") @@ -452,11 +452,11 @@ AC_MSG_ERROR(No supported threads found!) ]) ;; esac - AC_DEFINE(OF_THREADS, 1, [Whether we have threads]) + AC_DEFINE(OF_HAVE_THREADS, 1, [Whether we have threads]) AC_SUBST(USE_SRCS_THREADS, '${SRCS_THREADS}') AC_SUBST(USE_INCLUDES_THREADS, '${INCLUDES_THREADS}') AC_MSG_CHECKING(whether __thread works) AC_TRY_LINK([ @@ -468,11 +468,11 @@ __thread int x = 0; ], [ x++; ], [ AC_MSG_RESULT(yes) - AC_DEFINE(OF_COMPILER_TLS, 1, [Whether __thread works]) + AC_DEFINE(OF_HAVE_COMPILER_TLS, 1, [Whether __thread works]) ], [ AC_MSG_RESULT(no) ]) atomic_ops="none" @@ -519,11 +519,11 @@ atomic_ops="not needed" ]) AC_MSG_CHECKING(for atomic operations) AS_IF([test x"$atomic_ops" != x"none"], [ - AC_DEFINE(OF_ATOMIC_OPS, 1, [Whether we have atomic operations]) + AC_DEFINE(OF_HAVE_ATOMIC_OPS, 1, [Whether we have atomic operations]) AC_SUBST(ATOMIC_H, "atomic.h") ]) AC_MSG_RESULT($atomic_ops) AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket") @@ -544,11 +544,11 @@ AC_CHECK_HEADER(poll.h, [ AC_DEFINE(HAVE_POLL_H, 1, [Whether we have poll.h]) AC_SUBST(OFSTREAMOBSERVER_POLL_M, "OFStreamObserver_poll.m") ]) AC_CHECK_HEADERS(sys/select.h, [ - AC_DEFINE(OF_HAVE_SYS_SELECT_H, 1, [Whether we have sys/select.h]) + AC_DEFINE(HAVE_SYS_SELECT_H, 1, [Whether we have sys/select.h]) AC_SUBST(OFSTREAMOBSERVER_SELECT_M, "OFStreamObserver_select.m") ]) case "$host_os" in mingw*) AC_SUBST(OFSTREAMOBSERVER_SELECT_M, Index: src/OFApplication.m ================================================================== --- src/OFApplication.m +++ src/OFApplication.m @@ -24,11 +24,11 @@ #import "OFApplication.h" #import "OFString.h" #import "OFArray.h" #import "OFDictionary.h" -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS # import "OFThread.h" #endif #import "OFRunLoop.h" #import "autorelease.h" @@ -378,11 +378,11 @@ - (void)run { void *pool = objc_autoreleasePoolPush(); OFRunLoop *runLoop; -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS [OFThread OF_createMainThread]; runLoop = [OFRunLoop currentRunLoop]; #else runLoop = [[[OFRunLoop alloc] init] autorelease]; #endif Index: src/OFAutoreleasePool.m ================================================================== --- src/OFAutoreleasePool.m +++ src/OFAutoreleasePool.m @@ -20,30 +20,30 @@ #import "OFAutoreleasePool.h" #import "OFArray.h" #import "macros.h" -#if !defined(OF_COMPILER_TLS) && defined(OF_THREADS) +#if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) # import "threading.h" # import "OFInitializationFailedException.h" #endif #import "autorelease.h" #define MAX_CACHE_SIZE 0x20 -#if defined(OF_COMPILER_TLS) +#if defined(OF_HAVE_COMPILER_TLS) static __thread OFAutoreleasePool **cache = NULL; -#elif defined(OF_THREADS) +#elif defined(OF_HAVE_THREADS) static of_tlskey_t cacheKey; #else static OFAutoreleasePool **cache = NULL; #endif @implementation OFAutoreleasePool -#if !defined(OF_COMPILER_TLS) && defined(OF_THREADS) +#if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) + (void)initialize { if (self != [OFAutoreleasePool class]) return; @@ -53,11 +53,11 @@ } #endif + alloc { -#if !defined(OF_COMPILER_TLS) && defined(OF_THREADS) +#if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) OFAutoreleasePool **cache = of_tlskey_get(cacheKey); #endif if (cache != NULL) { unsigned i; @@ -117,11 +117,11 @@ [self dealloc]; } - (void)dealloc { -#if !defined(OF_COMPILER_TLS) && defined(OF_THREADS) +#if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) OFAutoreleasePool **cache = of_tlskey_get(cacheKey); #endif if (ignoreRelease) return; @@ -131,11 +131,11 @@ objc_autoreleasePoolPop(pool); if (cache == NULL) { cache = calloc(sizeof(OFAutoreleasePool*), MAX_CACHE_SIZE); -#if !defined(OF_COMPILER_TLS) && defined(OF_THREADS) +#if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) if (!of_tlskey_set(cacheKey, cache)) { free(cache); cache = NULL; } #endif Index: src/OFBlock.m ================================================================== --- src/OFBlock.m +++ src/OFBlock.m @@ -31,14 +31,14 @@ #import "OFAllocFailedException.h" #import "OFInitializationFailedException.h" #import "macros.h" -#ifdef OF_ATOMIC_OPS +#ifdef OF_HAVE_ATOMIC_OPS # import "atomic.h" #endif -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS # import "threading.h" #endif typedef struct of_block_byref_t of_block_byref_t; struct of_block_byref_t { @@ -156,11 +156,11 @@ static struct { Class isa; } alloc_failed_exception; -#if !defined(OF_ATOMIC_OPS) && defined(OF_THREADS) +#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 spinlocks[NUM_SPINLOCKS]; #endif @@ -187,11 +187,11 @@ return copy; } if (object_getClass((id)block) == (Class)&_NSConcreteMallocBlock) { -#if defined(OF_ATOMIC_OPS) +#ifdef OF_HAVE_ATOMIC_OPS of_atomic_inc_int(&block->flags); #else unsigned hash = SPINLOCK_HASH(block); OF_ENSURE(of_spinlock_lock(&spinlocks[hash])); @@ -209,11 +209,11 @@ of_block_literal_t *block = (of_block_literal_t*)block_; if (object_getClass((id)block) != (Class)&_NSConcreteMallocBlock) return; -#ifdef OF_ATOMIC_OPS +#ifdef OF_HAVE_ATOMIC_OPS if ((of_atomic_dec_int(&block->flags) & OF_BLOCK_REFCOUNT_MASK) == 0) { if (block->flags & OF_BLOCK_HAS_COPY_DISPOSE) block->descriptor->dispose_helper(block); free(block); @@ -373,11 +373,11 @@ objc_registerClassPair((Class)&_NSConcreteMallocBlock); # endif } #endif -#if !defined(OF_ATOMIC_OPS) +#ifndef OF_HAVE_ATOMIC_OPS + (void)initialize { size_t i; for (i = 0; i < NUM_SPINLOCKS; i++) Index: src/OFDate.m ================================================================== --- src/OFDate.m +++ src/OFDate.m @@ -27,11 +27,11 @@ #import "OFDate.h" #import "OFString.h" #import "OFDictionary.h" #import "OFXMLElement.h" -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS # import "OFMutex.h" #endif #import "OFSystemInfo.h" #import "OFInitializationFailedException.h" @@ -42,11 +42,11 @@ #import "autorelease.h" #import "macros.h" #import "of_strptime.h" #if (!defined(HAVE_GMTIME_R) || !defined(HAVE_LOCALTIME_R)) && \ - defined(OF_THREADS) + defined(OF_HAVE_THREADS) static OFMutex *mutex; #endif #ifdef HAVE_GMTIME_R # define GMTIME_RET(field) \ @@ -74,11 +74,11 @@ @throw [OFOutOfRangeException \ exceptionWithClass: [self class]]; \ \ return tm.field; #else -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS # define GMTIME_RET(field) \ time_t seconds_ = (time_t)seconds; \ struct tm *tm; \ \ if (seconds_ != floor(seconds)) \ @@ -160,11 +160,11 @@ 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30, }; @implementation OFDate #if (!defined(HAVE_GMTIME_R) || !defined(HAVE_LOCALTIME_R)) && \ - defined(OF_THREADS) + defined(OF_HAVE_THREADS) + (void)initialize { if (self == [OFDate class]) mutex = [[OFMutex alloc] init]; } @@ -523,11 +523,11 @@ #ifdef HAVE_GMTIME_R if (gmtime_r(&seconds_, &tm) == NULL) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; #else -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS [mutex lock]; @try { # endif struct tm *tmp; @@ -535,11 +535,11 @@ if ((tmp = gmtime(&seconds_)) == NULL) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; tm = *tmp; -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS } @finally { [mutex unlock]; } # endif #endif @@ -573,11 +573,11 @@ #ifdef HAVE_LOCALTIME_R if (localtime_r(&seconds_, &tm) == NULL) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; #else -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS [mutex lock]; @try { # endif struct tm *tmp; @@ -585,11 +585,11 @@ if ((tmp = localtime(&seconds_)) == NULL) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; tm = *tmp; -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS } @finally { [mutex unlock]; } # endif #endif Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -41,11 +41,11 @@ #endif #import "OFFile.h" #import "OFString.h" #import "OFArray.h" -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS # import "threading.h" #endif #import "OFDate.h" #import "OFApplication.h" #import "OFSystemInfo.h" @@ -99,11 +99,11 @@ OFStream *of_stdin = nil; OFStream *of_stdout = nil; OFStream *of_stderr = nil; -#if defined(OF_THREADS) && !defined(_WIN32) +#if defined(OF_HAVE_THREADS) && !defined(_WIN32) static of_mutex_t mutex; #endif static int parse_mode(const char *mode) { @@ -160,11 +160,11 @@ @interface OFFileSingleton: OFFile @end @implementation OFFile -#if defined(OF_THREADS) && !defined(_WIN32) +#if defined(OF_HAVE_THREADS) && !defined(_WIN32) + (void)initialize { if (self != [OFFile class]) return; @@ -473,11 +473,11 @@ if (owner == nil && group == nil) @throw [OFInvalidArgumentException exceptionWithClass: self selector: _cmd]; -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS if (!of_mutex_lock(&mutex)) @throw [OFLockFailedException exceptionWithClass: self]; @try { # endif @@ -506,11 +506,11 @@ owner: owner group: group]; gid = group_->gr_gid; } -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS } @finally { if (!of_mutex_unlock(&mutex)) @throw [OFUnlockFailedException exceptionWithClass: self]; } Index: src/OFMapTable.m ================================================================== --- src/OFMapTable.m +++ src/OFMapTable.m @@ -152,13 +152,13 @@ count: capacity]; memset(buckets, 0, capacity * sizeof(*buckets)); if (of_hash_seed != 0) -#if defined(OF_HAVE_ARC4RANDOM) +#if defined(HAVE_ARC4RANDOM) rotate = arc4random() & 31; -#elif defined(OF_HAVE_RANDOM) +#elif defined(HAVE_RANDOM) rotate = random() & 31; #else rotate = rand() & 31; #endif } @catch (id e) { Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -682,11 +682,11 @@ - (void)performSelector: (SEL)selector withObject: (id)object1 withObject: (id)object2 afterDelay: (double)delay; -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS /*! * @brief Performs the specified selector on the specified thread. * * @param selector The selector to perform * @param thread The thread on which to perform the selector Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -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 { Index: src/OFRunLoop.h ================================================================== --- src/OFRunLoop.h +++ src/OFRunLoop.h @@ -18,11 +18,11 @@ #import "OFStream.h" #import "OFStreamObserver.h" #import "OFTCPSocket.h" @class OFSortedList; -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS @class OFMutex; #endif @class OFTimer; @class OFMutableDictionary; @@ -30,11 +30,11 @@ * @brief A class providing a run loop for the application and its processes. */ @interface OFRunLoop: OFObject { OFSortedList *timersQueue; -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS OFMutex *timersQueueLock; #endif OFStreamObserver *streamObserver; OFMutableDictionary *readQueues; } Index: src/OFRunLoop.m ================================================================== --- src/OFRunLoop.m +++ src/OFRunLoop.m @@ -18,11 +18,11 @@ #include #import "OFRunLoop.h" #import "OFDictionary.h" -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS # import "OFThread.h" # import "OFMutex.h" #endif #import "OFSortedList.h" #import "OFTimer.h" @@ -136,11 +136,11 @@ return [[mainRunLoop retain] autorelease]; } + (OFRunLoop*)currentRunLoop { -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS return [[OFThread currentThread] runLoop]; #else return [self mainRunLoop]; #endif } @@ -287,11 +287,11 @@ { self = [super init]; @try { timersQueue = [[OFSortedList alloc] init]; -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS timersQueueLock = [[OFMutex alloc] init]; #endif streamObserver = [[OFStreamObserver alloc] init]; [streamObserver setDelegate: self]; @@ -306,11 +306,11 @@ } - (void)dealloc { [timersQueue release]; -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS [timersQueueLock release]; #endif [streamObserver release]; [readQueues release]; @@ -317,16 +317,16 @@ [super dealloc]; } - (void)addTimer: (OFTimer*)timer { -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS [timersQueueLock lock]; @try { #endif [timersQueue insertObject: timer]; -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS } @finally { [timersQueueLock unlock]; } #endif @@ -335,11 +335,11 @@ [streamObserver cancel]; } - (void)OF_removeTimer: (OFTimer*)timer { -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS [timersQueueLock lock]; @try { #endif of_list_object_t *iter; @@ -348,11 +348,11 @@ if ([iter->object isEqual: timer]) { [timersQueue removeListObject: iter]; break; } } -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS } @finally { [timersQueueLock unlock]; } #endif } @@ -589,11 +589,11 @@ void *pool = objc_autoreleasePoolPush(); OFDate *now = [OFDate date]; OFTimer *timer; OFDate *nextTimer; -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS [timersQueueLock lock]; @try { #endif of_list_object_t *listObject = [timersQueue firstListObject]; @@ -607,25 +607,25 @@ [timersQueue removeListObject: listObject]; [timer OF_setInRunLoop: nil]; } else timer = nil; -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS } @finally { [timersQueueLock unlock]; } #endif if ([timer isValid]) [timer fire]; -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS [timersQueueLock lock]; @try { #endif nextTimer = [[timersQueue firstObject] fireDate]; -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS } @finally { [timersQueueLock unlock]; } #endif Index: src/OFStreamObserver.h ================================================================== --- src/OFStreamObserver.h +++ src/OFStreamObserver.h @@ -26,11 +26,11 @@ @class OFStream; @class OFMutableArray; @class OFMutableDictionary; @class OFDataArray; -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS @class OFMutex; #endif /*! * @brief A protocol that needs to be implemented by delegates for @@ -86,11 +86,11 @@ id delegate; int cancelFD[2]; #ifdef _WIN32 struct sockaddr_in cancelAddr; #endif -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS OFMutex *mutex; #endif } #ifdef OF_HAVE_PROPERTIES Index: src/OFStreamObserver.m ================================================================== --- src/OFStreamObserver.m +++ src/OFStreamObserver.m @@ -30,11 +30,11 @@ #import "OFStream.h" #import "OFDataArray.h" #ifdef _WIN32 # import "OFTCPSocket.h" #endif -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS # import "OFMutex.h" #endif #ifdef HAVE_KQUEUE # import "OFStreamObserver_kqueue.h" @@ -146,11 +146,11 @@ maxFD = cancelFD[0]; FDToStream = [self allocMemoryWithSize: sizeof(OFStream*) count: maxFD + 1]; FDToStream[cancelFD[0]] = nil; -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS mutex = [[OFMutex alloc] init]; #endif } @catch (id e) { [self release]; @throw e; @@ -167,11 +167,11 @@ [readStreams release]; [writeStreams release]; [queue release]; [queueInfo release]; [queueFDs release]; -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS [mutex release]; #endif [super dealloc]; } @@ -186,67 +186,67 @@ delegate = delegate_; } - (void)addStreamForReading: (OFStream*)stream { -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS [mutex lock]; - @try { #endif + @try { int qi = QUEUE_ADD | QUEUE_READ; int fd = [stream fileDescriptorForReading]; [queue addObject: stream]; [queueInfo addItem: &qi]; [queueFDs addItem: &fd]; -#ifdef OF_THREADS } @finally { +#ifdef OF_HAVE_THREADS [mutex unlock]; - } #endif + } [self cancel]; } - (void)addStreamForWriting: (OFStream*)stream { -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS [mutex lock]; - @try { #endif + @try { int qi = QUEUE_ADD | QUEUE_WRITE; int fd = [stream fileDescriptorForWriting]; [queue addObject: stream]; [queueInfo addItem: &qi]; [queueFDs addItem: &fd]; -#ifdef OF_THREADS } @finally { +#ifdef OF_HAVE_THREADS [mutex unlock]; - } #endif + } [self cancel]; } - (void)removeStreamForReading: (OFStream*)stream { -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS [mutex lock]; - @try { #endif + @try { int qi = QUEUE_REMOVE | QUEUE_READ; int fd = [stream fileDescriptorForReading]; [queue addObject: stream]; [queueInfo addItem: &qi]; [queueFDs addItem: &fd]; -#ifdef OF_THREADS } @finally { +#ifdef OF_HAVE_THREADS [mutex unlock]; - } #endif + } #ifndef _WIN32 OF_ENSURE(write(cancelFD[1], "", 1) > 0); #else OF_ENSURE(sendto(cancelFD[1], "", 1, 0, (struct sockaddr*)&cancelAddr, @@ -254,25 +254,25 @@ #endif } - (void)removeStreamForWriting: (OFStream*)stream { -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS [mutex lock]; - @try { #endif + @try { int qi = QUEUE_REMOVE | QUEUE_WRITE; int fd = [stream fileDescriptorForWriting]; [queue addObject: stream]; [queueInfo addItem: &qi]; [queueFDs addItem: &fd]; -#ifdef OF_THREADS } @finally { +#ifdef OF_HAVE_THREADS [mutex unlock]; - } #endif + } #ifndef _WIN32 OF_ENSURE(write(cancelFD[1], "", 1) > 0); #else OF_ENSURE(sendto(cancelFD[1], "", 1, 0, (struct sockaddr*)&cancelAddr, @@ -304,14 +304,14 @@ abort(); } - (void)OF_processQueue { -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS [mutex lock]; - @try { #endif + @try { OFStream **queueObjects = [queue objects]; int *queueInfoItems = [queueInfo items]; int *queueFDsItems = [queueFDs items]; size_t i, count = [queue count]; @@ -368,15 +368,15 @@ } [queue removeAllObjects]; [queueInfo removeAllItems]; [queueFDs removeAllItems]; -#ifdef OF_THREADS } @finally { +#ifdef OF_HAVE_THREADS [mutex unlock]; - } #endif + } } - (void)observe { [self observeWithTimeout: -1]; Index: src/OFStreamObserver_select.h ================================================================== --- src/OFStreamObserver_select.h +++ src/OFStreamObserver_select.h @@ -19,11 +19,11 @@ #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS #endif -#ifdef OF_HAVE_SYS_SELECT_H +#ifdef HAVE_SYS_SELECT_H # include #endif #import "OFStreamObserver.h" Index: src/OFTCPSocket.h ================================================================== --- src/OFTCPSocket.h +++ src/OFTCPSocket.h @@ -128,11 +128,11 @@ * @param port The port on the host to connect to */ - (void)connectToHost: (OFString*)host port: (uint16_t)port; -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS /*! * @brief Asyncronously connect the OFTCPSocket to the specified destination. * * @param host The host to connect to * @param port The port on the host to connect to Index: src/OFTCPSocket.m ================================================================== --- src/OFTCPSocket.m +++ src/OFTCPSocket.m @@ -33,11 +33,11 @@ #endif #import "OFTCPSocket.h" #import "OFTCPSocket+SOCKS5.h" #import "OFString.h" -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS # import "OFThread.h" #endif #import "OFTimer.h" #import "OFRunLoop.h" @@ -57,11 +57,11 @@ #ifndef INVALID_SOCKET # define INVALID_SOCKET -1 #endif -#if defined(OF_THREADS) && !defined(HAVE_THREADSAFE_GETADDRINFO) +#if defined(OF_HAVE_THREADS) && !defined(HAVE_THREADSAFE_GETADDRINFO) # import "OFMutex.h" # import "OFDataArray.h" static OFMutex *mutex = nil; #endif @@ -79,11 +79,11 @@ Class of_tls_socket_class = Nil; static OFString *defaultSOCKS5Host = nil; static uint16_t defaultSOCKS5Port = 1080; -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS @interface OFTCPSocket_ConnectThread: OFThread { OFThread *sourceThread; OFTCPSocket *sock; OFString *host; @@ -214,11 +214,11 @@ } @end #endif @implementation OFTCPSocket -#if defined(OF_THREADS) && !defined(HAVE_THREADSAFE_GETADDRINFO) +#if defined(OF_HAVE_THREADS) && !defined(HAVE_THREADSAFE_GETADDRINFO) + (void)initialize { if (self == [OFTCPSocket class]) mutex = [[OFMutex alloc] init]; } @@ -342,20 +342,20 @@ #else BOOL connected = NO; struct hostent *he; struct sockaddr_in addr; char **ip; -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS OFDataArray *addrlist; addrlist = [[OFDataArray alloc] initWithItemSize: sizeof(char**)]; [mutex lock]; # endif if ((he = gethostbyname([host cStringWithEncoding: OF_STRING_ENCODING_NATIVE])) == NULL) { -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS [addrlist release]; [mutex unlock]; # endif @throw [OFAddressTranslationFailedException exceptionWithClass: [self class] @@ -367,11 +367,11 @@ addr.sin_family = AF_INET; addr.sin_port = OF_BSWAP16_IF_LE(port); if (he->h_addrtype != AF_INET || (sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) { -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS [addrlist release]; [mutex unlock]; # endif @throw [OFConnectionFailedException exceptionWithClass: [self class] @@ -378,11 +378,11 @@ socket: self host: host port: port]; } -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS @try { for (ip = he->h_addr_list; *ip != NULL; ip++) [addrlist addItem: ip]; /* Add the terminating NULL */ @@ -405,11 +405,11 @@ connected = YES; break; } -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS [addrlist release]; # endif if (!connected) { close(sock); @@ -427,11 +427,11 @@ if (SOCKS5Host != nil) [self OF_SOCKS5ConnectToHost: destinationHost port: destinationPort]; } -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS - (void)asyncConnectToHost: (OFString*)host port: (uint16_t)port target: (id)target selector: (SEL)selector { @@ -529,17 +529,17 @@ freeaddrinfo(res); #else struct hostent *he; -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS [mutex lock]; # endif if ((he = gethostbyname([host cStringWithEncoding: OF_STRING_ENCODING_NATIVE])) == NULL) { -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS [mutex unlock]; # endif @throw [OFAddressTranslationFailedException exceptionWithClass: [self class] socket: self @@ -549,11 +549,11 @@ memset(&addr, 0, sizeof(addr)); addr.in.sin_family = AF_INET; addr.in.sin_port = OF_BSWAP16_IF_LE(port); if (he->h_addrtype != AF_INET || he->h_addr_list[0] == NULL) { -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS [mutex unlock]; # endif @throw [OFAddressTranslationFailedException exceptionWithClass: [self class] socket: self @@ -560,11 +560,11 @@ host: host]; } memcpy(&addr.in.sin_addr.s_addr, he->h_addr_list[0], he->h_length); -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS [mutex unlock]; # endif if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) @throw [OFBindFailedException exceptionWithClass: [self class] socket: self @@ -703,11 +703,11 @@ encoding: OF_STRING_ENCODING_NATIVE]; } @finally { [self freeMemory: host]; } #else -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS [mutex lock]; @try { # endif host = inet_ntoa(((struct sockaddr_in*)sockAddr)->sin_addr); @@ -716,11 +716,11 @@ @throw [OFAddressTranslationFailedException exceptionWithClass: [self class]]; return [OFString stringWithCString: host encoding: OF_STRING_ENCODING_NATIVE]; -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS } @finally { [mutex unlock]; } # endif #endif Index: src/OFTimer.h ================================================================== --- src/OFTimer.h +++ src/OFTimer.h @@ -17,11 +17,11 @@ #import "OFObject.h" @class OFTimer; @class OFDate; @class OFRunLoop; -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS @class OFCondition; #endif #ifdef OF_HAVE_BLOCKS typedef void (^of_timer_block_t)(OFTimer*); @@ -40,11 +40,11 @@ BOOL repeats; #ifdef OF_HAVE_BLOCKS of_timer_block_t block; #endif BOOL isValid; -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS OFCondition *condition; BOOL done; #endif OFRunLoop *inRunLoop; } @@ -313,14 +313,14 @@ * @return The time interval in which the timer will repeat, if it is a * repeating timer */ - (double)timeInterval; -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS /*! * @brief Waits until the timer fired. */ - (void)waitUntilDone; #endif - (void)OF_setInRunLoop: (OFRunLoop*)inRunLoop; @end Index: src/OFTimer.m ================================================================== --- src/OFTimer.m +++ src/OFTimer.m @@ -21,11 +21,11 @@ #include #import "OFTimer.h" #import "OFDate.h" #import "OFRunLoop.h" -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS # import "OFCondition.h" #endif #import "OFInvalidArgumentException.h" @@ -235,11 +235,11 @@ object1 = [object1_ retain]; object2 = [object2_ retain]; arguments = arguments_; repeats = repeats_; isValid = YES; -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS condition = [[OFCondition alloc] init]; #endif } @catch (id e) { [self release]; @throw e; @@ -311,11 +311,11 @@ fireDate = [fireDate_ retain]; interval = interval_; repeats = repeats_; block = [block_ copy]; isValid = YES; -# ifdef OF_THREADS +# ifdef OF_HAVE_THREADS condition = [[OFCondition alloc] init]; # endif } @catch (id e) { [self release]; @throw e; @@ -338,11 +338,11 @@ [object1 release]; [object2 release]; #ifdef OF_HAVE_BLOCKS [block release]; #endif -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS [condition release]; #endif [super dealloc]; } @@ -386,11 +386,11 @@ } #ifdef OF_HAVE_BLOCKS } #endif -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS [condition lock]; @try { done = YES; [condition signal]; } @finally { @@ -446,11 +446,11 @@ - (BOOL)isValid { return isValid; } -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS - (void)waitUntilDone { [condition lock]; @try { if (done) { Index: src/ObjFW.h ================================================================== --- src/ObjFW.h +++ src/ObjFW.h @@ -85,11 +85,11 @@ #import "OFAlreadyConnectedException.h" #import "OFBindFailedException.h" #import "OFChangeDirectoryFailedException.h" #import "OFChangeFileModeFailedException.h" #import "OFChangeFileOwnerFailedException.h" -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS # import "OFConditionBroadcastFailedException.h" # import "OFConditionSignalFailedException.h" # import "OFConditionStillWaitingException.h" # import "OFConditionWaitFailedException.h" #endif @@ -122,11 +122,11 @@ #import "OFRenameFileFailedException.h" #import "OFSeekFailedException.h" #import "OFSetOptionFailedException.h" #import "OFStillLockedException.h" #import "OFSymlinkFailedException.h" -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS # import "OFThreadJoinFailedException.h" # import "OFThreadStartFailedException.h" # import "OFThreadStillRunningException.h" #endif #import "OFTruncatedDataException.h" @@ -135,20 +135,20 @@ #import "OFUnsupportedProtocolException.h" #import "OFWriteFailedException.h" #import "macros.h" -#ifdef OF_PLUGINS +#ifdef OF_HAVE_PLUGINS # import "OFPlugin.h" #endif -#ifdef OF_ATOMIC_OPS +#ifdef OF_HAVE_ATOMIC_OPS # import "atomic.h" #endif #import "OFLocking.h" -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS # import "threading.h" # import "OFThread.h" # import "OFThreadPool.h" # import "OFTLSKey.h" # import "OFMutex.h" Index: src/atomic.h ================================================================== --- src/atomic.h +++ src/atomic.h @@ -23,11 +23,11 @@ #endif static OF_INLINE int of_atomic_add_int(volatile int *p, int i) { -#if !defined(OF_THREADS) +#if !defined(OF_HAVE_THREADS) return (*p += i); #elif defined(OF_X86_ASM) || defined(OF_AMD64_ASM) if (sizeof(int) == 4) __asm__ ( "lock\n\t" @@ -67,11 +67,11 @@ } static OF_INLINE int32_t of_atomic_add_32(volatile int32_t *p, int32_t i) { -#if !defined(OF_THREADS) +#if !defined(OF_HAVE_THREADS) return (*p += i); #elif defined(OF_X86_ASM) || defined(OF_AMD64_ASM) __asm__ ( "lock\n\t" "xaddl %0, %2\n\t" @@ -91,11 +91,11 @@ } static OF_INLINE void* of_atomic_add_ptr(void* volatile *p, intptr_t i) { -#if !defined(OF_THREADS) +#if !defined(OF_HAVE_THREADS) return (*(char* volatile*)p += i); #elif defined(OF_X86_ASM) __asm__ ( "lock\n\t" "xaddl %0, %2\n\t" @@ -132,11 +132,11 @@ } static OF_INLINE int of_atomic_sub_int(volatile int *p, int i) { -#if !defined(OF_THREADS) +#if !defined(OF_HAVE_THREADS) return (*p -= i); #elif defined(OF_X86_ASM) || defined(OF_AMD64_ASM) if (sizeof(int) == 4) __asm__ ( "negl %0\n\t" @@ -178,11 +178,11 @@ } static OF_INLINE int32_t of_atomic_sub_32(volatile int32_t *p, int32_t i) { -#if !defined(OF_THREADS) +#if !defined(OF_HAVE_THREADS) return (*p -= i); #elif defined(OF_X86_ASM) || defined(OF_AMD64_ASM) __asm__ ( "negl %0\n\t" "lock\n\t" @@ -203,11 +203,11 @@ } static OF_INLINE void* of_atomic_sub_ptr(void* volatile *p, intptr_t i) { -#if !defined(OF_THREADS) +#if !defined(OF_HAVE_THREADS) return (*(char* volatile*)p -= i); #elif defined(OF_X86_ASM) __asm__ ( "negl %0\n\t" "lock\n\t" @@ -246,11 +246,11 @@ } static OF_INLINE int of_atomic_inc_int(volatile int *p) { -#if !defined(OF_THREADS) +#if !defined(OF_HAVE_THREADS) return ++*p; #elif defined(OF_X86_ASM) || defined(OF_AMD64_ASM) int i; if (sizeof(int) == 4) @@ -296,11 +296,11 @@ } static OF_INLINE int32_t of_atomic_inc_32(volatile int32_t *p) { -#if !defined(OF_THREADS) +#if !defined(OF_HAVE_THREADS) return ++*p; #elif defined(OF_X86_ASM) || defined(OF_AMD64_ASM) uint32_t i; __asm__ ( @@ -324,11 +324,11 @@ } static OF_INLINE int of_atomic_dec_int(volatile int *p) { -#if !defined(OF_THREADS) +#if !defined(OF_HAVE_THREADS) return --*p; #elif defined(OF_X86_ASM) || defined(OF_AMD64_ASM) int i; if (sizeof(int) == 4) @@ -374,11 +374,11 @@ } static OF_INLINE int32_t of_atomic_dec_32(volatile int32_t *p) { -#if !defined(OF_THREADS) +#if !defined(OF_HAVE_THREADS) return --*p; #elif defined(OF_X86_ASM) || defined(OF_AMD64_ASM) uint32_t i; __asm__ ( @@ -402,11 +402,11 @@ } static OF_INLINE unsigned int of_atomic_or_int(volatile unsigned int *p, unsigned int i) { -#if !defined(OF_THREADS) +#if !defined(OF_HAVE_THREADS) return (*p |= i); #elif defined(OF_X86_ASM) || defined(OF_AMD64_ASM) if (sizeof(int) == 4) __asm__ ( "0:\n\t" @@ -456,11 +456,11 @@ } static OF_INLINE uint32_t of_atomic_or_32(volatile uint32_t *p, uint32_t i) { -#if !defined(OF_THREADS) +#if !defined(OF_HAVE_THREADS) return (*p |= i); #elif defined(OF_X86_ASM) || defined(OF_AMD64_ASM) __asm__ ( "0:\n\t" "movl %2, %0\n\t" @@ -485,11 +485,11 @@ } static OF_INLINE unsigned int of_atomic_and_int(volatile unsigned int *p, unsigned int i) { -#if !defined(OF_THREADS) +#if !defined(OF_HAVE_THREADS) return (*p &= i); #elif defined(OF_X86_ASM) || defined(OF_AMD64_ASM) if (sizeof(int) == 4) __asm__ ( "0:\n\t" @@ -539,11 +539,11 @@ } static OF_INLINE uint32_t of_atomic_and_32(volatile uint32_t *p, uint32_t i) { -#if !defined(OF_THREADS) +#if !defined(OF_HAVE_THREADS) return (*p &= i); #elif defined(OF_X86_ASM) || defined(OF_AMD64_ASM) __asm__ ( "0:\n\t" "movl %2, %0\n\t" @@ -568,11 +568,11 @@ } static OF_INLINE unsigned int of_atomic_xor_int(volatile unsigned int *p, unsigned int i) { -#if !defined(OF_THREADS) +#if !defined(OF_HAVE_THREADS) return (*p ^= i); #elif defined(OF_X86_ASM) || defined(OF_AMD64_ASM) if (sizeof(int) == 4) __asm__ ( "0:\n\t" @@ -622,11 +622,11 @@ } static OF_INLINE uint32_t of_atomic_xor_32(volatile uint32_t *p, uint32_t i) { -#if !defined(OF_THREADS) +#if !defined(OF_HAVE_THREADS) return (*p ^= i); #elif defined(OF_X86_ASM) || defined(OF_AMD64_ASM) __asm__ ( "0:\n\t" "movl %2, %0\n\t" @@ -651,11 +651,11 @@ } static OF_INLINE BOOL of_atomic_cmpswap_int(volatile int *p, int o, int n) { -#if !defined(OF_THREADS) +#if !defined(OF_HAVE_THREADS) if (*p == o) { *p = n; return YES; } @@ -685,11 +685,11 @@ } static OF_INLINE BOOL of_atomic_cmpswap_32(volatile int32_t *p, int32_t o, int32_t n) { -#if !defined(OF_THREADS) +#if !defined(OF_HAVE_THREADS) if (*p == o) { *p = n; return YES; } @@ -719,11 +719,11 @@ } static OF_INLINE BOOL of_atomic_cmpswap_ptr(void* volatile *p, void *o, void *n) { -#if !defined(OF_THREADS) +#if !defined(OF_HAVE_THREADS) if (*p == o) { *p = n; return YES; } Index: src/autorelease.m ================================================================== --- src/autorelease.m +++ src/autorelease.m @@ -20,30 +20,30 @@ #include #import "OFObject.h" #import "OFSystemInfo.h" -#if !defined(OF_COMPILER_TLS) && defined(OF_THREADS) +#if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) # import "threading.h" #endif #import "macros.h" #import "autorelease.h" -#if defined(OF_COMPILER_TLS) +#if defined(OF_HAVE_COMPILER_TLS) static __thread id *objects = NULL; static __thread id *top = NULL; static __thread size_t size = 0; -#elif defined(OF_THREADS) +#elif defined(OF_HAVE_THREADS) static of_tlskey_t objectsKey, topKey, sizeKey; #else static id *objects = NULL; static id *top = NULL; static size_t size = 0; #endif -#if !defined(OF_COMPILER_TLS) && defined(OF_THREADS) +#if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) static void __attribute__((constructor)) init(void) { OF_ENSURE(of_tlskey_new(&objectsKey)); OF_ENSURE(of_tlskey_new(&topKey)); @@ -52,11 +52,11 @@ #endif void* objc_autoreleasePoolPush() { -#if !defined(OF_COMPILER_TLS) && defined(OF_THREADS) +#if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) id *top = of_tlskey_get(topKey); id *objects = of_tlskey_get(objectsKey); #endif ptrdiff_t offset = top - objects; @@ -64,11 +64,11 @@ } void objc_autoreleasePoolPop(void *offset) { -#if !defined(OF_COMPILER_TLS) && defined(OF_THREADS) +#if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) id *top = of_tlskey_get(topKey); id *objects = of_tlskey_get(objectsKey); #endif id *pool = objects + (ptrdiff_t)offset; id *iter; @@ -83,20 +83,20 @@ objects = NULL; top = NULL; } -#if !defined(OF_COMPILER_TLS) && defined(OF_THREADS) +#if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) OF_ENSURE(of_tlskey_set(topKey, top)); OF_ENSURE(of_tlskey_set(objectsKey, objects)); #endif } id _objc_rootAutorelease(id object) { -#if !defined(OF_COMPILER_TLS) && defined(OF_THREADS) +#if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) id *top = of_tlskey_get(topKey); id *objects = of_tlskey_get(objectsKey); size_t size = (size_t)(uintptr_t)of_tlskey_get(sizeKey); #endif @@ -105,11 +105,11 @@ OF_ENSURE((objects = malloc(size)) != NULL); top = objects; -#if !defined(OF_COMPILER_TLS) && defined(OF_THREADS) +#if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) OF_ENSURE(of_tlskey_set(objectsKey, objects)); OF_ENSURE(of_tlskey_set(sizeKey, (void*)(uintptr_t)size)); #endif } @@ -117,11 +117,11 @@ ptrdiff_t diff = top - objects; size += [OFSystemInfo pageSize]; OF_ENSURE((objects = realloc(objects, size)) != NULL); -#if !defined(OF_COMPILER_TLS) && defined(OF_THREADS) +#if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) OF_ENSURE(of_tlskey_set(objectsKey, objects)); OF_ENSURE(of_tlskey_set(sizeKey, (void*)(uintptr_t)size)); #endif top = objects + diff; @@ -128,11 +128,11 @@ } *top = object; top++; -#if !defined(OF_COMPILER_TLS) && defined(OF_THREADS) +#if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) OF_ENSURE(of_tlskey_set(topKey, top)); #endif return object; } Index: src/objfw-defs.h.in ================================================================== --- src/objfw-defs.h.in +++ src/objfw-defs.h.in @@ -1,18 +1,17 @@ #undef OF_APPLE_RUNTIME -#undef OF_ATOMIC_OPS #undef OF_BIG_ENDIAN -#undef OF_COMPILER_TLS #undef OF_FLOAT_BIG_ENDIAN #undef OF_HAVE_ASPRINTF +#undef OF_HAVE_ATOMIC_OPS +#undef OF_HAVE_COMPILER_TLS #undef OF_HAVE_GCC_ATOMIC_OPS #undef OF_HAVE_OSATOMIC #undef OF_HAVE_OSATOMIC_64 #undef OF_HAVE_PTHREADS +#undef OF_HAVE_PLUGINS #undef OF_HAVE_PTHREAD_SPINLOCKS #undef OF_HAVE_RECURSIVE_PTHREAD_MUTEXES #undef OF_HAVE_SCHED_YIELD -#undef OF_HAVE_SYS_SELECT_H +#undef OF_HAVE_THREADS #undef OF_OBJFW_RUNTIME -#undef OF_PLUGINS -#undef OF_THREADS #undef SIZE_MAX Index: src/runtime/property.m ================================================================== --- src/runtime/property.m +++ src/runtime/property.m @@ -22,18 +22,18 @@ #import "runtime-private.h" #import "OFObject.h" #import "macros.h" -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS # import "threading.h" # define NUM_SPINLOCKS 8 /* needs to be a power of 2 */ # define SPINLOCK_HASH(p) ((unsigned)((uintptr_t)p >> 4) & (NUM_SPINLOCKS - 1)) static of_spinlock_t spinlocks[NUM_SPINLOCKS]; #endif -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS static void __attribute__((constructor)) init(void) { size_t i; @@ -46,11 +46,11 @@ id objc_getProperty(id self, SEL _cmd, ptrdiff_t offset, BOOL atomic) { if (atomic) { id *ptr = (id*)(void*)((char*)self + offset); -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS unsigned hash = SPINLOCK_HASH(ptr); OF_ENSURE(of_spinlock_lock(&spinlocks[hash])); @try { return [[*ptr retain] autorelease]; @@ -69,11 +69,11 @@ objc_setProperty(id self, SEL _cmd, ptrdiff_t offset, id value, BOOL atomic, signed char copy) { if (atomic) { id *ptr = (id*)(void*)((char*)self + offset); -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS unsigned hash = SPINLOCK_HASH(ptr); OF_ENSURE(of_spinlock_lock(&spinlocks[hash])); @try { #endif @@ -89,11 +89,11 @@ default: *ptr = [value copy]; } [old release]; -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS } @finally { OF_ENSURE(of_spinlock_unlock(&spinlocks[hash])); } #endif @@ -121,17 +121,17 @@ void objc_getPropertyStruct(void *dest, const void *src, ptrdiff_t size, BOOL atomic, BOOL strong) { if (atomic) { -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS unsigned hash = SPINLOCK_HASH(src); OF_ENSURE(of_spinlock_lock(&spinlocks[hash])); #endif memcpy(dest, src, size); -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS OF_ENSURE(of_spinlock_unlock(&spinlocks[hash])); #endif return; } @@ -142,20 +142,20 @@ void objc_setPropertyStruct(void *dest, const void *src, ptrdiff_t size, BOOL atomic, BOOL strong) { if (atomic) { -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS unsigned hash = SPINLOCK_HASH(src); OF_ENSURE(of_spinlock_lock(&spinlocks[hash])); #endif memcpy(dest, src, size); -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS OF_ENSURE(of_spinlock_unlock(&spinlocks[hash])); #endif return; } memcpy(dest, src, size); } Index: src/runtime/runtime-private.h ================================================================== --- src/runtime/runtime-private.h +++ src/runtime/runtime-private.h @@ -147,11 +147,11 @@ const void*); extern void objc_sparsearray_free(struct objc_sparsearray*); extern void objc_sparsearray_cleanup(void); extern void objc_init_static_instances(struct objc_abi_symtab*); extern void __objc_exec_class(struct objc_abi_module*); -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS extern void objc_global_mutex_lock(void); extern void objc_global_mutex_unlock(void); extern void objc_global_mutex_free(void); #else # define objc_global_mutex_lock() Index: src/runtime/synchronized.m ================================================================== --- src/runtime/synchronized.m +++ src/runtime/synchronized.m @@ -20,11 +20,11 @@ #include #import "runtime.h" #import "runtime-private.h" -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS # import "threading.h" struct lock_s { id object; int count; @@ -43,11 +43,11 @@ #endif int objc_sync_enter(id object) { -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS struct lock_s *lock; if (!of_mutex_lock(&mutex)) OBJC_ERROR("Failed to lock mutex!"); @@ -91,11 +91,11 @@ } int objc_sync_exit(id object) { -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS struct lock_s *lock, *last = NULL; if (!of_mutex_lock(&mutex)) OBJC_ERROR("Failed to lock mutex!"); Index: src/threading.h ================================================================== --- src/threading.h +++ src/threading.h @@ -14,11 +14,12 @@ * file. */ #import "objfw-defs.h" -#if !defined(OF_THREADS) || (!defined(OF_HAVE_PTHREADS) && !defined(_WIN32)) +#if !defined(OF_HAVE_THREADS) || \ + (!defined(OF_HAVE_PTHREADS) && !defined(_WIN32)) # error No threads available! #endif #import "macros.h" @@ -37,11 +38,11 @@ HANDLE event; int count; } of_condition_t; #endif -#if defined(OF_ATOMIC_OPS) +#if defined(OF_HAVE_ATOMIC_OPS) # import "atomic.h" typedef volatile int of_spinlock_t; # define OF_SPINCOUNT 10 #elif defined(OF_HAVE_PTHREAD_SPINLOCKS) typedef pthread_spinlock_t of_spinlock_t; @@ -295,11 +296,11 @@ } static OF_INLINE BOOL of_spinlock_new(of_spinlock_t *spinlock) { -#if defined(OF_ATOMIC_OPS) +#if defined(OF_HAVE_ATOMIC_OPS) *spinlock = 0; return YES; #elif defined(OF_HAVE_PTHREAD_SPINLOCKS) return !pthread_spin_init(spinlock, 0); #else @@ -308,11 +309,11 @@ } static OF_INLINE BOOL of_spinlock_trylock(of_spinlock_t *spinlock) { -#if defined(OF_ATOMIC_OPS) +#if defined(OF_HAVE_ATOMIC_OPS) return of_atomic_cmpswap_int(spinlock, 0, 1); #elif defined(OF_HAVE_PTHREAD_SPINLOCKS) return !pthread_spin_trylock(spinlock); #else return of_mutex_trylock(spinlock); @@ -320,11 +321,11 @@ } static OF_INLINE BOOL of_spinlock_lock(of_spinlock_t *spinlock) { -#if defined(OF_ATOMIC_OPS) +#if defined(OF_HAVE_ATOMIC_OPS) # if defined(OF_HAVE_SCHED_YIELD) || defined(_WIN32) int i; for (i = 0; i < OF_SPINCOUNT; i++) if (of_spinlock_trylock(spinlock)) @@ -349,11 +350,11 @@ } static OF_INLINE BOOL of_spinlock_unlock(of_spinlock_t *spinlock) { -#if defined(OF_ATOMIC_OPS) +#if defined(OF_HAVE_ATOMIC_OPS) *spinlock = 0; return YES; #elif defined(OF_HAVE_PTHREAD_SPINLOCKS) return !pthread_spin_unlock(spinlock); #else @@ -362,11 +363,11 @@ } static OF_INLINE BOOL of_spinlock_free(of_spinlock_t *spinlock) { -#if defined(OF_ATOMIC_OPS) +#if defined(OF_HAVE_ATOMIC_OPS) return YES; #elif defined(OF_HAVE_PTHREAD_SPINLOCKS) return !pthread_spin_destroy(spinlock); #else return of_mutex_free(spinlock); Index: tests/TestsAppDelegate.m ================================================================== --- tests/TestsAppDelegate.m +++ tests/TestsAppDelegate.m @@ -134,23 +134,23 @@ [self setTests]; [self dateTests]; [self numberTests]; [self streamTests]; [self TCPSocketTests]; -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS [self threadTests]; #endif [self URLTests]; -#ifdef OF_THREADS +#ifdef OF_HAVE_THREADS [self HTTPClientTests]; #endif [self XMLParserTests]; [self XMLNodeTests]; [self XMLElementBuilderTests]; [self serializationTests]; [self JSONTests]; -#ifdef OF_PLUGINS +#ifdef OF_HAVE_PLUGINS [self pluginTests]; #endif [self forwardingTests]; #ifdef OF_HAVE_PROPERTIES [self propertiesTests];