Skip to content

Commit

Permalink
ThreadStart-related changes in asan_emscripten.cpp
Browse files Browse the repository at this point in the history
This deals with the following upstream changes:
llvm/llvm-project@4e1b55a
llvm/llvm-project@fd16d46
by adding `ThreadStartParams` class as `asan_win.cpp` did.
  • Loading branch information
aheejin committed Apr 7, 2024
1 parent 67108b2 commit 36ce3d3
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions system/lib/compiler-rt/lib/asan/asan_emscripten.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,19 @@ int emscripten_builtin_pthread_create(pthread_t *thread,
void *(*callback)(void *), void *arg);
}

struct ThreadStartParams {
thread_callback_t start_routine;
void *arg;
};

static thread_return_t THREAD_CALLING_CONV asan_thread_start(void *arg) {
AsanThread *t = (AsanThread *)arg;
SetCurrentThread(t);
return t->ThreadStart(GetTid());
t->ThreadStart(GetTid());
ThreadStartParams params;
t->GetStartData(params);
auto res = (*params.start_routine)(params.arg);
return res;
}

INTERCEPTOR(int, pthread_create, pthread_t *thread,
Expand All @@ -72,8 +81,8 @@ INTERCEPTOR(int, pthread_create, pthread_t *thread,
pthread_attr_getdetachstate(attr, &detached);

u32 current_tid = GetCurrentTidOrInvalid();
AsanThread *t =
AsanThread::Create(start_routine, arg, current_tid, &stack, detached);
ThreadStartParams params = {start_routine, arg};
AsanThread* t = AsanThread::Create(params, current_tid, &stack, detached);

int result;
{
Expand Down

0 comments on commit 36ce3d3

Please sign in to comment.