Skip to content

Commit a9597cc

Browse files
committed
Merge branch 'release/1.7.0' into main
2 parents 03604ff + 50688ca commit a9597cc

13 files changed

Lines changed: 147 additions & 64 deletions

File tree

Package.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,9 @@ let availability: [Available] = [
5959
Available("1.3.2", "macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4, visionOS 1.0"),
6060
Available("1.4.0", "macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4, visionOS 1.0"),
6161

62-
Available("1.4.1", "macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999"),
63-
Available("1.4.2", "macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999"),
64-
Available("1.5.0", "macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999"),
65-
Available("1.6.0", "macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999"),
66-
Available("1.6.1", "macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999"),
62+
Available("1.7.0", "macOS 27.0, iOS 27.0, watchOS 27.0, tvOS 27.0, visionOS 27.0"),
6763

68-
Available("99", "macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999"),
64+
Available("199", "macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999"),
6965
]
7066

7167
let swiftSettingsAvailability = availability.map(\.swiftSetting)

Proposals/0006-system-stat.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ These initializers use a typed `throws(Errno)` and require Swift 6.0 or later.
7979

8080
See the **Appendix** section at the end of this proposal for a table view of Swift API to C mappings.
8181

82-
All API are marked `@_alwaysEmitIntoClient` for performance and back-dating of availability.
82+
All API are marked `@_alwaysEmitIntoClient` for performance and back-dating of availability, except `Stat`'s `==` and `hash(into:)`, which are ordinary `public` API.
8383

8484
### FileType
8585

@@ -693,24 +693,27 @@ public struct Stat: RawRepresentable, Sendable {
693693

694694
/// File generation number
695695
///
696-
/// The file generation number is used to distinguish between different files
697-
/// that have used the same inode over time.
696+
/// The file generation number may be used to distinguish between different
697+
/// files that have used the same inode over time.
698698
///
699699
/// The corresponding C property is `st_gen`.
700-
/// - Note: Only available on Darwin, FreeBSD, and OpenBSD.
701-
public var generationNumber: Int { get set }
700+
/// - Note: Only available on Darwin, FreeBSD, and OpenBSD. The underlying C
701+
/// field is 32-bit on Darwin and OpenBSD, and 64-bit on FreeBSD.
702+
public var generationNumber: UInt64 { get set }
702703
#endif
703704
}
704705

705706
// MARK: - Equatable and Hashable
706707

707708
extension Stat: Equatable {
708-
/// Compares the raw bytes of two `Stat` structs for equality.
709+
/// Compares the meaningful file-metadata fields of two `Stat` values.
710+
///
711+
/// Alignment padding and platform reserved/"spare" fields are not compared.
709712
public static func == (lhs: Self, rhs: Self) -> Bool
710713
}
711714

