Skip to content

Commit 5e87d7c

Browse files
committed
fix build failures due to signed vs unsigned warnings
Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
1 parent 2e6188e commit 5e87d7c

File tree

4 files changed

+23
-22
lines changed

4 files changed

+23
-22
lines changed

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/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
@@ -694,7 +694,7 @@ _dispatch_root_queue_init_pthread_pool(dispatch_root_queue_context_t qc,
694694
{
695695
dispatch_pthread_root_queue_context_t pqc = qc->dgq_ctxt;
696696
int32_t thread_pool_size = overcommit ? DISPATCH_WORKQ_MAX_PTHREAD_COUNT :
697-
dispatch_hw_config(active_cpus);
697+
(int32_t)dispatch_hw_config(active_cpus);
698698
if (slowpath(pool_size) && pool_size < thread_pool_size) {
699699
thread_pool_size = pool_size;
700700
}

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)