Skip to content

Commit beed704

Browse files
dgrove-ossdas
authored andcommitted
Fixes to enable DISPATCH_DEBUG on Linux
Small fixes to code guarded under DISPATCH_DEBUG to fix Linux compilation issues. Signed-off-by: Daniel A. Steffen <[email protected]>
1 parent 50966a2 commit beed704

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

src/init.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ _dispatch_logv_init(void *context DISPATCH_UNUSED)
528528
struct timeval tv;
529529
gettimeofday(&tv, NULL);
530530
#if DISPATCH_DEBUG
531-
dispatch_log_basetime = mach_absolute_time();
531+
dispatch_log_basetime = _dispatch_absolute_time();
532532
#endif
533533
dprintf(dispatch_logfile, "=== log file opened for %s[%u] at "
534534
"%ld.%06u ===\n", getprogname() ?: "", getpid(),
@@ -560,7 +560,7 @@ _dispatch_logv_file(const char *msg, va_list ap)
560560

561561
#if DISPATCH_DEBUG
562562
offset += dsnprintf(&buf[offset], bufsiz - offset, "%llu\t",
563-
mach_absolute_time() - dispatch_log_basetime);
563+
_dispatch_absolute_time() - dispatch_log_basetime);
564564
#endif
565565
r = vsnprintf(&buf[offset], bufsiz - offset, msg, ap);
566566
if (r < 0) return;
@@ -657,7 +657,7 @@ _dispatch_debugv(dispatch_object_t dou, const char *msg, va_list ap)
657657
int r;
658658
#if DISPATCH_DEBUG && !DISPATCH_USE_OS_DEBUG_LOG
659659
offset += dsnprintf(&buf[offset], bufsiz - offset, "%llu\t\t%p\t",
660-
mach_absolute_time() - dispatch_log_basetime,
660+
_dispatch_absolute_time() - dispatch_log_basetime,
661661
(void *)_dispatch_thread_self());
662662
#endif
663663
if (dou._do) {

src/shims/linux_stubs.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,9 @@ unsigned short dispatch_timer__program_semaphore;
6363
unsigned short dispatch_timer__wake_semaphore;
6464
unsigned short dispatch_timer__fire_semaphore;
6565
unsigned short dispatch_timer__configure_semaphore;
66+
unsigned short dispatch_queue__pop_semaphore;
67+
unsigned short dispatch_callout__entry_semaphore;
68+
unsigned short dispatch_callout__return_semaphore;
69+
unsigned short dispatch_queue__push_semaphore;
6670
void (*_dispatch_block_special_invoke)(void*);
6771
struct dispatch_queue_attr_s _dispatch_queue_attr_concurrent;

src/source.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4704,8 +4704,12 @@ _evflagstr2(uint16_t *flagsp)
47044704
_evflag2(EV_RECEIPT);
47054705
_evflag2(EV_DISPATCH);
47064706
_evflag2(EV_UDATA_SPECIFIC);
4707+
#ifdef EV_POLL
47074708
_evflag2(EV_POLL);
4709+
#endif
4710+
#ifdef EV_OOBAND
47084711
_evflag2(EV_OOBAND);
4712+
#endif
47094713
_evflag2(EV_ERROR);
47104714
_evflag2(EV_EOF);
47114715
*flagsp = 0;
@@ -4814,7 +4818,12 @@ _dispatch_kevent_debug(const _dispatch_kevent_qos_s* kev, const char* str)
48144818
"ext[0] = 0x%llx, ext[1] = 0x%llx }: %s", kev, kev->ident,
48154819
_evfiltstr(kev->filter), _evflagstr(kev->flags, flagstr,
48164820
sizeof(flagstr)), kev->flags, kev->fflags, kev->data, kev->udata,
4817-
kev->ext[0], kev->ext[1], str);
4821+
#if DISPATCH_USE_KEVENT_QOS
4822+
kev->ext[0], kev->ext[1],
4823+
#else
4824+
0ull, 0ull,
4825+
#endif
4826+
str);
48184827
}
48194828

48204829
static void
@@ -4919,9 +4928,11 @@ _dispatch_kevent_debugger(void *context DISPATCH_UNUSED)
49194928
int val, r, fd, sock_opt = 1;
49204929
socklen_t slen = sizeof(sa_u);
49214930

4931+
#ifndef __linux__
49224932
if (issetugid()) {
49234933
return;
49244934
}
4935+
#endif
49254936
valstr = getenv("LIBDISPATCH_DEBUGGER");
49264937
if (!valstr) {
49274938
return;

0 commit comments

Comments
 (0)