Skip to content

Commit

Permalink
Made a few improvements to the WebAssembly support.
Browse files Browse the repository at this point in the history
  • Loading branch information
mdadams committed Nov 5, 2023
1 parent e7cbee6 commit 5010de0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ if(JAS_WASM)
set(JAS_STDC_VERSION "201112L")
set(JAS_ENABLE_MULTITHREADING_SUPPORT 0)
set(JAS_ENABLE_SHARED 0)
set(JAS_USE_JAS_INIT 0)
add_compile_definitions(JAS_WASI_LIBC)
endif()

Expand Down
12 changes: 6 additions & 6 deletions build/build_wasi_jasper
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ configure_options=(
-DCMAKE_INSTALL_PREFIX="$install_dir"
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_VERBOSE_MAKEFILE=1
-DJAS_CROSSCOMPILING=1
-DJAS_STDC_VERSION=201112L
-DJAS_ENABLE_MULTITHREADING_SUPPORT=0
-DJAS_ENABLE_SHARED=0
-DJAS_WASM=1
-DJAS_ENABLE_CXX=0
-DJAS_USE_JAS_INIT=1
-DJAS_STRICT=0
-DJAS_WASM=1
-DJAS_ENABLE_DOC=0
#-DJAS_CROSSCOMPILING=1
#-DJAS_STDC_VERSION=201112L
#-DJAS_ENABLE_MULTITHREADING_SUPPORT=0
#-DJAS_ENABLE_SHARED=0
#-DJAS_USE_JAS_INIT=0
)

cmake -H"$source_dir" -B"$build_dir" "${configure_options[@]}" || \
Expand Down
10 changes: 9 additions & 1 deletion src/libjasper/base/jas_malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,15 @@ void jas_basic_free(jas_allocator_t *allocator, void *ptr)

size_t jas_get_total_mem_size()
{
#if defined(__linux__)
#if defined(JAS_WASI_LIBC)
/*
NOTE: On the 32-bit WebAssembly platform, the unsigned integral type
size_t is likely to have a size of 32 bits. So, choose the maximum
memory to be less than 2 ^ 32 in order to avoid overflow.
*/
return JAS_CAST(size_t, 4096) * JAS_CAST(size_t, 1024) *
JAS_CAST(size_t, 1024) - 1;
#elif defined(__linux__)
struct sysinfo buf;
if (sysinfo(&buf)) {
return 0;
Expand Down

0 comments on commit 5010de0

Please sign in to comment.