Skip to content
This repository has been archived by the owner on Oct 20, 2020. It is now read-only.

Revision 0.4.0 #3

Merged
merged 27 commits into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
59a8744
use new initialization pattern (not as obvious as it could be)
glessard Apr 10, 2020
6f8a05c
test a custom type with atomics
glessard Apr 10, 2020
a568ac6
define the update AtomicProtocol
glessard Apr 10, 2020
41f770b
initial transfer of CAtomics to this package
glessard Apr 11, 2020
a8d8ead
some tests of C11Atomics
glessard Apr 11, 2020
de0fe39
complete atomic integer types
glessard Apr 11, 2020
48519ad
comment out tagged pointers and unmanaged (just zap OpaquePointer)
glessard Apr 11, 2020
3259863
complete atomic pointer types
glessard Apr 11, 2020
dd4842e
a better name for the C target
glessard Apr 11, 2020
dbd39ca
test integer types from CAtomicsPrimitives
glessard Apr 11, 2020
04e754d
test pointer types from CAtomicsPrimitives
glessard Apr 11, 2020
dc26879
define the new `PrimitiveAtomic` protocol
glessard Apr 10, 2020
c0f6e00
re-define `NullableAtomic` to fit the new design
glessard Apr 10, 2020
8d5e95a
Merge branch 'new-catomics' into rev-0.4.0
glessard Apr 12, 2020
f12bb62
switch atomics dependency
glessard Apr 12, 2020
a1dc4e5
update `UnsafeAtomic`
glessard Apr 12, 2020
b419d48
add the new conformances to pointer types and `Unmanaged`
glessard Apr 12, 2020
55e18a1
re-implement `UnsafeAtomicLazyReference` and tests
glessard Apr 12, 2020
9a66255
re-implement atomic integer types (and test)
glessard Apr 12, 2020
7cdd8fe
tweaks to AtomicProtocol's conditional conformance
glessard Apr 12, 2020
c559f66
fix a test of UnsafeAtomicLazyReference
glessard Apr 12, 2020
58d82e9
fix AtomicLazyReference source compatibility
glessard Apr 12, 2020
c896108
proper fix for Swift 3 compatibility mode
glessard Apr 13, 2020
81893a3
adjust CI configuration
glessard Apr 12, 2020
0cc4634
improve tests for nullable types
glessard Apr 13, 2020
8670f21
Merge branch 'master' into rev-0.4.0
glessard Apr 13, 2020
0739b73
Update README.md
glessard Apr 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:

- env: SWIFT=5.0.3

- env: SWIFT=5.1.5

- env: SWIFT=5.2.1

before_install:
Expand Down
10 changes: 5 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import PackageDescription
let package = Package(
name: "SwiftCompatibleAtomics",
products: [
.library(name: "SwiftCompatibleAtomics", targets: ["SwiftCompatibleAtomics"]),
],
dependencies: [
.package(url: "https://github.com/glessard/swift-atomics", from: "6.2.0")
.library(name: "SwiftCompatibleAtomics", type: .static, targets: ["SwiftCompatibleAtomics"]),
.library(name: "CAtomicsPrimitives", type: .static, targets: ["CAtomicsPrimitives"]),
],
targets: [
.target(name: "SwiftCompatibleAtomics", dependencies: ["CAtomics"]),
.target(name: "SwiftCompatibleAtomics", dependencies: ["CAtomicsPrimitives"]),
.testTarget(name: "SwiftCompatibleAtomicsTests", dependencies: ["SwiftCompatibleAtomics"]),
.target(name: "CAtomicsPrimitives", dependencies: []),
.testTarget(name: "CAtomicsPrimitivesTests", dependencies: ["CAtomicsPrimitives"]),
],
swiftLanguageVersions: [.v3, .v4, .v4_2, .version("5")]
)
8 changes: 4 additions & 4 deletions Package@swift-4.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ let package = Package(
name: "SwiftCompatibleAtomics",
products: [
.library(name: "SwiftCompatibleAtomics", targets: ["SwiftCompatibleAtomics"]),
],
dependencies: [
.package(url: "https://github.com/glessard/swift-atomics", from: "6.2.0")
.library(name: "CAtomicsPrimitives", type: .static, targets: ["CAtomicsPrimitives"]),
],
targets: [
.target(name: "SwiftCompatibleAtomics", dependencies: ["CAtomics"]),
.target(name: "SwiftCompatibleAtomics", dependencies: ["CAtomicsPrimitives"]),
.testTarget(name: "SwiftCompatibleAtomicsTests", dependencies: ["SwiftCompatibleAtomics"]),
.target(name: "CAtomicsPrimitives", dependencies: []),
.testTarget(name: "CAtomicsPrimitivesTests", dependencies: ["CAtomicsPrimitives"]),
],
swiftLanguageVersions: [3, 4, 5]
)
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

