Skip to content

Commit fefb6cf

Browse files
committed
Merge pull request swiftlang#33 from dgrove-oss/dispatch_debug_compile_fixes
Fixes to enable DISPATCH_DEBUG on Linux
2 parents 8b9c3a9 + 00db35a commit fefb6cf

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

src/init.c

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

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

src/shims/linux_stubs.c

+4
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,9 @@ unsigned short dispatch_timer__program_semaphore;
7070
unsigned short dispatch_timer__wake_semaphore;
7171
unsigned short dispatch_timer__fire_semaphore;
7272
unsigned short dispatch_timer__configure_semaphore;
73+
unsigned short dispatch_queue__pop_semaphore;
74+
unsigned short dispatch_callout__entry_semaphore;
75+
unsigned short dispatch_callout__return_semaphore;
76+
unsigned short dispatch_queue__push_semaphore;
7377
void (*_dispatch_block_special_invoke)(void*);
7478
struct dispatch_queue_attr_s _dispatch_queue_attr_concurrent;

src/source.c

+12-1
Original file line numberDiff line numberDiff line change
@@ -4707,8 +4707,12 @@ _evflagstr2(uint16_t *flagsp)
47074707
_evflag2(EV_RECEIPT);
47084708
_evflag2(EV_DISPATCH);
47094709
_evflag2(EV_UDATA_SPECIFIC);
4710+
#ifdef EV_POLL
47104711
_evflag2(EV_POLL);
4712+
#endif
4713+
#ifdef EV_OOBAND
47114714
_evflag2(EV_OOBAND);
4715+
#endif
47124716
_evflag2(EV_ERROR);
47134717
_evflag2(EV_EOF);
47144718
*flagsp = 0;
@@ -4816,7 +4820,12 @@ _dispatch_kevent_debug(const _dispatch_kevent_qos_s* kev, const char* str)
48164820
"ext[0] = 0x%llx, ext[1] = 0x%llx }: %s", kev, kev->ident,
48174821
_evfiltstr(kev->filter), _evflagstr(kev->flags, flagstr,
48184822
sizeof(flagstr)), kev->flags, kev->fflags, kev->data, kev->udata,
4819-
kev->ext[0], kev->ext[1], str);
4823+
#if DISPATCH_USE_KEVENT_QOS
4824+
kev->ext[0], kev->ext[1],
4825+
#else
4826+
0ull, 0ull,
4827+
#endif
4828+
str);
48204829
}
48214830

48224831
static void
@@ -4921,9 +4930,11 @@ _dispatch_kevent_debugger(void *context DISPATCH_UNUSED)
49214930
int val, r, fd, sock_opt = 1;
49224931
socklen_t slen = sizeof(sa_u);
49234932

4933+
#ifndef __linux__
49244934
if (issetugid()) {
49254935
return;
49264936
}
4937+
#endif
49274938
valstr = getenv("LIBDISPATCH_DEBUGGER");
49284939
if (!valstr) {
49294940
return;

0 commit comments

Comments
 (0)