From 3fb8e84fcf81b3730e1bde848441d5ec8bd5ecf4 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 20 Feb 2026 14:56:30 -0800 Subject: [PATCH] Use bool return type for various low emscripten APIs We converted a EM_BOOL from `int` to `bool` without too much fallout so I think should a backwards compatible change for all users. It is of course conceivable to construct code that would notice this change (e.g. `sizeof(emscripten_is_main_runtime_thread())` but its seems extremely unlikely. I think using the explicit bool type helps make these function more clear, and avoids confusion with tradition "0 means success" C functions. --- ChangeLog.md | 3 + site/source/docs/api_reference/proxying.h.rst | 22 +++--- system/include/emscripten/emscripten.h | 2 + system/include/emscripten/heap.h | 4 +- system/include/emscripten/proxying.h | 71 ++++++++++--------- system/include/emscripten/threading.h | 15 ++-- system/include/emscripten/wasm_worker.h | 3 +- system/lib/pthread/em_task_queue.c | 24 +++---- system/lib/pthread/em_task_queue.h | 15 ++-- system/lib/pthread/library_pthread_stub.c | 7 +- system/lib/pthread/proxying.c | 60 ++++++++-------- system/lib/pthread/proxying_stub.c | 24 +++---- system/lib/standalone/standalone.c | 6 +- .../test_codesize_mem_O3_grow_standalone.json | 8 +-- .../test_codesize_minimal_pthreads.json | 8 +-- ...t_codesize_minimal_pthreads_memgrowth.json | 8 +-- 16 files changed, 147 insertions(+), 133 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index f5acd99a7dbae..bc25de5a89384 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -20,6 +20,9 @@ See docs/process.md for more on how version tagging works. 5.0.2 (in development) ---------------------- +- Several low level emscripten APIs that return success/failure now return the + C `bool` type rather than `int`. For example `emscripten_proxy_sync` and + `emscripten_is_main_runtime_thread`. (#26316) - SDL2 port updated from 2.32.8 to 2.32.10. (#26298) - The remaining launcher scripts (e.g. `emcc.bat`) were removed from the git repository. These scripts are created by the `./bootstrap` script which diff --git a/site/source/docs/api_reference/proxying.h.rst b/site/source/docs/api_reference/proxying.h.rst index c6a42b8b00339..475845e2081fa 100644 --- a/site/source/docs/api_reference/proxying.h.rst +++ b/site/source/docs/api_reference/proxying.h.rst @@ -72,21 +72,21 @@ Functions Signal the end of a task proxied with ``emscripten_proxy_sync_with_ctx``. -.. c:function:: int emscripten_proxy_async(em_proxying_queue* q, pthread_t target_thread, void (*func)(void*), void* arg) +.. c:function:: bool emscripten_proxy_async(em_proxying_queue* q, pthread_t target_thread, void (*func)(void*), void* arg) Enqueue ``func`` to be called with argument ``arg`` on the given queue and thread then return immediately without waiting for ``func`` to be executed. - Returns 1 if the work was successfully enqueued or 0 otherwise. + Returns true if the work was successfully enqueued or false otherwise. -.. c:function:: int emscripten_proxy_sync(em_proxying_queue* q, pthread_t target_thread, void (*func)(void*), void* arg) +.. c:function:: bool emscripten_proxy_sync(em_proxying_queue* q, pthread_t target_thread, void (*func)(void*), void* arg) Enqueue ``func`` to be called with argument ``arg`` on the given queue and thread then wait for ``func`` to be executed synchronously before returning. - Returns 1 if the ``func`` was successfully completed and 0 otherwise, + Returns true if the ``func`` was successfully completed and false otherwise, including if the target thread is canceled or exits before the work is completed. -.. c:function:: int emscripten_proxy_sync_with_ctx(em_proxying_queue* q, pthread_t target_thread, void (*func)(em_proxying_ctx*, void*), void* arg) +.. c:function:: bool emscripten_proxy_sync_with_ctx(em_proxying_queue* q, pthread_t target_thread, void (*func)(em_proxying_ctx*, void*), void* arg) The same as ``emscripten_proxy_sync`` except that instead of waiting for the proxied function to return, it waits for the proxied task to be explicitly @@ -94,24 +94,24 @@ Functions ``emscripten_proxy_finish`` itself; it could instead store the context pointer and call ``emscripten_proxy_finish`` at an arbitrary later time. -.. c:function:: int emscripten_proxy_callback(em_proxying_queue* q, pthread_t target_thread, void (*func)(void*), void (*callback)(void*), void (*cancel)(void*), void* arg) +.. c:function:: bool emscripten_proxy_callback(em_proxying_queue* q, pthread_t target_thread, void (*func)(void*), void (*callback)(void*), void (*cancel)(void*), void* arg) Enqueue ``func`` on the given queue and thread. Once (and if) it finishes executing, it will asynchronously proxy ``callback`` back to the current thread on the same queue, or if the target thread dies before the work can be completed, ``cancel`` will be proxied back instead. All three function will - receive the same argument, ``arg``. Returns 1 if ``func`` was successfully - enqueued and the target thread notified or 0 otherwise. + receive the same argument, ``arg``. Returns true if ``func`` was successfully + enqueued and the target thread notified or false otherwise. -.. c:function:: int emscripten_proxy_callback_with_ctx(em_proxying_queue* q, pthread_t target_thread, void (*func)(em_proxying_ctx*, void*), void (*callback)(void*), void (*cancel)(void*), void* arg) +.. c:function:: bool emscripten_proxy_callback_with_ctx(em_proxying_queue* q, pthread_t target_thread, void (*func)(em_proxying_ctx*, void*), void (*callback)(void*), void (*cancel)(void*), void* arg) Enqueue ``func`` on the given queue and thread. Once (and if) it finishes the task by calling ``emscripten_proxy_finish`` on the given ``em_proxying_ctx``, it will asynchronously proxy ``callback`` back to the current thread on the same queue, or if the target thread dies before the work can be completed, ``cancel`` will be proxied back instead. All three function will receive the - same argument, ``arg``. Returns 1 if ``func`` was successfully enqueued and - the target thread notified or 0 otherwise. + same argument, ``arg``. Returns true if ``func`` was successfully enqueued and + the target thread notified or false otherwise. C++ API ------- diff --git a/system/include/emscripten/emscripten.h b/system/include/emscripten/emscripten.h index f364c1420fd8d..eee32a0b3ec0b 100644 --- a/system/include/emscripten/emscripten.h +++ b/system/include/emscripten/emscripten.h @@ -133,6 +133,8 @@ int emscripten_get_worker_queue_size(worker_handle worker); // misc. long emscripten_get_compiler_setting(const char *name); + +// Returns the value of -sASYNCIFY. Can be 0, 1, or 2 (in the case of JSPI). int emscripten_has_asyncify(void); void emscripten_debugger(void); diff --git a/system/include/emscripten/heap.h b/system/include/emscripten/heap.h index 2456fb09bd486..ec13b2081b6f1 100644 --- a/system/include/emscripten/heap.h +++ b/system/include/emscripten/heap.h @@ -7,6 +7,7 @@ #pragma once +#include #include #include #include @@ -31,7 +32,8 @@ uintptr_t *emscripten_get_sbrk_ptr(void); // src/settings.js variables MEMORY_GROWTH_GEOMETRIC_STEP, // MEMORY_GROWTH_GEOMETRIC_CAP and MEMORY_GROWTH_LINEAR_STEP. This function // cannot be used to shrink the size of the memory. -int emscripten_resize_heap(size_t requested_size) EM_IMPORT(emscripten_resize_heap); +// Returns true on success, false otherwise. +bool emscripten_resize_heap(size_t requested_size) EM_IMPORT(emscripten_resize_heap); // Returns the current size of the WebAssembly memory (referred to as heap for // legacy reason). diff --git a/system/include/emscripten/proxying.h b/system/include/emscripten/proxying.h index 1734821c3d306..e22d6f331d1b6 100644 --- a/system/include/emscripten/proxying.h +++ b/system/include/emscripten/proxying.h @@ -9,6 +9,7 @@ #include #include +#include #include #ifdef __cplusplus @@ -48,60 +49,60 @@ typedef struct em_proxying_ctx em_proxying_ctx; void emscripten_proxy_finish(em_proxying_ctx* ctx); // Enqueue `func` on the given queue and thread and return immediately. Returns -// 1 if the work was successfully enqueued and the target thread notified or 0 -// otherwise. -int emscripten_proxy_async(em_proxying_queue* q, +// true if the work was successfully enqueued and the target thread notified or +// false otherwise. +bool emscripten_proxy_async(em_proxying_queue* q, + pthread_t target_thread, + void (*func)(void*), + void* arg); + +// Enqueue `func` on the given queue and thread and wait for it to finish +// executing before returning. Returns true if the task was successfully +// completed and false otherwise, including if the target thread is canceled or +// exits before the work is completed. +bool emscripten_proxy_sync(em_proxying_queue* q, pthread_t target_thread, void (*func)(void*), void* arg); -// Enqueue `func` on the given queue and thread and wait for it to finish -// executing before returning. Returns 1 if the task was successfully completed -// and 0 otherwise, including if the target thread is canceled or exits before -// the work is completed. -int emscripten_proxy_sync(em_proxying_queue* q, - pthread_t target_thread, - void (*func)(void*), - void* arg); - // Enqueue `func` on the given queue and thread and wait for it to be executed // and for the task to be marked finished with `emscripten_proxy_finish` before // returning. `func` need not call `emscripten_proxy_finish` itself; it could // instead store the context pointer and call `emscripten_proxy_finish` at an -// arbitrary later time. Returns 1 if the task was successfully completed and 0 -// otherwise, including if the target thread is canceled or exits before the -// work is completed. -int emscripten_proxy_sync_with_ctx(em_proxying_queue* q, - pthread_t target_thread, - void (*func)(em_proxying_ctx*, void*), - void* arg); +// arbitrary later time. Returns true if the task was successfully completed and +// false otherwise, including if the target thread is canceled or exits before +// the work is completed. +bool emscripten_proxy_sync_with_ctx(em_proxying_queue* q, + pthread_t target_thread, + void (*func)(em_proxying_ctx*, void*), + void* arg); // Enqueue `func` on the given queue and thread. Once (and if) it finishes // executing, it will asynchronously proxy `callback` back to the current thread // on the same queue, or if the target thread dies before the work can be // completed, `cancel` will be proxied back instead. All three functions will -// receive the same argument, `arg`. Returns 1 if `func` was successfully -// enqueued and the target thread notified or 0 otherwise. -int emscripten_proxy_callback(em_proxying_queue* q, - pthread_t target_thread, - void (*func)(void*), - void (*callback)(void*), - void (*cancel)(void*), - void* arg); +// receive the same argument, `arg`. Returns true if `func` was successfully +// enqueued and the target thread notified or false otherwise. +bool emscripten_proxy_callback(em_proxying_queue* q, + pthread_t target_thread, + void (*func)(void*), + void (*callback)(void*), + void (*cancel)(void*), + void* arg); // Enqueue `func` on the given queue and thread. Once (and if) it finishes the // task by calling `emscripten_proxy_finish` on the given `em_proxying_ctx`, it // will asynchronously proxy `callback` back to the current thread on the same // queue, or if the target thread dies before the work can be completed, // `cancel` will be proxied back instead. All three functions will receive the -// same argument, `arg`. Returns 1 if `func` was successfully enqueued and the -// target thread notified or 0 otherwise. -int emscripten_proxy_callback_with_ctx(em_proxying_queue* q, - pthread_t target_thread, - void (*func)(em_proxying_ctx*, void*), - void (*callback)(void*), - void (*cancel)(void*), - void* arg); +// same argument, `arg`. Returns true if `func` was successfully enqueued and +// the target thread notified or false otherwise. +bool emscripten_proxy_callback_with_ctx(em_proxying_queue* q, + pthread_t target_thread, + void (*func)(em_proxying_ctx*, void*), + void (*callback)(void*), + void (*cancel)(void*), + void* arg); __attribute__((warn_unused_result)) em_promise_t emscripten_proxy_promise(em_proxying_queue* q, diff --git a/system/include/emscripten/threading.h b/system/include/emscripten/threading.h index f4f68d288db42..fbc34f4d77639 100644 --- a/system/include/emscripten/threading.h +++ b/system/include/emscripten/threading.h @@ -9,6 +9,7 @@ #include #include +#include #include // for EMSCRIPTEN_RESULT #include @@ -24,7 +25,7 @@ extern "C" { // pthread_create(), and the compiled page was built with threading support // enabled. If this returns 0, calls to pthread_create() will fail with return // code EAGAIN. -int emscripten_has_threading_support(void); +bool emscripten_has_threading_support(void); // Returns the number of logical cores on the system. int emscripten_num_logical_cores(void); @@ -39,14 +40,14 @@ int emscripten_futex_wait(volatile void/*uint32_t*/ * _Nonnull addr, uint32_t va // Returns -EINVAL if addr is null. int emscripten_futex_wake(volatile void/*uint32_t*/ * _Nonnull addr, int count); -// Returns 1 if the current thread is the thread that hosts the Emscripten +// Returns true if the current thread is the thread that hosts the Emscripten // runtime. -int emscripten_is_main_runtime_thread(void); +bool emscripten_is_main_runtime_thread(void); -// Returns 1 if the current thread is the main browser thread. In the case that -// the emscripten module is run in a worker there may be no pthread for which -// this returns 1. -int emscripten_is_main_browser_thread(void); +// Returns true if the current thread is the main browser thread. In the case +// that the Emscripten module is started in a worker there will be no thread +// for which this returns true. +bool emscripten_is_main_browser_thread(void); // A temporary workaround to issue // https://github.com/emscripten-core/emscripten/issues/3495: diff --git a/system/include/emscripten/wasm_worker.h b/system/include/emscripten/wasm_worker.h index edde682f85d4b..ac7662874aa42 100644 --- a/system/include/emscripten/wasm_worker.h +++ b/system/include/emscripten/wasm_worker.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -115,7 +116,7 @@ int emscripten_navigator_hardware_concurrency(void); // accesses, behavior differs across browsers, see // - https://bugzil.la/1246139 // - https://bugs.chromium.org/p/chromium/issues/detail?id=1167449 -int emscripten_atomics_is_lock_free(int byteWidth); +bool emscripten_atomics_is_lock_free(int byteWidth); #define emscripten_lock_t volatile uint32_t diff --git a/system/lib/pthread/em_task_queue.c b/system/lib/pthread/em_task_queue.c index 180be24d860ed..0eeb8f0bf8579 100644 --- a/system/lib/pthread/em_task_queue.c +++ b/system/lib/pthread/em_task_queue.c @@ -133,12 +133,12 @@ void em_task_queue_destroy(em_task_queue* queue) { } // Not thread safe. Returns 1 on success and 0 on failure. -static int em_task_queue_grow(em_task_queue* queue) { +static bool em_task_queue_grow(em_task_queue* queue) { // Allocate a larger task queue. int new_capacity = queue->capacity * 2; task* new_tasks = malloc(sizeof(task) * new_capacity); if (new_tasks == NULL) { - return 0; + return false; } // Copy the tasks such that the head of the queue is at the beginning of the // buffer. There are two cases to handle: either the queue wraps around the @@ -162,7 +162,7 @@ static int em_task_queue_grow(em_task_queue* queue) { queue->capacity = new_capacity; queue->head = 0; queue->tail = queued_tasks; - return 1; + return true; } void em_task_queue_execute(em_task_queue* queue) { @@ -197,13 +197,13 @@ void em_task_queue_cancel(em_task_queue* queue) { queue->notification = NOTIFICATION_NONE; } -int em_task_queue_enqueue(em_task_queue* queue, task t) { +bool em_task_queue_enqueue(em_task_queue* queue, task t) { if (em_task_queue_is_full(queue) && !em_task_queue_grow(queue)) { - return 0; + return false; } queue->tasks[queue->tail] = t; queue->tail = (queue->tail + 1) % queue->capacity; - return 1; + return true; } task em_task_queue_dequeue(em_task_queue* queue) { @@ -226,19 +226,19 @@ static void cancel_notification(void* arg) { em_task_queue_cancel(tasks); } -int em_task_queue_send(em_task_queue* queue, task t) { +bool em_task_queue_send(em_task_queue* queue, task t) { // Ensure the target mailbox will remain open or detect that it is already // closed. if (!emscripten_thread_mailbox_ref(queue->thread)) { - return 0; + return false; } pthread_mutex_lock(&queue->mutex); - int enqueued = em_task_queue_enqueue(queue, t); + bool enqueued = em_task_queue_enqueue(queue, t); pthread_mutex_unlock(&queue->mutex); if (!enqueued) { emscripten_thread_mailbox_unref(queue->thread); - return 0; + return false; } // We're done if there is already a pending notification for this task queue. @@ -247,7 +247,7 @@ int em_task_queue_send(em_task_queue* queue, task t) { atomic_exchange(&queue->notification, NOTIFICATION_PENDING); if (previous == NOTIFICATION_PENDING) { emscripten_thread_mailbox_unref(queue->thread); - return 1; + return true; } emscripten_thread_mailbox_send(queue->thread, @@ -255,5 +255,5 @@ int em_task_queue_send(em_task_queue* queue, task t) { .cancel = cancel_notification, .arg = queue}); emscripten_thread_mailbox_unref(queue->thread); - return 1; + return true; } diff --git a/system/lib/pthread/em_task_queue.h b/system/lib/pthread/em_task_queue.h index e9732baa8dcbd..7075855aa02cd 100644 --- a/system/lib/pthread/em_task_queue.h +++ b/system/lib/pthread/em_task_queue.h @@ -7,6 +7,7 @@ #pragma once +#include #include #include "proxying_notification_state.h" @@ -58,22 +59,22 @@ void em_task_queue_execute(em_task_queue* queue); void em_task_queue_cancel(em_task_queue* queue); // Not thread safe. -static inline int em_task_queue_is_empty(em_task_queue* queue) { +static inline bool em_task_queue_is_empty(em_task_queue* queue) { return queue->head == queue->tail; } // Not thread safe. -static inline int em_task_queue_is_full(em_task_queue* queue) { +static inline bool em_task_queue_is_full(em_task_queue* queue) { return queue->head == (queue->tail + 1) % queue->capacity; } -// Not thread safe. Returns 1 on success and 0 on failure. -int em_task_queue_enqueue(em_task_queue* queue, task t); +// Not thread safe. Returns true on success and false on failure. +bool em_task_queue_enqueue(em_task_queue* queue, task t); // Not thread safe. Assumes the queue is not empty. task em_task_queue_dequeue(em_task_queue* queue); // Atomically enqueue the task and schedule the queue to be executed next time -// its owning thread returns to its event loop. Returns 1 on success and 0 -// otherwise. Internally locks the queue. -int em_task_queue_send(em_task_queue* queue, task t); +// its owning thread returns to its event loop. Returns true on success and +// false otherwise. Internally locks the queue. +bool em_task_queue_send(em_task_queue* queue, task t); diff --git a/system/lib/pthread/library_pthread_stub.c b/system/lib/pthread/library_pthread_stub.c index 7d1a8100bf97f..6c9712378de00 100644 --- a/system/lib/pthread/library_pthread_stub.c +++ b/system/lib/pthread/library_pthread_stub.c @@ -17,7 +17,7 @@ #include #include -int emscripten_has_threading_support() { return 0; } +bool emscripten_has_threading_support() { return false; } int emscripten_num_logical_cores() { return 1; } @@ -32,7 +32,10 @@ int emscripten_futex_wake(volatile void /*uint32_t*/* addr, int count) { return 0; // success } -int emscripten_is_main_runtime_thread() { return 1; } +bool emscripten_is_main_runtime_thread() { + // TODO: We probably shouldn't be returning true here in WASM_WORKERS builds. + return true; +} void emscripten_main_thread_process_queued_calls() { // nop diff --git a/system/lib/pthread/proxying.c b/system/lib/pthread/proxying.c index fa5101a5d1ed3..f18c4d156bad7 100644 --- a/system/lib/pthread/proxying.c +++ b/system/lib/pthread/proxying.c @@ -146,7 +146,7 @@ void emscripten_proxy_execute_queue(em_proxying_queue* q) { } } -static int do_proxy(em_proxying_queue* q, pthread_t target_thread, task t) { +static bool do_proxy(em_proxying_queue* q, pthread_t target_thread, task t) { assert(q != NULL); pthread_mutex_lock(&q->mutex); bool is_system_queue = q == &system_proxying_queue; @@ -159,13 +159,13 @@ static int do_proxy(em_proxying_queue* q, pthread_t target_thread, task t) { } pthread_mutex_unlock(&q->mutex); if (tasks == NULL) { - return 0; + return false; } return em_task_queue_send(tasks, t); } -int emscripten_proxy_async(em_proxying_queue* q, +bool emscripten_proxy_async(em_proxying_queue* q, pthread_t target_thread, void (*func)(void*), void* arg) { @@ -384,7 +384,7 @@ static void call_with_ctx(void* arg) { ctx->func(ctx, ctx->arg); } -int emscripten_proxy_sync_with_ctx(em_proxying_queue* q, +bool emscripten_proxy_sync_with_ctx(em_proxying_queue* q, pthread_t target_thread, void (*func)(em_proxying_ctx*, void*), void* arg) { @@ -394,7 +394,7 @@ int emscripten_proxy_sync_with_ctx(em_proxying_queue* q, em_proxying_ctx_init_sync(&ctx, func, arg); if (!do_proxy(q, target_thread, (task){call_with_ctx, cancel_ctx, &ctx})) { em_proxying_ctx_deinit(&ctx); - return 0; + return false; } pthread_mutex_lock(&ctx.sync.mutex); while (ctx.sync.state == PENDING) { @@ -413,7 +413,7 @@ static void call_then_finish_task(em_proxying_ctx* ctx, void* arg) { emscripten_proxy_finish(ctx); } -int emscripten_proxy_sync(em_proxying_queue* q, +bool emscripten_proxy_sync(em_proxying_queue* q, pthread_t target_thread, void (*func)(void*), void* arg) { @@ -422,32 +422,32 @@ int emscripten_proxy_sync(em_proxying_queue* q, q, target_thread, call_then_finish_task, &t); } -static int do_proxy_callback(em_proxying_queue* q, - pthread_t target_thread, - void (*func)(em_proxying_ctx* ctx, void*), - void (*callback)(void*), - void (*cancel)(void*), - void* arg, - em_proxying_ctx* ctx) { +static bool do_proxy_callback(em_proxying_queue* q, + pthread_t target_thread, + void (*func)(em_proxying_ctx* ctx, void*), + void (*callback)(void*), + void (*cancel)(void*), + void* arg, + em_proxying_ctx* ctx) { em_proxying_ctx_init_callback( ctx, q, pthread_self(), func, callback, cancel, arg); if (!do_proxy(q, target_thread, (task){call_with_ctx, cancel_ctx, ctx})) { free_ctx(ctx); - return 0; + return false; } - return 1; + return true; } -int emscripten_proxy_callback_with_ctx(em_proxying_queue* q, - pthread_t target_thread, - void (*func)(em_proxying_ctx* ctx, - void*), - void (*callback)(void*), - void (*cancel)(void*), - void* arg) { +bool emscripten_proxy_callback_with_ctx(em_proxying_queue* q, + pthread_t target_thread, + void (*func)(em_proxying_ctx* ctx, + void*), + void (*callback)(void*), + void (*cancel)(void*), + void* arg) { em_proxying_ctx* ctx = malloc(sizeof(*ctx)); if (ctx == NULL) { - return 0; + return false; } return do_proxy_callback(q, target_thread, func, callback, cancel, arg, ctx); } @@ -477,12 +477,12 @@ static void callback_cancel(void* arg) { } } -int emscripten_proxy_callback(em_proxying_queue* q, - pthread_t target_thread, - void (*func)(void*), - void (*callback)(void*), - void (*cancel)(void*), - void* arg) { +bool emscripten_proxy_callback(em_proxying_queue* q, + pthread_t target_thread, + void (*func)(void*), + void (*callback)(void*), + void (*cancel)(void*), + void* arg) { // Allocate the em_proxying_ctx and the user ctx as a single block that will // be freed when the `em_proxying_ctx` is freed. struct block { @@ -491,7 +491,7 @@ int emscripten_proxy_callback(em_proxying_queue* q, }; struct block* block = malloc(sizeof(*block)); if (block == NULL) { - return 0; + return false; } block->cb_ctx = (callback_ctx){func, callback, cancel, arg}; return do_proxy_callback(q, diff --git a/system/lib/pthread/proxying_stub.c b/system/lib/pthread/proxying_stub.c index bd1058ca46e88..0ebb97c2375d9 100644 --- a/system/lib/pthread/proxying_stub.c +++ b/system/lib/pthread/proxying_stub.c @@ -25,23 +25,23 @@ void emscripten_proxy_execute_queue(em_proxying_queue* q) { abort(); } void emscripten_proxy_finish(em_proxying_ctx* ctx) { abort(); } -int emscripten_proxy_async(em_proxying_queue* q, - pthread_t target_thread, - void (*func)(void*), - void* arg) { +bool emscripten_proxy_async(em_proxying_queue* q, + pthread_t target_thread, + void (*func)(void*), + void* arg) { abort(); } -int emscripten_proxy_sync(em_proxying_queue* q, - pthread_t target_thread, - void (*func)(void*), - void* arg) { +bool emscripten_proxy_sync(em_proxying_queue* q, + pthread_t target_thread, + void (*func)(void*), + void* arg) { abort(); } -int emscripten_proxy_sync_with_ctx(em_proxying_queue* q, - pthread_t target_thread, - void (*func)(em_proxying_ctx*, void*), - void* arg) { +bool emscripten_proxy_sync_with_ctx(em_proxying_queue* q, + pthread_t target_thread, + void (*func)(em_proxying_ctx*, void*), + void* arg) { abort(); } diff --git a/system/lib/standalone/standalone.c b/system/lib/standalone/standalone.c index 1095fb4ddb7e0..dbc17febbea41 100644 --- a/system/lib/standalone/standalone.c +++ b/system/lib/standalone/standalone.c @@ -128,7 +128,7 @@ size_t emscripten_get_heap_max() { return emscripten_get_heap_size(); } -int emscripten_resize_heap(size_t size) { +bool emscripten_resize_heap(size_t size) { #if defined(EMSCRIPTEN_MEMORY_GROWTH) size_t old_size = __builtin_wasm_memory_size(0) * WASM_PAGE_SIZE; assert(old_size < size); @@ -139,10 +139,10 @@ int emscripten_resize_heap(size_t size) { // Success, update JS (see https://github.com/WebAssembly/WASI/issues/82) emscripten_notify_memory_growth(0); #endif - return 1; + return true; } #endif - return 0; + return false; } // Call clock_gettime with a particular clock and return the result in ms. diff --git a/test/codesize/test_codesize_mem_O3_grow_standalone.json b/test/codesize/test_codesize_mem_O3_grow_standalone.json index 0ff54ce0ef04b..6ee968a76c75c 100644 --- a/test/codesize/test_codesize_mem_O3_grow_standalone.json +++ b/test/codesize/test_codesize_mem_O3_grow_standalone.json @@ -1,10 +1,10 @@ { "a.out.js": 4107, "a.out.js.gz": 1992, - "a.out.nodebug.wasm": 5547, - "a.out.nodebug.wasm.gz": 2598, - "total": 9654, - "total_gz": 4590, + "a.out.nodebug.wasm": 5549, + "a.out.nodebug.wasm.gz": 2593, + "total": 9656, + "total_gz": 4585, "sent": [ "args_get", "args_sizes_get", diff --git a/test/codesize/test_codesize_minimal_pthreads.json b/test/codesize/test_codesize_minimal_pthreads.json index 61c5c81f68836..b09a7c7229abe 100644 --- a/test/codesize/test_codesize_minimal_pthreads.json +++ b/test/codesize/test_codesize_minimal_pthreads.json @@ -1,10 +1,10 @@ { "a.out.js": 7820, "a.out.js.gz": 3849, - "a.out.nodebug.wasm": 19729, - "a.out.nodebug.wasm.gz": 9140, - "total": 27549, - "total_gz": 12989, + "a.out.nodebug.wasm": 19726, + "a.out.nodebug.wasm.gz": 9135, + "total": 27546, + "total_gz": 12984, "sent": [ "a (memory)", "b (emscripten_get_now)", diff --git a/test/codesize/test_codesize_minimal_pthreads_memgrowth.json b/test/codesize/test_codesize_minimal_pthreads_memgrowth.json index 7de545ad85a8a..d940e2c20217a 100644 --- a/test/codesize/test_codesize_minimal_pthreads_memgrowth.json +++ b/test/codesize/test_codesize_minimal_pthreads_memgrowth.json @@ -1,10 +1,10 @@ { "a.out.js": 8243, "a.out.js.gz": 4056, - "a.out.nodebug.wasm": 19730, - "a.out.nodebug.wasm.gz": 9140, - "total": 27973, - "total_gz": 13196, + "a.out.nodebug.wasm": 19727, + "a.out.nodebug.wasm.gz": 9137, + "total": 27970, + "total_gz": 13193, "sent": [ "a (memory)", "b (emscripten_get_now)",