Skip to content

Commit e54ec3d

Browse files
authored
Merge pull request #5854 from jrose-apple/excise-silgen_name-from-Dispatch
Use an extra shims header to remove _silgen_name from Dispatch.
2 parents 42f0527 + 1c68744 commit e54ec3d

File tree

15 files changed

+248
-494
lines changed

15 files changed

+248
-494
lines changed

stdlib/public/SDK/Dispatch/Block.swift

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

13-
import SwiftShims
13+
import _SwiftDispatchOverlayShims
1414

1515
public struct DispatchWorkItemFlags : OptionSet, RawRepresentable {
1616
public let rawValue: UInt
@@ -39,14 +39,16 @@ public class DispatchWorkItem {
3939
internal var _block: _DispatchBlock
4040

4141
public init(qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], block: @escaping @convention(block) () -> ()) {
42-
_block = _swift_dispatch_block_create_with_qos_class(flags.rawValue,
43-
qos.qosClass.rawValue.rawValue, Int32(qos.relativePriority), block)
42+
_block = _swift_dispatch_block_create_with_qos_class(
43+
__dispatch_block_flags_t(rawValue: flags.rawValue),
44+
qos.qosClass.rawValue, Int32(qos.relativePriority), block)
4445
}
4546

4647
// Used by DispatchQueue.synchronously<T> to provide a path through
4748
// dispatch_block_t, as we know the lifetime of the block in question.
4849
internal init(flags: DispatchWorkItemFlags = [], noescapeBlock: () -> ()) {
49-
_block = _swift_dispatch_block_create_noescape(flags.rawValue, noescapeBlock)
50+
_block = _swift_dispatch_block_create_noescape(
51+
__dispatch_block_flags_t(rawValue: flags.rawValue), noescapeBlock)
5052
}
5153

5254
public func perform() {

stdlib/public/SDK/Dispatch/Data.swift

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

13-
import SwiftShims
13+
import _SwiftDispatchOverlayShims
1414

1515
public struct DispatchData : RandomAccessCollection, _ObjectiveCBridgeable {
1616
public typealias Iterator = DispatchDataIterator
@@ -31,8 +31,8 @@ public struct DispatchData : RandomAccessCollection, _ObjectiveCBridgeable {
3131

3232
fileprivate var _deallocator: (DispatchQueue?, @convention(block) () -> Void) {
3333
switch self {
34-
case .free: return (nil, _dispatch_data_destructor_free())
35-
case .unmap: return (nil, _dispatch_data_destructor_munmap())
34+
case .free: return (nil, _swift_dispatch_data_destructor_free())
35+
case .unmap: return (nil, _swift_dispatch_data_destructor_munmap())
3636
case .custom(let q, let b): return (q, b)
3737
}
3838
}
@@ -46,7 +46,7 @@ public struct DispatchData : RandomAccessCollection, _ObjectiveCBridgeable {
4646
/// - parameter count: The number of bytes to copy.
4747
public init(bytes buffer: UnsafeBufferPointer<UInt8>) {
4848
__wrapped = _swift_dispatch_data_create(
49-
buffer.baseAddress!, buffer.count, nil, _dispatch_data_destructor_default()) as! __DispatchData
49+
buffer.baseAddress!, buffer.count, nil, _swift_dispatch_data_destructor_default()) as! __DispatchData
5050
}
5151

5252
/// Initialize a `Data` without copying the bytes.
@@ -98,7 +98,7 @@ public struct DispatchData : RandomAccessCollection, _ObjectiveCBridgeable {
9898
/// - parameter bytes: A pointer to the bytes to copy in to the data.
9999
/// - parameter count: The number of bytes to copy.
100100
public mutating func append(_ bytes: UnsafePointer<UInt8>, count: Int) {
101-
let data = _swift_dispatch_data_create(bytes, count, nil, _dispatch_data_destructor_default()) as! __DispatchData
101+
let data = _swift_dispatch_data_create(bytes, count, nil, _swift_dispatch_data_destructor_default()) as! __DispatchData
102102
self.append(DispatchData(data: data))
103103
}
104104

@@ -285,16 +285,3 @@ extension DispatchData {
285285
return result!
286286
}
287287
}
288-
289-
@_silgen_name("_swift_dispatch_data_empty")
290-
internal func _swift_dispatch_data_empty() -> __DispatchData
291-
292-
@_silgen_name("_swift_dispatch_data_destructor_free")
293-
internal func _dispatch_data_destructor_free() -> _DispatchBlock
294-
295-
@_silgen_name("_swift_dispatch_data_destructor_munmap")
296-
internal func _dispatch_data_destructor_munmap() -> _DispatchBlock
297-
298-
@_silgen_name("_swift_dispatch_data_destructor_default")
299-
internal func _dispatch_data_destructor_default() -> _DispatchBlock
300-

stdlib/public/SDK/Dispatch/Dispatch.mm

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
#include <objc/runtime.h>
1515
#include <stdio.h>
1616

17-
#define DISPATCH_RUNTIME_STDLIB_INTERFACE __attribute__((__visibility__("default")))
18-
1917
@protocol OS_dispatch_source;
2018
@protocol OS_dispatch_source_mach_send;
2119
@protocol OS_dispatch_source_mach_recv;
@@ -49,59 +47,3 @@ static void _dispatch_overlay_constructor() {
4947
}
5048
}
5149

52-
#include "swift/Runtime/Config.h"
53-
54-
SWIFT_CC(swift) DISPATCH_RUNTIME_STDLIB_INTERFACE
55-
extern "C" dispatch_queue_attr_t
56-
_swift_dispatch_queue_concurrent(void) {
57-
return DISPATCH_QUEUE_CONCURRENT;
58-
}
59-
60-
SWIFT_CC(swift) DISPATCH_RUNTIME_STDLIB_INTERFACE
61-
extern "C" dispatch_queue_t
62-
_swift_dispatch_get_main_queue(void) {
63-
return dispatch_get_main_queue();
64-
}
65-
66-
SWIFT_CC(swift) DISPATCH_RUNTIME_STDLIB_INTERFACE
67-
extern "C" dispatch_data_t
68-
_swift_dispatch_data_empty(void) {
69-
return dispatch_data_empty;
70-
}
71-
72-
SWIFT_CC(swift) DISPATCH_RUNTIME_STDLIB_INTERFACE
73-
extern "C" dispatch_block_t
74-
_swift_dispatch_data_destructor_default(void) {
75-
return DISPATCH_DATA_DESTRUCTOR_DEFAULT;
76-
}
77-
78-
SWIFT_CC(swift) DISPATCH_RUNTIME_STDLIB_INTERFACE
79-
extern "C" dispatch_block_t
80-
_swift_dispatch_data_destructor_free(void) {
81-
return _dispatch_data_destructor_free;
82-
}
83-
84-
SWIFT_CC(swift) DISPATCH_RUNTIME_STDLIB_INTERFACE
85-
extern "C" dispatch_block_t
86-
_swift_dispatch_data_destructor_munmap(void) {
87-
return _dispatch_data_destructor_munmap;
88-
}
89-
90-
#define SOURCE(t) \
91-
SWIFT_CC(swift) \
92-
DISPATCH_RUNTIME_STDLIB_INTERFACE extern "C" dispatch_source_type_t \
93-
_swift_dispatch_source_type_##t(void) { \
94-
return DISPATCH_SOURCE_TYPE_##t; \
95-
}
96-
97-
SOURCE(DATA_ADD)
98-
SOURCE(DATA_OR)
99-
SOURCE(MACH_SEND)
100-
SOURCE(MACH_RECV)
101-
SOURCE(MEMORYPRESSURE)
102-
SOURCE(PROC)
103-
SOURCE(READ)
104-
SOURCE(SIGNAL)
105-
SOURCE(TIMER)
106-
SOURCE(VNODE)
107-
SOURCE(WRITE)

stdlib/public/SDK/Dispatch/Dispatch.swift

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

1313
@_exported import Dispatch
14-
import SwiftShims
14+
import _SwiftDispatchOverlayShims
1515

1616
/// dispatch_assert
1717

stdlib/public/SDK/Dispatch/Queue.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
// dispatch/queue.h
1414

15-
import SwiftShims
15+
import _SwiftDispatchOverlayShims
1616

1717
public final class DispatchSpecificKey<T> {
1818
public init() {}
@@ -353,9 +353,3 @@ private func _destructDispatchSpecificValue(ptr: UnsafeMutableRawPointer?) {
353353
Unmanaged<AnyObject>.fromOpaque(p).release()
354354
}
355355
}
356-
357-
@_silgen_name("_swift_dispatch_queue_concurrent")
358-
internal func _swift_dispatch_queue_concurrent() -> __OS_dispatch_queue_attr
359-
360-
@_silgen_name("_swift_dispatch_get_main_queue")
361-
internal func _swift_dispatch_get_main_queue() -> DispatchQueue

stdlib/public/SDK/Dispatch/Source.swift

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

1313
// import Foundation
14-
import SwiftShims
14+
import _SwiftDispatchOverlayShims
1515

1616
public extension DispatchSourceProtocol {
1717
typealias DispatchSourceHandler = @convention(block) () -> Void
@@ -153,56 +153,56 @@ public extension DispatchSource {
153153

154154
public class func makeMachSendSource(port: mach_port_t, eventMask: MachSendEvent, queue: DispatchQueue? = nil) -> DispatchSourceMachSend {
155155
return __dispatch_source_create(
156-
_swift_dispatch_source_type_mach_send(), UInt(port), eventMask.rawValue, queue) as DispatchSourceMachSend
156+
_swift_dispatch_source_type_MACH_SEND(), UInt(port), eventMask.rawValue, queue) as DispatchSourceMachSend
157157
}
158158

159159
public class func makeMachReceiveSource(port: mach_port_t, queue: DispatchQueue? = nil) -> DispatchSourceMachReceive {
160160
return __dispatch_source_create(
161-
_swift_dispatch_source_type_mach_recv(), UInt(port), 0, queue) as DispatchSourceMachReceive
161+
_swift_dispatch_source_type_MACH_RECV(), UInt(port), 0, queue) as DispatchSourceMachReceive
162162
}
163163

164164
public class func makeMemoryPressureSource(eventMask: MemoryPressureEvent, queue: DispatchQueue? = nil) -> DispatchSourceMemoryPressure {
165165
return __dispatch_source_create(
166-
_swift_dispatch_source_type_memorypressure(), 0, eventMask.rawValue, queue) as DispatchSourceMemoryPressure
166+
_swift_dispatch_source_type_MEMORYPRESSURE(), 0, eventMask.rawValue, queue) as DispatchSourceMemoryPressure
167167
}
168168

169169
public class func makeProcessSource(identifier: pid_t, eventMask: ProcessEvent, queue: DispatchQueue? = nil) -> DispatchSourceProcess {
170170
return __dispatch_source_create(
171-
_swift_dispatch_source_type_proc(), UInt(identifier), eventMask.rawValue, queue) as DispatchSourceProcess
171+
_swift_dispatch_source_type_PROC(), UInt(identifier), eventMask.rawValue, queue) as DispatchSourceProcess
172172
}
173173

174174
public class func makeReadSource(fileDescriptor: Int32, queue: DispatchQueue? = nil) -> DispatchSourceRead {
175175
return __dispatch_source_create(
176-
_swift_dispatch_source_type_read(), UInt(fileDescriptor), 0, queue) as DispatchSourceRead
176+
_swift_dispatch_source_type_READ(), UInt(fileDescriptor), 0, queue) as DispatchSourceRead
177177
}
178178

179179
public class func makeSignalSource(signal: Int32, queue: DispatchQueue? = nil) -> DispatchSourceSignal {
180180
return __dispatch_source_create(
181-
_swift_dispatch_source_type_signal(), UInt(signal), 0, queue) as DispatchSourceSignal
181+
_swift_dispatch_source_type_SIGNAL(), UInt(signal), 0, queue) as DispatchSourceSignal
182182
}
183183

184184
public class func makeTimerSource(flags: TimerFlags = [], queue: DispatchQueue? = nil) -> DispatchSourceTimer {
185-
return __dispatch_source_create(_swift_dispatch_source_type_timer(), 0, flags.rawValue, queue) as DispatchSourceTimer
185+
return __dispatch_source_create(_swift_dispatch_source_type_TIMER(), 0, flags.rawValue, queue) as DispatchSourceTimer
186186
}
187187

