Skip to content

Commit

Permalink
Merge pull request #758 from grynspan/jgrynspan/fix-windows-warnings
Browse files Browse the repository at this point in the history
Fix a number of warnings when building on Windows
  • Loading branch information
millenomi authored Jun 22, 2022
2 parents ecc678d + cc9c82e commit 4bf826d
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/event/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -766,9 +766,9 @@ _dispatch_timer_heap_update(dispatch_timer_heap_t dth,
#pragma mark timer unote

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

DISPATCH_ALWAYS_INLINE
static inline unsigned int
Expand Down
2 changes: 1 addition & 1 deletion src/event/workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ _dispatch_workq_count_runnable_workers(dispatch_workq_monitor_t mon)
// and Socket IO, but it is unclear if that includes normal IO.
HANDLE hThread = OpenThread(THREAD_QUERY_INFORMATION, FALSE, tid);
if (hThread == NULL) {
_dispatch_debug("workq: unable to open thread %u: %u", tid, GetLastError());
_dispatch_debug("workq: unable to open thread %lu: %lu", tid, GetLastError());
continue;
}

Expand Down
10 changes: 5 additions & 5 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -931,14 +931,14 @@ _dispatch_fault(const char *reason, const char *fmt, ...)
})

void
_dispatch_bug(size_t line, long val)
_dispatch_bug(size_t line, uintptr_t val)
{
dispatch_once_f(&_dispatch_build_pred, NULL, _dispatch_build_init);

if (_dispatch_bug_log_is_repeated()) return;

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

#if HAVE_MACH
Expand Down Expand Up @@ -1066,7 +1066,7 @@ _dispatch_bug_deprecated(const char *msg)
}

void
_dispatch_abort(size_t line, long val)
_dispatch_abort(size_t line, uintptr_t val)
{
_dispatch_bug(line, val);
abort();
Expand Down Expand Up @@ -1150,7 +1150,7 @@ _dispatch_logv_init(void *context DISPATCH_UNUSED)
szProgramName, GetCurrentProcessId(), tv.tv_sec,
(int)tv.tv_usec);
if (len > 0) {
len = MIN(len, sizeof(szMessage) - 1);
len = MIN(len, (int)sizeof(szMessage) - 1);
_write(dispatch_logfile, szMessage, len);
_write(dispatch_logfile, "\n", 1);
}
Expand Down
20 changes: 10 additions & 10 deletions src/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ DISPATCH_EXPORT DISPATCH_NOTHROW void dispatch_atfork_child(void);
extern uint8_t _dispatch_mode;

DISPATCH_EXPORT DISPATCH_NOINLINE DISPATCH_COLD
void _dispatch_bug(size_t line, long val);
void _dispatch_bug(size_t line, uintptr_t val);

#if HAVE_MACH
DISPATCH_NOINLINE DISPATCH_COLD
Expand All @@ -489,7 +489,7 @@ DISPATCH_NOINLINE DISPATCH_COLD
void _dispatch_bug_deprecated(const char *msg);

DISPATCH_NOINLINE DISPATCH_NORETURN DISPATCH_COLD
void _dispatch_abort(size_t line, long val);
void _dispatch_abort(size_t line, uintptr_t val);

#if !defined(DISPATCH_USE_OS_DEBUG_LOG) && DISPATCH_DEBUG
#if __has_include(<os/debug_private.h>)
Expand Down Expand Up @@ -549,23 +549,23 @@ void _dispatch_log(const char *msg, ...);
*/
DISPATCH_ALWAYS_INLINE
static inline void
_dispatch_assert(long e, size_t line) DISPATCH_STATIC_ASSERT_IF(!e)
_dispatch_assert(uintptr_t e, size_t line) DISPATCH_STATIC_ASSERT_IF(!e)
{
if (unlikely(DISPATCH_DEBUG && !e)) _dispatch_abort(line, e);
}
#define dispatch_assert(e) _dispatch_assert((long)(e), __LINE__)
#define dispatch_assert(e) _dispatch_assert((uintptr_t)(e), __LINE__)

/*
* A lot of API return zero upon success and not-zero on fail. Let's capture
* and log the non-zero value
*/
DISPATCH_ALWAYS_INLINE
static inline void
_dispatch_assert_zero(long e, size_t line) DISPATCH_STATIC_ASSERT_IF(e)
_dispatch_assert_zero(uintptr_t e, size_t line) DISPATCH_STATIC_ASSERT_IF(e)
{
if (unlikely(DISPATCH_DEBUG && e)) _dispatch_abort(line, e);
}
#define dispatch_assert_zero(e) _dispatch_assert_zero((long)(e), __LINE__)
#define dispatch_assert_zero(e) _dispatch_assert_zero((uintptr_t)(e), __LINE__)

