Skip to content

Releases: glessard/swift-atomics

Tweaks to compare-and-exchange functions

21 Apr 20:11
79608d7
Compare
Choose a tag to compare

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

21 Apr 20:04
4f1fedb
Compare
Choose a tag to compare
  • use intptr_t in tagged pointer unions.

Simplifications, mostly.

05 Dec 00:19
99eaf0e
Compare
Choose a tag to compare
  • 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.

Version 5

07 May 16:53
c88d92b
Compare
Choose a tag to compare

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

12 Feb 19:56
7883159
Compare
Choose a tag to compare
  • 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.

4.4.0

09 Feb 00:10
b2c3c71
Compare
Choose a tag to compare
  • 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

31 Aug 17:26
0fdd1a5
Compare
Choose a tag to compare
Merge pull request #21 from glessard/devel

update CI configuration

Improvements for Swift 4.1

18 Jul 20:28
e6d9325
Compare
Choose a tag to compare

Improved CAtomics

27 Sep 08:15
Compare
Choose a tag to compare

The underlying C package has a nicer interface when used from Swift.