Skip to content

Commit f932a06

Browse files
committed
merge darwin/darwin-006
2 parents 8976101 + cf8aae4 commit f932a06

33 files changed

+575
-394
lines changed

PATCHES

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,29 @@ github commits starting with 29bdc2f from
241241
[4a6ec51] APPLIED rdar://25159995
242242
[bc16cc9] APPLIED rdar://25159995
243243
[954ace4] APPLIED rdar://25159995
244+
[5ea30b5] APPLIED rdar://26822213
245+
[9f1e778] APPLIED rdar://26822213
246+
[3339b81] APPLIED rdar://26822213
247+
[4fa8d8d] APPLIED rdar://26822213
248+
[e922531] APPLIED rdar://26822213
249+
[195cbcf] APPLIED rdar://27303844
250+
[5b893c8] APPLIED rdar://27303844
251+
[92689ed] APPLIED rdar://27303844
252+
[ecc14fa] APPLIED rdar://27303844
253+
[2dbf83c] APPLIED rdar://27303844
254+
[78b9e82] APPLIED rdar://27303844
255+
[2c0e5ee] APPLIED rdar://27303844
256+
[5ee237f] APPLIED rdar://27600964
257+
[77299ec] APPLIED rdar://27600964
258+
[57c5c28] APPLIED rdar://27600964
259+
[f8423ec] APPLIED rdar://27600964
260+
[325f73d] APPLIED rdar://27600964
261+
[b84e87e] APPLIED rdar://27600964
262+
[ae71a91] APPLIED rdar://27600964
263+
[8669dea] APPLIED rdar://27600964
264+
[a8d0327] APPLIED rdar://27600964
265+
[2e4e6af] APPLIED rdar://27600964
266+
[2457fb2] APPLIED rdar://27600964
267+
[4d58038] APPLIED rdar://27600964
268+
[98d0a05] APPLIED rdar://27600964
269+
[8976101] APPLIED rdar://27600964

config/config.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
don't. */
1414
#define HAVE_DECL_FD_COPY 1
1515

