Skip to content

Commit 4911642

Browse files
committed
Add availability, fix CInterop availability issue on old Darwin platforms
1 parent 40e1deb commit 4911642

File tree

9 files changed

+56
-48
lines changed

9 files changed

+56
-48
lines changed

Package.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ let availability: [Available] = [
6464
Available("1.5.0", "macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999"),
6565
Available("1.6.0", "macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999"),
6666
Available("1.6.1", "macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999"),
67+
68+
Available("99", "macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999"),
6769
]
6870

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

Sources/System/FileSystem/FileFlags.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
// |------------------|---------------|---------------|---------------|
4040

4141
#if SYSTEM_PACKAGE_DARWIN || os(FreeBSD) || os(OpenBSD)
42-
// @available(System X.Y.Z, *)
42+
@available(System 99, *)
4343
extension CInterop {
4444
public typealias FileFlags = UInt32
4545
}
@@ -49,7 +49,7 @@ extension CInterop {
4949
///
5050
/// - Note: Only available on Darwin, FreeBSD, and OpenBSD.
5151
@frozen
52-
// @available(System X.Y.Z, *)
52+
@available(System 99, *)
5353
public struct FileFlags: OptionSet, Sendable, Hashable, Codable {
5454

5555
/// The raw C flags.

Sources/System/FileSystem/FileMode.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
///
1515
/// - Note: Only available on Unix-like platforms.
1616
@frozen
17-
// @available(System X.Y.Z, *)
17+
@available(System 99, *)
1818
public struct FileMode: RawRepresentable, Sendable, Hashable, Codable {
1919

2020
/// The raw C mode.

Sources/System/FileSystem/FileType.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
///
3535
/// - Note: Only available on Unix-like platforms.
3636
@frozen
37-
// @available(System X.Y.Z, *)
37+
@available(System 99, *)
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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#if !os(Windows)
1313
/// A Swift wrapper of the C `uid_t` type.
1414
@frozen
15-
// @available(System X.Y.Z, *)
15+
@available(System 99, *)
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 X.Y.Z, *)
33+
@available(System 99, *)
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 X.Y.Z, *)
51+
@available(System 99, *)
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 X.Y.Z, *)
69+
@available(System 99, *)
7070
public struct Inode: RawRepresentable, Sendable, Hashable, Codable {
7171

7272
/// The raw C `ino_t`.

Sources/System/FileSystem/Stat.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import Android
3535
///
3636
/// - Note: Only available on Unix-like platforms.
3737
@frozen
38-
// @available(System X.Y.Z, *)
38+
@available(System 99, *)
3939
public struct Stat: RawRepresentable, Sendable {
4040

4141
/// The raw C `stat` struct.
@@ -82,7 +82,6 @@ public struct Stat: RawRepresentable, Sendable {
8282
/// The corresponding C constant is `AT_RESOLVE_BENEATH`.
8383
/// - Note: Only available on Darwin and FreeBSD.
8484
@_alwaysEmitIntoClient
85-
@available(macOS 26.0, iOS 26.0, tvOS 26.0, watchOS 26.0, visionOS 26.0, *)
8685
public static var resolveBeneath: Flags { Flags(rawValue: _AT_RESOLVE_BENEATH) }
8786
#endif
8887
}
@@ -537,6 +536,7 @@ public struct Stat: RawRepresentable, Sendable {
537536

538537
// MARK: - Equatable and Hashable
539538

539+
@available(System 99, *)
540540
extension Stat: Equatable {
541541
@_alwaysEmitIntoClient
542542
/// Compares the raw bytes of two `Stat` structs for equality.
@@ -549,6 +549,7 @@ extension Stat: Equatable {
549549
}
550550
}
551551

552+
@available(System 99, *)
552553
extension Stat: Hashable {
553554
@_alwaysEmitIntoClient
554555
/// Hashes the raw bytes of this `Stat` struct.
@@ -563,7 +564,7 @@ extension Stat: Hashable {
563564

564565
// MARK: - FileDescriptor Extensions
565566

566-
// @available(System X.Y.Z, *)
567+
@available(System 99, *)
567568
extension FileDescriptor {
568569

569570
/// Creates a `Stat` struct for the file referenced by this `FileDescriptor`.
@@ -579,7 +580,7 @@ extension FileDescriptor {
579580

580581
// MARK: - FilePath Extensions
581582

582-
// @available(System X.Y.Z, *)
583+
@available(System 99, *)
583584
extension FilePath {
584585

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

Sources/System/Internals/Constants.swift

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -672,35 +672,35 @@ internal var _AT_RESOLVE_BENEATH: CInt { AT_RESOLVE_BENEATH }
672672
// MARK: - File Mode / File Type
673673

674674
@_alwaysEmitIntoClient
675-
internal var _MODE_FILETYPE_MASK: CInterop.Mode { S_IFMT }
675+
internal var _MODE_FILETYPE_MASK: mode_t { S_IFMT }
676676

677677
@_alwaysEmitIntoClient
678-
internal var _MODE_PERMISSIONS_MASK: CInterop.Mode { 0o7777 }
678+
internal var _MODE_PERMISSIONS_MASK: mode_t { 0o7777 }
679679

680680
@_alwaysEmitIntoClient
681-
internal var _S_IFDIR: CInterop.Mode { S_IFDIR }
681+
internal var _S_IFDIR: mode_t { S_IFDIR }
682682

683683
@_alwaysEmitIntoClient
684-
internal var _S_IFCHR: CInterop.Mode { S_IFCHR }
684+
internal var _S_IFCHR: mode_t { S_IFCHR }
685685

686686
@_alwaysEmitIntoClient
687-
internal var _S_IFBLK: CInterop.Mode { S_IFBLK }
687+
internal var _S_IFBLK: mode_t { S_IFBLK }
688688

689689
@_alwaysEmitIntoClient
690-
internal var _S_IFREG: CInterop.Mode { S_IFREG }
690+
internal var _S_IFREG: mode_t { S_IFREG }
691691

692692
@_alwaysEmitIntoClient
693-
internal var _S_IFIFO: CInterop.Mode { S_IFIFO }
693+
internal var _S_IFIFO: mode_t { S_IFIFO }
694694

695695
@_alwaysEmitIntoClient
696-
internal var _S_IFLNK: CInterop.Mode { S_IFLNK }
696+
internal var _S_IFLNK: mode_t { S_IFLNK }
697697

698698
@_alwaysEmitIntoClient
699-
internal var _S_IFSOCK: CInterop.Mode { S_IFSOCK }
699+
internal var _S_IFSOCK: mode_t { S_IFSOCK }
700700

701701
#if SYSTEM_PACKAGE_DARWIN || os(FreeBSD)
702702
@_alwaysEmitIntoClient
703-
internal var _S_IFWHT: CInterop.Mode { S_IFWHT }
703+
internal var _S_IFWHT: mode_t { S_IFWHT }
704704
#endif
705705

706706
// MARK: - stat/chflags File Flags
@@ -709,82 +709,82 @@ internal var _S_IFWHT: CInterop.Mode { S_IFWHT }
709709

710710
#if SYSTEM_PACKAGE_DARWIN || os(FreeBSD) || os(OpenBSD)
711711
@_alwaysEmitIntoClient
712-
internal var _UF_NODUMP: CInterop.FileFlags { UInt32(bitPattern: UF_NODUMP) }
712+
internal var _UF_NODUMP: UInt32 { UInt32(bitPattern: UF_NODUMP) }
713713

714714
@_alwaysEmitIntoClient
715-
internal var _UF_IMMUTABLE: CInterop.FileFlags { UInt32(bitPattern: UF_IMMUTABLE) }
715+
internal var _UF_IMMUTABLE: UInt32 { UInt32(bitPattern: UF_IMMUTABLE) }
716716

717717
@_alwaysEmitIntoClient
718-
internal var _UF_APPEND: CInterop.FileFlags { UInt32(bitPattern: UF_APPEND) }
718+
internal var _UF_APPEND: UInt32 { UInt32(bitPattern: UF_APPEND) }
719719

720720
@_alwaysEmitIntoClient
721-
internal var _SF_ARCHIVED: CInterop.FileFlags { UInt32(bitPattern: SF_ARCHIVED) }
721+
internal var _SF_ARCHIVED: UInt32 { UInt32(bitPattern: SF_ARCHIVED) }
722722

723723
@_alwaysEmitIntoClient
724-
internal var _SF_IMMUTABLE: CInterop.FileFlags { UInt32(bitPattern: SF_IMMUTABLE) }
724+
internal var _SF_IMMUTABLE: UInt32 { UInt32(bitPattern: SF_IMMUTABLE) }
725725

726726
@_alwaysEmitIntoClient
727-
internal var _SF_APPEND: CInterop.FileFlags { UInt32(bitPattern: SF_APPEND) }
727+
internal var _SF_APPEND: UInt32 { UInt32(bitPattern: SF_APPEND) }
728728
#endif
729729

730730
// MARK: Flags Available on Darwin and FreeBSD
731731

732732
#if SYSTEM_PACKAGE_DARWIN || os(FreeBSD)
733733
@_alwaysEmitIntoClient
734-
internal var _UF_OPAQUE: CInterop.FileFlags { UInt32(bitPattern: UF_OPAQUE) }
734+
internal var _UF_OPAQUE: UInt32 { UInt32(bitPattern: UF_OPAQUE) }
735735

736736
@_alwaysEmitIntoClient
737-
internal var _UF_HIDDEN: CInterop.FileFlags { UInt32(bitPattern: UF_HIDDEN) }
737+
internal var _UF_HIDDEN: UInt32 { UInt32(bitPattern: UF_HIDDEN) }
738738

739739
@_alwaysEmitIntoClient
740-
internal var _SF_NOUNLINK: CInterop.FileFlags { UInt32(bitPattern: SF_NOUNLINK) }
740+
internal var _SF_NOUNLINK: UInt32 { UInt32(bitPattern: SF_NOUNLINK) }
741741
#endif
742742

743743
// MARK: Flags Available on Darwin Only
744744

745745
#if SYSTEM_PACKAGE_DARWIN
746746
@_alwaysEmitIntoClient
747-
internal var _UF_COMPRESSED: CInterop.FileFlags { UInt32(bitPattern: UF_COMPRESSED) }
747+
internal var _UF_COMPRESSED: UInt32 { UInt32(bitPattern: UF_COMPRESSED) }
748748

749749
@_alwaysEmitIntoClient
750-
internal var _UF_TRACKED: CInterop.FileFlags { UInt32(bitPattern: UF_TRACKED) }
750+
internal var _UF_TRACKED: UInt32 { UInt32(bitPattern: UF_TRACKED) }
751751

752752
@_alwaysEmitIntoClient
753-
internal var _UF_DATAVAULT: CInterop.FileFlags { UInt32(bitPattern: UF_DATAVAULT) }
753+
internal var _UF_DATAVAULT: UInt32 { UInt32(bitPattern: UF_DATAVAULT) }
754754

755755
@_alwaysEmitIntoClient
756-
internal var _SF_RESTRICTED: CInterop.FileFlags { UInt32(bitPattern: SF_RESTRICTED) }
756+
internal var _SF_RESTRICTED: UInt32 { UInt32(bitPattern: SF_RESTRICTED) }
757757

758758
@_alwaysEmitIntoClient
759-
internal var _SF_FIRMLINK: CInterop.FileFlags { UInt32(bitPattern: SF_FIRMLINK) }
759+
internal var _SF_FIRMLINK: UInt32 { UInt32(bitPattern: SF_FIRMLINK) }
760760

761761
@_alwaysEmitIntoClient
762-
internal var _SF_DATALESS: CInterop.FileFlags { UInt32(bitPattern: SF_DATALESS) }
762+
internal var _SF_DATALESS: UInt32 { UInt32(bitPattern: SF_DATALESS) }
763763
#endif
764764

765765
// MARK: Flags Available on FreeBSD Only
766766

767767
#if os(FreeBSD)
768768
@_alwaysEmitIntoClient
769-
internal var _UF_NOUNLINK: CInterop.FileFlags { UInt32(bitPattern: UF_NOUNLINK) }
769+
internal var _UF_NOUNLINK: UInt32 { UInt32(bitPattern: UF_NOUNLINK) }
770770

771771
@_alwaysEmitIntoClient
772-
internal var _UF_OFFLINE: CInterop.FileFlags { UInt32(bitPattern: UF_OFFLINE) }
772+
internal var _UF_OFFLINE: UInt32 { UInt32(bitPattern: UF_OFFLINE) }
773773

774774
@_alwaysEmitIntoClient
775-
internal var _UF_READONLY: CInterop.FileFlags { UInt32(bitPattern: UF_READONLY) }
775+
internal var _UF_READONLY: UInt32 { UInt32(bitPattern: UF_READONLY) }
776776

777777
@_alwaysEmitIntoClient
778-
internal var _UF_REPARSE: CInterop.FileFlags { UInt32(bitPattern: UF_REPARSE) }
778+
internal var _UF_REPARSE: UInt32 { UInt32(bitPattern: UF_REPARSE) }
779779

780780
@_alwaysEmitIntoClient
781-
internal var _UF_SPARSE: CInterop.FileFlags { UInt32(bitPattern: UF_SPARSE) }
781+
internal var _UF_SPARSE: UInt32 { UInt32(bitPattern: UF_SPARSE) }
782782

783783
@_alwaysEmitIntoClient
784-
internal var _UF_SYSTEM: CInterop.FileFlags { UInt32(bitPattern: UF_SYSTEM) }
784+
internal var _UF_SYSTEM: UInt32 { UInt32(bitPattern: UF_SYSTEM) }
785785

786786
@_alwaysEmitIntoClient
787-
internal var _SF_SNAPSHOT: CInterop.FileFlags { UInt32(bitPattern: SF_SNAPSHOT) }
787+
internal var _SF_SNAPSHOT: UInt32 { UInt32(bitPattern: SF_SNAPSHOT) }
788788
#endif
789789

790790
#endif // !os(Windows)

Tests/SystemTests/FileModeTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import Android
3636
@Suite("FileMode")
3737
private struct FileModeTests {
3838

39+
@available(System 99, *)
3940
@Test func basics() async throws {
4041
var mode = FileMode(rawValue: S_IFREG | 0o644) // Regular file, rw-r--r--
4142
#expect(mode.type == .regular)
@@ -66,6 +67,7 @@ private struct FileModeTests {
6667
#expect(mode.type == mode2.type)
6768
}
6869

70+
@available(System 99, *)
6971
@Test func invalidInput() async throws {
7072
// No permissions, all other bits set
7173
var invalidMode = FileMode(rawValue: ~0o7777)

Tests/SystemTests/StatTests.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import Android
3939
@Suite("Stat")
4040
private struct StatTests {
4141

42+
@available(System 99, *)
4243
@Test func basics() async throws {
4344
try withTemporaryFilePath(basename: "Stat_basics") { tempDir in
4445
let dirStatFromFilePath = try tempDir.stat()
@@ -80,8 +81,8 @@ private struct StatTests {
8081
}
8182
}
8283

83-
@Test
84-
func followSymlinkInits() async throws {
84+
@available(System 99, *)
85+
@Test func followSymlinkInits() async throws {
8586
try withTemporaryFilePath(basename: "Stat_followSymlinkInits") { tempDir in
8687
let targetFilePath = tempDir.appending("target.txt")
8788
let symlinkPath = tempDir.appending("symlink")
@@ -189,6 +190,7 @@ private struct StatTests {
189190
}
190191
}
191192

193+
@available(System 99, *)
192194
@Test func permissions() async throws {
193195
try withTemporaryFilePath(basename: "Stat_permissions") { tempDir in
194196
let testFile = tempDir.appending("test.txt")
@@ -218,8 +220,8 @@ private struct StatTests {
218220
}
219221
}
220222

221-
@Test
222-
func times() async throws {
223+
@available(System 99, *)
224+
@Test func times() async throws {
223225
var start = timespec()
224226
try #require(clock_gettime(CLOCK_REALTIME, &start) == 0, "\(Errno.current)")
225227
start.tv_sec -= 1 // A little wiggle room
@@ -347,6 +349,7 @@ private struct StatTests {
347349
}
348350

349351
#if SYSTEM_PACKAGE_DARWIN || os(FreeBSD) || os(OpenBSD)
352+
@available(System 99, *)
350353
@Test func flags() async throws {
351354
try withTemporaryFilePath(basename: "Stat_flags") { tempDir in
352355
let filePath = tempDir.appending("test.txt")

0 commit comments

Comments
 (0)