Skip to content

Commit 547b2a5

Browse files
authored
Merge pull request #141 from glessard/requirement-update
2 parents 164fe8c + 87e68fc commit 547b2a5

File tree

8 files changed

+23
-215
lines changed

8 files changed

+23
-215
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.2
1+
// swift-tools-version:5.6
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
/*

Sources/System/FileDescriptor.swift

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ extension FileDescriptor {
4545
extension FileDescriptor {
4646
/// The desired read and write access for a newly opened file.
4747
@frozen
48-
public struct AccessMode: RawRepresentable, Hashable, Codable {
48+
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
49+
public struct AccessMode: RawRepresentable, Sendable, Hashable, Codable {
4950
/// The raw C access mode.
5051
@_alwaysEmitIntoClient
5152
public var rawValue: CInt
@@ -87,7 +88,8 @@ extension FileDescriptor {
8788

8889
/// Options that specify behavior for a newly-opened file.
8990
@frozen
90-
public struct OpenOptions: OptionSet, Hashable, Codable {
91+
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
92+
public struct OpenOptions: OptionSet, Sendable, Hashable, Codable {
9193
/// The raw C options.
9294
@_alwaysEmitIntoClient
9395
public var rawValue: CInt
@@ -311,7 +313,8 @@ extension FileDescriptor {
311313

312314
/// Options for specifying what a file descriptor's offset is relative to.
313315
@frozen
314-
public struct SeekOrigin: RawRepresentable, Hashable, Codable {
316+
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
317+
public struct SeekOrigin: RawRepresentable, Sendable, Hashable, Codable {
315318
/// The raw C value.
316319
@_alwaysEmitIntoClient
317320
public var rawValue: CInt
@@ -475,18 +478,7 @@ extension FileDescriptor.OpenOptions
475478
public var debugDescription: String { self.description }
476479
}
477480

478-
#if compiler(>=5.5) && canImport(_Concurrency)
479481
// The decision on whether to make FileDescriptor Sendable or not
480482
// is currently being discussed in https://github.com/apple/swift-system/pull/112
481483
//@available(*, unavailable, message: "File descriptors are not completely thread-safe.")
482484
//extension FileDescriptor: Sendable {}
483-
484-
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
485-
extension FileDescriptor.AccessMode: Sendable {}
486-
487-
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
488-
extension FileDescriptor.OpenOptions: Sendable {}
489-
490-
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
491-
extension FileDescriptor.SeekOrigin: Sendable {}
492-
#endif

Sources/System/FilePath/FilePath.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
/// are file-system–specific and have additional considerations
3939
/// like case insensitivity, Unicode normalization, and symbolic links.
4040
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
41-
public struct FilePath {
41+
public struct FilePath: Sendable {
4242
// TODO(docs): Section on all the new syntactic operations, lexical normalization, decomposition,
4343
// components, etc.
4444
internal var _storage: SystemString
@@ -67,8 +67,3 @@ extension FilePath {
6767

6868
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
6969
extension FilePath: Hashable, Codable {}
70-
71-
#if compiler(>=5.5) && canImport(_Concurrency)
72-
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
73-
extension FilePath: Sendable {}
74-
#endif

Sources/System/FilePath/FilePathComponentView.swift

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ extension FilePath {
2828
///
2929
/// path.components.removeAll { $0.kind == .currentDirectory }
3030
/// // path is "/home/username/bin/scripts/tree"
31-
public struct ComponentView {
31+
@available(/*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8, *)
32+
public struct ComponentView: Sendable {
3233
internal var _path: FilePath
3334
internal var _start: SystemString.Index
3435

@@ -39,30 +40,6 @@ extension FilePath {
3940
}
4041
}
4142

42-
#if SYSTEM_PACKAGE // Workaround for a __consuming getter bug in Swift 5.3.3
43-
/// View the non-root components that make up this path.
44-
public var components: ComponentView {
45-
get { ComponentView(self) }
46-
_modify {
47-
// RRC's empty init means that we can't guarantee that the yielded
48-
// view will restore our root. So copy it out first.
49-
//
50-
// TODO(perf): Small-form root (especially on Unix). Have Root
51-
// always copy out (not worth ref counting). Make sure that we're
52-
// not needlessly sliding values around or triggering a COW
53-
let rootStr = self.root?._systemString ?? SystemString()
54-
var comp = ComponentView(self)
55-
self = FilePath()
56-
defer {
57-
self = comp._path
58-
if root?._slice.elementsEqual(rootStr) != true {
59-
self.root = Root(rootStr)
60-
}
61-
}
62-
yield &comp
63-
}
64-
}
65-
#else
6643
/// View the non-root components that make up this path.
6744
public var components: ComponentView {
6845
__consuming get { ComponentView(self) }
@@ -85,13 +62,14 @@ extension FilePath {
8562
yield &comp
8663
}
8764
}
88-
#endif
8965
}
9066

9167
@available(/*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8, *)
9268
extension FilePath.ComponentView: BidirectionalCollection {
9369
public typealias Element = FilePath.Component
94-
public struct Index: Comparable, Hashable {
70+
71+
@available(/*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8, *)
72+
public struct Index: Sendable, Comparable, Hashable {
9573
internal typealias Storage = SystemString.Index
9674

9775
internal var _storage: Storage
@@ -239,11 +217,3 @@ extension FilePath.ComponentView {
239217
#endif // DEBUG
240218
}
241219
}
242-
243-
#if compiler(>=5.5) && canImport(_Concurrency)
244-
@available(/*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8, *)
245-
extension FilePath.ComponentView: Sendable {}
246-
247-
@available(/*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8, *)
248-
extension FilePath.ComponentView.Index: Sendable {}
249-
#endif

Sources/System/FilePath/FilePathComponents.swift

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ extension FilePath {
2828
/// * `\\server\share\`
2929
/// * `\\?\UNC\server\share\`
3030
/// * `\\?\Volume{12345678-abcd-1111-2222-123445789abc}\`
31-
public struct Root {
31+
@available(/*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8, *)
32+
public struct Root: Sendable {
3233
internal var _path: FilePath
3334
internal var _rootEnd: SystemString.Index
3435

@@ -54,7 +55,8 @@ extension FilePath {
5455
/// file.kind == .regular // true
5556
/// file.extension // "txt"
5657
/// path.append(file) // path is "/tmp/foo.txt"
57-
public struct Component {
58+
@available(/*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8, *)
59+
public struct Component: Sendable {
5860
internal var _path: FilePath
5961
internal var _range: Range<SystemString.Index>
6062

@@ -78,7 +80,8 @@ extension FilePath.Component {
7880
/// Whether a component is a regular file or directory name, or a special
7981
/// directory `.` or `..`
8082
@frozen
81-
public enum Kind {
83+
@available(/*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8, *)
84+
public enum Kind: Sendable {
8285
/// The special directory `.`, representing the current directory.
8386
case currentDirectory
8487

@@ -285,14 +288,3 @@ extension FilePath.Root {
285288
#endif
286289
}
287290
}
288-
289-
#if compiler(>=5.5) && canImport(_Concurrency)
290-
@available(/*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8, *)
291-
extension FilePath.Root: Sendable {}
292-
293-
@available(/*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8, *)
294-
extension FilePath.Component: Sendable {}
295-
296-
@available(/*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8, *)
297-
extension FilePath.Component.Kind: Sendable {}
298-
#endif

Sources/System/FilePermissions.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/// perms == [.ownerReadWrite, .groupRead, .otherRead] // true
1919
@frozen
2020
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
21-
public struct FilePermissions: OptionSet, Hashable, Codable {
21+
public struct FilePermissions: OptionSet, Sendable, Hashable, Codable {
2222
/// The raw C file permissions.
2323
@_alwaysEmitIntoClient
2424
public let rawValue: CModeT
@@ -175,8 +175,3 @@ extension FilePermissions
175175
/// A textual representation of the file permissions, suitable for debugging.
176176
public var debugDescription: String { self.description }
177177
}
178-
179-
#if compiler(>=5.5) && canImport(_Concurrency)
180-
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
181-
extension FilePermissions: Sendable {}
182-
#endif

Sources/System/SystemString.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
*/
99

