-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Memory fences for non-Darwin, non-x86 platforms.
- Loading branch information
Showing
26 changed files
with
149 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#if os(Linux) | ||
import ReactiveSwiftSupport | ||
#endif | ||
|
||
#if os(iOS) || os(tvOS) || os(watchOS) | ||
import Darwin.C.stdatomic | ||
#endif | ||
|
||
@inline(__always) | ||
internal func acquireFence() { | ||
#if !(arch(x86_64) || arch(i386)) | ||
#if os(iOS) || os(tvOS) || os(watchOS) | ||
atomic_thread_fence(memory_order_acquire) | ||
#else | ||
_reactiveSwift_acquire_fence() | ||
#endif | ||
#endif | ||
} | ||
|
||
@inline(__always) | ||
internal func releaseFence() { | ||
#if !(arch(x86_64) || arch(i386)) | ||
#if os(iOS) || os(tvOS) || os(watchOS) | ||
atomic_thread_fence(memory_order_release) | ||
#else | ||
_reactiveSwift_release_fence() | ||
#endif | ||
#endif | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
static void _reactiveSwift_release_fence(void) __attribute__((unused)); | ||
static void _reactiveSwift_acquire_fence(void) __attribute__((unused)); |
10 changes: 10 additions & 0 deletions
10
Sources/ReactiveSwiftSupport/include/ReactiveSwiftSupport.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#import <stdatomic.h> | ||
#import <string.h> | ||
|
||
static void _reactiveSwift_release_fence() { | ||
atomic_thread_fence(memory_order_release); | ||
} | ||
|
||
static void _reactiveSwift_acquire_fence() { | ||
atomic_thread_fence(memory_order_acquire); | ||
} |