/*
* For reporting bugs or impedance mismatches between libdispatch and external
Expand All @@ -575,25 +575,25 @@ _dispatch_assert_zero(long e, size_t line) DISPATCH_STATIC_ASSERT_IF(e)
*/
DISPATCH_ALWAYS_INLINE
static inline void
_dispatch_assume(long e, size_t line) DISPATCH_STATIC_ASSERT_IF(!e)
_dispatch_assume(uintptr_t e, size_t line) DISPATCH_STATIC_ASSERT_IF(!e)
{
if (unlikely(!e)) _dispatch_bug(line, e);
}
#define dispatch_assume(e) \
({ __typeof__(e) _e = (e); _dispatch_assume((long)_e, __LINE__); _e; })
({ __typeof__(e) _e = (e); _dispatch_assume((uintptr_t)_e, __LINE__); _e; })

/*
* A lot of API return zero upon success and not-zero on fail. Let's capture
* and log the non-zero value
*/
DISPATCH_ALWAYS_INLINE
static inline void
_dispatch_assume_zero(long e, size_t line) DISPATCH_STATIC_ASSERT_IF(e)
_dispatch_assume_zero(uintptr_t e, size_t line) DISPATCH_STATIC_ASSERT_IF(e)
{
if (unlikely(e)) _dispatch_bug(line, e);
}
#define dispatch_assume_zero(e) \
({ __typeof__(e) _e = (e); _dispatch_assume_zero((long)_e, __LINE__); _e; })
({ __typeof__(e) _e = (e); _dispatch_assume_zero((uintptr_t)_e, __LINE__); _e; })

/* Make sure the debug statments don't get too stale */
#define _dispatch_debug(x, args...) do { \
Expand Down
3 changes: 2 additions & 1 deletion src/queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ _dispatch_async_redirect_invoke(dispatch_continuation_t dc,
{
dispatch_thread_frame_s dtf;
struct dispatch_continuation_s *other_dc = dc->dc_other;
dispatch_invoke_flags_t ctxt_flags = (dispatch_invoke_flags_t)dc->dc_ctxt;
dispatch_invoke_flags_t ctxt_flags = (dispatch_invoke_flags_t)(uintptr_t)dc->dc_ctxt;
// if we went through _dispatch_root_queue_push_override,
// the "right" root queue was stuffed into dc_func
dispatch_queue_global_t assumed_rq = (dispatch_queue_global_t)dc->dc_func;
Expand Down Expand Up @@ -7013,6 +7013,7 @@ _dispatch_sig_thread(void *ctxt DISPATCH_UNUSED)
_dispatch_clear_stack(0);
#if defined(_WIN32)
Sleep(INFINITE);
__builtin_unreachable();
#else
_dispatch_sigsuspend();
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/shims/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ _dispatch_time_to_clock_and_value(dispatch_time_t time,
if (time & DISPATCH_WALLTIME_MASK) {
// Wall time (value 11 in bits 63, 62)
*clock = DISPATCH_CLOCK_WALL;
actual_value = time == DISPATCH_WALLTIME_NOW ?
actual_value = time == (dispatch_time_t)DISPATCH_WALLTIME_NOW ?
_dispatch_get_nanoseconds() : (uint64_t)-time;
} else {
// Continuous time (value 10 in bits 63, 62).
Expand Down
5 changes: 3 additions & 2 deletions src/source.c
Original file line number Diff line number Diff line change
Expand Up @@ -1398,11 +1398,12 @@ _dispatch_source_debug_attr(dispatch_source_t ds, char* buf, size_t bufsiz)
dispatch_source_refs_t dr = ds->ds_refs;
dispatch_queue_flags_t dqf = _dispatch_queue_atomic_flags(ds);
dispatch_unote_state_t du_state = _dispatch_unote_state(dr);
return dsnprintf(buf, bufsiz, "target = %s[%p], ident = 0x%x, "
return dsnprintf(buf, bufsiz, "target = %s[%p], ident = 0x%llx, "
"mask = 0x%x, pending_data = 0x%llx, registered = %d, "
"armed = %d, %s%s%s",
target && target->dq_label ? target->dq_label : "", target,
dr->du_ident, dr->du_fflags, (unsigned long long)dr->ds_pending_data,
(unsigned long long)dr->du_ident, dr->du_fflags,
(unsigned long long)dr->ds_pending_data,
_du_state_registered(du_state), _du_state_armed(du_state),
(dqf & DSF_CANCELED) ? "cancelled, " : "",
(dqf & DSF_NEEDS_EVENT) ? "needs-event, " : "",
Expand Down

0 comments on commit 4bf826d

Please sign in to comment.