16+
/* Define to 1 if you have the declaration of `NOTE_LOWAT', and to 0 if you
17+
don't. */
18+
#define HAVE_DECL_NOTE_LOWAT 1
19+
1620
/* Define to 1 if you have the declaration of `NOTE_NONE', and to 0 if you
1721
don't. */
1822
#define HAVE_DECL_NOTE_NONE 1

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ AC_CHECK_FUNCS([mach_port_construct])
353353
#
354354
AC_CHECK_DECLS([CLOCK_UPTIME, CLOCK_MONOTONIC], [], [],
355355
[[#include <time.h>]])
356-
AC_CHECK_DECLS([NOTE_NONE, NOTE_REAP, NOTE_REVOKE, NOTE_SIGNAL], [], [],
356+
AC_CHECK_DECLS([NOTE_NONE, NOTE_REAP, NOTE_REVOKE, NOTE_SIGNAL, NOTE_LOWAT], [], [],
357357
[[#include <sys/event.h>]])
358358
AC_CHECK_DECLS([FD_COPY], [], [], [[#include <sys/select.h>]])
359359
AC_CHECK_DECLS([SIGEMT], [], [], [[#include <signal.h>]])

dispatch/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ dispatch_HEADERS= \
2424
time.h
2525

2626
if HAVE_SWIFT
27-
dispatch_HEADERS+=module.modulemap
27+
dispatch_HEADERS+=module.map
2828
endif

dispatch/base.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
#define DISPATCH_MALLOC __attribute__((__malloc__))
6565
#define DISPATCH_ALWAYS_INLINE __attribute__((__always_inline__))
6666
#define DISPATCH_UNAVAILABLE __attribute__((__unavailable__))
67+
#define DISPATCH_UNAVAILABLE_MSG(msg) __attribute__((__unavailable__(msg)))
6768
#else
6869
/*! @parseOnly */
6970
#define DISPATCH_NORETURN
@@ -99,6 +100,16 @@
99100
#define DISPATCH_ALWAYS_INLINE
100101
/*! @parseOnly */
101102
#define DISPATCH_UNAVAILABLE
103+
/*! @parseOnly */
104+
#define DISPATCH_UNAVAILABLE_MSG(msg)
105+
#endif
106+
107+
#ifdef __linux__
108+
#define DISPATCH_LINUX_UNAVAILABLE() \
109+
DISPATCH_UNAVAILABLE_MSG( \
110+
"This interface is unavailable on linux systems")
111+
#else
112+
#define DISPATCH_LINUX_UNAVAILABLE()
102113
#endif
103114

104115
#ifndef DISPATCH_ALIAS_V2

dispatch/dispatch.h

Lines changed: 16 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -24,71 +24,36 @@
2424
#ifdef __APPLE__
2525
#include <Availability.h>
2626
#include <TargetConditionals.h>
27-
#endif
28-
#include <sys/cdefs.h>
29-
#include <sys/types.h>
30-
#include <stddef.h>
31-
#include <stdint.h>
32-
#include <stdbool.h>
33-
#include <stdarg.h>
34-
#include <unistd.h>
35-
#include <fcntl.h>
36-
37-
#ifdef __has_attribute
38-
#if __has_attribute(unavailable)
39-
#define __DISPATCH_UNAVAILABLE(msg) __attribute__((__unavailable__(msg)))
40-
#endif
41-
#endif
42-
#ifndef __DISPATCH_UNAVAILABLE
43-
#define __DISPATCH_UNAVAILABLE(msg)
44-
#endif
45-
46-
#ifdef __linux__
47-
#if __has_feature(modules)
48-
#include <stdio.h> // for off_t (to match Glibc.modulemap)
49-
#endif
50-
#define DISPATCH_LINUX_UNAVAILABLE() \
51-
__DISPATCH_UNAVAILABLE("This interface is unavailable on linux systems")
5227
#else
53-
#define DISPATCH_LINUX_UNAVAILABLE()
54-
#endif
55-
56-
#ifndef __OSX_AVAILABLE_STARTING
5728
#define __OSX_AVAILABLE_STARTING(x, y)
58-
#endif
59-
#ifndef __OSX_AVAILABLE_BUT_DEPRECATED
6029
#define __OSX_AVAILABLE_BUT_DEPRECATED(...)
61-
#endif
62-
#ifndef __OSX_AVAILABLE_BUT_DEPRECATED_MSG
6330
#define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(...)
64-
#endif
65-
66-
#ifndef __OSX_AVAILABLE
6731
#define __OSX_AVAILABLE(...)
68-
#endif
69-
#ifndef __IOS_AVAILABLE
7032
#define __IOS_AVAILABLE(...)
71-
#endif
72-
#ifndef __TVOS_AVAILABLE
7333
#define __TVOS_AVAILABLE(...)
74-
#endif
75-
#ifndef __WATCHOS_AVAILABLE
7634
#define __WATCHOS_AVAILABLE(...)
77-
#endif
78-
#ifndef __OSX_DEPRECATED
7935
#define __OSX_DEPRECATED(...)
80-
#endif
81-
#ifndef __IOS_DEPRECATED
8236
#define __IOS_DEPRECATED(...)
83-
#endif
84-
#ifndef __TVOS_DEPRECATED
8537
#define __TVOS_DEPRECATED(...)
86-
#endif
87-
#ifndef __WATCHOS_DEPRECATED
8838
#define __WATCHOS_DEPRECATED(...)
39+
#endif // __APPLE__
40+
41+
#include <sys/cdefs.h>
42+
#include <sys/types.h>
43+
#include <stddef.h>
44+
#include <stdint.h>
45+
#include <stdbool.h>
46+
#include <stdarg.h>
47+
#include <unistd.h>
48+
#include <fcntl.h>
49+
50+
#if defined(__linux__) && defined(__has_feature)
51+
#if __has_feature(modules)
52+
#include <stdio.h> // for off_t (to match Glibc.modulemap)
53+
#endif
8954
#endif
9055

91-
#define DISPATCH_API_VERSION 20160612
56+
#define DISPATCH_API_VERSION 20160712
9257

9358
#ifndef __DISPATCH_BUILDING_DISPATCH__
9459

dispatch/group.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ dispatch_group_async_f(dispatch_group_t group,
134134
* @discussion
135135
* This function waits for the completion of the blocks associated with the
136136
* given dispatch group, and returns after all blocks have completed or when
137-
* the specified timeout has elapsed. When a timeout occurs, the group is
138-
* restored to its original state.
137+
* the specified timeout has elapsed.
139138
*
140139
* This function will return immediately if there are no blocks associated
141140
* with the dispatch group (i.e. the group is empty).
@@ -262,7 +261,7 @@ dispatch_group_enter(dispatch_group_t group);
262261
*
263262
* @discussion
264263
* Calling this function indicates block has completed and left the dispatch
265-
* groupJ by a means other than dispatch_group_async().
264+
* group by a means other than dispatch_group_async().
266265
*
267266
* @param group
268267
* The dispatch group to update.

dispatch/module.map

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module Dispatch {
2+
requires blocks
3+
export *
4+
link "dispatch"
5+
link "BlocksRuntime"
6+
}
7+
8+
module DispatchIntrospection [system] [extern_c] {
9+
header "introspection.h"
10+
export *
11+
}
12+
13+
module CDispatch [system] [extern_c] {
14+
umbrella header "dispatch.h"
15+
module * { export * }
16+
export *
17+
requires blocks
18+
link "dispatch"
19+
link "BlocksRuntime"
20+
}

dispatch/module.modulemap

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
1-
module Dispatch {
2-
requires blocks
1+
module Dispatch [system] [extern_c] {
2+
umbrella header "dispatch.h"
3+
module * { export * }
34
export *
4-
link "dispatch"
5-
link "BlocksRuntime"
65
}
76

87
module DispatchIntrospection [system] [extern_c] {
98
header "introspection.h"
109
export *
1110
}
12-
13-
module CDispatch [system] [extern_c] {
14-
umbrella header "dispatch.h"
15-
module * { export * }
16-
export *
17-
requires blocks
18-
link "dispatch"
19-
link "BlocksRuntime"
20-
}

man/dispatch_source_create.3

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ Sources of this type allow applications to manually trigger the source's event
271271
handler via a call to
272272
.Fn dispatch_source_merge_data .
273273
The data will be merged with the source's pending data via an atomic add or
274-
logic OR (based on the source's type), and the event handler block will be
275-
submitted to the source's target queue. The
274+
atomic bitwise OR (based on the source's type), and the event handler block will
275+
be submitted to the source's target queue. The
276276
.Fa data
277277
is application defined. These sources have no
278278
.Fa handle
@@ -297,7 +297,8 @@ The data returned by
297297
.Fn dispatch_source_get_data
298298
indicates which of the events in the
299299
.Fa mask
300-
were observed. Note that because this source type will request notifications on the provided port, it should not be mixed with the use of
300+
were observed. Note that because this source type will request notifications on
301+
the provided port, it should not be mixed with the use of
301302
.Fn mach_port_request_notification
302303
on the same port.
303304
.Pp
@@ -314,8 +315,8 @@ on the mach port is waiting to be received.
314315
.Pp
315316
.Vt DISPATCH_SOURCE_TYPE_MEMORYPRESSURE
316317
.Pp
317-
Sources of this type monitor the system memory pressure condition for state changes.
318-
The
318+
Sources of this type monitor the system memory pressure condition for state
319+
changes. The
319320
.Fa handle
320321
is unused and should be zero. The
321322
.Fa mask

os/firehose_buffer_private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ typedef struct firehose_buffer_chunk_s {
6969
uint8_t fbc_data[FIREHOSE_BUFFER_CHUNK_SIZE
7070
- sizeof(firehose_buffer_pos_u)
7171
- sizeof(uint64_t)];
72-
} *firehose_buffer_chunk_t;
72+
} __attribute__((aligned(8))) *firehose_buffer_chunk_t;
7373

7474
typedef struct firehose_buffer_range_s {
7575
uint16_t fbr_offset; // offset from the start of the buffer

private/private.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
#endif /* !__DISPATCH_BUILDING_DISPATCH__ */
6767

6868
// <rdar://problem/9627726> Check that public and private dispatch headers match
69-
#if DISPATCH_API_VERSION != 20160612 // Keep in sync with <dispatch/dispatch.h>
69+
#if DISPATCH_API_VERSION != 20160712 // Keep in sync with <dispatch/dispatch.h>
7070
#error "Dispatch header mismatch between /usr/include and /usr/local/include"
7171
#endif
7272

@@ -199,10 +199,17 @@ DISPATCH_EXPORT DISPATCH_NOTHROW
199199
dispatch_runloop_handle_t
200200
_dispatch_get_main_queue_handle_4CF(void);
201201

202+
#if TARGET_OS_MAC
203+
__OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
204+
DISPATCH_EXPORT DISPATCH_NOTHROW
205+
void
206+
_dispatch_main_queue_callback_4CF(mach_msg_header_t *_Null_unspecified msg);
207+
#else
202208
__OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_4_0)
203209
DISPATCH_EXPORT DISPATCH_NOTHROW
204210
void
205211
_dispatch_main_queue_callback_4CF(void *_Null_unspecified msg);
212+
#endif
206213

207214
__OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0)
208215
DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT

private/queue_private.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,23 @@ dispatch_pthread_root_queue_flags_pool_size(uint8_t pool_size)
227227

228228
#endif /* __BLOCKS__ */
229229

230+
/*!
231+
* @function dispatch_pthread_root_queue_copy_current
232+
*
233+
* @abstract
234+
* Returns a reference to the pthread root queue object that has created the
235+
* currently executing thread, or NULL if the current thread is not associated
236+
* to a pthread root queue.
237+
*
238+
* @result
239+
* A new reference to a pthread root queue object or NULL.
240+
*/
241+
__OSX_AVAILABLE(10.12) __IOS_AVAILABLE(10.0)
242+
__TVOS_AVAILABLE(10.0) __WATCHOS_AVAILABLE(3.0)
243+
DISPATCH_EXPORT DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT DISPATCH_NOTHROW
244+
dispatch_queue_t _Nullable
245+
dispatch_pthread_root_queue_copy_current(void);
246+
230247
/*!
231248
* @constant DISPATCH_APPLY_CURRENT_ROOT_QUEUE
232249
* @discussion Constant to pass to the dispatch_apply() and dispatch_apply_f()

src/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ SWIFT_GEN_FILES= \
157157
$(SWIFT_OBJ_FILES:%=%.~partial.swiftdoc) \
158158
$(SWIFT_OBJ_FILES:%=%.~partial.swiftdeps)
159159

160-
SWIFTC_FLAGS = -Xcc -fmodule-map-file=$(abs_top_srcdir)/dispatch/module.modulemap -I$(abs_top_srcdir) -Xcc -fblocks
160+
SWIFTC_FLAGS = -Xcc -fmodule-map-file=$(abs_top_srcdir)/dispatch/module.map -I$(abs_top_srcdir) -Xcc -fblocks
161161
if DISPATCH_ENABLE_OPTIMIZATION
162162
SWIFTC_FLAGS+=-O
163163
endif

src/apply.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ _dispatch_apply_invoke2(void *ctxt, long invoke_flags)
8787
_dispatch_thread_event_destroy(&da->da_event);
8888
}
8989
if (os_atomic_dec2o(da, da_thr_cnt, release) == 0) {
90+
#if DISPATCH_INTROSPECTION
91+
_dispatch_continuation_free(da->da_dc);
92+
#endif
9093
_dispatch_continuation_free((dispatch_continuation_t)da);
9194
}
9295
}
@@ -145,6 +148,9 @@ _dispatch_apply_serial(void *ctxt)
145148
});
146149
} while (++idx < iter);
147150

151+
#if DISPATCH_INTROSPECTION
152+
_dispatch_continuation_free(da->da_dc);
153+
#endif
148154
_dispatch_continuation_free((dispatch_continuation_t)da);
149155
}
150156

@@ -262,7 +268,12 @@ dispatch_apply_f(size_t iterations, dispatch_queue_t dq, void *ctxt,
262268
da->da_iterations = iterations;
263269
da->da_nested = nested;
264270
da->da_thr_cnt = thr_cnt;
271+
#if DISPATCH_INTROSPECTION
272+
da->da_dc = _dispatch_continuation_alloc();
273+
*da->da_dc = dc;
274+
#else
265275
da->da_dc = &dc;
276+
#endif
266277
da->da_flags = 0;
267278

268279
if (slowpath(dq->dq_width == 1) || slowpath(thr_cnt <= 1)) {

src/data.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,12 @@ const dispatch_block_t _dispatch_data_destructor_none = ^{
108108
DISPATCH_INTERNAL_CRASH(0, "none destructor called");
109109
};
110110

111+
#if !HAVE_MACH
111112
const dispatch_block_t _dispatch_data_destructor_munmap = ^{
112113
DISPATCH_INTERNAL_CRASH(0, "munmap destructor called");
113114
};
114-
115-
#ifndef __linux__
115+
#else
116+
// _dispatch_data_destructor_munmap is a linker alias to the following
116117
const dispatch_block_t _dispatch_data_destructor_vm_deallocate = ^{
117118
DISPATCH_INTERNAL_CRASH(0, "vmdeallocate destructor called");
118119
};
@@ -253,7 +254,7 @@ dispatch_data_create_f(const void *buffer, size_t size, dispatch_queue_t queue,
253254
if (destructor != DISPATCH_DATA_DESTRUCTOR_DEFAULT &&
254255
destructor != DISPATCH_DATA_DESTRUCTOR_FREE &&
255256
destructor != DISPATCH_DATA_DESTRUCTOR_NONE &&
256-
#ifndef __linux__
257+
#if HAVE_MACH
257258
destructor != DISPATCH_DATA_DESTRUCTOR_VM_DEALLOCATE &&
258259
#endif
259260
destructor != DISPATCH_DATA_DESTRUCTOR_INLINE) {

0 commit comments

Comments
 (0)