-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pthread+dylink: Ensure code is in sync on thread start
We still don't have a great way to keep threads in sync but this at least means they will be correct at the moment the start. Part of #3494. Fixes: #16021
- Loading branch information
Showing
7 changed files
with
83 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <stdio.h> | ||
#include <dlfcn.h> | ||
#include <pthread.h> | ||
|
||
typedef void* (*thread_main_t)(void*); | ||
|
||
int main() { | ||
puts("hello from main"); | ||
|
||
void *lib_handle = dlopen("./liblib.so", RTLD_NOW); | ||
if (!lib_handle) { | ||
puts("cannot load side module"); | ||
puts(dlerror()); | ||
return 1; | ||
} | ||
|
||
thread_main_t tmain = (thread_main_t)dlsym(lib_handle, "side_module_thread_main"); | ||
if (!tmain) { | ||
puts("cannot find side function"); | ||
return 1; | ||
} | ||
|
||
printf("starting thread with %p\n", tmain); | ||
pthread_t t; | ||
pthread_create(&t, NULL, tmain, (void*)"hello"); | ||
pthread_join(t, NULL); | ||
|
||
printf("done\n"); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
call thread fn in side: hello |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <stdio.h> | ||
#include <emscripten.h> | ||
#include <pthread.h> | ||
|
||
EMSCRIPTEN_KEEPALIVE void* side_module_thread_main(void* arg) { | ||
printf("call thread fn in side: %s\n", (char*)arg); | ||
return NULL; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters