Skip to content

Commit 42588f5

Browse files
committed
Replace uses of @_silgen_name with uses of a shims header.
The header is in the main Swift repo because it's shared with the Darwin Dispatch overlay. No intended functionality change.
1 parent d36aebc commit 42588f5

File tree

5 files changed

+23
-93
lines changed

5 files changed

+23
-93
lines changed

src/swift/Block.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import CDispatch
14+
import _SwiftDispatchOverlayShims
1415

1516
public struct DispatchWorkItemFlags : OptionSet, RawRepresentable {
1617
public let rawValue: UInt
@@ -98,6 +99,3 @@ public class DispatchWorkItem {
9899
/// on the referential identity of a block. Particularly, dispatch_block_create.
99100
internal typealias _DispatchBlock = @convention(block) () -> Void
100101
internal typealias dispatch_block_t = @convention(block) () -> Void
101-
102-
@_silgen_name("_swift_dispatch_block_create_noescape")
103-
internal func _swift_dispatch_block_create_noescape(_ flags: dispatch_block_flags_t, _ block: () -> ()) -> _DispatchBlock

src/swift/Data.swift

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import CDispatch
14+
import _SwiftDispatchOverlayShims
1415

1516
public struct DispatchData : RandomAccessCollection {
1617
public typealias Iterator = DispatchDataIterator
@@ -37,8 +38,8 @@ public struct DispatchData : RandomAccessCollection {
3738

3839
fileprivate var _deallocator: (DispatchQueue?, @convention(block) () -> Void) {
3940
switch self {
40-
case .free: return (nil, _dispatch_data_destructor_free())
41-
case .unmap: return (nil, _dispatch_data_destructor_munmap())
41+
case .free: return (nil, _swift_dispatch_data_destructor_free())
42+
case .unmap: return (nil, _swift_dispatch_data_destructor_munmap())
4243
case .custom(let q, let b): return (q, b)
4344
}
4445
}
@@ -53,7 +54,7 @@ public struct DispatchData : RandomAccessCollection {
5354
public init(bytes buffer: UnsafeBufferPointer<UInt8>) {
5455
let d = buffer.baseAddress == nil ? _swift_dispatch_data_empty()
5556
: dispatch_data_create(buffer.baseAddress!, buffer.count, nil,
56-
_dispatch_data_destructor_default())
57+
_swift_dispatch_data_destructor_default())
5758
self.init(data: d)
5859
}
5960

@@ -64,7 +65,7 @@ public struct DispatchData : RandomAccessCollection {
6465
public init(bytes buffer: UnsafeRawBufferPointer) {
6566
let d = buffer.baseAddress == nil ? _swift_dispatch_data_empty()
6667
: dispatch_data_create(buffer.baseAddress!, buffer.count, nil,
67-
_dispatch_data_destructor_default())
68+
_swift_dispatch_data_destructor_default())
6869
self.init(data: d)
6970
}
7071

@@ -140,7 +141,7 @@ public struct DispatchData : RandomAccessCollection {
140141
/// - parameter count: The number of bytes to copy.
141142
@available(swift, deprecated: 4, message: "Use append(_: UnsafeRawBufferPointer) instead")
142143
public mutating func append(_ bytes: UnsafePointer<UInt8>, count: Int) {
143-
let data = dispatch_data_create(bytes, count, nil, _dispatch_data_destructor_default())
144+
let data = dispatch_data_create(bytes, count, nil, _swift_dispatch_data_destructor_default())
144145
self.append(DispatchData(data: data))
145146
}
146147

@@ -151,7 +152,7 @@ public struct DispatchData : RandomAccessCollection {
151152
public mutating func append(_ bytes: UnsafeRawBufferPointer) {
152153
// Nil base address does nothing.
153154
guard bytes.baseAddress != nil else { return }
154-
let data = dispatch_data_create(bytes.baseAddress!, bytes.count, nil, _dispatch_data_destructor_default())
155+
let data = dispatch_data_create(bytes.baseAddress!, bytes.count, nil, _swift_dispatch_data_destructor_default())
155156
self.append(DispatchData(data: data))
156157
}
157158

@@ -346,15 +347,3 @@ public struct DispatchDataIterator : IteratorProtocol, Sequence {
346347
internal var _count: Int
347348
internal var _position: DispatchData.Index
348349
}
349-
350-
@_silgen_name("_swift_dispatch_data_empty")
351-
internal func _swift_dispatch_data_empty() -> dispatch_data_t
352-
353-
@_silgen_name("_swift_dispatch_data_destructor_free")
354-
internal func _dispatch_data_destructor_free() -> _DispatchBlock
355-
356-
@_silgen_name("_swift_dispatch_data_destructor_munmap")
357-
internal func _dispatch_data_destructor_munmap() -> _DispatchBlock
358-
359-
@_silgen_name("_swift_dispatch_data_destructor_default")
360-
internal func _dispatch_data_destructor_default() -> _DispatchBlock

src/swift/Queue.swift

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// dispatch/queue.h
1414

1515
import CDispatch
16+
import _SwiftDispatchOverlayShims
1617

1718
public final class DispatchSpecificKey<T> {
1819
public init() {}
@@ -334,9 +335,6 @@ public extension DispatchQueue {
334335
}
335336

336337
#if os(Android)
337-
@_silgen_name("_dispatch_install_thread_detach_callback")
338-
private static func _dispatch_install_thread_detach_callback(_ cb: @escaping @convention(c) () -> Void)
339-
340338
public static func setThreadDetachCallback(_ cb: @escaping @convention(c) () -> Void) {
341339
_dispatch_install_thread_detach_callback(cb)
342340
}
@@ -348,12 +346,3 @@ private func _destructDispatchSpecificValue(ptr: UnsafeMutableRawPointer?) {
348346
Unmanaged<AnyObject>.fromOpaque(p).release()
349347
}
350348
}
351-
352-
@_silgen_name("_swift_dispatch_queue_concurrent")
353-
internal func _swift_dispatch_queue_concurrent() -> dispatch_queue_attr_t
354-
355-
@_silgen_name("_swift_dispatch_get_main_queue")
356-
internal func _swift_dispatch_get_main_queue() -> dispatch_queue_t
357-
358-
@_silgen_name("_swift_dispatch_apply_current")
359-
internal func _swift_dispatch_apply_current(_ iterations: Int, _ block: @convention(block) (Int) -> Void)

src/swift/Source.swift

Lines changed: 13 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import CDispatch
14+
import _SwiftDispatchOverlayShims
1415

1516
public extension DispatchSourceProtocol {
1617

@@ -151,71 +152,71 @@ public extension DispatchSource {
151152

152153
#if HAVE_MACH
153154
public class func makeMachSendSource(port: mach_port_t, eventMask: MachSendEvent, queue: DispatchQueue? = nil) -> DispatchSourceMachSend {
154-
let source = dispatch_source_create(_swift_dispatch_source_type_mach_send(), UInt(port), eventMask.rawValue, queue?.__wrapped)
155+
let source = dispatch_source_create(_swift_dispatch_source_type_MACH_SEND(), UInt(port), eventMask.rawValue, queue?.__wrapped)
155156
return DispatchSource(source: source) as DispatchSourceMachSend
156157
}
157158
#endif
158159

159160
#if HAVE_MACH
160161
public class func makeMachReceiveSource(port: mach_port_t, queue: DispatchQueue? = nil) -> DispatchSourceMachReceive {
161-
let source = dispatch_source_create(_swift_dispatch_source_type_mach_recv(), UInt(port), 0, queue?.__wrapped)
162+
let source = dispatch_source_create(_swift_dispatch_source_type_MACH_RECV(), UInt(port), 0, queue?.__wrapped)
162163
return DispatchSource(source) as DispatchSourceMachReceive
163164
}
164165
#endif
165166

166167
#if HAVE_MACH
167168
public class func makeMemoryPressureSource(eventMask: MemoryPressureEvent, queue: DispatchQueue? = nil) -> DispatchSourceMemoryPressure {
168-
let source = dispatch_source_create(_swift_dispatch_source_type_memorypressure(), 0, eventMask.rawValue, queue.__wrapped)
169+
let source = dispatch_source_create(_swift_dispatch_source_type_MEMORYPRESSURE(), 0, eventMask.rawValue, queue.__wrapped)
169170
return DispatchSourceMemoryPressure(source)
170171
}
171172
#endif
172173

173174
#if !os(Linux) && !os(Android)
174175
public class func makeProcessSource(identifier: pid_t, eventMask: ProcessEvent, queue: DispatchQueue? = nil) -> DispatchSourceProcess {
175-
let source = dispatch_source_create(_swift_dispatch_source_type_proc(), UInt(identifier), eventMask.rawValue, queue?.__wrapped)
176+
let source = dispatch_source_create(_swift_dispatch_source_type_PROC(), UInt(identifier), eventMask.rawValue, queue?.__wrapped)
176177
return DispatchSource(source: source) as DispatchSourceProcess
177178
}
178179
#endif
179180

180181
public class func makeReadSource(fileDescriptor: Int32, queue: DispatchQueue? = nil) -> DispatchSourceRead {
181-
let source = dispatch_source_create(_swift_dispatch_source_type_read(), UInt(fileDescriptor), 0, queue?.__wrapped)
182+
let source = dispatch_source_create(_swift_dispatch_source_type_READ(), UInt(fileDescriptor), 0, queue?.__wrapped)
182183
return DispatchSource(source: source) as DispatchSourceRead
183184
}
184185

185186
public class func makeSignalSource(signal: Int32, queue: DispatchQueue? = nil) -> DispatchSourceSignal {
186-
let source = dispatch_source_create(_swift_dispatch_source_type_signal(), UInt(signal), 0, queue?.__wrapped)
187+
let source = dispatch_source_create(_swift_dispatch_source_type_SIGNAL(), UInt(signal), 0, queue?.__wrapped)
187188
return DispatchSource(source: source) as DispatchSourceSignal
188189
}
189190

190191
public class func makeTimerSource(flags: TimerFlags = [], queue: DispatchQueue? = nil) -> DispatchSourceTimer {
191-
let source = dispatch_source_create(_swift_dispatch_source_type_timer(), 0, flags.rawValue, queue?.__wrapped)
192+
let source = dispatch_source_create(_swift_dispatch_source_type_TIMER(), 0, flags.rawValue, queue?.__wrapped)
192193
return DispatchSource(source: source) as DispatchSourceTimer
193194
}
194195

195196
public class func makeUserDataAddSource(queue: DispatchQueue? = nil) -> DispatchSourceUserDataAdd {
196-
let source = dispatch_source_create(_swift_dispatch_source_type_data_add(), 0, 0, queue?.__wrapped)
197+
let source = dispatch_source_create(_swift_dispatch_source_type_DATA_ADD(), 0, 0, queue?.__wrapped)
197198
return DispatchSource(source: source) as DispatchSourceUserDataAdd
198199
}
199200

200201
public class func makeUserDataOrSource(queue: DispatchQueue? = nil) -> DispatchSourceUserDataOr {
201-
let source = dispatch_source_create(_swift_dispatch_source_type_data_or(), 0, 0, queue?.__wrapped)
202+
let source = dispatch_source_create(_swift_dispatch_source_type_DATA_OR(), 0, 0, queue?.__wrapped)
202203
return DispatchSource(source: source) as DispatchSourceUserDataOr
203204
}
204205

205206
public class func makeUserDataReplaceSource(queue: DispatchQueue? = nil) -> DispatchSourceUserDataReplace {
206-
let source = dispatch_source_create(_swift_dispatch_source_type_data_replace(), 0, 0, queue?.__wrapped)
207+
let source = dispatch_source_create(_swift_dispatch_source_type_DATA_REPLACE(), 0, 0, queue?.__wrapped)
207208
return DispatchSource(source: source) as DispatchSourceUserDataReplace
208209
}
209210

210211
#if !os(Linux) && !os(Android)
211212
public class func makeFileSystemObjectSource(fileDescriptor: Int32, eventMask: FileSystemEvent, queue: DispatchQueue? = nil) -> DispatchSourceFileSystemObject {
212-
let source = dispatch_source_create(_swift_dispatch_source_type_vnode(), UInt(fileDescriptor), eventMask.rawValue, queue?.__wrapped)
213+
let source = dispatch_source_create(_swift_dispatch_source_type_VNODE(), UInt(fileDescriptor), eventMask.rawValue, queue?.__wrapped)
213214
return DispatchSource(source: source) as DispatchSourceFileSystemObject
214215
}
215216
#endif
216217

217218
public class func makeWriteSource(fileDescriptor: Int32, queue: DispatchQueue? = nil) -> DispatchSourceWrite {
218-
let source = dispatch_source_create(_swift_dispatch_source_type_write(), UInt(fileDescriptor), 0, queue?.__wrapped)
219+
let source = dispatch_source_create(_swift_dispatch_source_type_WRITE(), UInt(fileDescriptor), 0, queue?.__wrapped)
219220
return DispatchSource(source: source) as DispatchSourceWrite
220221
}
221222
}
@@ -669,45 +670,3 @@ public extension DispatchSourceUserDataReplace {
669670
dispatch_source_merge_data((self as! DispatchSource).__wrapped, data)
670671
}
671672
}
672-
673-
@_silgen_name("_swift_dispatch_source_type_DATA_ADD")
674-
internal func _swift_dispatch_source_type_data_add() -> dispatch_source_type_t
675-
676-
@_silgen_name("_swift_dispatch_source_type_DATA_OR")
677-
internal func _swift_dispatch_source_type_data_or() -> dispatch_source_type_t
678-
679-
@_silgen_name("_swift_dispatch_source_type_DATA_REPLACE")
680-
internal func _swift_dispatch_source_type_data_replace() -> dispatch_source_type_t
681-
682-
#if HAVE_MACH
683-
@_silgen_name("_swift_dispatch_source_type_MACH_SEND")
684-
internal func _swift_dispatch_source_type_mach_send() -> dispatch_source_type_t
685-
686-
@_silgen_name("_swift_dispatch_source_type_MACH_RECV")
687-
internal func _swift_dispatch_source_type_mach_recv() -> dispatch_source_type_t
688-
689-
@_silgen_name("_swift_dispatch_source_type_MEMORYPRESSURE")
690-
internal func _swift_dispatch_source_type_memorypressure() -> dispatch_source_type_t
691-
#endif
692-
693-
#if !os(Linux) && !os(Android)
694-
@_silgen_name("_swift_dispatch_source_type_PROC")
695-
internal func _swift_dispatch_source_type_proc() -> dispatch_source_type_t
696-
#endif
697-
698-
@_silgen_name("_swift_dispatch_source_type_READ")
699-
internal func _swift_dispatch_source_type_read() -> dispatch_source_type_t
700-
701-
@_silgen_name("_swift_dispatch_source_type_SIGNAL")
702-
internal func _swift_dispatch_source_type_signal() -> dispatch_source_type_t
703-
704-
@_silgen_name("_swift_dispatch_source_type_TIMER")
705-
internal func _swift_dispatch_source_type_timer() -> dispatch_source_type_t
706-
707-
#if !os(Linux) && !os(Android)
708-
@_silgen_name("_swift_dispatch_source_type_VNODE")
709-
internal func _swift_dispatch_source_type_vnode() -> dispatch_source_type_t
710-
#endif
711-
712-
@_silgen_name("_swift_dispatch_source_type_WRITE")
713-
internal func _swift_dispatch_source_type_write() -> dispatch_source_type_t

src/swift/Wrapper.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import CDispatch
14+
import _SwiftDispatchOverlayShims
1415

1516
// This file contains declarations that are provided by the
1617
// importer via Dispatch.apinote when the platform has Objective-C support
@@ -335,9 +336,3 @@ internal enum _OSQoSClass : UInt32 {
335336
}
336337
}
337338
}
338-
339-
@_silgen_name("_swift_dispatch_release")
340-
internal func _swift_dispatch_release(_ obj: dispatch_object_t) -> Void
341-
342-
@_silgen_name("_swift_dispatch_retain")
343-
internal func _swift_dispatch_retain(_ obj: dispatch_object_t) -> Void

0 commit comments

Comments
 (0)