Permalink
Browse files

Merge branch 'LucianoPAlmeida-no-sanitize-thread-atomic' into merge_l…

…uciano
  • Loading branch information...
kzaher committed Jan 31, 2019
2 parents 9a7c3db + e9d711b commit 65efb404c80fe1b23108c8fbb57d05b615e21c93
Showing with 415 additions and 236 deletions.
  1. +10 −13 .travis.yml
  2. +38 −13 Platform/AtomicInt.swift
  3. +24 −0 Rx.xcodeproj/project.pbxproj
  4. +2 −0 Rx.xcodeproj/xcshareddata/xcschemes/AllTests-iOS.xcscheme
  5. +3 −0 Rx.xcodeproj/xcshareddata/xcschemes/AllTests-macOS.xcscheme
  6. +2 −0 Rx.xcodeproj/xcshareddata/xcschemes/AllTests-tvOS.xcscheme
  7. +30 −5 RxAtomic/include/RxAtomic.h
  8. +2 −2 RxBlocking/RunLoopLock.swift
  9. +6 −8 RxSwift/Disposables/AnonymousDisposable.swift
  10. +4 −4 RxSwift/Disposables/BinaryDisposable.swift
  11. +1 −1 RxSwift/Disposables/RefCountDisposable.swift
  12. +2 −2 RxSwift/Disposables/ScheduledDisposable.swift
  13. +4 −4 RxSwift/Disposables/SingleAssignmentDisposable.swift
  14. +2 −2 RxSwift/Observables/Create.swift
  15. +5 −5 RxSwift/Observables/Map.swift
  16. +26 −26 RxSwift/Observables/Multicast.swift
  17. +14 −14 RxSwift/Observables/ObserveOn.swift
  18. +6 −6 RxSwift/Observables/Producer.swift
  19. +9 −10 RxSwift/Observables/Sink.swift
  20. +17 −12 RxSwift/Observables/Timer.swift
  21. +3 −3 RxSwift/Observers/ObserverBase.swift
  22. +3 −3 RxSwift/Rx.swift
  23. +3 −3 RxSwift/Schedulers/MainScheduler.swift
  24. +2 −2 RxSwift/Schedulers/SchedulerServices+Emulation.swift
  25. +1 −0 Sources/AllTestz/RxAtomic+Overrides.swift
  26. +1 −0 Sources/AllTestz/Synchronized.swift
  27. +30 −5 Sources/RxAtomic/include/RxAtomic.h
  28. +26 −26 Tests/RxSwiftTests/AtomicTests.swift
  29. +2 −2 Tests/RxSwiftTests/DisposableTest.swift
  30. +4 −4 Tests/RxSwiftTests/Observable+ObserveOnTests.swift
  31. +40 −29 Tests/RxSwiftTests/RecursiveLockTest.swift
  32. +20 −0 Tests/RxSwiftTests/RxAtomic+Overrides.swift
  33. +5 −5 Tests/RxSwiftTests/SchedulerTests.swift
  34. +28 −0 Tests/RxSwiftTests/Synchronized.swift
  35. +6 −6 Tests/RxSwiftTests/TestImplementations/Mocks/PrimitiveMockObserver.swift
  36. +0 −1 Tests/RxTest.swift
  37. +34 −20 scripts/validate-podspec.sh
@@ -36,35 +36,36 @@ matrix:
include:
- osx_image: xcode10
os: osx
env: BUILD="pod lib lint --swift-version=4 RxSwift.podspec"
env: BUILD="TARGET=RxSwift SWIFT_VERSION=4 ./scripts/validate-podspec.sh"

- osx_image: xcode10
os: osx
env: BUILD="pod lib lint --swift-version=4 RxCocoa.podspec"
env: BUILD="TARGET=RxCocoa SWIFT_VERSION=4 ./scripts/validate-podspec.sh"

- osx_image: xcode10
os: osx
env: BUILD="pod lib lint --swift-version=4 RxBlocking.podspec"
env: BUILD="TARGET=RxBlocking SWIFT_VERSION=4 ./scripts/validate-podspec.sh"

- osx_image: xcode10
os: osx
env: BUILD="pod lib lint --swift-version=4 RxTest.podspec"
env: BUILD="TARGET=RxTest SWIFT_VERSION=4 ./scripts/validate-podspec.sh"

- osx_image: xcode10
os: osx
env: BUILD="pod lib lint --swift-version=4.2 RxSwift.podspec"
env: BUILD="TARGET=RxSwift SWIFT_VERSION=4.2 ./scripts/validate-podspec.sh"

