Skip to content

Commit 22df1e7

Browse files
authored
Merge pull request swiftlang#254 from apple/das-darwin-libdispatch-890-merge-master
Merge darwin/libdispatch-890 to master
2 parents acb1b1e + 835418a commit 22df1e7

Some content is hidden

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

69 files changed

+4198
-3376
lines changed

Diff for: INSTALL.md

-12
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,6 @@ Specify the path to Apple's libpthread package, so that appropriate headers
8787
Specify the path to Apple's libplatform package, so that appropriate headers
8888
can be found and used.
8989
90-
`--with-apple-libclosure-source`
91-
92-
Specify the path to Apple's Libclosure package, so that appropriate headers
93-
can be found and used.
94-
9590
`--with-apple-xnu-source`
9691
9792
Specify the path to Apple's XNU package, so that appropriate headers can be
@@ -104,11 +99,6 @@ On systems where -fblocks is supported, specify an additional library path in wh
10499
The following options are likely to only be useful when building libdispatch on
105100
OS X as a replacement for /usr/lib/system/libdispatch.dylib:
106101
107-
`--with-apple-objc4-source`
108-
109-
Specify the path to Apple's objc4 package, so that appropriate headers can
110-
be found and used.
111-
112102
`--disable-libdispatch-init-constructor`
113103
114104
Do not tag libdispatch's init routine as __constructor, in which case it must be run manually before libdispatch routines can be called. This is the default when building on OS X. For /usr/lib/system/libdispatch.dylib the init routine is called automatically during process start.
@@ -131,9 +121,7 @@ libdispatch for /usr/lib/system on OS X El Capitan:
131121
--enable-apple-tsd-optimizations \
132122
--with-apple-libpthread-source=/path/to/10.11.0/libpthread-137.1.1 \
133123
--with-apple-libplatform-source=/path/to/10.11.0/libplatform-73.1.1 \
134-
--with-apple-libclosure-source=/path/to/10.11.0/libclosure-65 \
135124
--with-apple-xnu-source=/path/to/10.11.0/xnu-3247.1.106 \
136-
--with-apple-objc4-source=/path/to/10.11.0/objc4-680
137125
make check
138126
139127
### Building and installing for FreeBSD

Diff for: configure.ac

+1-27
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,6 @@ AC_ARG_WITH([apple-libplatform-source],
125125
CPPFLAGS="$CPPFLAGS -isystem $apple_libplatform_source_include_path"
126126
])
127127

