From 1a7de25f8b56d956b9cc8f7e9d8b83209248b53a Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Thu, 26 Nov 2026 15:54:11 -0500 Subject: [PATCH 01/15] Updated package manifest for Swift 6.4 --- Package.swift | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Package.swift b/Package.swift index fecceae..56d73ab 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.5 +// swift-tools-version:6.4 import PackageDescription import class Foundation.ProcessInfo @@ -9,10 +9,10 @@ let libraryType: PackageDescription.Product.Library.LibraryType? = dynamicLibrar var package = Package( name: "Netlink", platforms: [ - .macOS(.v10_15), - .iOS(.v13), - .watchOS(.v6), - .tvOS(.v13), + .macOS(.v13), + .iOS(.v16), + .watchOS(.v9), + .tvOS(.v16), ], products: [ .library( @@ -85,12 +85,10 @@ var package = Package( ] ) -// SwiftPM command plugins are only supported by Swift version 5.6 and later. -#if swift(>=5.6) +// Documentation generation let buildDocs = ProcessInfo.processInfo.environment["BUILDING_FOR_DOCUMENTATION_GENERATION"] != nil if buildDocs { package.dependencies += [ .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"), ] } -#endif From ab0b030b152a1a4b27dd71b3f0b797189c698b97 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Thu, 26 Nov 2026 15:54:11 -0500 Subject: [PATCH 02/15] Updated socket options for typed throws --- Sources/Netlink/SocketOption.swift | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Sources/Netlink/SocketOption.swift b/Sources/Netlink/SocketOption.swift index f23dc8c..a8d1995 100644 --- a/Sources/Netlink/SocketOption.swift +++ b/Sources/Netlink/SocketOption.swift @@ -39,47 +39,47 @@ public extension NetlinkSocketOption { public extension NetlinkSocketOption { struct AddMembership: SocketOption { - + @_alwaysEmitIntoClient public static var id: NetlinkSocketOption { .addMembership } - + public var group: CInt - + public init(group: CInt) { self.group = group } - - public func withUnsafeBytes(_ pointer: ((UnsafeRawBufferPointer) throws -> (Result))) rethrows -> Result { + + public func withUnsafeBytes(_ pointer: ((UnsafeRawBufferPointer) throws(Error) -> (Result))) rethrows -> Result where Error: Swift.Error { return try Swift.withUnsafeBytes(of: group) { bufferPointer in try pointer(bufferPointer) } } - - public static func withUnsafeBytes(_ body: (UnsafeMutableRawBufferPointer) throws -> ()) rethrows -> Self { + + public static func withUnsafeBytes(_ body: (UnsafeMutableRawBufferPointer) throws(Error) -> ()) rethrows -> Self where Error: Swift.Error { var value: CInt = 0 try Swift.withUnsafeMutableBytes(of: &value, body) return self.init(group: value) } } - + struct DropMembership: SocketOption { - + @_alwaysEmitIntoClient public static var id: NetlinkSocketOption { .dropMembership } - + public var group: CInt - + public init(group: CInt) { self.group = group } - - public func withUnsafeBytes(_ pointer: ((UnsafeRawBufferPointer) throws -> (Result))) rethrows -> Result { + + public func withUnsafeBytes(_ pointer: ((UnsafeRawBufferPointer) throws(Error) -> (Result))) rethrows -> Result where Error: Swift.Error { return try Swift.withUnsafeBytes(of: group) { bufferPointer in try pointer(bufferPointer) } } - - public static func withUnsafeBytes(_ body: (UnsafeMutableRawBufferPointer) throws -> ()) rethrows -> Self { + + public static func withUnsafeBytes(_ body: (UnsafeMutableRawBufferPointer) throws(Error) -> ()) rethrows -> Self where Error: Swift.Error { var value: CInt = 0 try Swift.withUnsafeMutableBytes(of: &value, body) return self.init(group: value) From 6b6d83db71d62935ce8a049f75d3579ccc4da250 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Thu, 26 Nov 2026 15:54:11 -0500 Subject: [PATCH 03/15] Updated socket address for typed throws and Sendable --- Sources/Netlink/SocketAddress.swift | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Sources/Netlink/SocketAddress.swift b/Sources/Netlink/SocketAddress.swift index d8c4de8..a2dc3c1 100644 --- a/Sources/Netlink/SocketAddress.swift +++ b/Sources/Netlink/SocketAddress.swift @@ -10,7 +10,7 @@ import SystemPackage import Socket @frozen -public struct NetlinkSocketAddress: Equatable, Hashable, SocketAddress { +public struct NetlinkSocketAddress: Equatable, Hashable, Sendable, SocketAddress { public typealias ProtocolID = NetlinkSocketProtocol @@ -33,17 +33,17 @@ public struct NetlinkSocketAddress: Equatable, Hashable, SocketAddress { ) } - public func withUnsafePointer( - _ body: (UnsafePointer, UInt32) throws -> Result - ) rethrows -> Result { - + public func withUnsafePointer( + _ body: (UnsafePointer, CInterop.SocketLength) throws(Error) -> Result + ) rethrows -> Result where Error: Swift.Error { + let socketAddress = CInterop.NetlinkSocketAddress( processID: processID, group: group ) return try socketAddress.withUnsafePointer(body) } - + public static func withUnsafePointer( _ pointer: UnsafeMutablePointer ) -> Self { @@ -51,9 +51,9 @@ public struct NetlinkSocketAddress: Equatable, Hashable, SocketAddress { return Self.init(pointer.pointee) } } - + public static func withUnsafePointer( - _ body: (UnsafeMutablePointer, UInt32) throws -> () + _ body: (UnsafeMutablePointer, CInterop.SocketLength) throws -> () ) rethrows -> Self { var socketAddress = CInterop.NetlinkSocketAddress() try socketAddress.withUnsafeMutablePointer(body) From 9f937eefb06090cfe78e19e759063b3309c2d679 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Thu, 26 Nov 2026 15:54:11 -0500 Subject: [PATCH 04/15] Added Sendable conformance to NetlinkSocketProtocol --- Sources/Netlink/SocketProtocol.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Netlink/SocketProtocol.swift b/Sources/Netlink/SocketProtocol.swift index 707040a..99dfe7b 100644 --- a/Sources/Netlink/SocketProtocol.swift +++ b/Sources/Netlink/SocketProtocol.swift @@ -12,7 +12,7 @@ import Socket /// Netlink Socket Protocol @frozen -public struct NetlinkSocketProtocol: RawRepresentable, Equatable, Hashable { +public struct NetlinkSocketProtocol: RawRepresentable, Equatable, Hashable, Sendable { public let rawValue: Int32 From 6f5ded7db2fb9bee1c6221e6e76eed00cd88fbb5 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Thu, 26 Nov 2026 15:54:11 -0500 Subject: [PATCH 05/15] Added Sendable conformance to ProcessID --- Sources/Netlink/ProcessID.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Netlink/ProcessID.swift b/Sources/Netlink/ProcessID.swift index b924157..4b8f1ca 100644 --- a/Sources/Netlink/ProcessID.swift +++ b/Sources/Netlink/ProcessID.swift @@ -10,7 +10,7 @@ import SystemPackage /// POSIX Process ID @frozen -public struct ProcessID: RawRepresentable, Equatable, Hashable, Codable { +public struct ProcessID: RawRepresentable, Equatable, Hashable, Codable, Sendable { /// The raw C process ID. @_alwaysEmitIntoClient From 3145dcdab9c3e46c2d3cc1b1d7b1ef3523efa566 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Thu, 26 Nov 2026 15:54:17 -0500 Subject: [PATCH 06/15] Updated NetlinkSocket for typed throws --- Sources/Netlink/Socket.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/Netlink/Socket.swift b/Sources/Netlink/Socket.swift index 68ad1b9..e09c08d 100644 --- a/Sources/Netlink/Socket.swift +++ b/Sources/Netlink/Socket.swift @@ -21,6 +21,7 @@ public final class NetlinkSocket { // MARK: - Initialization deinit { + let socket = self.socket Task(priority: .high) { await socket.close() } @@ -38,7 +39,7 @@ public final class NetlinkSocket { processID: .current, group: group ) - try fileDescriptor.closeIfThrows { + try fileDescriptor.closeIfThrows { () throws(Errno) in try fileDescriptor.bind(address) } // initialize socket From a10669e9239c4c80807a7c86161841c24e48d674 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Thu, 26 Nov 2026 15:54:17 -0500 Subject: [PATCH 07/15] Added Sendable conformance to NetlinkAttributeType --- Sources/Netlink/AttributeType.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Netlink/AttributeType.swift b/Sources/Netlink/AttributeType.swift index eb56fdc..309e541 100644 --- a/Sources/Netlink/AttributeType.swift +++ b/Sources/Netlink/AttributeType.swift @@ -8,7 +8,7 @@ @_implementationOnly import CNetlink /// Netlink Attribute Type -public struct NetlinkAttributeType: RawRepresentable, Equatable, Hashable, OptionSet { +public struct NetlinkAttributeType: RawRepresentable, Equatable, Hashable, OptionSet, Sendable { public let rawValue: UInt16 From 102e50d541d7e44d660a59bb09e8f5180eaa1f4c Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Thu, 26 Nov 2026 15:54:17 -0500 Subject: [PATCH 08/15] Removed usableFromInline from internal CSocketAddress --- Sources/Netlink/Internal/CSocketAddress.swift | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Sources/Netlink/Internal/CSocketAddress.swift b/Sources/Netlink/Internal/CSocketAddress.swift index 73f3a00..33813a1 100644 --- a/Sources/Netlink/Internal/CSocketAddress.swift +++ b/Sources/Netlink/Internal/CSocketAddress.swift @@ -8,15 +8,13 @@ import SystemPackage import Socket -@usableFromInline internal protocol CSocketAddress { - + static var family: SocketAddressFamily { get } } internal extension CSocketAddress { - - @usableFromInline + func withUnsafePointer( _ body: (UnsafePointer, UInt32) throws -> Result ) rethrows -> Result { @@ -25,7 +23,6 @@ internal extension CSocketAddress { } } - @usableFromInline mutating func withUnsafeMutablePointer( _ body: (UnsafeMutablePointer, UInt32) throws -> Result ) rethrows -> Result { From 5b774d956e33e5d71489321cea3a41ede90e3e7e Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Thu, 26 Nov 2026 15:54:17 -0500 Subject: [PATCH 09/15] Fixed implementation-only import of CNetlink --- Sources/Netlink/Internal/CInterop.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sources/Netlink/Internal/CInterop.swift b/Sources/Netlink/Internal/CInterop.swift index 9f9a22c..30393d4 100644 --- a/Sources/Netlink/Internal/CInterop.swift +++ b/Sources/Netlink/Internal/CInterop.swift @@ -54,8 +54,7 @@ internal extension CInterop.NetlinkSocketAddress { } extension CInterop.NetlinkSocketAddress: CSocketAddress { - - @usableFromInline + static var family: SocketAddressFamily { .netlink } } From ffd9dbe67605a5d3c0dd22275403f068cb591c26 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Thu, 26 Nov 2026 15:54:17 -0500 Subject: [PATCH 10/15] Added Sendable conformance to NetlinkGenericCommand --- Sources/NetlinkGeneric/GenericCommand.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/NetlinkGeneric/GenericCommand.swift b/Sources/NetlinkGeneric/GenericCommand.swift index c2bb607..3cc0578 100644 --- a/Sources/NetlinkGeneric/GenericCommand.swift +++ b/Sources/NetlinkGeneric/GenericCommand.swift @@ -7,7 +7,7 @@ @_implementationOnly import CNetlink -public struct NetlinkGenericCommand: RawRepresentable, Equatable, Hashable { +public struct NetlinkGenericCommand: RawRepresentable, Equatable, Hashable, Sendable { public let rawValue: UInt8 From 7cad0f034b4b9f0eeab793b18a0267c18deeb80e Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Thu, 26 Nov 2026 15:54:17 -0500 Subject: [PATCH 11/15] Added Sendable conformance to NetlinkGenericMulticastGroupName --- Sources/NetlinkGeneric/GenericGroupName.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/NetlinkGeneric/GenericGroupName.swift b/Sources/NetlinkGeneric/GenericGroupName.swift index 01e50c4..e4d4b15 100644 --- a/Sources/NetlinkGeneric/GenericGroupName.swift +++ b/Sources/NetlinkGeneric/GenericGroupName.swift @@ -5,7 +5,7 @@ // Created by Alsey Coleman Miller on 7/7/18. // -public struct NetlinkGenericMulticastGroupName: RawRepresentable, Equatable, Hashable, Codable { +public struct NetlinkGenericMulticastGroupName: RawRepresentable, Equatable, Hashable, Codable, Sendable { public let rawValue: String From 16efb80533d861096735131d39a3fc557d73a502 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Thu, 26 Nov 2026 15:54:17 -0500 Subject: [PATCH 12/15] Added Sendable conformance to NetlinkGenericVersion --- Sources/NetlinkGeneric/GenericVersion.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/NetlinkGeneric/GenericVersion.swift b/Sources/NetlinkGeneric/GenericVersion.swift index 6bb5c22..36facf2 100644 --- a/Sources/NetlinkGeneric/GenericVersion.swift +++ b/Sources/NetlinkGeneric/GenericVersion.swift @@ -6,7 +6,7 @@ // // -public struct NetlinkGenericVersion: RawRepresentable { +public struct NetlinkGenericVersion: RawRepresentable, Sendable { public let rawValue: UInt8 From 30e31366ec8017389d5824544a00ca0332622ba4 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Thu, 26 Nov 2026 15:54:17 -0500 Subject: [PATCH 13/15] Updated CI to Swift 6.4 --- .github/workflows/swift.yml | 42 +++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 07aa121..a5ee7e5 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -1,17 +1,25 @@ name: Swift -on: [push] + +on: + push: + branches: [master] + pull_request: + jobs: macos: name: macOS - runs-on: macos-latest + runs-on: macos-26 steps: - - name: Install Swift - uses: slashmo/install-swift@v0.3.0 - with: - version: 5.7.3 - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 + # Xcode provides the macOS SDK; the Swift 6.4 toolchain comes from swift.org. + - uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: latest-stable + - uses: SwiftyLab/setup-swift@latest + with: + swift-version: "6.4.2" - name: Swift Version run: swift --version - name: Build (Debug) @@ -20,20 +28,22 @@ jobs: run: swift build -c release - name: Test (Debug) run: swift test -c debug - + linux: - name: Linux + name: Linux (${{ matrix.arch }}) strategy: + fail-fast: false matrix: - swift: [5.7.3] - runs-on: ubuntu-20.04 + include: + - arch: x86_64 + runner: ubuntu-latest + - arch: arm64 + runner: ubuntu-24.04-arm + runs-on: ${{ matrix.runner }} + container: swift:6.4-noble steps: - - name: Install Swift - uses: slashmo/install-swift@v0.3.0 - with: - version: ${{ matrix.swift }} - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Swift Version run: swift --version - name: Build (Debug) From 406f31d4f3da3c752ddf8178e51246e3fff42720 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Thu, 26 Nov 2026 15:54:17 -0500 Subject: [PATCH 14/15] Updated ARM CI action versions --- .github/workflows/swift-arm.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/swift-arm.yml b/.github/workflows/swift-arm.yml index de3f377..c1ece26 100644 --- a/.github/workflows/swift-arm.yml +++ b/.github/workflows/swift-arm.yml @@ -8,7 +8,7 @@ jobs: container: colemancda/swift-armv7:latest-prebuilt steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Swift Version run: swift --version - name: Build (Release) @@ -18,7 +18,7 @@ jobs: export SWIFT_PACKAGE_BUILDDIR=$SWIFT_PACKAGE_SRCDIR/.build $SRC_ROOT/build-swift-package.sh - name: Archive Build artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: linux-armv7-crosscompile-test path: .build/*/*.xctest From a7702a1e814257200d9d802bd4bc2bb0be245b30 Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Thu, 26 Nov 2026 16:00:31 -0500 Subject: [PATCH 15/15] Crosscompile Armv7 with armhf SDK --- .github/workflows/swift-arm.yml | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/.github/workflows/swift-arm.yml b/.github/workflows/swift-arm.yml index c1ece26..85235e1 100644 --- a/.github/workflows/swift-arm.yml +++ b/.github/workflows/swift-arm.yml @@ -1,24 +1,35 @@ name: Swift ARM -on: [push] + +on: + push: + branches: [master] + pull_request: + jobs: linux-armv7-crosscompile-build: name: Crosscompile for Linux Armv7 runs-on: ubuntu-latest - container: colemancda/swift-armv7:latest-prebuilt steps: - name: Checkout uses: actions/checkout@v4 + # The SDK must match the host Swift toolchain version exactly. + - uses: SwiftyLab/setup-swift@latest + with: + swift-version: "6.4.2" + - name: Install armhf SDK + uses: swift-embedded-linux/armhf-action@main + id: armhf-sdk + with: + swift-version: 6.4.2 + distribution: debian-bookworm + arch: armv7 - name: Swift Version run: swift --version - name: Build (Release) - run: | - cd $SRC_ROOT - export SWIFT_PACKAGE_SRCDIR=$GITHUB_WORKSPACE - export SWIFT_PACKAGE_BUILDDIR=$SWIFT_PACKAGE_SRCDIR/.build - $SRC_ROOT/build-swift-package.sh + run: swift build -c release --build-system native --destination ${{ steps.armhf-sdk.outputs.destination_json }} - name: Archive Build artifacts uses: actions/upload-artifact@v4 with: - name: linux-armv7-crosscompile-test - path: .build/*/*.xctest + name: linux-armv7-crosscompile-build + path: .build/armv7-unknown-linux-gnueabihf/release/