1010
// A platform-native character representation, currently used for file paths
11-
internal struct SystemChar: RawRepresentable, Comparable, Hashable, Codable {
11+
internal struct SystemChar:
12+
RawRepresentable, Sendable, Comparable, Hashable, Codable {
1213
internal typealias RawValue = CInterop.PlatformChar
1314

1415
internal var rawValue: RawValue
@@ -61,7 +62,7 @@ extension SystemChar {
6162
// A platform-native string representation, currently for file paths
6263
//
6364
// Always null-terminated.
64-
internal struct SystemString {
65+
internal struct SystemString: Sendable {
6566
internal typealias Storage = [SystemChar]
6667
internal var nullTerminatedStorage: Storage
6768
}
@@ -288,11 +289,6 @@ extension SystemString {
288289
}
289290
}
290291

291-
#if compiler(>=5.5) && canImport(_Concurrency)
292-
extension SystemChar: Sendable {}
293-
extension SystemString: Sendable {}
294-
#endif
295-
296292
// TODO: SystemString should use a COW-interchangable storage form rather
297293
// than array, so you could "borrow" the storage from a non-bridged String
298294
// or Data or whatever

Tests/SystemTests/XCTestManifests.swift

Lines changed: 0 additions & 132 deletions
This file was deleted.

0 commit comments

Comments
 (0)