Skip to content

Commit 4bf826d

Browse files
authored
Merge pull request #758 from grynspan/jgrynspan/fix-windows-warnings
Fix a number of warnings when building on Windows
2 parents ecc678d + cc9c82e commit 4bf826d

File tree

7 files changed

+24
-22
lines changed

7 files changed

+24
-22
lines changed

Diff for: src/event/event.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -766,9 +766,9 @@ _dispatch_timer_heap_update(dispatch_timer_heap_t dth,
766766
#pragma mark timer unote
767767

768768
#define _dispatch_timer_du_debug(what, du) \
769-
_dispatch_debug("kevent-source[%p]: %s kevent[%p] { ident = 0x%x }", \
769+
_dispatch_debug("kevent-source[%p]: %s kevent[%p] { ident = 0x%llx }", \
770770
_dispatch_wref2ptr((du)->du_owner_wref), what, \
771-
(du), (du)->du_ident)
771+
(du), (unsigned long long)((du)->du_ident))
772772

773773
DISPATCH_ALWAYS_INLINE
774774
static inline unsigned int

Diff for: src/event/workqueue.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ _dispatch_workq_count_runnable_workers(dispatch_workq_monitor_t mon)
226226
// and Socket IO, but it is unclear if that includes normal IO.
227227
HANDLE hThread = OpenThread(THREAD_QUERY_INFORMATION, FALSE, tid);
228228
if (hThread == NULL) {
229-
_dispatch_debug("workq: unable to open thread %u: %u", tid, GetLastError());
229+
_dispatch_debug("workq: unable to open thread %lu: %lu", tid, GetLastError());
230230
continue;
231231
}
232232

Diff for: src/init.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -931,14 +931,14 @@ _dispatch_fault(const char *reason, const char *fmt, ...)
931931
})
932932

933933
void
934-
_dispatch_bug(size_t line, long val)
934+
_dispatch_bug(size_t line, uintptr_t val)
935935
{
936936
dispatch_once_f(&_dispatch_build_pred, NULL, _dispatch_build_init);
937937

938938
if (_dispatch_bug_log_is_repeated()) return;
939939

940-
_dispatch_log("BUG in libdispatch: %s - %lu - 0x%lx",
941-
_dispatch_build, (unsigned long)line, val);
940+
_dispatch_log("BUG in libdispatch: %s - %lu - 0x%llx",
941+
_dispatch_build, (unsigned long)line, (unsigned long long)val);
942942
}
943943

944944
#if HAVE_MACH
@@ -1066,7 +1066,7 @@ _dispatch_bug_deprecated(const char *msg)
10661066
}
10671067

10681068
void
1069-
_dispatch_abort(size_t line, long val)
1069+
_dispatch_abort(size_t line, uintptr_t val)
10701070
{
10711071
_dispatch_bug(line, val);
10721072
abort();
@@ -1150,7 +1150,7 @@ _dispatch_logv_init(void *context DISPATCH_UNUSED)
11501150
szProgramName, GetCurrentProcessId(), tv.tv_sec,
11511151
(int)tv.tv_usec);
11521152
if (len > 0) {
1153-
len = MIN(len, sizeof(szMessage) - 1);
1153+
len = MIN(len, (int)sizeof(szMessage) - 1);
11541154
_write(dispatch_logfile, szMessage, len);
11551155
_write(dispatch_logfile, "\n", 1);
11561156
}

Diff for: src/internal.h

+10-10
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ DISPATCH_EXPORT DISPATCH_NOTHROW void dispatch_atfork_child(void);
466466
extern uint8_t _dispatch_mode;
467467

468468
DISPATCH_EXPORT DISPATCH_NOINLINE DISPATCH_COLD
469-
void _dispatch_bug(size_t line, long val);
469+
void _dispatch_bug(size_t line, uintptr_t val);
470470

471471
#if HAVE_MACH
472472
DISPATCH_NOINLINE DISPATCH_COLD
@@ -489,7 +489,7 @@ DISPATCH_NOINLINE DISPATCH_COLD
489489
void _dispatch_bug_deprecated(const char *msg);
490490

491491
DISPATCH_NOINLINE DISPATCH_NORETURN DISPATCH_COLD
492-
void _dispatch_abort(size_t line, long val);
492+
void _dispatch_abort(size_t line, uintptr_t val);
493493

494494
#if !defined(DISPATCH_USE_OS_DEBUG_LOG) && DISPATCH_DEBUG
495495
#if __has_include(<os/debug_private.h>)
@@ -549,23 +549,23 @@ void _dispatch_log(const char *msg, ...);
549549
*/
550550
DISPATCH_ALWAYS_INLINE
551551
static inline void
552-
_dispatch_assert(long e, size_t line) DISPATCH_STATIC_ASSERT_IF(!e)
552+
_dispatch_assert(uintptr_t e, size_t line) DISPATCH_STATIC_ASSERT_IF(!e)
553553
{
554554
if (unlikely(DISPATCH_DEBUG && !e)) _dispatch_abort(line, e);
555555
}
556-
#define dispatch_assert(e) _dispatch_assert((long)(e), __LINE__)
556+
#define dispatch_assert(e) _dispatch_assert((uintptr_t)(e), __LINE__)
557557

