Skip to content

Commit acb1b1e

Browse files
authored
Merge pull request #252 from apple/das-darwin-008-merge-master
Merge tag darwin/darwin-008 on darwin/trunk.
2 parents 5a3c02a + 81a67c9 commit acb1b1e

File tree

11 files changed

+71
-54
lines changed

11 files changed

+71
-54
lines changed

PATCHES

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,23 @@ github commits starting with 29bdc2f from
312312
[787dd92] APPLIED rdar://30568673
313313
[ba4cac5] APPLIED rdar://30568673
314314
[7974138] APPLIED rdar://30568673
315+
[cd12dcb] APPLIED rdar://32283666
316+
[ff05109] APPLIED rdar://32283666
317+
[73315ee] APPLIED rdar://32283666
318+
[fcc1924] APPLIED rdar://32283666
319+
[272e818] APPLIED rdar://32283666
320+
[b6f8908] APPLIED rdar://32283666
321+
[a6c16d0] APPLIED rdar://32283666
322+
[1cc64e1] APPLIED rdar://32283666
323+
[d137aa4] APPLIED rdar://32283666
324+
[a69853f] APPLIED rdar://32283666
325+
[eea0667] APPLIED rdar://32283666
326+
[f84d21d] APPLIED rdar://32283666
327+
[3da8398] APPLIED rdar://32283666
328+
[2df80a3] APPLIED rdar://32283666
329+
[97a2f06] APPLIED rdar://32283666
330+
[f76b8f5] APPLIED rdar://32283666
331+
[3828fbb] APPLIED rdar://32283666
332+
[5e8789e] APPLIED rdar://32283666
333+
[3fba60a] APPLIED rdar://32283666
334+
[d6eb245] APPLIED rdar://32283666

dispatch/dispatch.h

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,17 @@
2424
#ifdef __APPLE__
2525
#include <Availability.h>
2626
#include <TargetConditionals.h>
27-
#else
28-
#ifndef API_AVAILABLE
29-
#define API_AVAILABLE(...)
27+
#include <os/base.h>
28+
#elif defined(__linux__)
29+
#include <os/linux_base.h>
3030
#endif
31-
#ifndef API_DEPRECATED
32-
#define API_DEPRECATED(...)
33-
#endif
34-
#ifndef API_UNAVAILABLE
35-
#define API_UNAVAILABLE(...)
36-
#endif
37-
#ifndef API_DEPRECATED_WITH_REPLACEMENT
38-
#define API_DEPRECATED_WITH_REPLACEMENT(...)
39-
#endif
40-
#endif // __APPLE__
4131

42-
#if HAVE_SYS_CDEFS_H
43-
#include <sys/cdefs.h>
44-
#endif
4532
#include <sys/types.h>
4633
#include <stddef.h>
4734
#include <stdint.h>
4835
#include <stdbool.h>
4936
#include <stdarg.h>
50-
#if HAVE_UNISTD_H
37+
#if !defined(HAVE_UNISTD_H) || HAVE_UNISTD_H
5138
#include <unistd.h>
5239
#endif
5340
#include <fcntl.h>

os/linux_base.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,23 @@
1515

1616
#include <sys/param.h>
1717

18+
#if HAVE_SYS_CDEFS_H
19+
#include <sys/cdefs.h>
20+
#endif
21+
22+
#ifndef API_AVAILABLE
23+
#define API_AVAILABLE(...)
24+
#endif
25+
#ifndef API_DEPRECATED
26+
#define API_DEPRECATED(...)
27+
#endif
28+
#ifndef API_UNAVAILABLE
29+
#define API_UNAVAILABLE(...)
30+
#endif
31+
#ifndef API_DEPRECATED_WITH_REPLACEMENT
32+
#define API_DEPRECATED_WITH_REPLACEMENT(...)
33+
#endif
34+
1835
#if __GNUC__
1936
#define OS_EXPECT(x, v) __builtin_expect((x), (v))
2037
#define OS_UNUSED __attribute__((__unused__))

os/object.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,11 @@
2323

2424
#ifdef __APPLE__
2525
#include <Availability.h>
26-
#include <TargetConditionals.h>
2726
#include <os/availability.h>
28-
#endif
29-
#ifdef __linux__
30-
#include <os/linux_base.h>
31-
#else
27+
#include <TargetConditionals.h>
3228
#include <os/base.h>
29+
#elif defined(__linux__)
30+
#include <os/linux_base.h>
3331
#endif
3432

