Skip to content

Commit 5b1b4ca

Browse files
loffgrenglessard
authored andcommitted
Remove allocatePortRightPair(), as move only types are not permitted in tuples
1 parent aabb8d0 commit 5b1b4ca

File tree

2 files changed

+0
-31
lines changed

2 files changed

+0
-31
lines changed

Sources/System/MachPort.swift

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -122,24 +122,6 @@ public enum Mach {
122122
/// receiving end.
123123
@frozen
124124
public struct SendOnceRight: MachPortRight {}
125-
126-
/// Create a connected pair of rights, one receive, and one send.
127-
///
128-
/// This function will abort if the rights could not be created.
129-
/// Callers may assert that valid rights are always returned.
130-
public static func allocatePortRightPair() ->
131-
(receive: Mach.Port<Mach.ReceiveRight>, send: Mach.Port<Mach.SendRight>) {
132-
var name = mach_port_name_t(MACH_PORT_NULL)
133-
let secret = mach_port_context_t(arc4random())
134-
withUnsafeMutablePointer(to: &name) { name in
135-
var options = mach_port_options_t()
136-
options.flags = UInt32(MPO_INSERT_SEND_RIGHT);
137-
withUnsafeMutablePointer(to: &options) { options in
138-
_machPrecondition(mach_port_construct(mach_task_self_, options, secret, name))
139-
}
140-
}
141-
return (Mach.Port(name: name, context: secret), Mach.Port(name: name))
142-
}
143125
}
144126

145127
extension Mach.Port where RightType == Mach.ReceiveRight {

Tests/SystemTests/MachPortTests.swift

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,19 +121,6 @@ final class MachPortTests: XCTestCase {
121121
}
122122
}
123123

124-
func testMakePair() throws {
125-
let (recv, send) = Mach.allocatePortRightPair()
126-
XCTAssert(recv.makeSendCount == 1)
127-
recv.withBorrowedName { rName in
128-
send.withBorrowedName { sName in
129-
XCTAssert(rName != 0xFFFFFFFF)
130-
XCTAssert(rName != MACH_PORT_NULL)
131-
// send and recv port names coalesce
132-
XCTAssert(rName == sName)
133-
}
134-
}
135-
}
136-
137124
func testCopySend() throws {
138125
let recv = Mach.Port<Mach.ReceiveRight>()
139126
let zero = recv.makeSendCount

0 commit comments

Comments
 (0)