- osx_image: xcode10
os: osx
env: BUILD="pod lib lint --swift-version=4.2 RxCocoa.podspec"
env: BUILD="TARGET=RxCocoa SWIFT_VERSION=4.2 ./scripts/validate-podspec.sh"

- osx_image: xcode10
os: osx
env: BUILD="pod lib lint --swift-version=4.2 RxBlocking.podspec"
env: BUILD="TARGET=RxBlocking SWIFT_VERSION=4.2 ./scripts/validate-podspec.sh"

- osx_image: xcode10
os: osx
env: BUILD="pod lib lint --swift-version=4.2 RxTest.podspec"
env: BUILD="TARGET=RxTest SWIFT_VERSION=4.2 ./scripts/validate-podspec.sh"


notifications:
slack: rxswift:3ykt2Z61f8GkdvhCZTYPduOL
@@ -81,11 +82,7 @@ script:
fi
-
if [[ ! -z "${BUILD}" ]] ; then
if [[ "${BUILD}" =~ ^pod[[:space:]].* ]]; then
gem install cocoapods --pre --no-rdoc --no-ri --no-document --quiet;
pod repo update;
fi;
eval "${BUILD}";
eval "TRAVIS=1 ${BUILD}";
else
if [[ "${DANGER}" -eq 1 ]] ; then
bundle install --path vendor/bundle;
@@ -11,23 +11,48 @@ import RxAtomic
typealias AtomicInt = RxAtomic.AtomicInt