3533
/*!

os/object_private.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,9 @@
2727
#ifndef __OS_OBJECT_PRIVATE__
2828
#define __OS_OBJECT_PRIVATE__
2929

30-
#if HAVE_SYS_CDEFS_H
31-
#include <sys/cdefs.h>
32-
#endif
33-
#include <stddef.h>
3430
#include <os/object.h>
35-
36-
#ifndef API_AVAILABLE
37-
#define API_AVAILABLE(...)
38-
#endif
31+
#include <stddef.h>
32+
#include <stdint.h>
3933

4034
#if __GNUC__
4135
#define OS_OBJECT_NOTHROW __attribute__((__nothrow__))

src/apply.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,20 +234,21 @@ dispatch_apply_f(size_t iterations, dispatch_queue_t dq, void *ctxt,
234234
if (slowpath(iterations == 0)) {
235235
return;
236236
}
237-
int32_t thr_cnt = dispatch_hw_config(active_cpus);
238-
dispatch_thread_context_t dtctxt = _dispatch_thread_context_find(_dispatch_apply_key);
237+
int32_t thr_cnt = (int32_t)dispatch_hw_config(active_cpus);
238+
dispatch_thread_context_t dtctxt =
239+
_dispatch_thread_context_find(_dispatch_apply_key);
239240
size_t nested = dtctxt ? dtctxt->dtc_apply_nesting : 0;
240241
dispatch_queue_t old_dq = _dispatch_queue_get_current();
241242

242243
if (!slowpath(nested)) {
243244
nested = iterations;
244245
} else {
245-
thr_cnt = nested < thr_cnt ? thr_cnt / nested : 1;
246+
thr_cnt = nested < (size_t)thr_cnt ? thr_cnt / (int32_t)nested : 1;
246247
nested = nested < DISPATCH_APPLY_MAX && iterations < DISPATCH_APPLY_MAX
247248
? nested * iterations : DISPATCH_APPLY_MAX;
248249
}
249-
if (iterations < thr_cnt) {
250-
thr_cnt = iterations;
250+
if (iterations < (size_t)thr_cnt) {
251+
thr_cnt = (int32_t)iterations;
251252
}
252253
if (slowpath(dq == DISPATCH_APPLY_CURRENT_ROOT_QUEUE)) {
253254
dq = old_dq ? old_dq : _dispatch_get_root_queue(

src/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ _dispatch_sigmask(void)
9292
r |= sigdelset(&mask, SIGPIPE);
9393
r |= sigdelset(&mask, SIGPROF);
9494
r |= pthread_sigmask(SIG_BLOCK, &mask, NULL);
95-
(void)dispatch_assume_zero(r);
95+
return dispatch_assume_zero(r);
9696
}
9797

9898
#pragma mark -

src/inline_internal.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -592,30 +592,30 @@ _dq_state_has_side_suspend_cnt(uint64_t dq_state)
592592
}
593593

594594
DISPATCH_ALWAYS_INLINE
595-
static inline uint32_t
595+
static inline int32_t
596596
_dq_state_extract_width_bits(uint64_t dq_state)
597597
{
598598
dq_state &= DISPATCH_QUEUE_WIDTH_MASK;
599-
return (uint32_t)(dq_state >> DISPATCH_QUEUE_WIDTH_SHIFT);
599+
return (int32_t)(dq_state >> DISPATCH_QUEUE_WIDTH_SHIFT);
600600
}
601601

602602
DISPATCH_ALWAYS_INLINE
603-
static inline uint32_t
603+
static inline int32_t
604604
_dq_state_available_width(uint64_t dq_state)
605605
{
606-
uint32_t full = DISPATCH_QUEUE_WIDTH_FULL;
606+
int32_t full = DISPATCH_QUEUE_WIDTH_FULL;
607607
if (likely(!(dq_state & DISPATCH_QUEUE_WIDTH_FULL_BIT))) {
608608
return full - _dq_state_extract_width_bits(dq_state);
609609
}
610610
return 0;
611611
}
612612

613613
DISPATCH_ALWAYS_INLINE
614-
static inline uint32_t
614+
static inline int32_t
615615
_dq_state_used_width(uint64_t dq_state, uint16_t dq_width)
616616
{
617-
uint32_t full = DISPATCH_QUEUE_WIDTH_FULL;
618-
uint32_t width = _dq_state_extract_width_bits(dq_state);
617+
int32_t full = DISPATCH_QUEUE_WIDTH_FULL;
618+
int32_t width = _dq_state_extract_width_bits(dq_state);
619619

620620
if (dq_state & DISPATCH_QUEUE_PENDING_BARRIER) {
621621
// DISPATCH_QUEUE_PENDING_BARRIER means (dq_width - 1) of the used width
@@ -1030,21 +1030,21 @@ _dispatch_queue_try_reserve_sync_width(dispatch_queue_t dq)
10301030
* possibly 0
10311031
*/
10321032
DISPATCH_ALWAYS_INLINE DISPATCH_WARN_RESULT
1033-
static inline uint32_t
1034-
_dispatch_queue_try_reserve_apply_width(dispatch_queue_t dq, uint32_t da_width)
1033+
static inline int32_t
1034+
_dispatch_queue_try_reserve_apply_width(dispatch_queue_t dq, int32_t da_width)
10351035
{
10361036
uint64_t old_state, new_state;
1037-
uint32_t width;
1037+
int32_t width;
10381038

10391039
(void)os_atomic_rmw_loop2o(dq, dq_state, old_state, new_state, relaxed, {
1040-
width = _dq_state_available_width(old_state);
1040+
width = (int32_t)_dq_state_available_width(old_state);
10411041
if (unlikely(!width)) {
10421042
os_atomic_rmw_loop_give_up(return 0);
10431043
}
10441044
if (width > da_width) {
10451045
width = da_width;
10461046
}
1047-
new_state = old_state + width * DISPATCH_QUEUE_WIDTH_INTERVAL;
1047+
new_state = old_state + (uint64_t)width * DISPATCH_QUEUE_WIDTH_INTERVAL;
10481048
});
10491049
return width;
10501050
}
@@ -1055,10 +1055,10 @@ _dispatch_queue_try_reserve_apply_width(dispatch_queue_t dq, uint32_t da_width)
10551055
*/
10561056
DISPATCH_ALWAYS_INLINE
10571057
static inline void
1058-
_dispatch_queue_relinquish_width(dispatch_queue_t dq, uint32_t da_width)
1058+
_dispatch_queue_relinquish_width(dispatch_queue_t dq, int32_t da_width)
10591059
{
10601060
(void)os_atomic_sub2o(dq, dq_state,
1061-
da_width * DISPATCH_QUEUE_WIDTH_INTERVAL, relaxed);
1061+
(uint64_t)da_width * DISPATCH_QUEUE_WIDTH_INTERVAL, relaxed);
10621062
}
10631063

