Skip to content

Commit d427c7a

Browse files
committed
Fix SWIFT_TASK_DEBUG_LOG macro
The threading library changed in the BackDeployConcurrency library resulting in the `SWIFT_TASK_DEBUG_LOG` macro not compiling. Fixing that. Also adding the logging pieces to the Compatibility 56 library.
1 parent 1108543 commit d427c7a

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

stdlib/public/BackDeployConcurrency/Actor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,7 @@ void DefaultActorImpl::giveUpThread(RunningJobInfo runner) {
12281228
}
12291229

12301230
#define LOG_STATE_TRANSITION \
1231-
SWIFT_TASK_DEBUG_LOG("actor %p transitioned from %zx to %zx (%s)\n", this, \
1231+
SWIFT_TASK_DEBUG_LOG("actor %p transitioned from %zx to %zx (%s)", this, \
12321232
oldState.Flags.getOpaqueValue(), \
12331233
newState.Flags.getOpaqueValue(), __FUNCTION__)
12341234
LOG_STATE_TRANSITION;

stdlib/public/BackDeployConcurrency/TaskGroup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ static void swift_taskGroup_initializeImpl(TaskGroup *group, const Metadata *T)
479479
// ==== add / attachChild ------------------------------------------------------
480480

481481
void TaskGroup::addChildTask(AsyncTask *child) {
482-
SWIFT_TASK_DEBUG_LOG("attach child task = %p to group = %p", child, group);
482+
SWIFT_TASK_DEBUG_LOG("attach child task = %p to group = %p", child, this);
483483

484484
// The counterpart of this (detachChild) is performed by the group itself,
485485
// when it offers the completed (child) task's value to a waiting task -

stdlib/public/BackDeployConcurrency/TaskPrivate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ namespace swift {
4747
#if 0
4848
#define SWIFT_TASK_DEBUG_LOG(fmt, ...) \
4949
fprintf(stderr, "[%lu] [%s:%d](%s) " fmt "\n", \
50-
(unsigned long)Thread::current()::platformThreadId(), \
50+
(unsigned long)Thread::current().platformThreadId(), \
5151
__FILE__, __LINE__, __FUNCTION__, \
5252
__VA_ARGS__)
5353
#else

stdlib/toolchain/Compatibility56/include/Concurrency/TaskPrivate.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,25 @@
2929

3030
namespace swift {
3131

32+
#if 0
33+
using ThreadID = decltype(pthread_self());
34+
35+
inline ThreadID _swift_get_thread_id() {
36+
#if defined(_WIN32)
37+
return GetCurrentThreadId();
38+
#else
39+
return pthread_self();
40+
#endif
41+
}
42+
43+
#define SWIFT_TASK_DEBUG_LOG(fmt, ...) \
44+
fprintf(stderr, "[%lu] [%s:%d](%s) " fmt "\n", \
45+
(unsigned long)_swift_get_thread_id(), \
46+
__FILE__, __LINE__, __FUNCTION__, \
47+
__VA_ARGS__)
48+
#else
3249
#define SWIFT_TASK_DEBUG_LOG(fmt ...) (void)0
50+
#endif
3351

3452
/// Allocate task-local memory on behalf of a specific task,
3553
/// not necessarily the current one. Generally this should only be

0 commit comments

Comments
 (0)