extension AtomicInt {
init(_ initialValue: Int32) {
public init(_ value: Int32) {
self.init()
self.initialize(initialValue)
AtomicInt_initialize(&self, value)
}
}

@discardableResult
mutating func increment() -> Int32 {
return self.add(1)
}
@discardableResult
@inline(__always)
func add(_ this: UnsafeMutablePointer<AtomicInt>, _ value: Int32) -> Int32 {
return AtomicInt_add(this, value)
}

@discardableResult
mutating func decrement() -> Int32 {
return self.sub(1)
}
@discardableResult
@inline(__always)
func sub(_ this: UnsafeMutablePointer<AtomicInt>, _ value: Int32) -> Int32 {
return AtomicInt_sub(this, value)
}

mutating func isFlagSet(_ mask: Int32) -> Bool {
return (self.load() & mask) != 0
}
@discardableResult
@inline(__always)
func fetchOr(_ this: UnsafeMutablePointer<AtomicInt>, _ mask: Int32) -> Int32 {
return AtomicInt_fetchOr(this, mask)
}

@inline(__always)
func load(_ this: UnsafeMutablePointer<AtomicInt>) -> Int32 {
return AtomicInt_load(this)
}

@discardableResult
@inline(__always)
func increment(_ this: UnsafeMutablePointer<AtomicInt>) -> Int32 {
return add(this, 1)
}

@discardableResult
@inline(__always)
func decrement(_ this: UnsafeMutablePointer<AtomicInt>) -> Int32 {
return sub(this, 1)
}

@inline(__always)
func isFlagSet(_ this: UnsafeMutablePointer<AtomicInt>, _ mask: Int32) -> Bool {
return (load(this) & mask) != 0
}
@@ -21,6 +21,9 @@
1E3079AC21FB52330072A7E6 /* AtomicTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E3079AB21FB52330072A7E6 /* AtomicTests.swift */; };
1E3079AD21FB52330072A7E6 /* AtomicTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E3079AB21FB52330072A7E6 /* AtomicTests.swift */; };
1E3079AE21FB52330072A7E6 /* AtomicTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E3079AB21FB52330072A7E6 /* AtomicTests.swift */; };
1E9DA0C522006858000EB80A /* Synchronized.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E9DA0C422006858000EB80A /* Synchronized.swift */; };
1E9DA0C622006858000EB80A /* Synchronized.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E9DA0C422006858000EB80A /* Synchronized.swift */; };
1E9DA0C722006858000EB80A /* Synchronized.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E9DA0C422006858000EB80A /* Synchronized.swift */; };
25F6ECBC1F48C366008552FA /* Maybe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 25F6ECBB1F48C366008552FA /* Maybe.swift */; };
25F6ECBE1F48C373008552FA /* Completable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 25F6ECBD1F48C373008552FA /* Completable.swift */; };
25F6ECC01F48C37C008552FA /* Single.swift in Sources */ = {isa = PBXBuildFile; fileRef = 25F6ECBF1F48C37C008552FA /* Single.swift */; };
@@ -667,6 +670,9 @@
C8A9B6F41DAD752200C9B027 /* Observable+BindTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8A9B6F31DAD752200C9B027 /* Observable+BindTests.swift */; };
C8A9B6F51DAD752200C9B027 /* Observable+BindTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8A9B6F31DAD752200C9B027 /* Observable+BindTests.swift */; };
C8A9B6F61DAD752200C9B027 /* Observable+BindTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8A9B6F31DAD752200C9B027 /* Observable+BindTests.swift */; };
C8ADC18E2200F9B000B611D4 /* RxAtomic+Overrides.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8ADC18D2200F9B000B611D4 /* RxAtomic+Overrides.swift */; };
C8ADC18F2200F9B000B611D4 /* RxAtomic+Overrides.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8ADC18D2200F9B000B611D4 /* RxAtomic+Overrides.swift */; };
C8ADC1902200F9B000B611D4 /* RxAtomic+Overrides.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8ADC18D2200F9B000B611D4 /* RxAtomic+Overrides.swift */; };
C8B0F70D1F530A1700548EBE /* SharingSchedulerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8B0F70C1F530A1700548EBE /* SharingSchedulerTests.swift */; };
C8B0F70E1F530A1700548EBE /* SharingSchedulerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8B0F70C1F530A1700548EBE /* SharingSchedulerTests.swift */; };
C8B0F70F1F530A1700548EBE /* SharingSchedulerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8B0F70C1F530A1700548EBE /* SharingSchedulerTests.swift */; };
@@ -919,6 +925,7 @@
1AF67DA11CED420A00C310FA /* PublishSubjectTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PublishSubjectTest.swift; sourceTree = "<group>"; };
1AF67DA51CED430100C310FA /* ReplaySubjectTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReplaySubjectTest.swift; sourceTree = "<group>"; };
1E3079AB21FB52330072A7E6 /* AtomicTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AtomicTests.swift; sourceTree = "<group>"; };
1E9DA0C422006858000EB80A /* Synchronized.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Synchronized.swift; sourceTree = "<group>"; };
25F6ECBB1F48C366008552FA /* Maybe.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Maybe.swift; sourceTree = "<group>"; };
25F6ECBD1F48C373008552FA /* Completable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Completable.swift; sourceTree = "<group>"; };
25F6ECBF1F48C37C008552FA /* Single.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Single.swift; sourceTree = "<group>"; };
@@ -1352,6 +1359,7 @@
C8A81C9F1E05E82C0008DEF4 /* DispatchQueue+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "DispatchQueue+Extensions.swift"; sourceTree = "<group>"; };
C8A81CA51E05EAF70008DEF4 /* Binder+Tests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Binder+Tests.swift"; sourceTree = "<group>"; };
C8A9B6F31DAD752200C9B027 /* Observable+BindTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Observable+BindTests.swift"; sourceTree = "<group>"; };
C8ADC18D2200F9B000B611D4 /* RxAtomic+Overrides.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "RxAtomic+Overrides.swift"; sourceTree = "<group>"; };
C8B0F70C1F530A1700548EBE /* SharingSchedulerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharingSchedulerTests.swift; sourceTree = "<group>"; };
C8B0F7101F530CA700548EBE /* PublishRelay.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PublishRelay.swift; sourceTree = "<group>"; };
C8B0F7141F530F5900548EBE /* PublishRelay+Signal.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "PublishRelay+Signal.swift"; sourceTree = "<group>"; };
@@ -1983,6 +1991,8 @@
C801DE3D1F6EAD57008DB060 /* CompletableTest.swift */,
C801DE491F6EBB84008DB060 /* Observable+PrimitiveSequenceTest.swift */,
C82FF0EE1F93DD2E00BDB34D /* ObservableType+SubscriptionTests.swift */,
1E9DA0C422006858000EB80A /* Synchronized.swift */,
C8ADC18D2200F9B000B611D4 /* RxAtomic+Overrides.swift */,
);
path = RxSwiftTests;
sourceTree = "<group>";
@@ -2684,6 +2694,7 @@
};
C8165ABB21891AFF00494BEF = {
CreatedOnToolsVersion = 10.1;
LastSwiftMigration = 1010;
};
C83508C21C386F6F0027C24C = {
CreatedOnToolsVersion = 7.2;
@@ -3169,6 +3180,7 @@
C83509521C38706E0027C24C /* MainSchedulerTests.swift in Sources */,
C835094D1C38706E0027C24C /* BagTest.swift in Sources */,
54700CA01CE37E1800EF3A8F /* UINavigationItem+RxTests.swift.swift in Sources */,
1E9DA0C522006858000EB80A /* Synchronized.swift in Sources */,
C820A9C21EB509FC00D431BC /* Observable+SkipTests.swift in Sources */,
C820A9DE1EB50CF800D431BC /* Observable+ThrottleTests.swift in Sources */,
C820A9921EB4FD1400D431BC /* Observable+SwitchIfEmptyTests.swift in Sources */,
@@ -3188,6 +3200,7 @@
C820A9EE1EB50EA100D431BC /* Observable+ScanTests.swift in Sources */,
C8D970E91F532FD30058F2FE /* Driver+Test.swift in Sources */,
C820A96A1EB4F64800D431BC /* Observable+JustTests.swift in Sources */,
C8ADC18E2200F9B000B611D4 /* RxAtomic+Overrides.swift in Sources */,
C820A98E1EB4FCC400D431BC /* Observable+SwitchTests.swift in Sources */,
C81B6AAA1DB2C15C0047CF86 /* Platform.Darwin.swift in Sources */,
C81A097D1E6C27A100900B3B /* Observable+ZipTests.swift in Sources */,
@@ -3217,6 +3230,7 @@
C820A9871EB4FB5B00D431BC /* Observable+DebugTests.swift in Sources */,
C8C4F1881DE9DF0200003FA7 /* UITableView+RxTests.swift in Sources */,
C820A9FF1EB5110E00D431BC /* Observable+DematerializeTests.swift in Sources */,
1E9DA0C622006858000EB80A /* Synchronized.swift in Sources */,
C83509EE1C3875580027C24C /* Observable.Extensions.swift in Sources */,
C83509BD1C38750D0027C24C /* ControlPropertyTests.swift in Sources */,
C83509E11C3875500027C24C /* TestVirtualScheduler.swift in Sources */,
@@ -3237,6 +3251,7 @@
C820A9E71EB50DB900D431BC /* Observable+TimerTests.swift in Sources */,
C820A97F1EB4FA5A00D431BC /* Observable+RepeatTests.swift in Sources */,
C8C4F1781DE9DF0200003FA7 /* UIActivityIndicatorView+RxTests.swift in Sources */,
C8ADC18F2200F9B000B611D4 /* RxAtomic+Overrides.swift in Sources */,
C83509BF1C3875220027C24C /* DelegateProxyTest+UIKit.swift in Sources */,
C8D970F31F532FD30058F2FE /* SharedSequence+OperatorTest.swift in Sources */,
C820A94B1EB4E75E00D431BC /* Observable+AmbTests.swift in Sources */,
@@ -3396,6 +3411,7 @@
C8350A071C38755E0027C24C /* MainSchedulerTests.swift in Sources */,
C8D970F41F532FD30058F2FE /* SharedSequence+OperatorTest.swift in Sources */,
C820A9F01EB50EA100D431BC /* Observable+ScanTests.swift in Sources */,
C8ADC1902200F9B000B611D4 /* RxAtomic+Overrides.swift in Sources */,
C83509B81C38750D0027C24C /* ControlEventTests.swift in Sources */,
C83509CB1C3875230027C24C /* KVOObservableTests.swift in Sources */,
C83509C81C3875230027C24C /* DelegateProxyTest.swift in Sources */,
@@ -3460,6 +3476,7 @@
C83509D11C38752E0027C24C /* RuntimeStateSnapshot.swift in Sources */,
C8350A221C38756B0027C24C /* VariableTest.swift in Sources */,
C8A53AE71F09292A00490535 /* Completable+AndThen.swift in Sources */,
1E9DA0C722006858000EB80A /* Synchronized.swift in Sources */,
C83509D21C3875380027C24C /* RXObjCRuntime+Testing.m in Sources */,
C8353CDE1DA19BA000BE3F5C /* MessageProcessingStage.swift in Sources */,
1E3079AE21FB52330072A7E6 /* AtomicTests.swift in Sources */,
@@ -3919,6 +3936,7 @@
C8165AC121891B0000494BEF /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
@@ -3929,12 +3947,15 @@
PRODUCT_BUNDLE_IDENTIFIER = io.rx.RxAtomic;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
};
name = Debug;
};
C8165AC221891B0000494BEF /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
@@ -3945,12 +3966,14 @@
PRODUCT_BUNDLE_IDENTIFIER = io.rx.RxAtomic;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
};
name = Release;
};
C8165AC321891B0000494BEF /* Release-Tests */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
@@ -3961,6 +3984,7 @@
PRODUCT_BUNDLE_IDENTIFIER = io.rx.RxAtomic;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
};
name = "Release-Tests";
};
@@ -10,6 +10,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
enableThreadSanitizer = "YES"
enableUBSanitizer = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
@@ -10,6 +10,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
enableThreadSanitizer = "YES"
enableUBSanitizer = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
@@ -32,6 +34,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
enableThreadSanitizer = "YES"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
@@ -10,6 +10,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
enableThreadSanitizer = "YES"
enableUBSanitizer = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
@@ -15,31 +15,56 @@

