diff --git a/SyphonDispatch.c b/SyphonDispatch.c index 563f6ff..df10b10 100644 --- a/SyphonDispatch.c +++ b/SyphonDispatch.c @@ -117,7 +117,7 @@ static atomic_uintptr_t mWorkDoneSignal = (uintptr_t)NULL; #pragma mark Constructor and Destructor __attribute__((destructor)) -static void finalizer() +static void finalizer(void) { struct timeval start; if(gettimeofday(&start, NULL) == 0) @@ -181,7 +181,7 @@ static void *_SyphonDispatchChannelLoop(SyphonDispatchChannel *channel) return NULL; } -static dispatch_semaphore_t _SyphonDispatchGetWorkSemaphore() +static dispatch_semaphore_t _SyphonDispatchGetWorkSemaphore(void) { dispatch_semaphore_t sem = (dispatch_semaphore_t)atomic_load(&mWorkDoneSignal); if (!sem) diff --git a/SyphonMessageQueue.m b/SyphonMessageQueue.m index 37288ca..74aafca 100644 --- a/SyphonMessageQueue.m +++ b/SyphonMessageQueue.m @@ -28,7 +28,7 @@ */ #import "SyphonMessageQueue.h" -#import +#import #import /* @@ -72,7 +72,7 @@ @implementation SyphonMessageQueue os_unfair_lock _lock; void *_head; OSQueueHead _pool; // TODO: or maybe manage our own within the lock as we lock anyway - void *_info; + atomic_uintptr_t _info; } - (id)init @@ -186,15 +186,15 @@ - (BOOL)copyAndDequeue:(NSData **)content type:(uint32_t *)type - (void *)userInfo { - return _info; + return (void *)atomic_load(&_info); } - (void)setUserInfo:(void *)info { bool result; do { - void *old = _info; - result = OSAtomicCompareAndSwapPtrBarrier(old, info, &_info); + uintptr_t old = _info; + result = atomic_compare_exchange_strong(&_info, &old, (uintptr_t)info); } while (!result); } @end diff --git a/SyphonPrivate.h b/SyphonPrivate.h index 3b2591c..740bd55 100644 --- a/SyphonPrivate.h +++ b/SyphonPrivate.h @@ -31,6 +31,8 @@ #ifdef __OBJC__ +#import // For SyphonSafeBool + #define kSyphonIdentifier @"info.v002.Syphon" // NSNotification names for Syphon's distributed notifications @@ -60,7 +62,7 @@ extern NSString * const SyphonServerOptionStencilBufferResolution; NSString *SyphonCreateUUIDString(void) NS_RETURNS_RETAINED; -typedef volatile int32_t SyphonSafeBool; +typedef atomic_int_fast32_t SyphonSafeBool; BOOL SyphonSafeBoolGet(SyphonSafeBool *b); void SyphonSafeBoolSet(SyphonSafeBool *b, BOOL value); diff --git a/SyphonPrivate.m b/SyphonPrivate.m index 017866e..5b0b1f8 100644 --- a/SyphonPrivate.m +++ b/SyphonPrivate.m @@ -28,7 +28,6 @@ */ #import "SyphonPrivate.h" -#import // For SyphonSafeBool NSString * const SyphonServerDescriptionDictionaryVersionKey = @"SyphonServerDescriptionDictionaryVersionKey"; NSString * const SyphonServerDescriptionUUIDKey = @"SyphonServerDescriptionUUIDKey"; @@ -67,6 +66,6 @@ void SyphonSafeBoolSet(SyphonSafeBool *b, BOOL value) int32_t new = value ? 1 : 0; do { int32_t old = *b; - result = OSAtomicCompareAndSwap32(old, new, b); + result = atomic_compare_exchange_strong(b, &old, new); } while (!result); } diff --git a/SyphonServerBase.m b/SyphonServerBase.m index 3a62c9c..a9cc925 100644 --- a/SyphonServerBase.m +++ b/SyphonServerBase.m @@ -15,7 +15,7 @@ + (void)retireRemainingServers; @end __attribute__((destructor)) -static void finalizer() +static void finalizer(void) { [SyphonServerBase retireRemainingServers]; }