diff --git a/ReactiveObjC.podspec b/ReactiveObjC.podspec index c6e440265..172de166f 100644 --- a/ReactiveObjC.podspec +++ b/ReactiveObjC.podspec @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.social_media_url = "https://twitter.com/ReactiveCocoa" s.ios.deployment_target = "8.0" - s.osx.deployment_target = "10.9" + s.osx.deployment_target = "10.13" s.watchos.deployment_target = "2.0" s.tvos.deployment_target = "9.0" diff --git a/ReactiveObjC.xcodeproj/project.pbxproj b/ReactiveObjC.xcodeproj/project.pbxproj index 1417bb70f..1a023b9de 100644 --- a/ReactiveObjC.xcodeproj/project.pbxproj +++ b/ReactiveObjC.xcodeproj/project.pbxproj @@ -1977,6 +1977,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, ); mainGroup = D04725E019E49ED7006002AA; @@ -2760,7 +2761,7 @@ CURRENT_PROJECT_VERSION = 1; ENABLE_TESTABILITY = YES; IPHONEOS_DEPLOYMENT_TARGET = 8.0; - MACOSX_DEPLOYMENT_TARGET = 10.9; + MACOSX_DEPLOYMENT_TARGET = 10.13; PRODUCT_BUNDLE_IDENTIFIER = "org.reactivecocoa.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(PROJECT_NAME)"; TVOS_DEPLOYMENT_TARGET = 9.0; @@ -2783,7 +2784,7 @@ CURRENT_PROJECT_VERSION = 1; GCC_OPTIMIZATION_LEVEL = 0; IPHONEOS_DEPLOYMENT_TARGET = 8.0; - MACOSX_DEPLOYMENT_TARGET = 10.9; + MACOSX_DEPLOYMENT_TARGET = 10.13; PRODUCT_BUNDLE_IDENTIFIER = "org.reactivecocoa.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(PROJECT_NAME)"; TVOS_DEPLOYMENT_TARGET = 9.0; @@ -2909,7 +2910,7 @@ CODE_SIGNING_REQUIRED = NO; CURRENT_PROJECT_VERSION = 1; IPHONEOS_DEPLOYMENT_TARGET = 8.0; - MACOSX_DEPLOYMENT_TARGET = 10.9; + MACOSX_DEPLOYMENT_TARGET = 10.13; PRODUCT_BUNDLE_IDENTIFIER = "org.reactivecocoa.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(PROJECT_NAME)"; TVOS_DEPLOYMENT_TARGET = 9.0; @@ -2983,7 +2984,7 @@ CODE_SIGNING_REQUIRED = NO; CURRENT_PROJECT_VERSION = 1; IPHONEOS_DEPLOYMENT_TARGET = 8.0; - MACOSX_DEPLOYMENT_TARGET = 10.9; + MACOSX_DEPLOYMENT_TARGET = 10.13; PRODUCT_BUNDLE_IDENTIFIER = "org.reactivecocoa.$(PRODUCT_NAME:rfc1034identifier)-Tests"; PRODUCT_NAME = "$(PROJECT_NAME)"; TVOS_DEPLOYMENT_TARGET = 9.0; diff --git a/ReactiveObjC.xcodeproj/xcshareddata/xcschemes/ReactiveObjC-macOS.xcscheme b/ReactiveObjC.xcodeproj/xcshareddata/xcschemes/ReactiveObjC-macOS.xcscheme index 5b5fe5247..af110df40 100644 --- a/ReactiveObjC.xcodeproj/xcshareddata/xcschemes/ReactiveObjC-macOS.xcscheme +++ b/ReactiveObjC.xcodeproj/xcshareddata/xcschemes/ReactiveObjC-macOS.xcscheme @@ -3,7 +3,7 @@ LastUpgradeVersion = "0800" version = "1.3"> + + + + @@ -82,17 +91,6 @@ - - - - - - - - -#import -#import "RACmetamacros.h" +#import +#import "metamacros.h" /// Creates a signal which observes `KEYPATH` on `TARGET` for changes. /// diff --git a/ReactiveObjC/RACCommand.m b/ReactiveObjC/RACCommand.m index 22d8a5ea7..0a6f31045 100644 --- a/ReactiveObjC/RACCommand.m +++ b/ReactiveObjC/RACCommand.m @@ -7,7 +7,7 @@ // #import "RACCommand.h" -#import +#import #import "NSArray+RACSequenceAdditions.h" #import "NSObject+RACDeallocating.h" #import "NSObject+RACDescription.h" @@ -17,7 +17,7 @@ #import "RACScheduler.h" #import "RACSequence.h" #import "RACSignal+Operations.h" -#import +#import NSString * const RACCommandErrorDomain = @"RACCommandErrorDomain"; NSString * const RACUnderlyingCommandErrorKey = @"RACUnderlyingCommandErrorKey"; @@ -26,7 +26,7 @@ @interface RACCommand () { // Atomic backing variable for `allowsConcurrentExecution`. - volatile uint32_t _allowsConcurrentExecution; + atomic_uint _allowsConcurrentExecution; } /// A subject that sends added execution signals. @@ -55,9 +55,9 @@ - (BOOL)allowsConcurrentExecution { - (void)setAllowsConcurrentExecution:(BOOL)allowed { if (allowed) { - OSAtomicOr32Barrier(1, &_allowsConcurrentExecution); + atomic_fetch_or(&_allowsConcurrentExecution, 1); } else { - OSAtomicAnd32Barrier(0, &_allowsConcurrentExecution); + atomic_fetch_and(&_allowsConcurrentExecution, 0); } [self.allowsConcurrentExecutionSubject sendNext:@(_allowsConcurrentExecution)]; diff --git a/ReactiveObjC/RACDisposable.m b/ReactiveObjC/RACDisposable.m index 25f266977..79e713619 100644 --- a/ReactiveObjC/RACDisposable.m +++ b/ReactiveObjC/RACDisposable.m @@ -8,7 +8,7 @@ #import "RACDisposable.h" #import "RACScopedDisposable.h" -#import +#import @interface RACDisposable () { // A copied block of type void (^)(void) containing the logic for disposal, @@ -16,7 +16,7 @@ @interface RACDisposable () { // NULL if the receiver is already disposed. // // This should only be used atomically. - void * volatile _disposeBlock; + _Atomic(void *) _disposeBlock; } @end @@ -35,7 +35,7 @@ - (instancetype)init { self = [super init]; _disposeBlock = (__bridge void *)self; - OSMemoryBarrier(); + atomic_thread_fence(memory_order_seq_cst); return self; } @@ -46,7 +46,7 @@ - (instancetype)initWithBlock:(void (^)(void))block { self = [super init]; _disposeBlock = (void *)CFBridgingRetain([block copy]); - OSMemoryBarrier(); + atomic_thread_fence(memory_order_seq_cst); return self; } @@ -69,7 +69,7 @@ - (void)dispose { while (YES) { void *blockPtr = _disposeBlock; - if (OSAtomicCompareAndSwapPtrBarrier(blockPtr, NULL, &_disposeBlock)) { + if (atomic_compare_exchange_strong(&_disposeBlock, &blockPtr, NULL)) { if (blockPtr != (__bridge void *)self) { disposeBlock = CFBridgingRelease(blockPtr); } diff --git a/ReactiveObjC/RACDynamicSequence.m b/ReactiveObjC/RACDynamicSequence.m index 86d8be9c2..d17ee833c 100644 --- a/ReactiveObjC/RACDynamicSequence.m +++ b/ReactiveObjC/RACDynamicSequence.m @@ -7,7 +7,7 @@ // #import "RACDynamicSequence.h" -#import +#import // Determines how RACDynamicSequences will be deallocated before the next one is // shifted onto the autorelease pool. @@ -114,10 +114,10 @@ + (RACSequence *)sequenceWithLazyDependency:(id (^)(void))dependencyBlock headBl } - (void)dealloc { - static volatile int32_t directDeallocCount = 0; + static atomic_int directDeallocCount = 0; - if (OSAtomicIncrement32(&directDeallocCount) >= DEALLOC_OVERFLOW_GUARD) { - OSAtomicAdd32(-DEALLOC_OVERFLOW_GUARD, &directDeallocCount); + if (atomic_fetch_add(&directDeallocCount, 1) + 1 >= DEALLOC_OVERFLOW_GUARD) { + atomic_fetch_add(&directDeallocCount, -DEALLOC_OVERFLOW_GUARD); // Put this sequence's tail onto the autorelease pool so we stop // recursing. diff --git a/ReactiveObjC/RACKVOChannel.h b/ReactiveObjC/RACKVOChannel.h index 74d90b1c5..e2120cd3a 100644 --- a/ReactiveObjC/RACKVOChannel.h +++ b/ReactiveObjC/RACKVOChannel.h @@ -7,8 +7,8 @@ // #import "RACChannel.h" -#import -#import "RACmetamacros.h" +#import +#import "metamacros.h" /// Creates a RACKVOChannel to the given key path. When the targeted object /// deallocates, the channel will complete. diff --git a/ReactiveObjC/RACMulticastConnection.m b/ReactiveObjC/RACMulticastConnection.m index f59824500..3b6183535 100644 --- a/ReactiveObjC/RACMulticastConnection.m +++ b/ReactiveObjC/RACMulticastConnection.m @@ -11,7 +11,7 @@ #import "RACDisposable.h" #import "RACSerialDisposable.h" #import "RACSubject.h" -#import +#import @interface RACMulticastConnection () { RACSubject *_signal; @@ -24,7 +24,7 @@ @interface RACMulticastConnection () { // // If the swap is unsuccessful it means that `_sourceSignal` has already been // connected and the caller has no action to take. - int32_t volatile _hasConnected; + _Atomic(BOOL) _hasConnected; } @property (nonatomic, readonly, strong) RACSignal *sourceSignal; @@ -51,7 +51,8 @@ - (instancetype)initWithSourceSignal:(RACSignal *)source subject:(RACSubject *)s #pragma mark Connecting - (RACDisposable *)connect { - BOOL shouldConnect = OSAtomicCompareAndSwap32Barrier(0, 1, &_hasConnected); + BOOL expected = NO; + BOOL shouldConnect = atomic_compare_exchange_strong(&_hasConnected, &expected, YES); if (shouldConnect) { self.serialDisposable.disposable = [self.sourceSignal subscribe:_signal]; @@ -61,11 +62,11 @@ - (RACDisposable *)connect { } - (RACSignal *)autoconnect { - __block volatile int32_t subscriberCount = 0; + __block atomic_int subscriberCount = 0; return [[RACSignal createSignal:^(id subscriber) { - OSAtomicIncrement32Barrier(&subscriberCount); + atomic_fetch_add(&subscriberCount, 1); RACDisposable *subscriptionDisposable = [self.signal subscribe:subscriber]; RACDisposable *connectionDisposable = [self connect]; @@ -73,7 +74,7 @@ - (RACSignal *)autoconnect { return [RACDisposable disposableWithBlock:^{ [subscriptionDisposable dispose]; - if (OSAtomicDecrement32Barrier(&subscriberCount) == 0) { + if (atomic_fetch_sub(&subscriberCount, 1) - 1 == 0) { [connectionDisposable dispose]; } }]; diff --git a/ReactiveObjC/RACSignal+Operations.m b/ReactiveObjC/RACSignal+Operations.m index 55c8294d7..95e53d72a 100644 --- a/ReactiveObjC/RACSignal+Operations.m +++ b/ReactiveObjC/RACSignal+Operations.m @@ -26,7 +26,7 @@ #import "RACSubscriber.h" #import "RACTuple.h" #import "RACUnit.h" -#import +#import #import NSString * const RACSignalErrorDomain = @"RACSignalErrorDomain"; @@ -649,7 +649,7 @@ - (RACDisposable *)setKeyPath:(NSString *)keyPath onObject:(NSObject *)object ni // Purposely not retaining 'object', since we want to tear down the binding // when it deallocates normally. - __block void * volatile objectPtr = (__bridge void *)object; + __block _Atomic(void *) objectPtr = (__bridge void *)object; RACDisposable *subscriptionDisposable = [self subscribeNext:^(id x) { // Possibly spec, possibly compiler bug, but this __bridge cast does not @@ -701,7 +701,7 @@ - (RACDisposable *)setKeyPath:(NSString *)keyPath onObject:(NSObject *)object ni while (YES) { void *ptr = objectPtr; - if (OSAtomicCompareAndSwapPtrBarrier(ptr, NULL, &objectPtr)) { + if (atomic_compare_exchange_strong(&objectPtr, &ptr, NULL)) { break; } } @@ -1051,17 +1051,17 @@ - (RACSignal *)subscribeOn:(RACScheduler *)scheduler { - (RACSignal *)deliverOnMainThread { return [[RACSignal createSignal:^(id subscriber) { - __block volatile int32_t queueLength = 0; + __block atomic_int queueLength = 0; void (^performOnMainThread)(dispatch_block_t) = ^(dispatch_block_t block) { - int32_t queued = OSAtomicIncrement32(&queueLength); + int32_t queued = atomic_fetch_add(&queueLength, 1) + 1; if (NSThread.isMainThread && queued == 1) { block(); - OSAtomicDecrement32(&queueLength); + atomic_fetch_sub(&queueLength, 1); } else { dispatch_async(dispatch_get_main_queue(), ^{ block(); - OSAtomicDecrement32(&queueLength); + atomic_fetch_sub(&queueLength, 1); }); } }; diff --git a/ReactiveObjC/RACSignal.m b/ReactiveObjC/RACSignal.m index 84607f681..eb79e6039 100644 --- a/ReactiveObjC/RACSignal.m +++ b/ReactiveObjC/RACSignal.m @@ -21,7 +21,7 @@ #import "RACSubject.h" #import "RACSubscriber+Private.h" #import "RACTuple.h" -#import +#import @implementation RACSignal @@ -108,12 +108,12 @@ - (RACSignal *)bind:(RACSignalBindBlock (^)(void))block { return [[RACSignal createSignal:^(id subscriber) { RACSignalBindBlock bindingBlock = block(); - __block volatile int32_t signalCount = 1; // indicates self + __block atomic_int signalCount = 1; // indicates self RACCompoundDisposable *compoundDisposable = [RACCompoundDisposable compoundDisposable]; void (^completeSignal)(RACDisposable *) = ^(RACDisposable *finishedDisposable) { - if (OSAtomicDecrement32Barrier(&signalCount) == 0) { + if (atomic_fetch_sub(&signalCount, 1) - 1 == 0) { [subscriber sendCompleted]; [compoundDisposable dispose]; } else { @@ -122,7 +122,7 @@ - (RACSignal *)bind:(RACSignalBindBlock (^)(void))block { }; void (^addSignal)(RACSignal *) = ^(RACSignal *signal) { - OSAtomicIncrement32Barrier(&signalCount); + atomic_fetch_add(&signalCount, 1); RACSerialDisposable *selfDisposable = [[RACSerialDisposable alloc] init]; [compoundDisposable addDisposable:selfDisposable]; diff --git a/ReactiveObjC/RACSubscriptingAssignmentTrampoline.h b/ReactiveObjC/RACSubscriptingAssignmentTrampoline.h index 7e1ff5782..9c44c555c 100644 --- a/ReactiveObjC/RACSubscriptingAssignmentTrampoline.h +++ b/ReactiveObjC/RACSubscriptingAssignmentTrampoline.h @@ -7,7 +7,7 @@ // #import -#import +#import @class RACSignal; diff --git a/ReactiveObjC/extobjc/EXTRuntimeExtensions.m b/ReactiveObjC/extobjc/EXTRuntimeExtensions.m index 0e1a3f937..99c10e980 100644 --- a/ReactiveObjC/extobjc/EXTRuntimeExtensions.m +++ b/ReactiveObjC/extobjc/EXTRuntimeExtensions.m @@ -7,7 +7,7 @@ // Released under the MIT license. // -#import +#import "EXTRuntimeExtensions.h" #import #import @@ -62,7 +62,7 @@ if (!next) { fprintf(stderr, "ERROR: Could not read class name in attribute string \"%s\" for property %s\n", attrString, property_getName(property)); - return NULL; + goto errorOut; } if (className != next) {