Skip to content

Commit 86b7618

Browse files
committed
Merge libdispatch-685
Unchanged import from Apple open source release at http://opensource.apple.com/tarballs/libdispatch/libdispatch-685.tar.gz
1 parent a535573 commit 86b7618

File tree

104 files changed

+20053
-9463
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+20053
-9463
lines changed

INSTALL

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@ OS X as a replacement for /usr/lib/system/libdispatch.dylib:
5656
Specify the path to Apple's objc4 package, so that appropriate headers can
5757
be found and used.
5858

59-
--with-apple-libauto-source
60-
61-
Specify the path to Apple's libauto package, so that appropriate headers
62-
can be found and used.
63-
6459
--disable-libdispatch-init-constructor
6560

6661
Do not tag libdispatch's init routine as __constructor, in which case it
@@ -90,8 +85,7 @@ libdispatch for /usr/lib/system on OS X El Capitan:
9085
--with-apple-libplatform-source=/path/to/10.11.0/libplatform-73.1.1 \
9186
--with-apple-libclosure-source=/path/to/10.11.0/libclosure-65 \
9287
--with-apple-xnu-source=/path/to/10.11.0/xnu-3247.1.106 \
93-
--with-apple-objc4-source=/path/to/10.11.0/objc4-680 \
94-
--with-apple-libauto-source=/path/to/10.11.0/libauto-186
88+
--with-apple-objc4-source=/path/to/10.11.0/objc4-680
9589
make check
9690

9791
Typical configuration line for FreeBSD 8.x and 9.x to build libdispatch with

config/config.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
you don't. */
5050
#define HAVE_DECL_VQ_VERYLOWDISK 1
5151

52+
/* Define to 1 if you have the declaration of `VQ_QUOTA', and to 0 if
53+
you don't. */
54+
#define HAVE_DECL_VQ_QUOTA 1
55+
5256
/* Define to 1 if you have the <dlfcn.h> header file. */
5357
#define HAVE_DLFCN_H 1
5458

@@ -79,6 +83,9 @@
7983
/* Define to 1 if you have the `mach_absolute_time' function. */
8084
#define HAVE_MACH_ABSOLUTE_TIME 1
8185

86+
/* Define to 1 if you have the `mach_port_construct' function. */
87+
#define HAVE_MACH_PORT_CONSTRUCT 1
88+
8289
/* Define to 1 if you have the `malloc_create_zone' function. */
8390
#define HAVE_MALLOC_CREATE_ZONE 1
8491

configure.ac

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,6 @@ AC_ARG_WITH([apple-objc4-source],
5858
apple_objc4_source_runtime_path=${withval}/runtime
5959
])
6060