#define Atomic(swift_type, llvm_type) \
typedef struct { volatile atomic_##llvm_type atom; } Atomic##swift_type;\
static __inline__ __attribute__((__always_inline__)) SWIFT_NAME(Atomic##swift_type.initialize(self:_:)) \
static __inline__ __attribute__((__always_inline__)) SWIFT_NAME(Atomic##swift_type.initialize(_:_:)) \
void Atomic##swift_type##_Initialize(Atomic##swift_type * _Nonnull self, llvm_type value) { \
atomic_init(&self->atom, value);\
}\
\
static __inline__ __attribute__((__always_inline__)) SWIFT_NAME(Atomic##swift_type.load(self:)) \
static __inline__ __attribute__((__always_inline__)) SWIFT_NAME(Atomic##swift_type.load(_:)) \
llvm_type Atomic##swift_type##_Load(Atomic##swift_type * _Nonnull self) { \
return atomic_load(&self->atom);\
}\
\
static __inline__ __attribute__((__always_inline__)) SWIFT_NAME(Atomic##swift_type.fetchOr(self:_:)) \
static __inline__ __attribute__((__always_inline__)) SWIFT_NAME(Atomic##swift_type.fetchOr(_:_:)) \
llvm_type Atomic##swift_type##_FetchOr(Atomic##swift_type * _Nonnull self, llvm_type mask) { \
return atomic_fetch_or(&self->atom, mask);\
}\
\
static __inline__ __attribute__((__always_inline__)) SWIFT_NAME(Atomic##swift_type.add(self:_:)) \
static __inline__ __attribute__((__always_inline__)) SWIFT_NAME(Atomic##swift_type.add(_:_:)) \
llvm_type Atomic##swift_type##_Add(Atomic##swift_type * _Nonnull self, llvm_type value) { \
return atomic_fetch_add(&self->atom, value);\
}\
\
static __inline__ __attribute__((__always_inline__)) SWIFT_NAME(Atomic##swift_type.sub(self:_:)) \
static __inline__ __attribute__((__always_inline__)) SWIFT_NAME(Atomic##swift_type.sub(_:_:)) \
llvm_type Atomic##swift_type##_Sub(Atomic##swift_type * _Nonnull self, llvm_type value) { \
return atomic_fetch_sub(&self->atom, value);\
}\
\
static __inline__ __attribute__((__always_inline__)) \
void Atomic##swift_type##_initialize(Atomic##swift_type * _Nonnull self, llvm_type value) { \
atomic_init(&self->atom, value);\
}\
\
static __inline__ __attribute__((__always_inline__)) \
llvm_type Atomic##swift_type##_load(Atomic##swift_type * _Nonnull self) { \
return atomic_load(&self->atom);\
}\
\
static __inline__ __attribute__((__always_inline__)) \
llvm_type Atomic##swift_type##_fetchOr(Atomic##swift_type * _Nonnull self, llvm_type mask) { \
return atomic_fetch_or(&self->atom, mask);\
}\
\
static __inline__ __attribute__((__always_inline__)) \
llvm_type Atomic##swift_type##_add(Atomic##swift_type * _Nonnull self, llvm_type value) { \
return atomic_fetch_add(&self->atom, value);\
}\
\
static __inline__ __attribute__((__always_inline__)) \
llvm_type Atomic##swift_type##_sub(Atomic##swift_type * _Nonnull self, llvm_type value) { \
return atomic_fetch_sub(&self->atom, value);\
}\
\

Atomic(Int, int)

@@ -47,7 +47,7 @@ final class RunLoopLock {
}

func stop() {
if self._calledStop.decrement() > 1 {
if decrement(&self._calledStop) > 1 {
return
}
CFRunLoopPerformBlock(self._currentRunLoop, runLoopModeRaw) {
@@ -57,7 +57,7 @@ final class RunLoopLock {
}

func run() throws {
if self._calledRun.increment() != 0 {
if increment(&self._calledRun) != 0 {
fatalError("Run can be only called once")
}
if let timeout = self._timeout {
Oops, something went wrong.

0 comments on commit 65efb40

Please sign in to comment.