summaryrefslogtreecommitdiff
path: root/test cases/wasm/2 threads/threads.c
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-02-24 10:55:31 -0800
committerDylan Baker <dylan@pnwbakers.com>2020-02-27 16:35:02 -0800
commit771b0d3ffbc7b034b436d4ad27be7d0a1da6b3cd (patch)
tree051bf624f251dceb88a0c36d4c4affac7a4914ea /test cases/wasm/2 threads/threads.c
parentb2f86c461b72e405695ab1491baba00f45af93a6 (diff)
downloadmeson-771b0d3ffbc7b034b436d4ad27be7d0a1da6b3cd.tar.gz
compilers/mixins/emscripten: Implement thread support
Emscripten has pthread support (as well as C++ threads), but we don't currently implement them. This fixes that by adding the necessary code. The one thing I'm not sure about is setting the pool size. The docs suggest that you really want to do this to ensure that your code works correctly, but the number should really be configurable, not sure how to set that. Fixes #6684
Diffstat (limited to 'test cases/wasm/2 threads/threads.c')
-rw-r--r--test cases/wasm/2 threads/threads.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/test cases/wasm/2 threads/threads.c b/test cases/wasm/2 threads/threads.c
new file mode 100644
index 000000000..e79bff170
--- /dev/null
+++ b/test cases/wasm/2 threads/threads.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <pthread.h>
+
+void inthread(void * args) {
+ sleep(1);
+ printf("In thread\n");
+}
+
+int main() {
+#ifdef __EMSCRIPTEN_PTHREADS__
+ pthread_t thread_id;
+ printf("Before Thread\n");
+ pthread_create(&thread_id, NULL, (void *)*inthread, NULL);
+ pthread_join(thread_id, NULL);
+ printf("After Thread\n");
+ return 0;
+#else
+# error "threads not enabled\n"
+#endif
+}