2
2
//
3
3
// This source file is part of the Swift.org open source project
4
4
//
5
- // Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5
+ // Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
6
6
// Licensed under Apache License v2.0 with Runtime Library Exception
7
7
//
8
8
// See https://swift.org/LICENSE.txt for license information
9
9
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10
10
//
11
11
// ===----------------------------------------------------------------------===//
12
+ //
13
+ // Note that this file is used by both swift-corelibs-libdispatch and the
14
+ // Dispatch overlay for Darwin in swift/stdlib/public/SDK/Dispatch/.
15
+ //
16
+ // ===----------------------------------------------------------------------===//
17
+
12
18
13
19
#ifndef SWIFT_STDLIB_SHIMS_DISPATCHSHIMS_H
14
20
#define SWIFT_STDLIB_SHIMS_DISPATCHSHIMS_H
15
21
16
- @ import Dispatch;
22
+ # include < dispatch/dispatch.h >
17
23
24
+ #ifdef __OBJC__
18
25
#define SWIFT_DISPATCH_RETURNS_RETAINED __attribute__ ((__ns_returns_retained__))
26
+ #else
27
+ #define SWIFT_DISPATCH_RETURNS_RETAINED
28
+ #endif
29
+
19
30
#define SWIFT_DISPATCH_NOESCAPE __attribute__ ((__noescape__))
20
31
21
32
#pragma clang assume_nonnull begin
@@ -25,7 +36,12 @@ namespace swift { extern "C" {
25
36
#endif
26
37
27
38
typedef void (^__swift_shims_dispatch_block_t )(void );
39
+
40
+ #ifdef __OBJC__
28
41
typedef id __swift_shims_dispatch_data_t ;
42
+ #else
43
+ typedef void *__swift_shims_dispatch_data_t ;
44
+ #endif
29
45
30
46
31
47
static inline dispatch_queue_attr_t
@@ -66,21 +82,24 @@ _swift_dispatch_data_destructor_munmap(void) {
66
82
SWIFT_DISPATCH_SOURCE_TYPE (DATA_ADD)
67
83
SWIFT_DISPATCH_SOURCE_TYPE(DATA_OR)
68
84
SWIFT_DISPATCH_SOURCE_TYPE(DATA_REPLACE)
85
+ SWIFT_DISPATCH_SOURCE_TYPE(READ)
86
+ SWIFT_DISPATCH_SOURCE_TYPE(SIGNAL)
87
+ SWIFT_DISPATCH_SOURCE_TYPE(TIMER)
88
+ SWIFT_DISPATCH_SOURCE_TYPE(WRITE)
89
+
90
+ #if __APPLE__
69
91
SWIFT_DISPATCH_SOURCE_TYPE (MACH_SEND)
70
92
SWIFT_DISPATCH_SOURCE_TYPE(MACH_RECV)
71
93
SWIFT_DISPATCH_SOURCE_TYPE(MEMORYPRESSURE)
72
94
SWIFT_DISPATCH_SOURCE_TYPE(PROC)
73
- SWIFT_DISPATCH_SOURCE_TYPE(READ)
74
- SWIFT_DISPATCH_SOURCE_TYPE(SIGNAL)
75
- SWIFT_DISPATCH_SOURCE_TYPE(TIMER)
76
95
SWIFT_DISPATCH_SOURCE_TYPE(VNODE)
77
- SWIFT_DISPATCH_SOURCE_TYPE(WRITE)
96
+ # endif
78
97
79
98
80
99
static inline __swift_shims_dispatch_block_t
81
100
_swift_dispatch_block_create_with_qos_class (
82
101
dispatch_block_flags_t flags,
83
- qos_class_t qos,
102
+ dispatch_qos_class_t qos,
84
103
int relative_priority,
85
104
__swift_shims_dispatch_block_t _Nonnull block) {
86
105
return dispatch_block_create_with_qos_class (
@@ -158,7 +177,7 @@ static inline void _swift_dispatch_after(
158
177
159
178
160
179
static inline void _swift_dispatch_apply_current (
161
- unsigned int iterations,
180
+ size_t iterations,
162
181
void SWIFT_DISPATCH_NOESCAPE (^block)(long )) {
163
182
dispatch_apply (iterations, (dispatch_queue_t _Nonnull)0 , ^(size_t i){
164
183
block ((long )i);
@@ -204,6 +223,18 @@ static inline void _swift_dispatch_source_set_registration_handler(
204
223
dispatch_source_set_registration_handler (source, block);
205
224
}
206
225
226
+ #if defined(__ANDROID__)
227
+ extern void _dispatch_install_thread_detach_callback (dispatch_function_t cb);
228
+ #endif
229
+
230
+ static inline void _swift_dispatch_retain (dispatch_object_t object) {
231
+ dispatch_retain (object);
232
+ }
233
+
234
+ static inline void _swift_dispatch_release (dispatch_object_t object) {
235
+ dispatch_release (object);
236
+ }
237
+
207
238
#ifdef __cplusplus
208
239
}} // extern "C", namespace swift
209
240
#endif
0 commit comments