From af1a266670d040d2f4083ff309d732d648afba2a Mon Sep 17 00:00:00 2001 From: Angelos Mouzakitis Date: Tue, 10 Oct 2023 14:33:42 +0000 Subject: Add submodule dependency files Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec --- meson/test cases/wasm/2 threads/meson.build | 10 ++++++++++ meson/test cases/wasm/2 threads/threads.c | 21 +++++++++++++++++++++ meson/test cases/wasm/2 threads/threads.cpp | 13 +++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 meson/test cases/wasm/2 threads/meson.build create mode 100644 meson/test cases/wasm/2 threads/threads.c create mode 100644 meson/test cases/wasm/2 threads/threads.cpp (limited to 'meson/test cases/wasm/2 threads') diff --git a/meson/test cases/wasm/2 threads/meson.build b/meson/test cases/wasm/2 threads/meson.build new file mode 100644 index 000000000..cb682b877 --- /dev/null +++ b/meson/test cases/wasm/2 threads/meson.build @@ -0,0 +1,10 @@ +project( + 'threads', + 'c', 'cpp', + default_options : ['cpp_std=c++11'], +) + +dep_threads = dependency('threads') + +executable('threads-c', 'threads.c', dependencies : dep_threads) +executable('threads-c++', 'threads.cpp', dependencies : dep_threads) diff --git a/meson/test cases/wasm/2 threads/threads.c b/meson/test cases/wasm/2 threads/threads.c new file mode 100644 index 000000000..e79bff170 --- /dev/null +++ b/meson/test cases/wasm/2 threads/threads.c @@ -0,0 +1,21 @@ +#include +#include +#include + +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 +} diff --git a/meson/test cases/wasm/2 threads/threads.cpp b/meson/test cases/wasm/2 threads/threads.cpp new file mode 100644 index 000000000..1caa73da3 --- /dev/null +++ b/meson/test cases/wasm/2 threads/threads.cpp @@ -0,0 +1,13 @@ +#include +#include +#include + +int main(void) { + std::cout << "Before thread" << std::endl; + std::thread t([]() { + sleep(1); + std::cout << "In a thread." << std::endl; + }); + t.join(); + std::cout << "After thread" << std::endl; +} -- cgit 1.2.3-korg