Skip to content

Commit 12baba9

Browse files
committed
machPrecondition should have a leading underscore
1 parent a2bf0d5 commit 12baba9

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

Sources/System/MachPort.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import Darwin.Mach
1313

1414
public protocol MachPortRight {}
1515

16-
private func machPrecondition(
16+
private func _machPrecondition(
1717
file: StaticString = #file,
1818
line: UInt = #line,
1919
_ body: @autoclosure () -> kern_return_t
@@ -50,7 +50,7 @@ public enum Mach {
5050
precondition(name != 0xFFFFFFFF /* MACH_PORT_DEAD */, "Receive rights cannot be dead names")
5151

5252
let secret = mach_port_context_t(arc4random())
53-
machPrecondition(mach_port_guard(mach_task_self_, name, secret, 0))
53+
_machPrecondition(mach_port_guard(mach_task_self_, name, secret, 0))
5454
self.context = secret
5555
}
5656
else {
@@ -75,14 +75,14 @@ public enum Mach {
7575
deinit {
7676
if name == 0xFFFFFFFF /* MACH_PORT_DEAD */ {
7777
precondition(RightType.self != ReceiveRight.self, "Receive rights cannot be dead names")
78-
machPrecondition(mach_port_mod_refs(mach_task_self_, name, MACH_PORT_RIGHT_DEAD_NAME, -1))
78+
_machPrecondition(mach_port_mod_refs(mach_task_self_, name, MACH_PORT_RIGHT_DEAD_NAME, -1))
7979
} else {
8080
if RightType.self == ReceiveRight.self {
81-
machPrecondition(mach_port_destruct(mach_task_self_, name, -1, context))
81+
_machPrecondition(mach_port_destruct(mach_task_self_, name, -1, context))
8282
} else if RightType.self == SendRight.self {
83-
machPrecondition(mach_port_mod_refs(mach_task_self_, name, MACH_PORT_RIGHT_SEND, -1))
83+
_machPrecondition(mach_port_mod_refs(mach_task_self_, name, MACH_PORT_RIGHT_SEND, -1))
8484
} else if RightType.self == SendOnceRight.self {
85-
machPrecondition(mach_port_mod_refs(mach_task_self_, name, MACH_PORT_RIGHT_SEND_ONCE, -1))
85+
_machPrecondition(mach_port_mod_refs(mach_task_self_, name, MACH_PORT_RIGHT_SEND_ONCE, -1))
8686
}
8787
}
8888
}
@@ -122,7 +122,7 @@ public enum Mach {
122122
var options = mach_port_options_t()
123123
options.flags = UInt32(MPO_INSERT_SEND_RIGHT);
124124
withUnsafeMutablePointer(to: &options) { options in
125-
machPrecondition(mach_port_construct(mach_task_self_, options, secret, name))
125+
_machPrecondition(mach_port_construct(mach_task_self_, options, secret, name))
126126
}
127127
}
128128
return (Mach.Port(name: name, context: secret), Mach.Port(name: name))
@@ -153,7 +153,7 @@ public extension Mach.Port where RightType == Mach.ReceiveRight {
153153
init() {
154154
var storage: mach_port_name_t = mach_port_name_t(MACH_PORT_NULL)
155155
withUnsafeMutablePointer(to: &storage) { storage in
156-
machPrecondition(mach_port_allocate(mach_task_self_, MACH_PORT_RIGHT_RECEIVE, storage))
156+
_machPrecondition(mach_port_allocate(mach_task_self_, MACH_PORT_RIGHT_RECEIVE, storage))
157157
}
158158

159159
// name-only init will guard ReceiveRights
@@ -190,7 +190,7 @@ public extension Mach.Port where RightType == Mach.ReceiveRight {
190190
/// Mach.ReceiveRights. Use relinquish() to avoid the syscall and extract
191191
/// the context value along with the port name.
192192
__consuming func unguardAndRelinquish() -> mach_port_name_t {
193-
machPrecondition(mach_port_unguard(mach_task_self_, name, context))
193+
_machPrecondition(mach_port_unguard(mach_task_self_, name, context))
194194
return name
195195
}
196196

@@ -220,7 +220,7 @@ public extension Mach.Port where RightType == Mach.ReceiveRight {
220220

221221
withUnsafeMutablePointer(to: &newRight) { newRight in
222222
withUnsafeMutablePointer(to: &newRightType) { newRightType in
223-
machPrecondition(
223+
_machPrecondition(
224224
mach_port_extract_right(mach_task_self_,
225225
name,
226226
mach_msg_type_name_t(MACH_MSG_TYPE_MAKE_SEND_ONCE),
@@ -246,7 +246,7 @@ public extension Mach.Port where RightType == Mach.ReceiveRight {
246246
let how = MACH_MSG_TYPE_MAKE_SEND
247247

248248
// name is the same because send and recv rights are coalesced
249-
machPrecondition(mach_port_insert_right(mach_task_self_, name, name, mach_msg_type_name_t(how)))
249+
_machPrecondition(mach_port_insert_right(mach_task_self_, name, name, mach_msg_type_name_t(how)))
250250

251251
return Mach.Port(name: name)
252252
}
@@ -261,14 +261,14 @@ public extension Mach.Port where RightType == Mach.ReceiveRight {
261261
withUnsafeMutablePointer(to: &size) { size in
262262
withUnsafeMutablePointer(to: &status) { status in
263263
let info = UnsafeMutableRawPointer(status).bindMemory(to: integer_t.self, capacity: 1)
264-
machPrecondition(mach_port_get_attributes(mach_task_self_, name, MACH_PORT_RECEIVE_STATUS, info, size))
264+
_machPrecondition(mach_port_get_attributes(mach_task_self_, name, MACH_PORT_RECEIVE_STATUS, info, size))
265265
}
266266
}
267267
return status.mps_mscount
268268
}
269269

270270
set {
271-
machPrecondition(mach_port_set_mscount(mach_task_self_, name, newValue))
271+
_machPrecondition(mach_port_set_mscount(mach_task_self_, name, newValue))
272272
}
273273
}
274274
}
@@ -302,7 +302,7 @@ public extension Mach.Port where RightType == Mach.SendRight {
302302
if kr == KERN_INVALID_CAPABILITY {
303303
throw Mach.PortRightError.deadName
304304
}
305-
machPrecondition(kr)
305+
_machPrecondition(kr)
306306

307307
return Mach.Port(name: name)
308308
}

0 commit comments

Comments
 (0)