From c83b8b42a9ccd953f65234b1ff92b83d33949d11 Mon Sep 17 00:00:00 2001 From: eloparco Date: Wed, 15 Mar 2023 00:10:39 +0000 Subject: [PATCH 1/6] feat: implement sync primitives instead of using pthread ones --- .../libraries/lib-wasi-threads/test/common.h | 11 ++- .../lib-wasi-threads/test/global_lock.c | 11 ++- .../lib-wasi-threads/test/sync_primitives.h | 75 +++++++++++++++++++ 3 files changed, 85 insertions(+), 12 deletions(-) create mode 100644 core/iwasm/libraries/lib-wasi-threads/test/sync_primitives.h diff --git a/core/iwasm/libraries/lib-wasi-threads/test/common.h b/core/iwasm/libraries/lib-wasi-threads/test/common.h index d032f824c3..3645c460be 100644 --- a/core/iwasm/libraries/lib-wasi-threads/test/common.h +++ b/core/iwasm/libraries/lib-wasi-threads/test/common.h @@ -6,11 +6,11 @@ #include #include #include -#include #include #include #include +#include "sync_primitives.h" #include "wasi_thread_start.h" typedef enum { @@ -25,7 +25,7 @@ static bool termination_in_main_thread; static blocking_task_type_t blocking_task_type; #define NUM_THREADS 3 -static pthread_barrier_t barrier; +static barrier_t barrier; typedef struct { start_args_t base; @@ -51,7 +51,7 @@ void start_job() { /* Wait for all threads (including the main thread) to be ready */ - pthread_barrier_wait(&barrier); + barrier_wait(&barrier); run_long_task(); /* Task to be interrupted */ assert(false && "Thread termination test failed"); } @@ -60,7 +60,7 @@ void terminate_process() { /* Wait for all threads (including the main thread) to be ready */ - pthread_barrier_wait(&barrier); + barrier_wait(&barrier); if (termination_by_trap) __builtin_trap(); @@ -90,8 +90,7 @@ test_termination(bool trap, bool main, blocking_task_type_t task_type) int thread_id = -1, i; shared_t data[NUM_THREADS] = { 0 }; - assert(pthread_barrier_init(&barrier, NULL, NUM_THREADS + 1) == 0 - && "Failed to init barrier"); + barrier_init(&barrier, NUM_THREADS + 1); for (i = 0; i < NUM_THREADS; i++) { /* No graceful memory free to simplify the test */ diff --git a/core/iwasm/libraries/lib-wasi-threads/test/global_lock.c b/core/iwasm/libraries/lib-wasi-threads/test/global_lock.c index 282bec71c2..ca3ea09732 100644 --- a/core/iwasm/libraries/lib-wasi-threads/test/global_lock.c +++ b/core/iwasm/libraries/lib-wasi-threads/test/global_lock.c @@ -11,8 +11,8 @@ #include #include #include -#include +#include "sync_primitives.h" #include "wasi_thread_start.h" enum CONSTANTS { @@ -22,7 +22,7 @@ enum CONSTANTS { TIMEOUT = 10LL * SECOND }; -pthread_mutex_t mutex; +mutex_t mutex; int g_count = 0; typedef struct { @@ -36,9 +36,9 @@ __wasi_thread_start_C(int thread_id, int *start_arg) shared_t *data = (shared_t *)start_arg; for (int i = 0; i < NUM_ITER; i++) { - pthread_mutex_lock(&mutex); + mutex_lock(&mutex); g_count++; - pthread_mutex_unlock(&mutex); + mutex_unlock(&mutex); } __atomic_store_n(&data->th_done, 1, __ATOMIC_SEQ_CST); @@ -51,7 +51,7 @@ main(int argc, char **argv) shared_t data[NUM_THREADS] = { 0 }; int thread_ids[NUM_THREADS]; - assert(pthread_mutex_init(&mutex, NULL) == 0 && "Failed to init mutex"); + mutex_init(&mutex); for (int i = 0; i < NUM_THREADS; i++) { assert(start_args_init(&data[i].base)); @@ -73,6 +73,5 @@ main(int argc, char **argv) assert(g_count == (NUM_THREADS * NUM_ITER) && "Global count not updated correctly"); - assert(pthread_mutex_destroy(&mutex) == 0 && "Failed to destroy mutex"); return EXIT_SUCCESS; } diff --git a/core/iwasm/libraries/lib-wasi-threads/test/sync_primitives.h b/core/iwasm/libraries/lib-wasi-threads/test/sync_primitives.h new file mode 100644 index 0000000000..dfc4131f1c --- /dev/null +++ b/core/iwasm/libraries/lib-wasi-threads/test/sync_primitives.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2023 Amazon.com Inc. or its affiliates. All rights reserved. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + */ + +#include + +/* Mutex */ + +typedef int mutex_t; + +void +mutex_init(mutex_t *mutex) +{ + *mutex = 0; +} + +static bool +try_mutex_lock(mutex_t *mutex) +{ + int expected = 0; + return __atomic_compare_exchange_n(mutex, &expected, 1, false, + __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); +} + +void +mutex_lock(mutex_t *mutex) +{ + while (!try_mutex_lock(mutex)) + __builtin_wasm_memory_atomic_wait32(mutex, 1, -1); +} + +void +mutex_unlock(mutex_t *mutex) +{ + __atomic_store_n(mutex, 0, __ATOMIC_SEQ_CST); + __builtin_wasm_memory_atomic_notify(mutex, 1); +} + +/* Barrier */ + +typedef struct { + int count; + int num_threads; + int mutex; + int ready; +} barrier_t; + +void +barrier_init(barrier_t *barrier, int num_threads) +{ + barrier->count = 0; + barrier->num_threads = num_threads; + barrier->mutex = 0; + barrier->ready = 0; +} + +void +barrier_wait(barrier_t *barrier) +{ + bool no_wait; + + mutex_lock(&barrier->mutex); + barrier->count++; + no_wait = (barrier->count >= barrier->num_threads); + mutex_unlock(&barrier->mutex); + + if (no_wait) { + __atomic_store_n(&barrier->ready, 1, __ATOMIC_SEQ_CST); + __builtin_wasm_memory_atomic_notify(&barrier->ready, 1); + return; + } + + __builtin_wasm_memory_atomic_wait32(&barrier->ready, 0, -1); +} \ No newline at end of file From fcea51ce3f1838a0e6c3741f77de881163e8206c Mon Sep 17 00:00:00 2001 From: eloparco Date: Wed, 15 Mar 2023 22:58:32 +0000 Subject: [PATCH 2/6] fix: notify all waiting threads --- core/iwasm/libraries/lib-wasi-threads/test/sync_primitives.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/iwasm/libraries/lib-wasi-threads/test/sync_primitives.h b/core/iwasm/libraries/lib-wasi-threads/test/sync_primitives.h index dfc4131f1c..6a62dcc079 100644 --- a/core/iwasm/libraries/lib-wasi-threads/test/sync_primitives.h +++ b/core/iwasm/libraries/lib-wasi-threads/test/sync_primitives.h @@ -59,15 +59,16 @@ void barrier_wait(barrier_t *barrier) { bool no_wait; + int count; mutex_lock(&barrier->mutex); - barrier->count++; + count = barrier->count++; no_wait = (barrier->count >= barrier->num_threads); mutex_unlock(&barrier->mutex); if (no_wait) { __atomic_store_n(&barrier->ready, 1, __ATOMIC_SEQ_CST); - __builtin_wasm_memory_atomic_notify(&barrier->ready, 1); + __builtin_wasm_memory_atomic_notify(&barrier->ready, count); return; } From 4f5ff0c736b8b40ab672c00381c35644a0eae4b5 Mon Sep 17 00:00:00 2001 From: eloparco Date: Thu, 16 Mar 2023 10:29:01 +0000 Subject: [PATCH 3/6] fix: reset barrier when threshold is reached --- .../libraries/lib-wasi-threads/test/sync_primitives.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/iwasm/libraries/lib-wasi-threads/test/sync_primitives.h b/core/iwasm/libraries/lib-wasi-threads/test/sync_primitives.h index 6a62dcc079..0ba2c1741b 100644 --- a/core/iwasm/libraries/lib-wasi-threads/test/sync_primitives.h +++ b/core/iwasm/libraries/lib-wasi-threads/test/sync_primitives.h @@ -58,12 +58,15 @@ barrier_init(barrier_t *barrier, int num_threads) void barrier_wait(barrier_t *barrier) { - bool no_wait; + bool no_wait = false; int count; mutex_lock(&barrier->mutex); count = barrier->count++; - no_wait = (barrier->count >= barrier->num_threads); + if (barrier->count >= barrier->num_threads) { + no_wait = true; + barrier->count = 0; + } mutex_unlock(&barrier->mutex); if (no_wait) { From 1227d42e3a46238231465eb22a0d7bb2061a8890 Mon Sep 17 00:00:00 2001 From: eloparco Date: Sun, 19 Mar 2023 23:40:11 +0000 Subject: [PATCH 4/6] feat: use preprocessor option to decide pthread primitive implementation to use --- .../libraries/lib-wasi-threads/test/common.h | 14 ++++-- .../lib-wasi-threads/test/global_lock.c | 14 ++++-- .../lib-wasi-threads/test/sync_primitives.h | 48 ++++++++++++------- 3 files changed, 50 insertions(+), 26 deletions(-) diff --git a/core/iwasm/libraries/lib-wasi-threads/test/common.h b/core/iwasm/libraries/lib-wasi-threads/test/common.h index 3645c460be..8ad1b439df 100644 --- a/core/iwasm/libraries/lib-wasi-threads/test/common.h +++ b/core/iwasm/libraries/lib-wasi-threads/test/common.h @@ -10,7 +10,12 @@ #include #include +#if USE_PTHREAD_SYNC_PRIMITIVES != 0 +#include +#else #include "sync_primitives.h" +#endif + #include "wasi_thread_start.h" typedef enum { @@ -25,7 +30,7 @@ static bool termination_in_main_thread; static blocking_task_type_t blocking_task_type; #define NUM_THREADS 3 -static barrier_t barrier; +static pthread_barrier_t barrier; typedef struct { start_args_t base; @@ -51,7 +56,7 @@ void start_job() { /* Wait for all threads (including the main thread) to be ready */ - barrier_wait(&barrier); + pthread_barrier_wait(&barrier); run_long_task(); /* Task to be interrupted */ assert(false && "Thread termination test failed"); } @@ -60,7 +65,7 @@ void terminate_process() { /* Wait for all threads (including the main thread) to be ready */ - barrier_wait(&barrier); + pthread_barrier_wait(&barrier); if (termination_by_trap) __builtin_trap(); @@ -90,7 +95,8 @@ test_termination(bool trap, bool main, blocking_task_type_t task_type) int thread_id = -1, i; shared_t data[NUM_THREADS] = { 0 }; - barrier_init(&barrier, NUM_THREADS + 1); + assert(pthread_barrier_init(&barrier, NULL, NUM_THREADS + 1) == 0 + && "Failed to init barrier"); for (i = 0; i < NUM_THREADS; i++) { /* No graceful memory free to simplify the test */ diff --git a/core/iwasm/libraries/lib-wasi-threads/test/global_lock.c b/core/iwasm/libraries/lib-wasi-threads/test/global_lock.c index ca3ea09732..e733dd0dc3 100644 --- a/core/iwasm/libraries/lib-wasi-threads/test/global_lock.c +++ b/core/iwasm/libraries/lib-wasi-threads/test/global_lock.c @@ -12,7 +12,12 @@ #include #include +#if USE_PTHREAD_SYNC_PRIMITIVES != 0 +#include +#else #include "sync_primitives.h" +#endif + #include "wasi_thread_start.h" enum CONSTANTS { @@ -22,7 +27,7 @@ enum CONSTANTS { TIMEOUT = 10LL * SECOND }; -mutex_t mutex; +pthread_mutex_t mutex; int g_count = 0; typedef struct { @@ -36,9 +41,9 @@ __wasi_thread_start_C(int thread_id, int *start_arg) shared_t *data = (shared_t *)start_arg; for (int i = 0; i < NUM_ITER; i++) { - mutex_lock(&mutex); + pthread_mutex_lock(&mutex); g_count++; - mutex_unlock(&mutex); + pthread_mutex_unlock(&mutex); } __atomic_store_n(&data->th_done, 1, __ATOMIC_SEQ_CST); @@ -51,7 +56,7 @@ main(int argc, char **argv) shared_t data[NUM_THREADS] = { 0 }; int thread_ids[NUM_THREADS]; - mutex_init(&mutex); + assert(pthread_mutex_init(&mutex, NULL) == 0 && "Failed to init mutex"); for (int i = 0; i < NUM_THREADS; i++) { assert(start_args_init(&data[i].base)); @@ -73,5 +78,6 @@ main(int argc, char **argv) assert(g_count == (NUM_THREADS * NUM_ITER) && "Global count not updated correctly"); + assert(pthread_mutex_destroy(&mutex) == 0 && "Failed to destroy mutex"); return EXIT_SUCCESS; } diff --git a/core/iwasm/libraries/lib-wasi-threads/test/sync_primitives.h b/core/iwasm/libraries/lib-wasi-threads/test/sync_primitives.h index 0ba2c1741b..4b7dac8ec9 100644 --- a/core/iwasm/libraries/lib-wasi-threads/test/sync_primitives.h +++ b/core/iwasm/libraries/lib-wasi-threads/test/sync_primitives.h @@ -7,34 +7,43 @@ /* Mutex */ -typedef int mutex_t; +typedef int pthread_mutex_t; -void -mutex_init(mutex_t *mutex) +int +pthread_mutex_init(pthread_mutex_t *mutex, void *unused) { *mutex = 0; + return 0; +} + +int +pthread_mutex_destroy(pthread_mutex_t *mutex) +{ + return 0; } static bool -try_mutex_lock(mutex_t *mutex) +try_pthread_mutex_lock(pthread_mutex_t *mutex) { int expected = 0; return __atomic_compare_exchange_n(mutex, &expected, 1, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } -void -mutex_lock(mutex_t *mutex) +int +pthread_mutex_lock(pthread_mutex_t *mutex) { - while (!try_mutex_lock(mutex)) + while (!try_pthread_mutex_lock(mutex)) __builtin_wasm_memory_atomic_wait32(mutex, 1, -1); + return 0; } -void -mutex_unlock(mutex_t *mutex) +int +pthread_mutex_unlock(pthread_mutex_t *mutex) { __atomic_store_n(mutex, 0, __ATOMIC_SEQ_CST); __builtin_wasm_memory_atomic_notify(mutex, 1); + return 0; } /* Barrier */ @@ -44,36 +53,39 @@ typedef struct { int num_threads; int mutex; int ready; -} barrier_t; +} pthread_barrier_t; -void -barrier_init(barrier_t *barrier, int num_threads) +int +pthread_barrier_init(pthread_barrier_t *barrier, void *unused, int num_threads) { barrier->count = 0; barrier->num_threads = num_threads; - barrier->mutex = 0; barrier->ready = 0; + pthread_mutex_init(&barrier->mutex, NULL); + + return 0; } -void -barrier_wait(barrier_t *barrier) +int +pthread_barrier_wait(pthread_barrier_t *barrier) { bool no_wait = false; int count; - mutex_lock(&barrier->mutex); + pthread_mutex_lock(&barrier->mutex); count = barrier->count++; if (barrier->count >= barrier->num_threads) { no_wait = true; barrier->count = 0; } - mutex_unlock(&barrier->mutex); + pthread_mutex_unlock(&barrier->mutex); if (no_wait) { __atomic_store_n(&barrier->ready, 1, __ATOMIC_SEQ_CST); __builtin_wasm_memory_atomic_notify(&barrier->ready, count); - return; + return 0; } __builtin_wasm_memory_atomic_wait32(&barrier->ready, 0, -1); + return 0; } \ No newline at end of file From c379e63a24c808763158b8b91cfbcf5de6de9875 Mon Sep 17 00:00:00 2001 From: eloparco Date: Sun, 19 Mar 2023 23:43:06 +0000 Subject: [PATCH 5/6] fix: remove outdated sample now part of the tests --- samples/wasi-threads/README.md | 2 - samples/wasi-threads/wasm-apps/CMakeLists.txt | 3 +- .../wasm-apps/thread_termination.c | 142 ------------------ 3 files changed, 1 insertion(+), 146 deletions(-) delete mode 100644 samples/wasi-threads/wasm-apps/thread_termination.c diff --git a/samples/wasi-threads/README.md b/samples/wasi-threads/README.md index a5e1aed3c6..a79a3cd6a6 100644 --- a/samples/wasi-threads/README.md +++ b/samples/wasi-threads/README.md @@ -11,8 +11,6 @@ $ cmake .. $ make ... $ ./iwasm wasm-apps/no_pthread.wasm -... -$ ./iwasm wasm-apps/exception_propagation.wasm ``` ## Run samples in AOT mode diff --git a/samples/wasi-threads/wasm-apps/CMakeLists.txt b/samples/wasi-threads/wasm-apps/CMakeLists.txt index a6b288449a..87f21e9fd5 100644 --- a/samples/wasi-threads/wasm-apps/CMakeLists.txt +++ b/samples/wasi-threads/wasm-apps/CMakeLists.txt @@ -43,5 +43,4 @@ function (compile_sample SOURCE_FILE) ) endfunction () -compile_sample(no_pthread.c wasi_thread_start.S) -compile_sample(thread_termination.c wasi_thread_start.S) +compile_sample(no_pthread.c wasi_thread_start.S) \ No newline at end of file diff --git a/samples/wasi-threads/wasm-apps/thread_termination.c b/samples/wasi-threads/wasm-apps/thread_termination.c deleted file mode 100644 index 9f5cf1fe89..0000000000 --- a/samples/wasi-threads/wasm-apps/thread_termination.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (C) 2022 Amazon.com Inc. or its affiliates. All rights reserved. - * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - */ -#ifndef __wasi__ -#error This example only compiles to WASM/WASI target -#endif - -#include -#include -#include -#include -#include -#include - -#include "wasi_thread_start.h" - -#define BUSY_WAIT 0 -#define ATOMIC_WAIT 1 -#define POLL_ONEOFF 2 - -/* Change parameters here to modify the sample behavior */ -#define TEST_TERMINATION_BY_TRAP 0 /* Otherwise `proc_exit` termination */ -#define TEST_TERMINATION_IN_MAIN_THREAD 1 /* Otherwise in spawn thread */ -#define LONG_TASK_IMPL ATOMIC_WAIT - -#define TIMEOUT_SECONDS 10 -#define NUM_THREADS 3 -static pthread_barrier_t barrier; - -typedef struct { - start_args_t base; - bool throw_exception; -} shared_t; - -void -run_long_task() -{ -#if LONG_TASK_IMPL == BUSY_WAIT - for (int i = 0; i < TIMEOUT_SECONDS; i++) - sleep(1); -#elif LONG_TASK_IMPL == ATOMIC_WAIT - __builtin_wasm_memory_atomic_wait32(0, 0, -1); -#else - sleep(TIMEOUT_SECONDS); -#endif -} - -void -start_job() -{ - /* Wait for all threads (including the main thread) to be ready */ - pthread_barrier_wait(&barrier); - run_long_task(); /* Task to be interrupted */ - assert(false && "Thread termination test failed"); -} - -void -terminate_process() -{ - /* Wait for all other threads (including main thread) to be ready */ - printf("Waiting before terminating\n"); - pthread_barrier_wait(&barrier); - - printf("Force termination\n"); -#if TEST_TERMINATION_BY_TRAP == 1 - __builtin_trap(); -#else - __wasi_proc_exit(33); -#endif -} - -void -__wasi_thread_start_C(int thread_id, int *start_arg) -{ - shared_t *data = (shared_t *)start_arg; - - if (data->throw_exception) { - terminate_process(); - } - else { - printf("Thread running\n"); - - start_job(); - } -} - -int -main(int argc, char **argv) -{ - int thread_id = -1, i; - shared_t data[NUM_THREADS] = { 0 }; - - if (pthread_barrier_init(&barrier, NULL, NUM_THREADS + 1) != 0) { - printf("Failed to init barrier\n"); - return EXIT_FAILURE; - } - - for (i = 0; i < NUM_THREADS; i++) { - /* No graceful memory free to simplify the example */ - if (!start_args_init(&data[i].base)) { - printf("Failed to allocate thread's stack\n"); - return EXIT_FAILURE; - } - } - - /* Create a thread that forces termination through trap or `proc_exit` */ -#if TEST_TERMINATION_IN_MAIN_THREAD == 1 - data[0].throw_exception = false; -#else - data[0].throw_exception = true; -#endif - thread_id = __wasi_thread_spawn(&data[0]); - if (thread_id < 0) { - printf("Failed to create thread: %d\n", thread_id); - return EXIT_FAILURE; - } - - /* Create two additional threads to test exception propagation */ - data[1].throw_exception = false; - thread_id = __wasi_thread_spawn(&data[1]); - if (thread_id < 0) { - printf("Failed to create thread: %d\n", thread_id); - return EXIT_FAILURE; - } - data[2].throw_exception = false; - thread_id = __wasi_thread_spawn(&data[2]); - if (thread_id < 0) { - printf("Failed to create thread: %d\n", thread_id); - return EXIT_FAILURE; - } - -#if TEST_TERMINATION_IN_MAIN_THREAD == 1 - printf("Force termination (main thread)\n"); - terminate_process(); -#else /* TEST_TERMINATION_IN_MAIN_THREAD */ - printf("Main thread running\n"); - - start_job(); -#endif /* TEST_TERMINATION_IN_MAIN_THREAD */ - return EXIT_SUCCESS; -} From 6b2999f2386494bf596d62699814af0e1e20173b Mon Sep 17 00:00:00 2001 From: eloparco Date: Sun, 26 Mar 2023 00:17:07 +0000 Subject: [PATCH 6/6] feat: use pthread primitives by default and update ci to use wasi-libc commit that fixes atomic operation --- .github/workflows/compilation_on_android_ubuntu.yml | 8 ++++---- .github/workflows/compilation_on_sgx.yml | 4 ++-- core/iwasm/libraries/lib-wasi-threads/test/common.h | 6 +++--- core/iwasm/libraries/lib-wasi-threads/test/global_lock.c | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/compilation_on_android_ubuntu.yml b/.github/workflows/compilation_on_android_ubuntu.yml index 6654e1b31b..062b172974 100644 --- a/.github/workflows/compilation_on_android_ubuntu.yml +++ b/.github/workflows/compilation_on_android_ubuntu.yml @@ -368,9 +368,9 @@ jobs: mkdir wasi-libc cd wasi-libc git init - # "Rename thread_spawn import" commit on main branch + # "Fix a_store operation in atomic.h" commit on main branch git fetch https://github.com/WebAssembly/wasi-libc \ - 8f5275796a82f8ecfd0833a4f3f444fa37ed4546 + 1dfe5c302d1c5ab621f7abf04620fae92700fd22 git checkout FETCH_HEAD make -j \ AR=/opt/wasi-sdk/bin/llvm-ar \ @@ -532,9 +532,9 @@ jobs: mkdir wasi-libc cd wasi-libc git init - # "Rename thread_spawn import" commit on main branch + # "Fix a_store operation in atomic.h" commit on main branch git fetch https://github.com/WebAssembly/wasi-libc \ - 8f5275796a82f8ecfd0833a4f3f444fa37ed4546 + 1dfe5c302d1c5ab621f7abf04620fae92700fd22 git checkout FETCH_HEAD make -j \ AR=/opt/wasi-sdk/bin/llvm-ar \ diff --git a/.github/workflows/compilation_on_sgx.yml b/.github/workflows/compilation_on_sgx.yml index 2988a6fe15..a26f27aaf6 100644 --- a/.github/workflows/compilation_on_sgx.yml +++ b/.github/workflows/compilation_on_sgx.yml @@ -265,9 +265,9 @@ jobs: mkdir wasi-libc cd wasi-libc git init - # "Rename thread_spawn import" commit on main branch + # "Fix a_store operation in atomic.h" commit on main branch git fetch https://github.com/WebAssembly/wasi-libc \ - 8f5275796a82f8ecfd0833a4f3f444fa37ed4546 + 1dfe5c302d1c5ab621f7abf04620fae92700fd22 git checkout FETCH_HEAD make \ AR=/opt/wasi-sdk/bin/llvm-ar \ diff --git a/core/iwasm/libraries/lib-wasi-threads/test/common.h b/core/iwasm/libraries/lib-wasi-threads/test/common.h index 8ad1b439df..01ca932c5e 100644 --- a/core/iwasm/libraries/lib-wasi-threads/test/common.h +++ b/core/iwasm/libraries/lib-wasi-threads/test/common.h @@ -10,10 +10,10 @@ #include #include -#if USE_PTHREAD_SYNC_PRIMITIVES != 0 -#include -#else +#if USE_CUSTOM_SYNC_PRIMITIVES != 0 #include "sync_primitives.h" +#else +#include #endif #include "wasi_thread_start.h" diff --git a/core/iwasm/libraries/lib-wasi-threads/test/global_lock.c b/core/iwasm/libraries/lib-wasi-threads/test/global_lock.c index e733dd0dc3..f81fca49b9 100644 --- a/core/iwasm/libraries/lib-wasi-threads/test/global_lock.c +++ b/core/iwasm/libraries/lib-wasi-threads/test/global_lock.c @@ -12,10 +12,10 @@ #include #include -#if USE_PTHREAD_SYNC_PRIMITIVES != 0 -#include -#else +#if USE_CUSTOM_SYNC_PRIMITIVES != 0 #include "sync_primitives.h" +#else +#include #endif #include "wasi_thread_start.h"