mirror of
https://github.com/apple/swift-system
synced 2026-11-22 04:30:46 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a309bbd8a | ||
|
|
ecde55d15e |
No files matched your search
+4
-4
@@ -25,7 +25,7 @@ struct Available {
|
||||
self.name = "System"
|
||||
self.version = version
|
||||
self.osAvailability = osAvailability
|
||||
self.sourceAvailability = "macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, visionOS 1.0"
|
||||
self.sourceAvailability = "macOS 14.0, iOS 8.0, watchOS 2.0, tvOS 9.0, visionOS 1.0"
|
||||
}
|
||||
|
||||
var swiftSetting: SwiftSetting {
|
||||
@@ -81,7 +81,7 @@ let swiftSettings = swiftSettingsAvailability + swiftSettingsCI + [
|
||||
"SYSTEM_PACKAGE_DARWIN",
|
||||
.when(platforms: [.macOS, .macCatalyst, .iOS, .watchOS, .tvOS, .visionOS])),
|
||||
.define("SYSTEM_PACKAGE"),
|
||||
.define("ENABLE_MOCKING", .when(configuration: .debug)),
|
||||
// .define("ENABLE_MOCKING", .when(configuration: .debug)),
|
||||
.enableExperimentalFeature("Lifetimes"),
|
||||
]
|
||||
|
||||
@@ -97,8 +97,8 @@ let platforms: [SupportedPlatform] = [
|
||||
.tvOS("26"),
|
||||
.visionOS("26"),
|
||||
]
|
||||
#else
|
||||
let platforms: [SupportedPlatform]? = nil
|
||||
#else
|
||||
let platforms: [SupportedPlatform] = [.macOS(.v14)]
|
||||
#endif
|
||||
|
||||
#if os(Linux)
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
/// occurred.
|
||||
@frozen
|
||||
@available(System 0.0.1, *)
|
||||
public struct Errno: RawRepresentable, Error, Hashable, Codable {
|
||||
public struct Errno: RawRepresentable, Error, Hashable {
|
||||
/// The raw C error number.
|
||||
@_alwaysEmitIntoClient
|
||||
public let rawValue: CInt
|
||||
@@ -1390,6 +1390,10 @@ public struct Errno: RawRepresentable, Error, Hashable, Codable {
|
||||
public static var EOPNOTSUPP: Errno { notSupportedOnSocket }
|
||||
}
|
||||
|
||||
#if !hasFeature(Embedded)
|
||||
extension FileDescriptor: Codable {}
|
||||
#endif
|
||||
|
||||
// Constants defined in header but not man page
|
||||
@available(System 0.0.1, *)
|
||||
extension Errno {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
/// in the same way as you manage a raw C file handle.
|
||||
@frozen
|
||||
@available(System 0.0.1, *)
|
||||
public struct FileDescriptor: RawRepresentable, Hashable, Codable {
|
||||
public struct FileDescriptor: RawRepresentable, Hashable {
|
||||
/// The raw C file handle.
|
||||
@_alwaysEmitIntoClient
|
||||
public let rawValue: CInt
|
||||
@@ -25,6 +25,10 @@ public struct FileDescriptor: RawRepresentable, Hashable, Codable {
|
||||
public init(rawValue: CInt) { self.rawValue = rawValue }
|
||||
}
|
||||
|
||||
#if !hasFeature(Embedded)
|
||||
extension FileDescriptor: Codable {}
|
||||
#endif
|
||||
|
||||
// Standard file descriptors.
|
||||
@available(System 0.0.1, *)
|
||||
extension FileDescriptor {
|
||||
@@ -46,7 +50,7 @@ extension FileDescriptor {
|
||||
/// The desired read and write access for a newly opened file.
|
||||
@frozen
|
||||
@available(System 0.0.1, *)
|
||||
public struct AccessMode: RawRepresentable, Sendable, Hashable, Codable {
|
||||
public struct AccessMode: RawRepresentable, Sendable, Hashable {
|
||||
/// The raw C access mode.
|
||||
@_alwaysEmitIntoClient
|
||||
public var rawValue: CInt
|
||||
@@ -89,7 +93,7 @@ extension FileDescriptor {
|
||||
/// Options that specify behavior for a newly-opened file.
|
||||
@frozen
|
||||
@available(System 0.0.1, *)
|
||||
public struct OpenOptions: OptionSet, Sendable, Hashable, Codable {
|
||||
public struct OpenOptions: OptionSet, Sendable, Hashable {
|
||||
/// The raw C options.
|
||||
@_alwaysEmitIntoClient
|
||||
public var rawValue: CInt
|
||||
@@ -327,7 +331,7 @@ extension FileDescriptor {
|
||||
/// Options for specifying what a file descriptor's offset is relative to.
|
||||
@frozen
|
||||
@available(System 0.0.1, *)
|
||||
public struct SeekOrigin: RawRepresentable, Sendable, Hashable, Codable {
|
||||
public struct SeekOrigin: RawRepresentable, Sendable, Hashable {
|
||||
/// The raw C value.
|
||||
@_alwaysEmitIntoClient
|
||||
public var rawValue: CInt
|
||||
@@ -402,6 +406,14 @@ extension FileDescriptor {
|
||||
}
|
||||
}
|
||||
|
||||
#if !hasFeature(Embedded)
|
||||
extension FileDescriptor.AccessMode: Codable { }
|
||||
|
||||
extension FileDescriptor.OpenOptions: Codable { }
|
||||
|
||||
extension FileDescriptor.SeekOrigin: Codable { }
|
||||
#endif
|
||||
|
||||
@available(System 0.0.1, *)
|
||||
extension FileDescriptor.AccessMode
|
||||
: CustomStringConvertible, CustomDebugStringConvertible
|
||||
|
||||
@@ -68,6 +68,7 @@ extension FilePath {
|
||||
@available(System 0.0.1, *)
|
||||
extension FilePath: Hashable {}
|
||||
|
||||
#if !hasFeature(Embedded)
|
||||
@available(System 0.0.1, *)
|
||||
extension FilePath: Codable {
|
||||
// Encoder is synthesized; it probably should have been explicit and used
|
||||
@@ -88,3 +89,4 @@ extension FilePath: Codable {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -128,9 +128,15 @@ extension SystemString {
|
||||
}
|
||||
}
|
||||
|
||||
#if hasFeature(Embedded)
|
||||
protocol _StrSliceCodable {}
|
||||
#else
|
||||
protocol _StrSliceCodable: Codable {}
|
||||
#endif
|
||||
|
||||
// Unifying protocol for common functionality between roots, components,
|
||||
// and views onto SystemString and FilePath.
|
||||
internal protocol _StrSlice: _PlatformStringable, Hashable, Codable {
|
||||
internal protocol _StrSlice: _PlatformStringable, Hashable, _StrSliceCodable {
|
||||
var _storage: SystemString { get }
|
||||
var _range: Range<SystemString.Index> { get }
|
||||
|
||||
@@ -138,6 +144,7 @@ internal protocol _StrSlice: _PlatformStringable, Hashable, Codable {
|
||||
|
||||
func _invariantCheck()
|
||||
}
|
||||
|
||||
extension _StrSlice {
|
||||
internal var _slice: Slice<SystemString> {
|
||||
Slice(base: _storage, bounds: _range)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
/// perms == [.ownerReadWrite, .groupRead, .otherRead] // true
|
||||
@frozen
|
||||
@available(System 0.0.1, *)
|
||||
public struct FilePermissions: OptionSet, Sendable, Hashable, Codable {
|
||||
public struct FilePermissions: OptionSet, Sendable, Hashable {
|
||||
/// The raw C file permissions.
|
||||
@_alwaysEmitIntoClient
|
||||
public let rawValue: CModeT
|
||||
@@ -132,6 +132,10 @@ public struct FilePermissions: OptionSet, Sendable, Hashable, Codable {
|
||||
public static var saveText: FilePermissions { .init(rawValue: 0o1000) }
|
||||
}
|
||||
|
||||
#if !hasFeature(Embedded)
|
||||
extension FilePermissions: Codable { }
|
||||
#endif
|
||||
|
||||
@available(System 0.0.1, *)
|
||||
extension FilePermissions
|
||||
: CustomStringConvertible, CustomDebugStringConvertible
|
||||
|
||||
@@ -13,7 +13,7 @@ public extension IORing {
|
||||
}
|
||||
|
||||
public extension IORing.Completion {
|
||||
struct Flags: OptionSet, Hashable, Codable {
|
||||
struct Flags: OptionSet, Hashable {
|
||||
public let rawValue: UInt32
|
||||
|
||||
@inlinable public init(rawValue: UInt32) {
|
||||
@@ -32,6 +32,10 @@ public extension IORing.Completion {
|
||||
}
|
||||
}
|
||||
|
||||
#if !hasFeature(Embedded)
|
||||
extension IORing.Completion.Flags: Codable {}
|
||||
#endif
|
||||
|
||||
public extension IORing.Completion {
|
||||
@inlinable var context: UInt64 {
|
||||
get {
|
||||
|
||||
@@ -45,7 +45,7 @@ extension RawIORequest {
|
||||
case unlinkAt = 36
|
||||
}
|
||||
|
||||
public struct Flags: OptionSet, Hashable, Codable {
|
||||
public struct Flags: OptionSet, Hashable {
|
||||
public let rawValue: UInt8
|
||||
|
||||
@inlinable public init(rawValue: UInt8) {
|
||||
@@ -135,7 +135,7 @@ extension RawIORequest {
|
||||
// splice_flags
|
||||
}
|
||||
|
||||
public struct ReadWriteFlags: OptionSet, Hashable, Codable {
|
||||
public struct ReadWriteFlags: OptionSet, Hashable {
|
||||
public var rawValue: UInt32
|
||||
@inlinable public init(rawValue: UInt32) {
|
||||
self.rawValue = rawValue
|
||||
@@ -156,7 +156,7 @@ extension RawIORequest {
|
||||
@inlinable public static var append: RawIORequest.ReadWriteFlags { ReadWriteFlags(rawValue: 1 << 4) }
|
||||
}
|
||||
|
||||
public struct TimeOutFlags: OptionSet, Hashable, Codable {
|
||||
public struct TimeOutFlags: OptionSet, Hashable {
|
||||
public var rawValue: UInt32
|
||||
|
||||
@inlinable public init(rawValue: UInt32) {
|
||||
@@ -168,6 +168,16 @@ extension RawIORequest {
|
||||
}
|
||||
}
|
||||
|
||||
#if !hasFeature(Embedded)
|
||||
extension IORing.Completion.Flags: Codable {}
|
||||
|
||||
extension RawIORequest.Flags: Codable {}
|
||||
|
||||
extension RawIORequest.ReadWriteFlags: Codable {}
|
||||
|
||||
extension RawIORequest.TimeOutFlags: Codable {}
|
||||
#endif
|
||||
|
||||
extension RawIORequest {
|
||||
@inlinable
|
||||
static func nop() -> RawIORequest {
|
||||
|
||||
@@ -37,10 +37,17 @@ internal typealias _COffT = off_t
|
||||
// MARK: syscalls and variables
|
||||
|
||||
#if SYSTEM_PACKAGE_DARWIN
|
||||
#if hasFeature(Embedded)
|
||||
internal var system_errno: CInt {
|
||||
get { _DarwinFoundation1.errno }
|
||||
set { _DarwinFoundation1.errno = newValue }
|
||||
}
|
||||
#else
|
||||
internal var system_errno: CInt {
|
||||
get { Darwin.errno }
|
||||
set { Darwin.errno = newValue }
|
||||
}
|
||||
#endif
|
||||
#elseif os(Windows)
|
||||
internal var system_errno: CInt {
|
||||
get {
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
*/
|
||||
|
||||
// A platform-native character representation, currently used for file paths
|
||||
internal struct SystemChar:
|
||||
RawRepresentable, Sendable, Comparable, Hashable, Codable {
|
||||
internal struct SystemChar: RawRepresentable, Sendable, Comparable, Hashable {
|
||||
internal typealias RawValue = CInterop.PlatformChar
|
||||
|
||||
internal var rawValue: RawValue
|
||||
@@ -23,6 +22,10 @@ internal struct SystemChar:
|
||||
}
|
||||
}
|
||||
|
||||
#if !hasFeature(Embedded)
|
||||
extension SystemChar: Codable {}
|
||||
#endif
|
||||
|
||||
extension SystemChar {
|
||||
internal init(ascii: Unicode.Scalar) {
|
||||
self.init(rawValue: numericCast(UInt8(ascii: ascii)))
|
||||
@@ -137,6 +140,7 @@ extension SystemString: RandomAccessCollection, MutableCollection {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension SystemString: RangeReplaceableCollection {
|
||||
internal mutating func replaceSubrange<C: Collection>(
|
||||
_ subrange: Range<Index>, with newElements: C
|
||||
@@ -173,7 +177,10 @@ extension SystemString: RangeReplaceableCollection {
|
||||
}
|
||||
}
|
||||
|
||||
extension SystemString: Hashable, Codable {
|
||||
extension SystemString: Hashable {}
|
||||
|
||||
#if !hasFeature(Embedded)
|
||||
extension SystemString: Codable {
|
||||
// Encoder is synthesized; it probably should have been explicit and used
|
||||
// a single-value container, but making that change now is somewhat risky.
|
||||
|
||||
@@ -194,9 +201,9 @@ extension SystemString: Hashable, Codable {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
extension SystemString {
|
||||
|
||||
internal func withNullTerminatedSystemChars<T>(
|
||||
_ f: (UnsafeBufferPointer<SystemChar>) throws -> T
|
||||
) rethrows -> T {
|
||||
|
||||
@@ -52,7 +52,7 @@ internal func _debugPrecondition(
|
||||
// Only check in debug mode.
|
||||
if _slowPath(_isDebugAssertConfiguration()) {
|
||||
precondition(
|
||||
condition(), String(describing: message), file: file, line: line)
|
||||
condition(), "\(message)", file: file, line: line)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user