188188
public class func makeUserDataAddSource(queue: DispatchQueue? = nil) -> DispatchSourceUserDataAdd {
189-
return __dispatch_source_create(_swift_dispatch_source_type_data_add(), 0, 0, queue) as DispatchSourceUserDataAdd
189+
return __dispatch_source_create(_swift_dispatch_source_type_DATA_ADD(), 0, 0, queue) as DispatchSourceUserDataAdd
190190
}
191191

192192
public class func makeUserDataOrSource(queue: DispatchQueue? = nil) -> DispatchSourceUserDataOr {
193-
return __dispatch_source_create(_swift_dispatch_source_type_data_or(), 0, 0, queue) as DispatchSourceUserDataOr
193+
return __dispatch_source_create(_swift_dispatch_source_type_DATA_OR(), 0, 0, queue) as DispatchSourceUserDataOr
194194
}
195195

196196
public class func makeFileSystemObjectSource(
197197
fileDescriptor: Int32, eventMask: FileSystemEvent, queue: DispatchQueue? = nil) -> DispatchSourceFileSystemObject
198198
{
199199
return __dispatch_source_create(
200-
_swift_dispatch_source_type_vnode(), UInt(fileDescriptor), eventMask.rawValue, queue) as DispatchSourceFileSystemObject
200+
_swift_dispatch_source_type_VNODE(), UInt(fileDescriptor), eventMask.rawValue, queue) as DispatchSourceFileSystemObject
201201
}
202202