10641064
/* Used by target-queue recursing code
@@ -1474,7 +1474,7 @@ _dispatch_queue_push_update_head(dispatch_queue_t dq,
14741474
DISPATCH_ALWAYS_INLINE
14751475
static inline void
14761476
_dispatch_root_queue_push_inline(dispatch_queue_t dq, dispatch_object_t _head,
1477-
dispatch_object_t _tail, unsigned int n)
1477+
dispatch_object_t _tail, int n)
14781478
{
14791479
struct dispatch_object_s *head = _head._do, *tail = _tail._do;
14801480
if (unlikely(_dispatch_queue_push_update_tail_list(dq, head, tail))) {

src/queue.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ _dispatch_root_queue_init_pthread_pool(dispatch_root_queue_context_t qc,
695695
{
696696
dispatch_pthread_root_queue_context_t pqc = qc->dgq_ctxt;
697697
int32_t thread_pool_size = overcommit ? DISPATCH_WORKQ_MAX_PTHREAD_COUNT :
698-
dispatch_hw_config(active_cpus);
698+
(int32_t)dispatch_hw_config(active_cpus);
699699
if (slowpath(pool_size) && pool_size < thread_pool_size) {
700700
thread_pool_size = pool_size;
701701
}

src/shims.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
#endif // HAVE_PTHREAD_WORKQUEUES
5151

5252
#if DISPATCH_USE_INTERNAL_WORKQUEUE
53-
#include <event/workqueue_internal.h>
53+
#include "event/workqueue_internal.h"
5454
#endif
5555

5656
#if HAVE_PTHREAD_NP_H

src/trace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ _dispatch_trace_client_callout2(void *ctxt, size_t i, void (*f)(void *, size_t))
132132
DISPATCH_ALWAYS_INLINE
133133
static inline void
134134
_dispatch_trace_root_queue_push_list(dispatch_queue_t dq,
135-
dispatch_object_t _head, dispatch_object_t _tail, unsigned int n)
135+
dispatch_object_t _head, dispatch_object_t _tail, int n)
136136
{
137137
if (slowpath(DISPATCH_QUEUE_PUSH_ENABLED())) {
138138
struct dispatch_object_s *dou = _head._do;

0 commit comments

Comments
 (0)