558558
/*
559559
* A lot of API return zero upon success and not-zero on fail. Let's capture
560560
* and log the non-zero value
561561
*/
562562
DISPATCH_ALWAYS_INLINE
563563
static inline void
564-
_dispatch_assert_zero(long e, size_t line) DISPATCH_STATIC_ASSERT_IF(e)
564+
_dispatch_assert_zero(uintptr_t e, size_t line) DISPATCH_STATIC_ASSERT_IF(e)
565565
{
566566
if (unlikely(DISPATCH_DEBUG && e)) _dispatch_abort(line, e);
567567
}
568-
#define dispatch_assert_zero(e) _dispatch_assert_zero((long)(e), __LINE__)
568+
#define dispatch_assert_zero(e) _dispatch_assert_zero((uintptr_t)(e), __LINE__)
569569

570570
/*
571571
* For reporting bugs or impedance mismatches between libdispatch and external
@@ -575,25 +575,25 @@ _dispatch_assert_zero(long e, size_t line) DISPATCH_STATIC_ASSERT_IF(e)
575575
*/
576576
DISPATCH_ALWAYS_INLINE
577577
static inline void
578-
_dispatch_assume(long e, size_t line) DISPATCH_STATIC_ASSERT_IF(!e)
578+
_dispatch_assume(uintptr_t e, size_t line) DISPATCH_STATIC_ASSERT_IF(!e)
579579
{
580580
if (unlikely(!e)) _dispatch_bug(line, e);
581581
}
582582
#define dispatch_assume(e) \
583-
({ __typeof__(e) _e = (e); _dispatch_assume((long)_e, __LINE__); _e; })
583+
({ __typeof__(e) _e = (e); _dispatch_assume((uintptr_t)_e, __LINE__); _e; })
584584

585585
/*
586586
* A lot of API return zero upon success and not-zero on fail. Let's capture
587587
* and log the non-zero value
588588
*/
589589
DISPATCH_ALWAYS_INLINE
590590
static inline void
591-
_dispatch_assume_zero(long e, size_t line) DISPATCH_STATIC_ASSERT_IF(e)
591+
_dispatch_assume_zero(uintptr_t e, size_t line) DISPATCH_STATIC_ASSERT_IF(e)
592592
{
593593
if (unlikely(e)) _dispatch_bug(line, e);
594594
}
595595
#define dispatch_assume_zero(e) \
596-
({ __typeof__(e) _e = (e); _dispatch_assume_zero((long)_e, __LINE__); _e; })
596+
({ __typeof__(e) _e = (e); _dispatch_assume_zero((uintptr_t)_e, __LINE__); _e; })
597597

598598
/* Make sure the debug statments don't get too stale */
599599
#define _dispatch_debug(x, args...) do { \

Diff for: src/queue.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ _dispatch_async_redirect_invoke(dispatch_continuation_t dc,
773773
{
774774
dispatch_thread_frame_s dtf;
775775
struct dispatch_continuation_s *other_dc = dc->dc_other;
776-
dispatch_invoke_flags_t ctxt_flags = (dispatch_invoke_flags_t)dc->dc_ctxt;
776+
dispatch_invoke_flags_t ctxt_flags = (dispatch_invoke_flags_t)(uintptr_t)dc->dc_ctxt;
777777
// if we went through _dispatch_root_queue_push_override,
778778
// the "right" root queue was stuffed into dc_func
779779
dispatch_queue_global_t assumed_rq = (dispatch_queue_global_t)dc->dc_func;
@@ -7013,6 +7013,7 @@ _dispatch_sig_thread(void *ctxt DISPATCH_UNUSED)
70137013
_dispatch_clear_stack(0);
70147014
#if defined(_WIN32)
70157015
Sleep(INFINITE);
7016+
__builtin_unreachable();
70167017
#else
70177018
_dispatch_sigsuspend();
70187019
#endif

Diff for: src/shims/time.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ _dispatch_time_to_clock_and_value(dispatch_time_t time,
263263
if (time & DISPATCH_WALLTIME_MASK) {
264264
// Wall time (value 11 in bits 63, 62)
265265
*clock = DISPATCH_CLOCK_WALL;
266-
actual_value = time == DISPATCH_WALLTIME_NOW ?
266+
actual_value = time == (dispatch_time_t)DISPATCH_WALLTIME_NOW ?
267267
_dispatch_get_nanoseconds() : (uint64_t)-time;
268268
} else {
269269
// Continuous time (value 10 in bits 63, 62).

Diff for: src/source.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -1398,11 +1398,12 @@ _dispatch_source_debug_attr(dispatch_source_t ds, char* buf, size_t bufsiz)
13981398
dispatch_source_refs_t dr = ds->ds_refs;
13991399
dispatch_queue_flags_t dqf = _dispatch_queue_atomic_flags(ds);
14001400
dispatch_unote_state_t du_state = _dispatch_unote_state(dr);
1401-
return dsnprintf(buf, bufsiz, "target = %s[%p], ident = 0x%x, "
1401+
return dsnprintf(buf, bufsiz, "target = %s[%p], ident = 0x%llx, "
14021402
"mask = 0x%x, pending_data = 0x%llx, registered = %d, "
14031403
"armed = %d, %s%s%s",
14041404
target && target->dq_label ? target->dq_label : "", target,
1405-
dr->du_ident, dr->du_fflags, (unsigned long long)dr->ds_pending_data,
1405+
(unsigned long long)dr->du_ident, dr->du_fflags,
1406+
(unsigned long long)dr->ds_pending_data,
14061407
_du_state_registered(du_state), _du_state_armed(du_state),
14071408
(dqf & DSF_CANCELED) ? "cancelled, " : "",
14081409
(dqf & DSF_NEEDS_EVENT) ? "needs-event, " : "",

0 commit comments

Comments
 (0)