[Concurrency] Replace SWIFT_TASK_PRINTF_DEBUG with a SWIFT_TASK_DEBUG_LOG macro.

This macro takes the string and parameters directly, and is conditionally defined to either call fprintf or ignore its arguments. This makes the call sites a little more pleasant (no #if scattered about) and ensures every log includes the thread ID and a newline automatically.
This commit is contained in:
Mike Ash
2021-08-25 10:44:48 -04:00
parent 0045fe3c9a
commit d5c0469f3e
5 changed files with 53 additions and 106 deletions

View File

@@ -31,18 +31,14 @@ TSanFunc *tsan_acquire, *tsan_release;
void swift::_swift_tsan_acquire(void *addr) {
if (tsan_acquire) {
tsan_acquire(addr);
#if SWIFT_TASK_PRINTF_DEBUG
fprintf(stderr, "[%lu] tsan_acquire on %p\n", _swift_get_thread_id(), addr);
#endif
SWIFT_TASK_DEBUG_LOG("tsan_acquire on %p", addr);
}
}
void swift::_swift_tsan_release(void *addr) {
if (tsan_release) {
tsan_release(addr);
#if SWIFT_TASK_PRINTF_DEBUG
fprintf(stderr, "[%lu] tsan_release on %p\n", _swift_get_thread_id(), addr);
#endif
SWIFT_TASK_DEBUG_LOG("tsan_release on %p", addr);
}
}