diff --git a/Sources/System/MachPort.swift b/Sources/System/MachPort.swift index 5615b31..04d2cc5 100644 --- a/Sources/System/MachPort.swift +++ b/Sources/System/MachPort.swift @@ -7,7 +7,7 @@ See https://swift.org/LICENSE.txt for license information */ -#if swift(>=5.8) && $MoveOnly && (os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) +#if false && swift(>=5.8) && $MoveOnly && (os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) import Darwin.Mach @@ -27,8 +27,7 @@ internal func _machPrecondition( @available(/*System 1.3.0: macOS 9999, iOS 9999, watchOS 9999, tvOS 9999*/iOS 8, *) @frozen public enum Mach { - @_moveOnly - public struct Port { + public struct Port: ~Copyable { @usableFromInline internal var _name: mach_port_name_t @@ -122,24 +121,6 @@ public enum Mach { /// receiving end. @frozen public struct SendOnceRight: MachPortRight {} - - /// Create a connected pair of rights, one receive, and one send. - /// - /// This function will abort if the rights could not be created. - /// Callers may assert that valid rights are always returned. - public static func allocatePortRightPair() -> - (receive: Mach.Port, send: Mach.Port) { - var name = mach_port_name_t(MACH_PORT_NULL) - let secret = mach_port_context_t(arc4random()) - withUnsafeMutablePointer(to: &name) { name in - var options = mach_port_options_t() - options.flags = UInt32(MPO_INSERT_SEND_RIGHT); - withUnsafeMutablePointer(to: &options) { options in - _machPrecondition(mach_port_construct(mach_task_self_, options, secret, name)) - } - } - return (Mach.Port(name: name, context: secret), Mach.Port(name: name)) - } } extension Mach.Port where RightType == Mach.ReceiveRight { diff --git a/Tests/SystemTests/MachPortTests.swift b/Tests/SystemTests/MachPortTests.swift index 5c119d1..31a654c 100644 --- a/Tests/SystemTests/MachPortTests.swift +++ b/Tests/SystemTests/MachPortTests.swift @@ -7,11 +7,17 @@ See https://swift.org/LICENSE.txt for license information */ -#if swift(>=5.8) && $MoveOnly && (os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) +#if false && swift(>=5.8) && $MoveOnly && (os(macOS) || os(iOS) || os(watchOS) || os(tvOS)) import XCTest import Darwin.Mach +#if SYSTEM_PACKAGE +import SystemPackage +#else +import System +#endif + final class MachPortTests: XCTestCase { func refCountForMachPortName(name:mach_port_name_t, kind:mach_port_right_t) -> mach_port_urefs_t { var refCount:mach_port_urefs_t = 0 @@ -121,19 +127,6 @@ final class MachPortTests: XCTestCase { } } - func testMakePair() throws { - let (recv, send) = Mach.allocatePortRightPair() - XCTAssert(recv.makeSendCount == 1) - recv.withBorrowedName { rName in - send.withBorrowedName { sName in - XCTAssert(rName != 0xFFFFFFFF) - XCTAssert(rName != MACH_PORT_NULL) - // send and recv port names coalesce - XCTAssert(rName == sName) - } - } - } - func testCopySend() throws { let recv = Mach.Port() let zero = recv.makeSendCount