203203
public class func makeWriteSource(fileDescriptor: Int32, queue: DispatchQueue? = nil) -> DispatchSourceWrite {
204204
return __dispatch_source_create(
205-
_swift_dispatch_source_type_write(), UInt(fileDescriptor), 0, queue) as DispatchSourceWrite
205+
_swift_dispatch_source_type_WRITE(), UInt(fileDescriptor), 0, queue) as DispatchSourceWrite
206206
}
207207
}
208208

@@ -331,36 +331,3 @@ public extension DispatchSourceUserDataOr {
331331
__dispatch_source_merge_data(self as! DispatchSource, data)
332332
}
333333
}
334-
335-
@_silgen_name("_swift_dispatch_source_type_DATA_ADD")
336-
internal func _swift_dispatch_source_type_data_add() -> __dispatch_source_type_t
337-
338-
@_silgen_name("_swift_dispatch_source_type_DATA_OR")
339-
internal func _swift_dispatch_source_type_data_or() -> __dispatch_source_type_t
340-
341-
@_silgen_name("_swift_dispatch_source_type_MACH_SEND")
342-
internal func _swift_dispatch_source_type_mach_send() -> __dispatch_source_type_t
343-
344-
@_silgen_name("_swift_dispatch_source_type_MACH_RECV")
345-
internal func _swift_dispatch_source_type_mach_recv() -> __dispatch_source_type_t
346-
347-
@_silgen_name("_swift_dispatch_source_type_MEMORYPRESSURE")
348-
internal func _swift_dispatch_source_type_memorypressure() -> __dispatch_source_type_t
349-
350-
@_silgen_name("_swift_dispatch_source_type_PROC")
351-
internal func _swift_dispatch_source_type_proc() -> __dispatch_source_type_t
352-
353-
@_silgen_name("_swift_dispatch_source_type_READ")
354-
internal func _swift_dispatch_source_type_read() -> __dispatch_source_type_t
355-
356-
@_silgen_name("_swift_dispatch_source_type_SIGNAL")
357-
internal func _swift_dispatch_source_type_signal() -> __dispatch_source_type_t
358-
359-
@_silgen_name("_swift_dispatch_source_type_TIMER")
360-
internal func _swift_dispatch_source_type_timer() -> __dispatch_source_type_t
361-
362-
@_silgen_name("_swift_dispatch_source_type_VNODE")
363-
internal func _swift_dispatch_source_type_vnode() -> __dispatch_source_type_t
364-
365-
@_silgen_name("_swift_dispatch_source_type_WRITE")
366-
internal func _swift_dispatch_source_type_write() -> __dispatch_source_type_t

stdlib/public/SDK/Dispatch/Time.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
import SwiftShims
13+
import _SwiftDispatchOverlayShims
1414

1515
public struct DispatchTime : Comparable {
1616
public let rawValue: dispatch_time_t

stdlib/public/SwiftShims/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
set(sources
22
AssertionReporting.h
33
CoreFoundationShims.h
4-
DispatchShims.h
54
FoundationShims.h
65
GlobalObjects.h
76
HeapObject.h
@@ -15,6 +14,7 @@ set(sources
1514
UnicodeShims.h
1615
Visibility.h
1716

17+
DispatchOverlayShims.h
1818
ObjectiveCOverlayShims.h
1919
OSOverlayShims.h
2020
SafariServicesOverlayShims.h

0 commit comments

Comments
 (0)