This is a source-compatible version of [Karoy Lorentey](https://github.com/lorentey)'s pitched `Atomics` submodule for the Swift standard library. His pitch is [here](https://gist.github.com/lorentey/cf8703b5974ebe8f85cfb92a6628880d), his implementation is [here](https://github.com/apple/swift/pull/30553), the discussion is [here](https://forums.swift.org/t/low-level-atomic-operations/34683).

This package uses Clang's C11 atomics support, and works with Swift 4.1 and up. It cannot make some of the guarantees that the official pitch makes, but code that is legal with `import Atomics` should also be legal with `import SwiftCompatibleAtomics`. This gives many Swift users the chance to try out the pitched functionality without having to build a custom toolchain.
This package uses Clang's C11 atomics support, and works with Swift 4.1 and up. It cannot make some of the guarantees that the official implementation can make, but code that is legal with `import Atomics` should also be legal with `import SwiftCompatibleAtomics`. This gives many Swift users the chance to try out the pitched functionality without having to build a custom toolchain.

While the major version is less than 1, the intention is to keep pace with the pitched implementation of `Atomics`, incrementing the minor version when a source-breaking change occurs in the `Atomics` pitch.

If and when the pitch is accepted and its implementation merged, the corresponding compatible implementation will become `1.0.0`.

In the meantime, use by adding the following dependency to your project's `Package.swift`:
```
.package(url: "https://github.com/glessard/SwiftCompatibleAtomics", from: "0.3.0")
.package(url: "https://github.com/glessard/SwiftCompatibleAtomics", from: "0.4.0")
```
or, if you prefer to avoid source breaking changes:
```
.package(url: "https://github.com/glessard/SwiftCompatibleAtomics", .upToNextMinor(from: "0.3.0"))
.package(url: "https://github.com/glessard/SwiftCompatibleAtomics", .upToNextMinor(from: "0.4.0"))
```

### Version History
Expand All @@ -24,3 +24,5 @@ or, if you prefer to avoid source breaking changes:
0.2.0 Fixed a source compatibility issue

0.3.0 Renamed 'UnsafeAtomic' to 'UnsafePointerToAtomic', matching pitched implementation as of April 7th

0.4.0 Implemented the solution in two protocol layers, matching pitched implementation as of April 10th
14 changes: 14 additions & 0 deletions Sources/CAtomicsPrimitives/CAtomics.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// CAtomics.c
//
// Created by Guillaume Lessard on 2015-05-21.
// Copyright (c) 2015-2020 Guillaume Lessard. All rights reserved.
// This file is distributed under the BSD 3-clause license. See LICENSE for details.
//

#include "CAtomics.h"

// See: http://clang.llvm.org/doxygen/stdatomic_8h_source.html
// http://clang.llvm.org/docs/LanguageExtensions.html#c11-atomic-builtins
// http://en.cppreference.com/w/c/atomic
// http://en.cppreference.com/w/c/atomic/atomic_compare_exchange
Loading