61-
AC_ARG_WITH([apple-libauto-source],
62-
[AS_HELP_STRING([--with-apple-libauto-source],
63-
[Specify path to Apple libauto source])], [
64-
apple_libauto_source_path=${withval}
65-
CPPFLAGS="$CPPFLAGS -isystem $apple_libauto_source_path"
66-
])
67-
6861
AC_CACHE_CHECK([for System.framework/PrivateHeaders], dispatch_cv_system_privateheaders,
6962
[AS_IF([test -d /System/Library/Frameworks/System.framework/PrivateHeaders],
7063
[dispatch_cv_system_privateheaders=yes], [dispatch_cv_system_privateheaders=no])]
@@ -267,6 +260,7 @@ AC_CHECK_HEADER([mach/mach.h], [
267260
have_mach=true], [have_mach=false]
268261
)
269262
AM_CONDITIONAL(USE_MIG, $have_mach)
263+
AC_CHECK_FUNCS([mach_port_construct])
270264

271265
#
272266
# Find functions and declarations we care about.
@@ -277,7 +271,7 @@ AC_CHECK_DECLS([NOTE_NONE, NOTE_REAP, NOTE_REVOKE, NOTE_SIGNAL], [], [],
277271
[[#include <sys/event.h>]])
278272
AC_CHECK_DECLS([FD_COPY], [], [], [[#include <sys/select.h>]])
279273
AC_CHECK_DECLS([SIGEMT], [], [], [[#include <signal.h>]])
280-
AC_CHECK_DECLS([VQ_UPDATE, VQ_VERYLOWDISK], [], [], [[#include <sys/mount.h>]])
274+
AC_CHECK_DECLS([VQ_UPDATE, VQ_VERYLOWDISK, VQ_QUOTA], [], [], [[#include <sys/mount.h>]])
281275
AC_CHECK_DECLS([program_invocation_short_name], [], [], [[#include <errno.h>]])
282276
AC_CHECK_FUNCS([pthread_key_init_np pthread_main_np mach_absolute_time malloc_create_zone sysconf])
283277

dispatch/base.h

Lines changed: 98 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@
2525
#error "Please #include <dispatch/dispatch.h> instead of this file directly."
2626
#endif
2727

28+
#ifndef __has_builtin
29+
#define __has_builtin(x) 0
30+
#endif
31+
#ifndef __has_include
32+
#define __has_include(x) 0
33+
#endif
34+
#ifndef __has_feature
35+
#define __has_feature(x) 0
36+
#endif
37+
#ifndef __has_attribute
38+
#define __has_attribute(x) 0
39+
#endif
40+
#ifndef __has_extension
41+
#define __has_extension(x) 0
42+
#endif
43+
2844
#if __GNUC__
2945
#define DISPATCH_NORETURN __attribute__((__noreturn__))
3046
#define DISPATCH_NOTHROW __attribute__((__nothrow__))
@@ -85,6 +101,14 @@
85101
#define DISPATCH_UNAVAILABLE
86102
#endif
87103

104+
#ifndef DISPATCH_ALIAS_V2
105+
#if TARGET_OS_MAC
106+
#define DISPATCH_ALIAS_V2(sym) __asm__("_" #sym "$V2")
107+
#else
108+
#define DISPATCH_ALIAS_V2(sym)
109+
#endif
110+
#endif
111+
88112
#if TARGET_OS_WIN32 && defined(__DISPATCH_BUILDING_DISPATCH__) && \
89113
defined(__cplusplus)
90114
#define DISPATCH_EXPORT extern "C" extern __declspec(dllexport)
@@ -108,41 +132,106 @@
108132

109133
#if __GNUC__
110134
#define DISPATCH_EXPECT(x, v) __builtin_expect((x), (v))
135+
#define dispatch_compiler_barrier() __asm__ __volatile__("" ::: "memory")
111136
#else
112137
#define DISPATCH_EXPECT(x, v) (x)
138+
#define dispatch_compiler_barrier() do { } while (0)
139+
#endif
140+
141+
#if __has_attribute(not_tail_called)
142+
#define DISPATCH_NOT_TAIL_CALLED __attribute__((__not_tail_called__))
143+
#else
144+
#define DISPATCH_NOT_TAIL_CALLED
145+
#endif
146+
147+
#if __has_builtin(__builtin_assume)
148+
#define DISPATCH_COMPILER_CAN_ASSUME(expr) __builtin_assume(expr)
149+
#else
150+
#define DISPATCH_COMPILER_CAN_ASSUME(expr) ((void)(expr))
151+
#endif
152+
153+
#if __has_attribute(noescape)
154+
#define DISPATCH_NOESCAPE __attribute__((__noescape__))
155+
#else
156+
#define DISPATCH_NOESCAPE
157+
#endif
158+
159+
#if __has_feature(assume_nonnull)
160+
#define DISPATCH_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
161+
#define DISPATCH_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
162+
#else
163+
#define DISPATCH_ASSUME_NONNULL_BEGIN
164+
#define DISPATCH_ASSUME_NONNULL_END
165+
#endif
166+
167+
#if !__has_feature(nullability)
168+
#ifndef _Nullable
169+
#define _Nullable
170+
#endif
171+
#ifndef _Nonnull
172+
#define _Nonnull
173+
#endif
174+
#ifndef _Null_unspecified
175+
#define _Null_unspecified
176+
#endif
113177
#endif
114178

115179
#ifndef DISPATCH_RETURNS_RETAINED_BLOCK
116-
#if defined(__has_attribute)
117180
#if __has_attribute(ns_returns_retained)
118181
#define DISPATCH_RETURNS_RETAINED_BLOCK __attribute__((__ns_returns_retained__))
119182
#else
120183
#define DISPATCH_RETURNS_RETAINED_BLOCK
121184
#endif
122-
#else
123-
#define DISPATCH_RETURNS_RETAINED_BLOCK
124-
#endif
125185
#endif
126186

127-
#if defined(__has_feature) && defined(__has_extension)
128187
#if __has_feature(objc_fixed_enum) || __has_extension(cxx_strong_enums)
129188
#define DISPATCH_ENUM(name, type, ...) \
130189
typedef enum : type { __VA_ARGS__ } name##_t
131190
#else
132191
#define DISPATCH_ENUM(name, type, ...) \
133192
enum { __VA_ARGS__ }; typedef type name##_t
134193
#endif
194+
135195
#if __has_feature(enumerator_attributes)
136196
#define DISPATCH_ENUM_AVAILABLE_STARTING __OSX_AVAILABLE_STARTING
197+
#define DISPATCH_ENUM_AVAILABLE(os, version) __##os##_AVAILABLE(version)
137198
#else
138199
#define DISPATCH_ENUM_AVAILABLE_STARTING(...)
200+
#define DISPATCH_ENUM_AVAILABLE(...)
139201
#endif
202+
203+
#if defined(SWIFT_SDK_OVERLAY_DISPATCH_EPOCH) && \
204+
SWIFT_SDK_OVERLAY_DISPATCH_EPOCH >= 2
205+
#define DISPATCH_SWIFT3_OVERLAY 1
140206
#else
141-
#define DISPATCH_ENUM(name, type, ...) \
142-
enum { __VA_ARGS__ }; typedef type name##_t
143-
#define DISPATCH_ENUM_AVAILABLE_STARTING(...)
207+
#define DISPATCH_SWIFT3_OVERLAY 0
208+
#endif // SWIFT_SDK_OVERLAY_DISPATCH_EPOCH >= 2
209+
210+
#if __has_feature(attribute_availability_swift)
211+
#define DISPATCH_SWIFT_UNAVAILABLE(_msg) \
212+
__attribute__((__availability__(swift, unavailable, message=_msg)))
213+
#else
214+
#define DISPATCH_SWIFT_UNAVAILABLE(_msg)
215+
#endif
216+
217+
#if DISPATCH_SWIFT3_OVERLAY
218+
#define DISPATCH_SWIFT3_UNAVAILABLE(_msg) DISPATCH_SWIFT_UNAVAILABLE(_msg)
219+
#else
220+
#define DISPATCH_SWIFT3_UNAVAILABLE(_msg)
221+
#endif
222+
223+
#if __has_attribute(swift_private)
224+
#define DISPATCH_REFINED_FOR_SWIFT __attribute__((__swift_private__))
225+
#else
226+
#define DISPATCH_REFINED_FOR_SWIFT
227+
#endif
228+
229+
#if __has_attribute(swift_name)
230+
#define DISPATCH_SWIFT_NAME(_name) __attribute__((__swift_name__(#_name)))
231+
#else
232+
#define DISPATCH_SWIFT_NAME(_name)
144233
#endif
145234

146-
typedef void (*dispatch_function_t)(void *);
235+
typedef void (*dispatch_function_t)(void *_Nullable);
147236

148237
#endif

dispatch/block.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
* @group Dispatch block objects
3333
*/
3434

35+
DISPATCH_ASSUME_NONNULL_BEGIN
36+
3537
__BEGIN_DECLS
3638

3739
/*!
@@ -270,7 +272,8 @@ dispatch_block_create_with_qos_class(dispatch_block_flags_t flags,
270272
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0)
271273
DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NOTHROW
272274
void
273-
dispatch_block_perform(dispatch_block_flags_t flags, dispatch_block_t block);
275+
dispatch_block_perform(dispatch_block_flags_t flags,
276+
DISPATCH_NOESCAPE dispatch_block_t block);
274277

275278
/*!
276279
* @function dispatch_block_wait
@@ -288,7 +291,7 @@ dispatch_block_perform(dispatch_block_flags_t flags, dispatch_block_t block);
288291
* dispatch block object may either be waited on once and executed once,
289292
* or it may be executed any number of times. The behavior of any other
290293
* combination is undefined. Submission to a dispatch queue counts as an
291-
* execution, even if cancelation (dispatch_block_cancel) means the block's
294+
* execution, even if cancellation (dispatch_block_cancel) means the block's
292295
* code never runs.
293296
*
294297
* The result of calling this function from multiple threads simultaneously
@@ -417,6 +420,8 @@ dispatch_block_testcancel(dispatch_block_t block);
417420

418421
__END_DECLS
419422

423+
DISPATCH_ASSUME_NONNULL_END
424+
420425
#endif // __BLOCKS__
421426

422427
#endif // __DISPATCH_BLOCK__

dispatch/data.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#include <dispatch/base.h> // for HeaderDoc
2727
#endif
2828

29+
DISPATCH_ASSUME_NONNULL_BEGIN
30+
2931
__BEGIN_DECLS
3032

3133
/*! @header
@@ -39,7 +41,7 @@ __BEGIN_DECLS
3941
* @typedef dispatch_data_t
4042
* A dispatch object representing memory regions.
4143
*/
42-
DISPATCH_DECL(dispatch_data);
44+
DISPATCH_DATA_DECL(dispatch_data);
4345

4446
/*!
4547
* @var dispatch_data_empty
@@ -120,8 +122,8 @@ DISPATCH_EXPORT DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT DISPATCH_NOTHROW
120122
dispatch_data_t
121123
dispatch_data_create(const void *buffer,
122124
size_t size,
123-
dispatch_queue_t queue,
124-
dispatch_block_t destructor);
125+
dispatch_queue_t _Nullable queue,
126+
dispatch_block_t _Nullable destructor);
125127
#endif /* __BLOCKS__ */
126128

127129
/*!
@@ -161,8 +163,8 @@ DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_RETURNS_RETAINED
161163
DISPATCH_WARN_RESULT DISPATCH_NOTHROW
162164
dispatch_data_t
163165
dispatch_data_create_map(dispatch_data_t data,
164-
const void **buffer_ptr,
165-
size_t *size_ptr);
166+
const void *_Nullable *_Nullable buffer_ptr,
167+
size_t *_Nullable size_ptr);
166168

167169
/*!
168170
* @function dispatch_data_create_concat
@@ -275,4 +277,6 @@ dispatch_data_copy_region(dispatch_data_t data,
275277

276278
__END_DECLS
277279

280+
DISPATCH_ASSUME_NONNULL_END
281+
278282
#endif /* __DISPATCH_DATA__ */

dispatch/dispatch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
#define __OSX_AVAILABLE_STARTING(x, y)
4343
#endif
4444

45-
#define DISPATCH_API_VERSION 20141121
45+
#define DISPATCH_API_VERSION 20160612
4646

4747
#ifndef __DISPATCH_BUILDING_DISPATCH__
4848

dispatch/group.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#include <dispatch/base.h> // for HeaderDoc
2727
#endif
2828

29+
DISPATCH_ASSUME_NONNULL_BEGIN
30+
2931
/*!
3032
* @typedef dispatch_group_t
3133
* @abstract
@@ -119,7 +121,7 @@ DISPATCH_NOTHROW
119121
void
120122
dispatch_group_async_f(dispatch_group_t group,
121123
dispatch_queue_t queue,
122-
void *context,
124+
void *_Nullable context,
123125
dispatch_function_t work);
124126

125127
/*!
@@ -229,7 +231,7 @@ DISPATCH_NOTHROW
229231
void
230232
dispatch_group_notify_f(dispatch_group_t group,
231233
dispatch_queue_t queue,
232-
void *context,
234+
void *_Nullable context,
233235
dispatch_function_t work);
234236

235237
/*!
@@ -273,4 +275,6 @@ dispatch_group_leave(dispatch_group_t group);
273275

274276
__END_DECLS
275277

278+
DISPATCH_ASSUME_NONNULL_END
279+
276280
#endif

dispatch/introspection.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
#include <dispatch/dispatch.h>
2525

26+
DISPATCH_ASSUME_NONNULL_BEGIN
27+
2628
/*!
2729
* @header
2830
*
@@ -152,7 +154,7 @@ __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0)
152154
DISPATCH_EXPORT
153155
void
154156
dispatch_introspection_hook_queue_callout_begin(dispatch_queue_t queue,
155-
void *context, dispatch_function_t function);
157+
void *_Nullable context, dispatch_function_t function);
156158

157159
/*!
158160
* @function dispatch_introspection_hook_queue_callout_end
@@ -177,8 +179,10 @@ __OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0)
177179
DISPATCH_EXPORT
178180
void
179181
dispatch_introspection_hook_queue_callout_end(dispatch_queue_t queue,
180-
void *context, dispatch_function_t function);
182+
void *_Nullable context, dispatch_function_t function);
181183

182184
__END_DECLS
183185

186+
DISPATCH_ASSUME_NONNULL_END
187+
184188
#endif

0 commit comments

Comments
 (0)