128-
AC_ARG_WITH([apple-libclosure-source],
129-
[AS_HELP_STRING([--with-apple-libclosure-source],
130-
[Specify path to Apple libclosure source])], [
131-
apple_libclosure_source_path=${withval}
132-
CPPFLAGS="$CPPFLAGS -isystem $apple_libclosure_source_path"
133-
])
134-
135128
AC_ARG_WITH([apple-xnu-source],
136129
[AS_HELP_STRING([--with-apple-xnu-source],
137130
[Specify path to Apple XNU source])], [
@@ -143,12 +136,6 @@ AC_ARG_WITH([apple-xnu-source],
143136
CPPFLAGS="$CPPFLAGS -idirafter $apple_xnu_source_libkern_path -isystem $apple_xnu_source_bsd_path -isystem $apple_xnu_source_libsyscall_path -isystem $apple_xnu_source_libproc_path "
144137
])
145138

146-
AC_ARG_WITH([apple-objc4-source],
147-
[AS_HELP_STRING([--with-apple-objc4-source],
148-
[Specify path to Apple objc4 source])], [
149-
apple_objc4_source_runtime_path=${withval}/runtime
150-
])
151-
152139
AC_CACHE_CHECK([for System.framework/PrivateHeaders], dispatch_cv_system_privateheaders,
153140
[AS_IF([test -d /System/Library/Frameworks/System.framework/PrivateHeaders],
154141
[dispatch_cv_system_privateheaders=yes], [dispatch_cv_system_privateheaders=no])]
@@ -387,24 +374,11 @@ AC_CHECK_HEADER([Foundation/Foundation.h],
387374
[have_foundation=true], [have_foundation=false]
388375
)
389376
AM_CONDITIONAL(HAVE_FOUNDATION, $have_foundation)
390-
# hack for objc4/runtime/objc-internal.h
391-
AS_IF([test -n "$apple_objc4_source_runtime_path"], [
392-
saveCPPFLAGS="$CPPFLAGS"
393-
CPPFLAGS="$CPPFLAGS -I."
394-
ln -fsh "$apple_objc4_source_runtime_path" objc
395-
])
396-
AC_CHECK_HEADER([objc/objc-internal.h], [
377+
AC_CHECK_HEADER([objc/runtime.h], [
397378
AC_DEFINE(HAVE_OBJC, 1, [Define if you have the Objective-C runtime])
398379
have_objc=true], [have_objc=false],
399380
[#include <objc/runtime.h>]
400381
)
401-
AS_IF([test -n "$apple_objc4_source_runtime_path"], [
402-
rm -f objc
403-
CPPFLAGS="$saveCPPFLAGS"
404-
AC_CONFIG_COMMANDS([src/objc],
405-
[ln -fsh "$apple_objc4_source_runtime_path" src/objc],
406-
[apple_objc4_source_runtime_path="$apple_objc4_source_runtime_path"])
407-
])
408382
AM_CONDITIONAL(USE_OBJC, $have_objc)
409383
AC_LANG_POP([Objective C])
410384

Diff for: dispatch/dispatch.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#ifdef __APPLE__
2525
#include <Availability.h>
26+
#include <os/availability.h>
2627
#include <TargetConditionals.h>
2728
#include <os/base.h>
2829
#elif defined(__linux__)
@@ -47,7 +48,7 @@
4748
#endif
4849
#endif
4950

50-
#define DISPATCH_API_VERSION 20160831
51+
#define DISPATCH_API_VERSION 20170124
5152

5253
#ifndef __DISPATCH_BUILDING_DISPATCH__
5354

Diff for: dispatch/queue.h

+45-9
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,49 @@ dispatch_sync_f(dispatch_queue_t queue,
206206
void *_Nullable context,
207207
dispatch_function_t work);
208208

209+
210+
#if !defined(__APPLE__) || TARGET_OS_WATCH || TARGET_OS_TV || \
211+
(defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && \
212+
__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_0) || \
213+
(defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \
214+
__MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_9)
215+
#define DISPATCH_APPLY_AUTO_AVAILABLE 1
216+
#else
217+
#define DISPATCH_APPLY_AUTO_AVAILABLE 0
218+
#endif
219+
220+
/*!
221+
* @constant DISPATCH_APPLY_AUTO
222+
*
223+
* @abstract
224+
* Constant to pass to dispatch_apply() or dispatch_apply_f() to request that
225+
* the system automatically use worker threads that match the configuration of
226+
* the current thread most closely.
227+
*
228+
* @discussion
229+
* When submitting a block for parallel invocation, passing this constant as the
230+
* queue argument will automatically use the global concurrent queue that
231+
* matches the Quality of Service of the caller most closely.
232+
*
233+
* No assumptions should be made about which global concurrent queue will
234+
* actually be used.
235+
*
236+
* Using this constant deploys backward to macOS 10.9, iOS 7.0 and any tvOS or
237+
* watchOS version.
238+
*/
239+
#if DISPATCH_APPLY_AUTO_AVAILABLE
240+
#define DISPATCH_APPLY_AUTO ((dispatch_queue_t _Nonnull)0)
241+
#endif
242+
209243
/*!
210244
* @function dispatch_apply
211245
*
212246
* @abstract
213-
* Submits a block to a dispatch queue for multiple invocations.
247+
* Submits a block to a dispatch queue for parallel invocation.
214248
*
215249
* @discussion
216-
* Submits a block to a dispatch queue for multiple invocations. This function
217-
* waits for the task block to complete before returning. If the target queue
250+
* Submits a block to a dispatch queue for parallel invocation. This function
251+
* waits for the task block to complete before returning. If the specified queue
218252
* is concurrent, the block may be invoked concurrently, and it must therefore
219253
* be reentrant safe.
220254
*
@@ -224,8 +258,9 @@ dispatch_sync_f(dispatch_queue_t queue,
224258
* The number of iterations to perform.
225259
*
226260
* @param queue
227-
* The target dispatch queue to which the block is submitted.
228-
* The result of passing NULL in this parameter is undefined.
261+
* The dispatch queue to which the block is submitted.
262+
* The preferred value to pass is DISPATCH_APPLY_AUTO to automatically use
263+
* a queue appropriate for the calling thread.
229264
*
230265
* @param block
231266
* The block to be invoked the specified number of iterations.
@@ -243,7 +278,7 @@ dispatch_apply(size_t iterations, dispatch_queue_t queue,
243278
* @function dispatch_apply_f
244279
*
245280
* @abstract
246-
* Submits a function to a dispatch queue for multiple invocations.
281+
* Submits a function to a dispatch queue for parallel invocation.
247282
*
248283
* @discussion
249284
* See dispatch_apply() for details.
@@ -252,14 +287,15 @@ dispatch_apply(size_t iterations, dispatch_queue_t queue,
252287
* The number of iterations to perform.
253288
*
254289
* @param queue
255-
* The target dispatch queue to which the function is submitted.
256-
* The result of passing NULL in this parameter is undefined.
290+
* The dispatch queue to which the function is submitted.
291+
* The preferred value to pass is DISPATCH_APPLY_AUTO to automatically use
292+
* a queue appropriate for the calling thread.
257293
*
258294
* @param context
259295
* The application-defined context parameter to pass to the function.
260296
*
261297
* @param work
262-
* The application-defined function to invoke on the target queue. The first
298+
* The application-defined function to invoke on the specified queue. The first
263299
* parameter passed to this function is the context provided to
264300
* dispatch_apply_f(). The second parameter passed to this function is the
265301
* current index of iteration.

0 commit comments

Comments
 (0)