712715
extension Stat: Hashable {
713-
/// Hashes the raw bytes of this `Stat` struct.
716+
/// Hashes the meaningful file-metadata fields of a `Stat` struct.
714717
public func hash(into hasher: inout Hasher)
715718
}
716719
```

Sources/System/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ add_library(SystemPackage
2424
set_target_properties(SystemPackage PROPERTIES
2525
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
2626
target_compile_options(SystemPackage PRIVATE
27-
-enable-experimental-feature Lifetimes)
27+
-enable-experimental-feature Lifetimes
28+
"SHELL:-package-name swift-system")
2829
target_sources(SystemPackage PRIVATE
2930
FilePath/FilePath.swift
3031
FilePath/FilePathComponents.swift

Sources/System/FileOperations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ extension FileDescriptor {
230230
internal func _read(
231231
into buffer: UnsafeMutableRawBufferPointer,
232232
retryOnInterrupt: Bool
233-
) throws -> Result<Int, Errno> {
233+
) -> Result<Int, Errno> {
234234
valueOrErrno(retryOnInterrupt: retryOnInterrupt) {
235235
system_read(self.rawValue, buffer.baseAddress, buffer.count)
236236
}

Sources/System/FileSystem/FileFlags.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift System open source project
44
//
5-
// Copyright (c) 2025 Apple Inc. and the Swift System project authors
5+
// Copyright (c) 2025 - 2026 Apple Inc. and the Swift System project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -45,7 +45,7 @@
4545
///
4646
/// - Note: Only available on Darwin, FreeBSD, and OpenBSD.
4747
@frozen
48-
@available(System 99, *)
48+
@available(System 1.7.0, *)
4949
public struct FileFlags: OptionSet, Sendable, Hashable, Codable {
5050

5151
/// The raw C flags.

Sources/System/FileSystem/FileMode.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift System open source project
44
//
5-
// Copyright (c) 2025 Apple Inc. and the Swift System project authors
5+
// Copyright (c) 2025 - 2026 Apple Inc. and the Swift System project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -14,7 +14,7 @@
1414
///
1515
/// - Note: Only available on Unix-like platforms.
1616
@frozen
17-
@available(System 99, *)
17+
@available(System 1.7.0, *)
1818
public struct FileMode: RawRepresentable, Sendable, Hashable, Codable {
1919

2020
/// The raw C mode.

Sources/System/FileSystem/FileType.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift System open source project
44
//
5-
// Copyright (c) 2025 Apple Inc. and the Swift System project authors
5+
// Copyright (c) 2025 - 2026 Apple Inc. and the Swift System project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -34,7 +34,7 @@
3434
///
3535
/// - Note: Only available on Unix-like platforms.
3636
@frozen
37-
@available(System 99, *)
37+
@available(System 1.7.0, *)
3838
public struct FileType: RawRepresentable, Sendable, Hashable, Codable {
3939

4040
/// The raw file-type bits from the C mode.

Sources/System/FileSystem/Identifiers.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift System open source project
44
//
5-
// Copyright (c) 2025 Apple Inc. and the Swift System project authors
5+
// Copyright (c) 2025 - 2026 Apple Inc. and the Swift System project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -12,7 +12,7 @@
1212
#if !os(Windows)
1313
/// A Swift wrapper of the C `uid_t` type.
1414
@frozen
15-
@available(System 99, *)
15+
@available(System 1.7.0, *)
1616
public struct UserID: RawRepresentable, Sendable, Hashable, Codable {
1717

1818
/// The raw C `uid_t`.
@@ -30,7 +30,7 @@ public struct UserID: RawRepresentable, Sendable, Hashable, Codable {
3030

3131
/// A Swift wrapper of the C `gid_t` type.
3232
@frozen
33-
@available(System 99, *)
33+
@available(System 1.7.0, *)
3434
public struct GroupID: RawRepresentable, Sendable, Hashable, Codable {
3535

3636
/// The raw C `gid_t`.
@@ -48,7 +48,7 @@ public struct GroupID: RawRepresentable, Sendable, Hashable, Codable {
4848

4949
/// A Swift wrapper of the C `dev_t` type.
5050
@frozen
51-
@available(System 99, *)
51+
@available(System 1.7.0, *)
5252
public struct DeviceID: RawRepresentable, Sendable, Hashable, Codable {
5353

5454
/// The raw C `dev_t`.
@@ -66,7 +66,7 @@ public struct DeviceID: RawRepresentable, Sendable, Hashable, Codable {
6666

6767
/// A Swift wrapper of the C `ino_t` type.
6868
@frozen
69-
@available(System 99, *)
69+
@available(System 1.7.0, *)
7070
public struct Inode: RawRepresentable, Sendable, Hashable, Codable {
7171

7272
/// The raw C `ino_t`.

Sources/System/FileSystem/Stat.swift

Lines changed: 74 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift System open source project
44
//
5-
// Copyright (c) 2025 Apple Inc. and the Swift System project authors
5+
// Copyright (c) 2025 - 2026 Apple Inc. and the Swift System project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -35,7 +35,7 @@ import Android
3535
///
3636
/// - Note: Only available on Unix-like platforms.
3737
@frozen
38-
@available(System 99, *)
38+
@available(System 1.7.0, *)
3939
public struct Stat: RawRepresentable, Sendable {
4040

4141
/// The raw C `stat` struct.
@@ -521,50 +521,101 @@ public struct Stat: RawRepresentable, Sendable {
521521

522522
/// File generation number
523523
///
524-
/// The file generation number is used to distinguish between different files
525-
/// that have used the same inode over time.
524+
/// The file generation number may be used to distinguish between different
525+
/// files that have used the same inode over time.
526526
///
527527
/// The corresponding C property is `st_gen`.
528-
/// - Note: Only available on Darwin, FreeBSD, and OpenBSD.
528+
/// - Note: Only available on Darwin, FreeBSD, and OpenBSD. The underlying C
529+
/// field is 32-bit on Darwin and OpenBSD, and 64-bit on FreeBSD.
529530
@_alwaysEmitIntoClient
530-
public var generationNumber: Int {
531-
get { Int(rawValue.st_gen) }
532-
set { rawValue.st_gen = numericCast(newValue)}
531+
public var generationNumber: UInt64 {
532+
get { UInt64(rawValue.st_gen) }
533+
set { rawValue.st_gen = numericCast(newValue) }
533534
}
534535
#endif
535536
}
536537

537538
// MARK: - Equatable and Hashable
538539

539-
@available(System 99, *)
540+
@available(System 1.7.0, *)
540541
extension Stat: Equatable {
541-
@_alwaysEmitIntoClient
542-
/// Compares the raw bytes of two `Stat` structs for equality.
542+
/// Compares the meaningful file-metadata fields of two `Stat` values.
543+
///
544+
/// Alignment padding and platform reserved/"spare" fields are not compared.
543545
public static func == (lhs: Self, rhs: Self) -> Bool {
544-
return withUnsafeBytes(of: lhs.rawValue) { lhsBytes in
545-
withUnsafeBytes(of: rhs.rawValue) { rhsBytes in
546-
lhsBytes.elementsEqual(rhsBytes)
547-
}
546+
guard lhs.rawValue.st_dev == rhs.rawValue.st_dev,
547+
lhs.rawValue.st_ino == rhs.rawValue.st_ino,
548+
lhs.rawValue.st_mode == rhs.rawValue.st_mode,
549+
lhs.rawValue.st_nlink == rhs.rawValue.st_nlink,
550+
lhs.rawValue.st_uid == rhs.rawValue.st_uid,
551+
lhs.rawValue.st_gid == rhs.rawValue.st_gid,
552+
lhs.rawValue.st_rdev == rhs.rawValue.st_rdev,
553+
lhs.rawValue.st_size == rhs.rawValue.st_size,
554+
lhs.rawValue.st_blksize == rhs.rawValue.st_blksize,
555+
lhs.rawValue.st_blocks == rhs.rawValue.st_blocks,
556+
lhs.st_atim.tv_sec == rhs.st_atim.tv_sec,
557+
lhs.st_atim.tv_nsec == rhs.st_atim.tv_nsec,
558+
lhs.st_mtim.tv_sec == rhs.st_mtim.tv_sec,
559+
lhs.st_mtim.tv_nsec == rhs.st_mtim.tv_nsec,
560+
lhs.st_ctim.tv_sec == rhs.st_ctim.tv_sec,
561+
lhs.st_ctim.tv_nsec == rhs.st_ctim.tv_nsec else {
562+
return false
563+
}
564+
#if SYSTEM_PACKAGE_DARWIN || os(FreeBSD)
565+
guard lhs.st_birthtim.tv_sec == rhs.st_birthtim.tv_sec,
566+
lhs.st_birthtim.tv_nsec == rhs.st_birthtim.tv_nsec else {
567+
return false
568+
}
569+
#endif
570+
#if SYSTEM_PACKAGE_DARWIN || os(FreeBSD) || os(OpenBSD)
571+
guard lhs.rawValue.st_flags == rhs.rawValue.st_flags,
572+
lhs.rawValue.st_gen == rhs.rawValue.st_gen else {
573+
return false
548574
}
575+
#endif
576+
return true
549577
}
550578
}
551579

552-
@available(System 99, *)
580+
@available(System 1.7.0, *)
553581
extension Stat: Hashable {
554-
@_alwaysEmitIntoClient
555-
/// Hashes the raw bytes of this `Stat` struct.
582+
/// Hashes the meaningful file-metadata fields of a `Stat` struct.
583+
///
584+
/// These are the same fields compared by `==`, fed in the same order.
585+
/// Alignment padding and platform reserved/"spare" fields are not hashed.
556586
public func hash(into hasher: inout Hasher) {
557-
withUnsafeBytes(of: rawValue) { bytes in
558-
hasher.combine(bytes: bytes)
559-
}
587+
hasher.combine(rawValue.st_dev)
588+
hasher.combine(rawValue.st_ino)
589+
hasher.combine(rawValue.st_mode)
590+
hasher.combine(rawValue.st_nlink)
591+
hasher.combine(rawValue.st_uid)
592+
hasher.combine(rawValue.st_gid)
593+
hasher.combine(rawValue.st_rdev)
594+
hasher.combine(rawValue.st_size)
595+
hasher.combine(rawValue.st_blksize)
596+
hasher.combine(rawValue.st_blocks)
597+
hasher.combine(st_atim.tv_sec)
598+
hasher.combine(st_atim.tv_nsec)
599+
hasher.combine(st_mtim.tv_sec)
600+
hasher.combine(st_mtim.tv_nsec)
601+
hasher.combine(st_ctim.tv_sec)
602+
hasher.combine(st_ctim.tv_nsec)
603+
#if SYSTEM_PACKAGE_DARWIN || os(FreeBSD)
604+
hasher.combine(st_birthtim.tv_sec)
605+
hasher.combine(st_birthtim.tv_nsec)
606+
#endif
607+
#if SYSTEM_PACKAGE_DARWIN || os(FreeBSD) || os(OpenBSD)
608+
hasher.combine(rawValue.st_flags)
609+
hasher.combine(rawValue.st_gen)
610+
#endif
560611
}
561612
}
562613

563614
// MARK: - CustomStringConvertible and CustomDebugStringConvertible
564615

565616
// MARK: - FileDescriptor Extensions
566617

567-
@available(System 99, *)
618+
@available(System 1.7.0, *)
568619
extension FileDescriptor {
569620

570621
/// Creates a `Stat` struct for the file referenced by this `FileDescriptor`.
@@ -580,7 +631,7 @@ extension FileDescriptor {
580631

581632
// MARK: - FilePath Extensions
582633

583-
@available(System 99, *)
634+
@available(System 1.7.0, *)
584635
extension FilePath {
585636

586637
/// Creates a `Stat` struct for the file referenced by this `FilePath`.

Sources/System/Internals/CInterop.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift System open source project
33

4-
Copyright (c) 2020 - 2024 Apple Inc. and the Swift System project authors
4+
Copyright (c) 2020 - 2026 Apple Inc. and the Swift System project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -106,7 +106,7 @@ extension CInterop {
106106
}
107107
}
108108

109-
@available(System 99, *)
109+
@available(System 1.7.0, *)
110110
extension CInterop {
111111
public typealias DeviceID = dev_t
112112
public typealias Inode = ino_t

0 commit comments

Comments
 (0)