@@ -276,7 +276,8 @@ static ExecutorRef swift_task_getCurrentExecutorImpl() {
276276 auto result = (currentTracking ? currentTracking->getActiveExecutor ()
277277 : ExecutorRef::generic ());
278278#if SWIFT_TASK_PRINTF_DEBUG
279- fprintf (stderr, " [%p] getting current executor %p\n " , pthread_self (), result.getIdentity ());
279+ fprintf (stderr, " [%lu] getting current executor %p\n " ,
280+ _swift_get_thread_id (), result.getIdentity ());
280281#endif
281282 return result;
282283}
@@ -1181,7 +1182,8 @@ static Job *preprocessQueue(JobRef first,
11811182
11821183void DefaultActorImpl::giveUpThread (RunningJobInfo runner) {
11831184#if SWIFT_TASK_PRINTF_DEBUG
1184- fprintf (stderr, " [%p] giving up thread for actor %p\n " , pthread_self (), this );
1185+ fprintf (stderr, " [%lu] giving up thread for actor %p\n " ,
1186+ _swift_get_thread_id (), this );
11851187#endif
11861188 auto oldState = CurrentState.load (std::memory_order_acquire);
11871189 assert (oldState.Flags .isAnyRunningStatus ());
@@ -1245,8 +1247,10 @@ void DefaultActorImpl::giveUpThread(RunningJobInfo runner) {
12451247 }
12461248
12471249#if SWIFT_TASK_PRINTF_DEBUG
1248- # define LOG_STATE_TRANSITION fprintf (stderr, " [%p] actor %p transitioned from %zx to %zx (%s)\n " , \
1249- pthread_self (), this, oldState.Flags.getOpaqueValue(), newState.Flags.getOpaqueValue(), __FUNCTION__)
1250+ # define LOG_STATE_TRANSITION \
1251+ fprintf (stderr, " [%lu] actor %p transitioned from %zx to %zx (%s)\n " , \
1252+ _swift_get_thread_id (), this , oldState.Flags .getOpaqueValue (), \
1253+ newState.Flags .getOpaqueValue (), __FUNCTION__)
12501254#else
12511255# define LOG_STATE_TRANSITION ((void )0 )
12521256#endif
@@ -1503,7 +1507,8 @@ SWIFT_CC(swiftasync)
15031507static void processDefaultActor(DefaultActorImpl *currentActor,
15041508 RunningJobInfo runner) {
15051509#if SWIFT_TASK_PRINTF_DEBUG
1506- fprintf (stderr, " [%p] processDefaultActor %p\n " , pthread_self (), currentActor);
1510+ fprintf (stderr, " [%lu] processDefaultActor %p\n " ,
1511+ _swift_get_thread_id (), currentActor);
15071512#endif
15081513 DefaultActorImpl *actor = currentActor;
15091514
@@ -1529,7 +1534,8 @@ static void processDefaultActor(DefaultActorImpl *currentActor,
15291534 runner);
15301535
15311536#if SWIFT_TASK_PRINTF_DEBUG
1532- fprintf (stderr, " [%p] processDefaultActor %p claimed job %p\n " , pthread_self (), currentActor, job);
1537+ fprintf (stderr, " [%lu] processDefaultActor %p claimed job %p\n " ,
1538+ _swift_get_thread_id (), currentActor, job);
15331539#endif
15341540
15351541 // If we failed to claim a job, we have nothing to do.
@@ -1551,7 +1557,8 @@ static void processDefaultActor(DefaultActorImpl *currentActor,
15511557 auto currentExecutor = trackingInfo.getActiveExecutor ();
15521558
15531559#if SWIFT_TASK_PRINTF_DEBUG
1554- fprintf (stderr, " [%p] processDefaultActor %p current executor now %p\n " , pthread_self (), currentActor, currentExecutor.getIdentity ());
1560+ fprintf (stderr, " [%lu] processDefaultActor %p current executor now %p\n " ,
1561+ _swift_get_thread_id (), currentActor, currentExecutor.getIdentity ());
15551562#endif
15561563
15571564 if (!currentExecutor.isDefaultActor ()) {
@@ -1872,7 +1879,8 @@ static void runOnAssumedThread(AsyncTask *task, ExecutorRef executor,
18721879 trackingInfo.leave ();
18731880
18741881#if SWIFT_TASK_PRINTF_DEBUG
1875- fprintf (stderr, " [%p] leaving assumed thread, current executor is %p\n " , pthread_self (), executor.getIdentity ());
1882+ fprintf (stderr, " [%lu] leaving assumed thread, current executor is %p\n " ,
1883+ _swift_get_thread_id (), executor.getIdentity ());
18761884#endif
18771885
18781886 if (executor.isDefaultActor ())
@@ -1888,7 +1896,9 @@ static void swift_task_switchImpl(SWIFT_ASYNC_CONTEXT AsyncContext *resumeContex
18881896 (trackingInfo ? trackingInfo->getActiveExecutor ()
18891897 : ExecutorRef::generic ());
18901898#if SWIFT_TASK_PRINTF_DEBUG
1891- fprintf (stderr, " [%p] trying to switch from executor %p to %p\n " , pthread_self (), currentExecutor.getIdentity (), newExecutor.getIdentity ());
1899+ fprintf (stderr, " [%lu] trying to switch from executor %p to %p\n " ,
1900+ _swift_get_thread_id (), currentExecutor.getIdentity (),
1901+ newExecutor.getIdentity ());
18921902#endif
18931903
18941904 // If the current executor is compatible with running the new executor,
@@ -1916,7 +1926,8 @@ static void swift_task_switchImpl(SWIFT_ASYNC_CONTEXT AsyncContext *resumeContex
19161926 !shouldYieldThread () &&
19171927 tryAssumeThreadForSwitch (newExecutor, runner)) {
19181928#if SWIFT_TASK_PRINTF_DEBUG
1919- fprintf (stderr, " [%p] switch succeeded, task %p assumed thread for executor %p\n " , pthread_self (), task, newExecutor.getIdentity ());
1929+ fprintf (stderr, " [%lu] switch succeeded, task %p assumed thread for executor %p\n " ,
1930+ _swift_get_thread_id (), task, newExecutor.getIdentity ());
19201931#endif
19211932 giveUpThreadForSwitch (currentExecutor, runner);
19221933 // 'return' forces tail call
@@ -1926,7 +1937,8 @@ static void swift_task_switchImpl(SWIFT_ASYNC_CONTEXT AsyncContext *resumeContex
19261937 // Otherwise, just asynchronously enqueue the task on the given
19271938 // executor.
19281939#if SWIFT_TASK_PRINTF_DEBUG
1929- fprintf (stderr, " [%p] switch failed, task %p enqueued on executor %p\n " , pthread_self (), task, newExecutor.getIdentity ());
1940+ fprintf (stderr, " [%lu] switch failed, task %p enqueued on executor %p\n " ,
1941+ _swift_get_thread_id (), task, newExecutor.getIdentity ());
19301942#endif
19311943 swift_task_enqueue (task, newExecutor);
19321944}
@@ -1946,7 +1958,8 @@ void _swift_task_enqueueOnExecutor(Job *job, HeapObject *executor,
19461958SWIFT_CC (swift)
19471959static void swift_task_enqueueImpl(Job *job, ExecutorRef executor) {
19481960#if SWIFT_TASK_PRINTF_DEBUG
1949- fprintf (stderr, " [%p] enqueue job %p on executor %p\n " , pthread_self (), job, executor.getIdentity ());
1961+ fprintf (stderr, " [%lu] enqueue job %p on executor %p\n " ,
1962+ _swift_get_thread_id (), job, executor.getIdentity ());
19501963#endif
19511964
19521965 assert (job && " no job provided" );
0 commit comments