The markdown parsing is broken/disabled for release notes. Sorry about that, I'm chasing the source of a crash that's been bringing this website down for the last couple of days.
Tweaks to compare-and-exchange functions
4 years ago
Move choice between weak and strong CAS out of the C parameter list in `CAtomics`
- In the `CAtomics` module, all types have direct `CompareAndExchangeWeak` and `CompareAndExchangeStrong` functions rather than a single function with a parameter selecting between strong and weak.
- The old version of `CompareAndExchange` with a `CASType` parameter still exists, but forwards to either of the other two, making it objectively worse.
- `SwiftAtomics` internally adapts to the above, but is otherwise unchanged.
Fix for Windows
4 years ago
- use `intptr_t` in tagged pointer unions.
Simplifications, mostly.
4 years ago
- Changes the default memory ordering parameters in SwiftAtomics. The defaults are now `.acquire` for loading operations, `.release` for storing operations, and `.acqrel` for read-modify-write operations.
- Removes the `load()` function on `AtomicReference`.
`load` required locking, and it failed once every several million attempts (under contention), and that just wasn't good enough. (It fails seldom enough that what I thought had been extensive testing prior to version 4.2.0 was in fact insufficient.) There's been a fair bit of trying to fix it in the last year, but nothing has completely worked. The correct solution may require collaboration with Swift's ARC reference-counting runtime, and therefore will have to wait until a similar type appears in the standard library.
This release has major changes to the `CAtomics` package, in that it no longer uses swift-style function names, but uses (once more) C-style names: it switches from using the `SWIFT_NAME` macro to `__attribute__((overloadable))`. This allows all the necessary changes to have a similar shape, as
`AtomicInt.load(_ order: LoadMemoryOrder)`
becomes
`CAtomicsLoad(_ atomic: UnsafeMutablePointer<AtomicInt>, order: LoadMemoryOrder)`.
The Swift-style module is renamed to `SwiftAtomics`, which is less presumptuous than just `Atomics`.
(Still presumptuous, but the standard library is unlikely to ever have a module named `SwiftAtomics`.)
Finally, tagged pointers are now usable from the `SwiftAtomics` module, after having been usable from `CAtomics` since `4.4.0`.
Fix for Swift 5 compiler
5 years ago
- The Swift 5 compiler no longer imports structs with large alignments.
This defeats the approach I previously took to pad structs.
- In order to get padded structs to mitigate false sharing effects, the package
now inserts explicit padding rather than explicitly requesting a large alignment.
This is not the ideal solution, but it's good enough for most cases.
- The padded types are renamed from 4.4.0, with abject apologies to anyone
who might be affected. I should have tried building with Swift 5 a tad earlier.
- Adds tagged pointers to the CAtomics package, taking advantage of 128-bit atomic instructions in x64 and ARM64
- Adds cache-aligned variants to various types from CAtomics. These types take an entire cache line to themselves, which can be useful in some cases.
- Adds initializers, such as `AtomicInt32.init(_ value: Int32)` and `AtomicRawPointer.init(_ pointer: UnsafeRawPointer)`. Previously one had to use a default initializer followed by a call to the `initialize` method.
- Adds a compare-and-swap operation to `AtomicReference`
- Supports the Windows build of Swift
Improvements for Swift 4.2
5 years ago
Improvements for Swift 4.1
5 years ago
Improved CAtomics
6 years ago
The underlying C package has a nicer interface when used from Swift.