Skip to content

Commit 1cbb2cb

Browse files
authored
Merge pull request #127 from loffgren/no-tuple-api
2 parents aabb8d0 + 7bcc01f commit 1cbb2cb

File tree

2 files changed

+9
-35
lines changed

2 files changed

+9
-35
lines changed

Sources/System/MachPort.swift

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
See https://swift.org/LICENSE.txt for license information
88
*/
99

10-
#if swift(>=5.8) && $MoveOnly && (os(macOS) || os(iOS) || os(watchOS) || os(tvOS))
10+
#if false && swift(>=5.8) && $MoveOnly && (os(macOS) || os(iOS) || os(watchOS) || os(tvOS))
1111

1212
import Darwin.Mach
1313

@@ -27,8 +27,7 @@ internal func _machPrecondition(
2727
@available(/*System 1.3.0: macOS 9999, iOS 9999, watchOS 9999, tvOS 9999*/iOS 8, *)
2828
@frozen
2929
public enum Mach {
30-
@_moveOnly
31-
public struct Port<RightType: MachPortRight> {
30+
public struct Port<RightType: MachPortRight>: ~Copyable {
3231
@usableFromInline
3332
internal var _name: mach_port_name_t
3433

@@ -122,24 +121,6 @@ public enum Mach {
122121
/// receiving end.
123122
@frozen
124123
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-
}
143124
}
144125

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

Tests/SystemTests/MachPortTests.swift

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@
77
See https://swift.org/LICENSE.txt for license information
88
*/
99

10-
#if swift(>=5.8) && $MoveOnly && (os(macOS) || os(iOS) || os(watchOS) || os(tvOS))
10+
#if false && swift(>=5.8) && $MoveOnly && (os(macOS) || os(iOS) || os(watchOS) || os(tvOS))
1111

1212
import XCTest
1313
import Darwin.Mach
1414

15+
#if SYSTEM_PACKAGE
16+
import SystemPackage
17+
#else
18+
import System
19+
#endif
20+
1521
final class MachPortTests: XCTestCase {
1622
func refCountForMachPortName(name:mach_port_name_t, kind:mach_port_right_t) -> mach_port_urefs_t {
1723
var refCount:mach_port_urefs_t = 0
@@ -121,19 +127,6 @@ final class MachPortTests: XCTestCase {
121127
}
122128
}
123129

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-
137130
func testCopySend() throws {
138131
let recv = Mach.Port<Mach.ReceiveRight>()
139132
let zero = recv.makeSendCount

0 commit comments

Comments
 (0)