Skip to content

Commit

Permalink
Incorporate feedback from Rokhini
Browse files Browse the repository at this point in the history
  • Loading branch information
grynspan committed May 6, 2022
1 parent e9d4041 commit cc9c82e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
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: %lu", tid, GetLastError());
_dispatch_debug("workq: unable to open thread %lu: %lu", tid, GetLastError());
continue;
}

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

void
_dispatch_bug(size_t line, intptr_t 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%llx",
_dispatch_build, (unsigned long)line,
(unsigned long long)(uintptr_t)val);
_dispatch_build, (unsigned long)line, (unsigned long long)val);
}

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

void
_dispatch_abort(size_t line, intptr_t val)
_dispatch_abort(size_t line, uintptr_t val)
{
_dispatch_bug(line, val);
abort();
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, intptr_t 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, intptr_t 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(intptr_t 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((intptr_t)(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(intptr_t 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((intptr_t)(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(intptr_t e, size_t line) DISPATCH_STATIC_ASSERT_IF(e)
*/
DISPATCH_ALWAYS_INLINE
static inline void
_dispatch_assume(intptr_t 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((intptr_t)_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(intptr_t 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((intptr_t)_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
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 == (uint64_t)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

0 comments on commit cc9c82e

Please sign in to comment.