From bcc40449aa0b6bc297e274e1588243d36cb1b5cf Mon Sep 17 00:00:00 2001 From: stackotter Date: Sat, 11 May 2024 22:45:12 +1000 Subject: [PATCH 1/3] Replace swift-system fork with actual swift-system so that Socket can be used as a stable versioned dependency (instead of an exact one) --- Package.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index 290bd25..4b60442 100644 --- a/Package.swift +++ b/Package.swift @@ -23,8 +23,8 @@ var package = Package( ], dependencies: [ .package( - url: "https://github.com/PureSwift/swift-system", - branch: "feature/dynamic-lib" + url: "https://github.com/apple/swift-system", + from: "1.2.1" ) ], targets: [ From 9945adfb7b2b089b1f9963db31544f604d260293 Mon Sep 17 00:00:00 2001 From: stackotter Date: Sat, 11 May 2024 22:48:00 +1000 Subject: [PATCH 2/3] Fix pointer related build warnings --- Sources/Socket/System/CInternetAddress.swift | 6 ++++-- Sources/Socket/System/SocketAddress/UnixSocketAddress.swift | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Sources/Socket/System/CInternetAddress.swift b/Sources/Socket/System/CInternetAddress.swift index 7792057..b0a60c4 100644 --- a/Sources/Socket/System/CInternetAddress.swift +++ b/Sources/Socket/System/CInternetAddress.swift @@ -18,8 +18,10 @@ internal extension CInternetAddress { /** inet_pton() returns 1 on success (network address was successfully converted). 0 is returned if src does not contain a character string representing a valid network address in the specified address family. If af does not contain a valid address family, -1 is returned and errno is set to EAFNOSUPPORT. */ - let result = string.withCString { - system_inet_pton(Self.family.rawValue, $0, &self) + let result = string.withCString { stringPointer in + withUnsafeMutablePointer(to: &self) { selfPointer in + system_inet_pton(Self.family.rawValue, stringPointer, selfPointer) + } } guard result == 1 else { assert(result != -1, "Invalid address family") diff --git a/Sources/Socket/System/SocketAddress/UnixSocketAddress.swift b/Sources/Socket/System/SocketAddress/UnixSocketAddress.swift index 98adf12..b026f0f 100644 --- a/Sources/Socket/System/SocketAddress/UnixSocketAddress.swift +++ b/Sources/Socket/System/SocketAddress/UnixSocketAddress.swift @@ -35,7 +35,7 @@ public struct UnixSocketAddress: SocketAddress, Equatable, Hashable { pathBytes .bindMemory(to: CInterop.PlatformChar.self) .baseAddress! - .assign(from: platformString, count: path.length + 1) + .update(from: platformString, count: path.length + 1) } return try socketAddress.withUnsafePointer(body) } From 916166402dcbe85fa83b8a55768aad8c72065fc8 Mon Sep 17 00:00:00 2001 From: Greg Cotten Date: Wed, 5 Mar 2025 16:38:16 -0800 Subject: [PATCH 3/3] defensively unify CSocket imports --- Sources/Socket/System/CInterop.swift | 1 + Sources/Socket/System/Constants.swift | 2 ++ Sources/Socket/System/Syscalls.swift | 1 + 3 files changed, 4 insertions(+) diff --git a/Sources/Socket/System/CInterop.swift b/Sources/Socket/System/CInterop.swift index 8597839..4387248 100644 --- a/Sources/Socket/System/CInterop.swift +++ b/Sources/Socket/System/CInterop.swift @@ -12,6 +12,7 @@ import Glibc import CSocket import Musl #elseif canImport(WASILibc) +import CSocket import WASILibc #elseif canImport(Bionic) import CSocket diff --git a/Sources/Socket/System/Constants.swift b/Sources/Socket/System/Constants.swift index 3656b9a..a0f3ab0 100644 --- a/Sources/Socket/System/Constants.swift +++ b/Sources/Socket/System/Constants.swift @@ -6,6 +6,7 @@ import Darwin import CSocket import ucrt #elseif canImport(Glibc) +import CSocket import Glibc #elseif canImport(Musl) import CSocket @@ -14,6 +15,7 @@ import Musl import CSocket import WASILibc #elseif canImport(Android) +import CSocket import Android #else #error("Unsupported Platform") diff --git a/Sources/Socket/System/Syscalls.swift b/Sources/Socket/System/Syscalls.swift index 50c973c..4639b98 100644 --- a/Sources/Socket/System/Syscalls.swift +++ b/Sources/Socket/System/Syscalls.swift @@ -12,6 +12,7 @@ import Glibc import CSocket import Musl #elseif canImport(WASILibc) +import CSocket import WASILibc #elseif canImport(Bionic) import CSocket